style<Launcher>: move hotkeys to about dialog

This commit is contained in:
leo 2021-07-20 20:15:22 +08:00
parent 287e3b3bc8
commit a7a1817ad2
8 changed files with 68 additions and 141 deletions

View file

@ -8,7 +8,7 @@
mc:Ignorable="d"
WindowStartupLocation="CenterOwner"
Title="{DynamicResource Text.About}"
Height="280" Width="400"
Width="400" SizeToContent="Height"
ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
@ -75,16 +75,52 @@
FontSize="11"
Text="VERSION: v1.0 .NET: v5.0"/>
<DataGrid
x:Name="hotkeys"
Grid.Row="2"
Margin="16,8"
Background="{DynamicResource Brush.Contents}"
GridLinesVisibility="All"
HorizontalGridLinesBrush="{DynamicResource Brush.Border0}"
VerticalGridLinesBrush="{DynamicResource Brush.Border0}"
HeadersVisibility="Column"
RowHeight="24"
ColumnHeaderHeight="24"
BorderThickness="1,1,0,0"
BorderBrush="{DynamicResource Brush.Border0}">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Border BorderThickness="0,0,1,1" BorderBrush="{DynamicResource Brush.Border0}" Background="{DynamicResource Brush.Window}">
<TextBlock
Text="{TemplateBinding Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="DemiBold"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="100" Header="{DynamicResource Text.Hotkeys.Col.Key}" Binding="{Binding .Key}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Hotkeys.Col.Desc}" Binding="{Binding .Desc}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
</DataGrid.Columns>
</DataGrid>
<!-- Official site -->
<TextBlock HorizontalAlignment="Center" Margin="0,16,0,4">
<Hyperlink NavigateUri="https://gitee.com/sourcegit/sourcegit.git" RequestNavigate="OnRequestNavigate">
<Run Text="https://gitee.com/sourcegit/sourcegit.git"/>
</Hyperlink>
<TextBlock HorizontalAlignment="Center" Margin="0,4">
<Hyperlink NavigateUri="https://gitee.com/sourcegit/sourcegit.git" RequestNavigate="OnRequestNavigate">
<Run Text="https://gitee.com/sourcegit/sourcegit.git"/>
</Hyperlink>
</TextBlock>
<!-- Copyrights -->
<TextBlock
Margin="0,4"
Margin="0,4,0,16"
Text="Copyright © sourcegit 2021. All rights reserved."
HorizontalAlignment="Center"/>
</StackPanel>

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
@ -10,6 +11,12 @@ namespace SourceGit.Views {
/// </summary>
public partial class About : Controls.Window {
public class Keymap {
public string Key { get; set; }
public string Desc { get; set; }
public Keymap(string k, string d) { Key = k; Desc = App.Text($"Hotkeys.{d}"); }
}
public About() {
InitializeComponent();
@ -18,6 +25,16 @@ namespace SourceGit.Views {
var dotnetVer = framework.Substring(framework.IndexOf("=") + 1);
version.Text = $"VERSION : v{asm.Version.Major}.{asm.Version.Minor} .NET : {dotnetVer}";
hotkeys.ItemsSource = new List<Keymap>() {
new Keymap("CTRL + T", "NewTab"),
new Keymap("CTRL + W", "CloseTab"),
new Keymap("CTRL + TAB", "NextTab"),
new Keymap("CTRL + [1-9]", "SwitchTo"),
new Keymap("CTRL + F", "Search"),
new Keymap("F5", "Refresh"),
new Keymap("SPACE", "ToggleStage"),
};
}
private void OnRequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {

View file

@ -1,88 +0,0 @@
<controls:Window
x:Class="SourceGit.Views.Hotkeys"
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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
mc:Ignorable="d"
SizeToContent="Height" Width="400"
Title="{DynamicResource Text.Hotkeys}"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="1"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Title bar -->
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Icon -->
<Path Grid.Column="0" Margin="6,0" Width="16" Height="16" Data="{StaticResource Icon.Hotkeys}"/>
<!-- Title -->
<TextBlock Grid.Column="1" Text="{DynamicResource Text.Hotkeys}"/>
<!-- Close -->
<controls:IconButton
Grid.Column="3"
Click="Quit"
Width="28"
Padding="8"
Icon="{StaticResource Icon.Close}"
HoverBackground="Red"
WindowChrome.IsHitTestVisibleInChrome="True"/>
</Grid>
<Rectangle
Grid.Row="1"
Height="1"
HorizontalAlignment="Stretch"
Fill="{DynamicResource Brush.Border0}"/>
<DataGrid
x:Name="container"
Grid.Row="2"
Margin="8"
Background="{DynamicResource Brush.Contents}"
GridLinesVisibility="All"
HorizontalGridLinesBrush="{DynamicResource Brush.Border0}"
VerticalGridLinesBrush="{DynamicResource Brush.Border0}"
HeadersVisibility="Column"
RowHeight="24"
ColumnHeaderHeight="24"
BorderThickness="1,1,0,0"
BorderBrush="{DynamicResource Brush.Border0}">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Border BorderThickness="0,0,1,1" BorderBrush="{DynamicResource Brush.Border0}" Background="{DynamicResource Brush.Window}">
<TextBlock
Text="{TemplateBinding Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="DemiBold"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="100" Header="{DynamicResource Text.Hotkeys.Col.Key}" Binding="{Binding .Key}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Hotkeys.Col.Desc}" Binding="{Binding .Desc}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</controls:Window>

View file

@ -1,35 +0,0 @@
using System.Collections.Generic;
using System.Windows;
namespace SourceGit.Views {
/// <summary>
/// 快捷键说明
/// </summary>
public partial class Hotkeys : Controls.Window {
public class Keymap {
public string Key { get; set; }
public string Desc { get; set; }
public Keymap(string k, string d) { Key = k; Desc = App.Text($"Hotkeys.{d}"); }
}
public Hotkeys() {
InitializeComponent();
container.ItemsSource = new List<Keymap>() {
new Keymap("CTRL + T", "NewTab"),
new Keymap("CTRL + W", "CloseTab"),
new Keymap("CTRL + TAB", "NextTab"),
new Keymap("CTRL + [1-9]", "SwitchTo"),
new Keymap("CTRL + F", "Search"),
new Keymap("F5", "Refresh"),
new Keymap("SPACE", "ToggleStage"),
};
}
private void Quit(object sender, RoutedEventArgs e) {
Close();
}
}
}

View file

@ -25,7 +25,7 @@
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="250"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<!-- Bottom border -->
@ -43,11 +43,13 @@
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Height="27" WindowChrome.IsHitTestVisibleInChrome="True">
<controls:IconButton Click="OpenPreference" Width="28" Padding="6" Icon="{StaticResource Icon.Preference}" ToolTip="{DynamicResource Text.Launcher.Preference}"/>
<ToggleButton Style="{StaticResource Style.ToggleButton.Theme}" Width="28" IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseDarkTheme, Mode=TwoWay}" Checked="ChangeTheme" Unchecked="ChangeTheme" ToolTip="{DynamicResource Text.ThemeSwitcher}"/>
<controls:IconButton Click="OpenHotkeys" Width="28" Padding="6" Icon="{StaticResource Icon.Hotkeys}" ToolTip="{DynamicResource Text.Hotkeys}"/>
<controls:IconButton Click="OpenAbout" Width="28" Padding="6" Icon="{StaticResource Icon.Help}" ToolTip="{DynamicResource Text.Launcher.About}"/>
<controls:IconButton Click="Minimize" Width="28" Padding="8" Icon="{StaticResource Icon.Minimize}" HoverBackground="#40000000" Opacity="1"/>
<Rectangle Margin="4,0" Width="1" Height="16" VerticalAlignment="Center" Fill="{DynamicResource Brush.Border2}"/>
<controls:IconButton Click="Minimize" Width="28" Padding="9" Icon="{StaticResource Icon.Minimize}" 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"/>
<controls:IconButton Click="Quit" Width="28" Padding="9" Icon="{StaticResource Icon.Close}" HoverBackground="Red" Opacity="1"/>
</StackPanel>
</Grid>

View file

@ -78,11 +78,6 @@ namespace SourceGit.Views {
dialog.ShowDialog();
}
private void OpenHotkeys(object sender, RoutedEventArgs e) {
var dialog = new Hotkeys() { Owner = this };
dialog.ShowDialog();
}
private void OpenAbout(object sender, RoutedEventArgs e) {
var dialog = new About() { Owner = this };
dialog.ShowDialog();