mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
chore: 调整条件执行语句的作用域
This commit is contained in:
@@ -39,8 +39,16 @@ namespace MaaWpfGui.Helper
|
||||
private readonly double Width = double.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.WindowWidth, DefaultDouble.ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture);
|
||||
private readonly double Height = double.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.WindowHeight, DefaultDouble.ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture);
|
||||
|
||||
public void MoveWindowToDisplay(string displayName, Window window)
|
||||
/// <summary>
|
||||
/// Move MaaWpfGui.RootView
|
||||
/// </summary>
|
||||
private void MoveWindowToDisplay(string displayName, Window window)
|
||||
{
|
||||
if (Math.Abs(Left - DefaultDouble) < 0.01f || Math.Abs(Top - DefaultDouble) < 0.01f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var screen = Screen.AllScreens.FirstOrDefault(x => x.DeviceName == displayName);
|
||||
if (screen != null)
|
||||
{
|
||||
@@ -56,37 +64,40 @@ namespace MaaWpfGui.Helper
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Center other windows in MaaWpfGui.RootView
|
||||
/// </summary>
|
||||
private void MoveWindowToDisplay(Window window)
|
||||
{
|
||||
var mainWindow = Application.Current.MainWindow;
|
||||
if (mainWindow.WindowState == WindowState.Normal)
|
||||
{
|
||||
// In Stylet, CreateWindow().WindowStartupLocation is CenterScreen or CenterOwner (if w.WSLoc == Manual && w.Left == NaN && w.Top == NaN && ...)
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = mainWindow!.Left + ((mainWindow.Width - window.Width) / 2);
|
||||
window.Top = mainWindow.Top + ((mainWindow.Height - window.Height) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Window CreateWindow(object viewModel, bool isDialog, IViewAware ownerViewModel)
|
||||
{
|
||||
Window window = base.CreateWindow(viewModel, isDialog, ownerViewModel);
|
||||
if (bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.LoadPositionAndSize, bool.TrueString)))
|
||||
if (window is RootView)
|
||||
{
|
||||
if (isDialog || ownerViewModel != null || Math.Abs(Left - DefaultDouble) < 0.01f || Math.Abs(Top - DefaultDouble) < 0.01f)
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
if (window is RootView)
|
||||
bool needMoveRootView = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.LoadPositionAndSize, bool.TrueString));
|
||||
if (needMoveRootView)
|
||||
{
|
||||
MoveWindowToDisplay(ScreenName, window);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Center other windows in MaaWpfGui.RootView
|
||||
var mainWindow = Application.Current.MainWindow;
|
||||
if (mainWindow.WindowState == WindowState.Normal)
|
||||
{
|
||||
// In Stylet, CreateWindow().WindowStartupLocation is CenterScreen or CenterOwner (if w.WSLoc == Manual && w.Left == NaN && w.Top == NaN && ...)
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = mainWindow!.Left + ((mainWindow.Width - window.Width) / 2);
|
||||
window.Top = mainWindow.Top + ((mainWindow.Height - window.Height) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var app = Application.Current as App;
|
||||
app!.DarkToStart();
|
||||
var app = Application.Current as App;
|
||||
app!.DarkToStart();
|
||||
}
|
||||
else if (!isDialog && ownerViewModel == null)
|
||||
{
|
||||
MoveWindowToDisplay(window);
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user