mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Persistence of settings window size/position (#2319)
should be good enough imo
This commit is contained in:
parent
47cf9e70cb
commit
83e3c487a9
@ -140,7 +140,9 @@ namespace Bloxstrap
|
|||||||
if (interlock.IsAcquired)
|
if (interlock.IsAcquired)
|
||||||
{
|
{
|
||||||
bool showAlreadyRunningWarning = Process.GetProcessesByName(App.ProjectName).Length > 1;
|
bool showAlreadyRunningWarning = Process.GetProcessesByName(App.ProjectName).Length > 1;
|
||||||
new UI.Elements.Settings.MainWindow(showAlreadyRunningWarning).Show();
|
|
||||||
|
var window = new UI.Elements.Settings.MainWindow(showAlreadyRunningWarning);
|
||||||
|
window.Show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
public AppState Studio { get; set; } = new();
|
public AppState Studio { get; set; } = new();
|
||||||
|
|
||||||
|
public WindowState SettingsWindow { get; set; } = new();
|
||||||
|
|
||||||
public List<string> ModManifest { get; set; } = new();
|
public List<string> ModManifest { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
Bloxstrap/Models/WindowState.cs
Normal file
13
Bloxstrap/Models/WindowState.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace Bloxstrap.Models
|
||||||
|
{
|
||||||
|
public class WindowState
|
||||||
|
{
|
||||||
|
public double Width { get; set; }
|
||||||
|
|
||||||
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
public double Left { get; set; }
|
||||||
|
|
||||||
|
public double Top { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ namespace Bloxstrap.UI.Elements.Settings
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : INavigationWindow
|
public partial class MainWindow : INavigationWindow
|
||||||
{
|
{
|
||||||
|
private Models.WindowState _state => App.State.Prop.SettingsWindow;
|
||||||
|
|
||||||
public MainWindow(bool showAlreadyRunningWarning)
|
public MainWindow(bool showAlreadyRunningWarning)
|
||||||
{
|
{
|
||||||
var viewModel = new MainWindowViewModel();
|
var viewModel = new MainWindowViewModel();
|
||||||
@ -33,6 +35,30 @@ namespace Bloxstrap.UI.Elements.Settings
|
|||||||
|
|
||||||
if (showAlreadyRunningWarning)
|
if (showAlreadyRunningWarning)
|
||||||
ShowAlreadyRunningSnackbar();
|
ShowAlreadyRunningSnackbar();
|
||||||
|
|
||||||
|
LoadState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadState()
|
||||||
|
{
|
||||||
|
if (_state.Left > SystemParameters.VirtualScreenWidth)
|
||||||
|
_state.Left = 0;
|
||||||
|
|
||||||
|
if (_state.Top > SystemParameters.VirtualScreenHeight)
|
||||||
|
_state.Top = 0;
|
||||||
|
|
||||||
|
if (_state.Width > 0)
|
||||||
|
this.Width = _state.Width;
|
||||||
|
|
||||||
|
if (_state.Height > 0)
|
||||||
|
this.Height = _state.Height;
|
||||||
|
|
||||||
|
if (_state.Left > 0 && _state.Top > 0)
|
||||||
|
{
|
||||||
|
this.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||||
|
this.Left = _state.Left;
|
||||||
|
this.Top = _state.Top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ShowAlreadyRunningSnackbar()
|
private async void ShowAlreadyRunningSnackbar()
|
||||||
@ -67,6 +93,14 @@ namespace Bloxstrap.UI.Elements.Settings
|
|||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_state.Width = this.Width;
|
||||||
|
_state.Height = this.Height;
|
||||||
|
|
||||||
|
_state.Top = this.Top;
|
||||||
|
_state.Left = this.Left;
|
||||||
|
|
||||||
|
App.State.Save();
|
||||||
|
|
||||||
if (!e.Cancel)
|
if (!e.Cancel)
|
||||||
App.Terminate();
|
App.Terminate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user