feature<Window>: remember window state

This commit is contained in:
leo 2022-01-04 14:52:13 +08:00
parent 9f58e0c715
commit f04c01b878
3 changed files with 12 additions and 3 deletions

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Windows;
namespace SourceGit.Models { namespace SourceGit.Models {
@ -125,6 +126,11 @@ namespace SourceGit.Models {
/// </summary> /// </summary>
public double Height { get; set; } = 600; public double Height { get; set; } = 600;
/// <summary>
/// 保存上次关闭时是否最大化中
/// </summary>
public WindowState State { get; set; } = WindowState.Normal;
/// <summary> /// <summary>
/// 将提交信息面板与提交记录左右排布 /// 将提交信息面板与提交记录左右排布
/// </summary> /// </summary>

View file

@ -25,7 +25,11 @@ namespace SourceGit.Views.Controls {
public Window() { public Window() {
Style = FindResource("Style.Window") as Style; Style = FindResource("Style.Window") as Style;
Loaded += (_, __) => adornerLayer = AdornerLayer.GetAdornerLayer(Content as FrameworkElement);
Loaded += (_, __) => {
adornerLayer = AdornerLayer.GetAdornerLayer(Content as FrameworkElement);
OnStateChanged(null);
};
} }
public static void AddAdorner(FrameworkElement windowContext, Adorner adorner) { public static void AddAdorner(FrameworkElement windowContext, Adorner adorner) {
@ -50,8 +54,6 @@ namespace SourceGit.Views.Controls {
} }
protected override void OnStateChanged(EventArgs e) { protected override void OnStateChanged(EventArgs e) {
base.OnStateChanged(e);
if (WindowState == WindowState.Maximized) { if (WindowState == WindowState.Maximized) {
if (!IsMaximized) IsMaximized = true; if (!IsMaximized) IsMaximized = true;
BorderThickness = new Thickness(0); BorderThickness = new Thickness(0);

View file

@ -14,6 +14,7 @@
Title="{DynamicResource Text.About.Title}" Title="{DynamicResource Text.About.Title}"
Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}" Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}"
Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}" Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}"
WindowState="{Binding Source={x:Static models:Preference.Instance}, Path=Window.State, Mode=TwoWay}"
Closing="OnClosing"> Closing="OnClosing">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>