mirror of
https://github.com/Pixeval/Pixeval.git
synced 2025-01-08 11:47:34 +08:00
最大化设置持久化 (#365)
This commit is contained in:
parent
d701cfa906
commit
f644064274
@ -50,7 +50,7 @@ public static class WindowFactory
|
||||
if (element.XamlRoot is null)
|
||||
ThrowHelper.ArgumentNull(element.XamlRoot, $"{nameof(element.XamlRoot)} should not be null.");
|
||||
|
||||
return _forkedWindowsInternal.Find(window => element.XamlRoot == window.Content.XamlRoot)
|
||||
return _forkedWindowsInternal.Find(window => element.XamlRoot == window.Content.XamlRoot)
|
||||
?? ThrowHelper.ArgumentOutOfRange<UIElement, EnhancedWindow>(element, $"Specified {nameof(element)} is not existed in any of {nameof(ForkedWindows)}.");
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public static class WindowFactory
|
||||
return window;
|
||||
}
|
||||
|
||||
public static EnhancedWindow Init(this EnhancedWindow window, string title, SizeInt32 size = default)
|
||||
public static EnhancedWindow Init(this EnhancedWindow window, string title, SizeInt32 size = default, bool isMaximized = false)
|
||||
{
|
||||
window.Initialize(new InitializeInfo
|
||||
{
|
||||
@ -105,6 +105,8 @@ public static class WindowFactory
|
||||
IconPath = IconAbsolutePath,
|
||||
Title = title
|
||||
});
|
||||
if (isMaximized)
|
||||
window.AppWindow.Presenter.To<OverlappedPresenter>().Maximize();
|
||||
window.FrameLoaded += (s, _) => s.To<FrameworkElement>().RequestedTheme = WindowSettings.Theme;
|
||||
return window;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public partial class App
|
||||
.WithLoaded((s, _) => s.To<Frame>().NavigateTo<LoginPage>(w))
|
||||
.WithClosing((_, _) => AppInfo.SaveContext()) // TODO: 从运行打开应用的时候不会ExitApp,就算是调用App.Current.Exit();
|
||||
.WithSizeLimit(800, 360)
|
||||
.Init(AppInfo.AppIdentifier, AppViewModel.AppSettings.WindowSize.ToSizeInt32())
|
||||
.Init(AppInfo.AppIdentifier, AppViewModel.AppSettings.WindowSize.ToSizeInt32(), AppViewModel.AppSettings.IsMaximized)
|
||||
.Activate();
|
||||
|
||||
RegisterUnhandledExceptionHandler();
|
||||
|
@ -200,7 +200,13 @@ public static partial class AppInfo
|
||||
public static void SaveContext()
|
||||
{
|
||||
// Save the current resolution
|
||||
App.AppViewModel.AppSettings.WindowSize = WindowFactory.RootWindow.AppWindow.Size.ToSize();
|
||||
if (WindowFactory.RootWindow.AppWindow.Presenter is OverlappedPresenter { State: OverlappedPresenterState.Maximized })
|
||||
App.AppViewModel.AppSettings.IsMaximized = true;
|
||||
else
|
||||
{
|
||||
App.AppViewModel.AppSettings.IsMaximized = false;
|
||||
App.AppViewModel.AppSettings.WindowSize = WindowFactory.RootWindow.AppWindow.Size.ToSize();
|
||||
}
|
||||
if (!App.AppViewModel.SignOutExit)
|
||||
{
|
||||
if (App.AppViewModel.MakoClient != null!)
|
||||
|
@ -248,6 +248,10 @@ public partial record AppSettings : IWindowSettings
|
||||
[SyntheticSetting]
|
||||
public Size WindowSize { get; set; } = WindowHelper.EstimatedWindowSize().ToSize();
|
||||
|
||||
[AttributeIgnore(typeof(SettingsViewModelAttribute<>))]
|
||||
[SyntheticSetting]
|
||||
public bool IsMaximized { get; set; } = false;
|
||||
|
||||
public MakoClientConfiguration ToMakoClientConfiguration()
|
||||
{
|
||||
return new MakoClientConfiguration(5000, !DisableDomainFronting, MirrorHost, CultureInfo.CurrentUICulture);
|
||||
|
Loading…
Reference in New Issue
Block a user