From 26171e19c4af605414e8e106b797374305f8dd88 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 24 Jul 2023 11:34:47 +0800 Subject: [PATCH] style: reduce titlebar height when window maximized --- .../Converters/WindowStateToTitleBarHeight.cs | 22 +++++++++++++++++++ src/Views/Launcher.xaml | 17 +++++++++----- src/Views/Widgets/PageTabBar.xaml | 4 ++-- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/Views/Converters/WindowStateToTitleBarHeight.cs diff --git a/src/Views/Converters/WindowStateToTitleBarHeight.cs b/src/Views/Converters/WindowStateToTitleBarHeight.cs new file mode 100644 index 00000000..71eb580b --- /dev/null +++ b/src/Views/Converters/WindowStateToTitleBarHeight.cs @@ -0,0 +1,22 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace SourceGit.Views.Converters { + + /// + /// 将当前窗口的状态转换为标题栏高度 + /// + public class WindowStateToTitleBarHeight : IValueConverter { + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + WindowState state = (WindowState)value; + return state == WindowState.Normal ? 36 : 30; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Views/Launcher.xaml b/src/Views/Launcher.xaml index 2065c0ac..f47212b9 100644 --- a/src/Views/Launcher.xaml +++ b/src/Views/Launcher.xaml @@ -8,6 +8,7 @@ xmlns:controls="clr-namespace:SourceGit.Views.Controls" xmlns:widgets="clr-namespace:SourceGit.Views.Widgets" xmlns:models="clr-namespace:SourceGit.Models" + xmlns:converters="clr-namespace:SourceGit.Views.Converters" mc:Ignorable="d" WindowStartupLocation="CenterScreen" MinWidth="1024" MinHeight="768" @@ -16,16 +17,20 @@ 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"> + + + + - + - + @@ -36,8 +41,8 @@