MistEO
2023-01-28 23:41:55 +08:00
parent 6b1c14ed75
commit a2ccd4924b
2 changed files with 11 additions and 9 deletions

View File

@@ -12,6 +12,7 @@
// </copyright>
using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using Stylet;
@@ -29,10 +30,11 @@ namespace MaaWpfGui
private readonly int ScreenWidth = int.Parse(ViewStatusStorage.Get("GUI.Monitor.Width", "-1"));
private readonly int ScreenHeight = int.Parse(ViewStatusStorage.Get("GUI.Monitor.Height", "-1"));
private readonly double Left = double.Parse(ViewStatusStorage.Get("GUI.Position.Left", "-1"));
private readonly double Top = double.Parse(ViewStatusStorage.Get("GUI.Position.Top", "-1"));
private readonly double Width = double.Parse(ViewStatusStorage.Get("GUI.Size.Width", "-1"));
private readonly double Height = double.Parse(ViewStatusStorage.Get("GUI.Size.Height", "-1"));
private static readonly double DefaultDouble = -114514;
private readonly double Left = double.Parse(ViewStatusStorage.Get("GUI.Position.Left", DefaultDouble.ToString()), CultureInfo.InvariantCulture);
private readonly double Top = double.Parse(ViewStatusStorage.Get("GUI.Position.Top", DefaultDouble.ToString()), CultureInfo.InvariantCulture);
private readonly double Width = double.Parse(ViewStatusStorage.Get("GUI.Size.Width", DefaultDouble.ToString()), CultureInfo.InvariantCulture);
private readonly double Height = double.Parse(ViewStatusStorage.Get("GUI.Size.Height", DefaultDouble.ToString()), CultureInfo.InvariantCulture);
private readonly string RootView = "MaaWpfGui.RootView";
@@ -61,7 +63,7 @@ namespace MaaWpfGui
Window window = base.CreateWindow(viewModel, isDialog, ownerViewModel);
if (bool.Parse(ViewStatusStorage.Get("GUI.PositionAndSize.Load", bool.TrueString)))
{
if (isDialog || ownerViewModel != null || Left == -1 || Top == -1)
if (isDialog || ownerViewModel != null || Left == DefaultDouble || Top == DefaultDouble)
{
return window;
}

View File

@@ -2190,10 +2190,10 @@ namespace MaaWpfGui
ViewStatusStorage.Set("GUI.Monitor.Width", screenRect.Width.ToString());
ViewStatusStorage.Set("GUI.Monitor.Height", screenRect.Height.ToString());
ViewStatusStorage.Set("GUI.Position.Left", (mainWindow.Left - screenRect.Left).ToString());
ViewStatusStorage.Set("GUI.Position.Top", (mainWindow.Top - screenRect.Top).ToString());
ViewStatusStorage.Set("GUI.Size.Width", mainWindow.Width.ToString());
ViewStatusStorage.Set("GUI.Size.Height", mainWindow.Height.ToString());
ViewStatusStorage.Set("GUI.Position.Left", (mainWindow.Left - screenRect.Left).ToString(CultureInfo.InvariantCulture));
ViewStatusStorage.Set("GUI.Position.Top", (mainWindow.Top - screenRect.Top).ToString(CultureInfo.InvariantCulture));
ViewStatusStorage.Set("GUI.Size.Width", mainWindow.Width.ToString(CultureInfo.InvariantCulture));
ViewStatusStorage.Set("GUI.Size.Height", mainWindow.Height.ToString(CultureInfo.InvariantCulture));
}
private bool _useAlternateStage = Convert.ToBoolean(ViewStatusStorage.Get("GUI.UseAlternateStage", bool.FalseString));