style<Launcher>: reduce titlebar height when window maximized

This commit is contained in:
leo 2023-07-24 11:34:47 +08:00
parent cd197d13f0
commit 26171e19c4
3 changed files with 36 additions and 7 deletions

View file

@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace SourceGit.Views.Converters {
/// <summary>
/// 将当前窗口的状态转换为标题栏高度
/// </summary>
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();
}
}
}

View file

@ -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">
<Window.Resources>
<converters:WindowStateToTitleBarHeight x:Key="WindowStateToTitleBarHeight"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="{Binding ElementName=me, Path=WindowState, Converter={StaticResource WindowStateToTitleBarHeight}}"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Titlebar -->
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="46"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="360"/>
</Grid.ColumnDefinitions>
@ -36,8 +41,8 @@
<!-- Main Menu -->
<Button
Grid.Column="0"
Margin="0,6,0,0"
Width="32" Height="32"
Width="28" Height="28"
VerticalAlignment="Bottom"
Background="Transparent"
BorderThickness="0"
WindowChrome.IsHitTestVisibleInChrome="True"
@ -49,12 +54,14 @@
<widgets:PageTabBar
Grid.Column="1"
x:Name="tabs"
Height="30"
VerticalAlignment="Bottom"
TabAdd="OnTabAdding"
TabSelected="OnTabSelected"
TabClosed="OnTabClosed"/>
<!-- Right controls -->
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="30" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="Minimize" Width="48" IconSize="10" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="48" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
<controls:IconButton Click="Quit" Width="48" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>

View file

@ -7,8 +7,8 @@
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
mc:Ignorable="d"
d:DesignHeight="28" d:DesignWidth="800">
<Grid Margin="0,6,0,0">
d:DesignHeight="32" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1"/>
<ColumnDefinition Width="Auto"/>