mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 00:24:59 +00:00
style<Window>: icons for MaximizeWindow/RestoreWindow button
This commit is contained in:
parent
787c1a02d5
commit
794394ef0c
9 changed files with 64 additions and 27 deletions
|
@ -1,5 +1,6 @@
|
|||
<controls:Window
|
||||
x:Class="SourceGit.Views.Blame"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
|
@ -35,7 +36,7 @@
|
|||
<!-- Window Commands -->
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True">
|
||||
<controls:IconButton Click="Minimize" Width="28" Padding="8" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<controls:IconButton Click="MaximizeOrRestore" Width="28" Padding="8" Icon="{StaticResource Icon.Maximize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="28" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
|
||||
<controls:IconButton Click="Quit" Width="28" Padding="8" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
|
|
@ -114,14 +114,6 @@ namespace SourceGit.Views {
|
|||
SystemCommands.MinimizeWindow(this);
|
||||
}
|
||||
|
||||
private void MaximizeOrRestore(object sender, RoutedEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
SystemCommands.MaximizeWindow(this);
|
||||
} else {
|
||||
SystemCommands.RestoreWindow(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,17 @@ namespace SourceGit.Views.Controls {
|
|||
/// </summary>
|
||||
public class Window : System.Windows.Window {
|
||||
|
||||
public static readonly DependencyProperty IsMaximizedProperty = DependencyProperty.Register(
|
||||
"IsMaximized",
|
||||
typeof(bool),
|
||||
typeof(Window),
|
||||
new PropertyMetadata(false, OnIsMaximizedChanged));
|
||||
|
||||
public bool IsMaximized {
|
||||
get { return (bool)GetValue(IsMaximizedProperty); }
|
||||
set { SetValue(IsMaximizedProperty, value); }
|
||||
}
|
||||
|
||||
public Window() {
|
||||
Background = FindResource("Brush.Window") as Brush;
|
||||
BorderBrush = FindResource("Brush.WindowBorder") as Brush;
|
||||
|
@ -29,13 +40,26 @@ namespace SourceGit.Views.Controls {
|
|||
var content = Content as FrameworkElement;
|
||||
|
||||
if (WindowState == WindowState.Maximized) {
|
||||
if (!IsMaximized) IsMaximized = true;
|
||||
BorderThickness = new Thickness(0);
|
||||
content.Margin = new Thickness((SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.WorkArea.Width) / 2);
|
||||
} else {
|
||||
if (IsMaximized) IsMaximized = false;
|
||||
BorderThickness = new Thickness(1);
|
||||
content.Margin = new Thickness(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void OnIsMaximizedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
Window w = d as Window;
|
||||
if (w != null) {
|
||||
if (w.IsMaximized) {
|
||||
SystemCommands.MaximizeWindow(w);
|
||||
} else {
|
||||
SystemCommands.RestoreWindow(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<controls:Window
|
||||
x:Class="SourceGit.Views.Histories"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
|
@ -36,7 +37,7 @@
|
|||
<!-- Window Commands -->
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" WindowChrome.IsHitTestVisibleInChrome="True">
|
||||
<controls:IconButton Click="Minimize" Width="28" Padding="8" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<controls:IconButton Click="MaximizeOrRestore" Width="28" Padding="8" Icon="{StaticResource Icon.Maximize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="28" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
|
||||
<controls:IconButton Click="Quit" Width="28" Padding="8" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
|
|
@ -36,14 +36,6 @@ namespace SourceGit.Views {
|
|||
SystemCommands.MinimizeWindow(this);
|
||||
}
|
||||
|
||||
private void MaximizeOrRestore(object sender, RoutedEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
SystemCommands.MaximizeWindow(this);
|
||||
} else {
|
||||
SystemCommands.RestoreWindow(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<controls:IconButton Click="OpenPreference" Width="28" Padding="6" Icon="{StaticResource Icon.Preference}" ToolTip="{StaticResource Text.Launcher.Preference}"/>
|
||||
<controls:IconButton Click="OpenAbout" Width="28" Padding="6" Icon="{StaticResource Icon.Help}" ToolTip="{StaticResource Text.Launcher.About}"/>
|
||||
<controls:IconButton Click="Minimize" Width="28" Padding="8" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<controls:IconButton Click="MaximizeOrRestore" Width="28" Padding="8" Icon="{StaticResource Icon.Maximize}" HoverBackground="#40000000" Opacity="1"/>
|
||||
<ToggleButton Style="{StaticResource Style.ToggleButton.MaxOrRestore}" Width="28" IsChecked="{Binding ElementName=me, Path=IsMaximized}"/>
|
||||
<controls:IconButton Click="Quit" Width="28" Padding="8" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
|
|
@ -57,14 +57,6 @@ namespace SourceGit.Views {
|
|||
SystemCommands.MinimizeWindow(this);
|
||||
}
|
||||
|
||||
private void MaximizeOrRestore(object sender, RoutedEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
SystemCommands.MaximizeWindow(this);
|
||||
} else {
|
||||
SystemCommands.RestoreWindow(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue