mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
style<Launcher>: reduce titlebar height when window maximized
This commit is contained in:
parent
cd197d13f0
commit
26171e19c4
3 changed files with 36 additions and 7 deletions
22
src/Views/Converters/WindowStateToTitleBarHeight.cs
Normal file
22
src/Views/Converters/WindowStateToTitleBarHeight.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||||
xmlns:models="clr-namespace:SourceGit.Models"
|
xmlns:models="clr-namespace:SourceGit.Models"
|
||||||
|
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
MinWidth="1024" MinHeight="768"
|
MinWidth="1024" MinHeight="768"
|
||||||
|
@ -16,16 +17,20 @@
|
||||||
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}"
|
WindowState="{Binding Source={x:Static models:Preference.Instance}, Path=Window.State, Mode=TwoWay}"
|
||||||
Closing="OnClosing">
|
Closing="OnClosing">
|
||||||
|
<Window.Resources>
|
||||||
|
<converters:WindowStateToTitleBarHeight x:Key="WindowStateToTitleBarHeight"/>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="36"/>
|
<RowDefinition Height="{Binding ElementName=me, Path=WindowState, Converter={StaticResource WindowStateToTitleBarHeight}}"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Titlebar -->
|
<!-- Titlebar -->
|
||||||
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="46"/>
|
<ColumnDefinition Width="40"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="360"/>
|
<ColumnDefinition Width="360"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
@ -36,8 +41,8 @@
|
||||||
<!-- Main Menu -->
|
<!-- Main Menu -->
|
||||||
<Button
|
<Button
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="0,6,0,0"
|
Width="28" Height="28"
|
||||||
Width="32" Height="32"
|
VerticalAlignment="Bottom"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
WindowChrome.IsHitTestVisibleInChrome="True"
|
WindowChrome.IsHitTestVisibleInChrome="True"
|
||||||
|
@ -49,12 +54,14 @@
|
||||||
<widgets:PageTabBar
|
<widgets:PageTabBar
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
x:Name="tabs"
|
x:Name="tabs"
|
||||||
|
Height="30"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
TabAdd="OnTabAdding"
|
TabAdd="OnTabAdding"
|
||||||
TabSelected="OnTabSelected"
|
TabSelected="OnTabSelected"
|
||||||
TabClosed="OnTabClosed"/>
|
TabClosed="OnTabClosed"/>
|
||||||
|
|
||||||
<!-- Right controls -->
|
<!-- 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"/>
|
<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}"/>
|
<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"/>
|
<controls:IconButton Click="Quit" Width="48" IconSize="10" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||||
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
|
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="28" d:DesignWidth="800">
|
d:DesignHeight="32" d:DesignWidth="800">
|
||||||
<Grid Margin="0,6,0,0">
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="1"/>
|
<ColumnDefinition Width="1"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
|
Loading…
Reference in a new issue