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

@ -41,7 +41,6 @@
<Geometry x:Key="Icon.ScrollRight">M27 3 L 75 51 L 27 100z</Geometry>
<Geometry x:Key="Icon.Preference">M716.3 383.1c0 38.4-6.5 76-19.4 111.8l-10.7 29.7 229.6 229.5c44.5 44.6 44.5 117.1 0 161.6a113.6 113.6 0 01-80.8 33.5a113.6 113.6 0 01-80.8-33.5L529 694l-32 13a331.6 331.6 0 01-111.9 19.4A333.5 333.5 0 0150 383.1c0-39 6.8-77.2 20-113.6L285 482l194-195-214-210A331 331 0 01383.1 50A333.5 333.5 0 01716.3 383.1zM231.6 31.6l-22.9 9.9a22.2 22.2 0 00-5.9 4.2a19.5 19.5 0 000 27.5l215 215.2L288.4 417.8 77.8 207.1a26 26 0 00-17.2-7.1a22.8 22.8 0 00-21.5 15a400.5 400.5 0 00-7.5 16.6A381.6 381.6 0 000 384c0 211.7 172.2 384 384 384c44.3 0 87.6-7.5 129-22.3L743.1 975.8A163.5 163.5 0 00859.5 1024c43.9 0 85.3-17.1 116.4-48.2a164.8 164.8 0 000-233L745.5 513C760.5 471.5 768 428 768 384C768 172 596 0 384 0c-53 0-104 10.5-152.5 31.5z</Geometry>
<Geometry x:Key="Icon.Hotkeys">M512 0C229.216 0 0 229.216 0 512c0 282.752 229.216 512 512 512s512-229.248 512-512c0-282.784-229.216-512-512-512z m0 957.92C266.112 957.92 66.08 757.888 66.08 512S266.112 66.08 512 66.08 957.92 266.112 957.92 512 757.888 957.92 512 957.92zM192 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM384 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM576 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM832 320h-64a32 32 0 0 0-32 32v128h-160a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h256a32 32 0 0 0 32-32v-192a32 32 0 0 0-32-32zM320 544v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h96a32 32 0 0 0 32-32zM384 576h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM800 640H256a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h544a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32z</Geometry>
<Geometry x:Key="Icon.Setting">M928 500a21 21 0 00-19-20L858 472a11 11 0 01-9-9c-1-6-2-13-3-19a11 11 0 015-12l46-25a21 21 0 0010-26l-8-22a21 21 0 00-24-13l-51 10a11 11 0 01-12-6c-3-6-6-11-10-17a11 11 0 011-13l34-39a21 21 0 001-28l-15-18a20 20 0 00-27-4l-45 27a11 11 0 01-13-1c-5-4-10-9-15-12a11 11 0 01-3-12l19-49a21 21 0 00-9-26l-20-12a21 21 0 00-27 6L650 193a9 9 0 01-11 3c-1-1-12-5-20-7a11 11 0 01-7-10l1-52a21 21 0 00-17-22l-23-4a21 21 0 00-24 14L532 164a11 11 0 01-11 7h-20a11 11 0 01-11-7l-17-49a21 21 0 00-24-15l-23 4a21 21 0 00-17 22l1 52a11 11 0 01-8 11c-5 2-15 6-19 7c-4 1-8 0-12-4l-33-40A21 21 0 00313 146l-20 12A21 21 0 00285 184l19 49a11 11 0 01-3 12c-5 4-10 8-15 12a11 11 0 01-13 1L228 231a21 21 0 00-27 4L186 253a21 21 0 001 28L221 320a11 11 0 011 13c-3 5-7 11-10 17a11 11 0 01-12 6l-51-10a21 21 0 00-24 13l-8 22a21 21 0 0010 26l46 25a11 11 0 015 12l0 3c-1 6-2 11-3 16a11 11 0 01-9 9l-51 8A21 21 0 0096 500v23A21 21 0 00114 544l51 8a11 11 0 019 9c1 6 2 13 3 19a11 11 0 01-5 12l-46 25a21 21 0 00-10 26l8 22a21 21 0 0024 13l51-10a11 11 0 0112 6c3 6 6 11 10 17a11 11 0 01-1 13l-34 39a21 21 0 00-1 28l15 18a20 20 0 0027 4l45-27a11 11 0 0113 1c5 4 10 9 15 12a11 11 0 013 12l-19 49a21 21 0 009 26l20 12a21 21 0 0027-6L374 832c3-3 7-5 10-4c7 3 12 5 20 7a11 11 0 018 10l-1 52a21 21 0 0017 22l23 4a21 21 0 0024-14l17-50a11 11 0 0111-7h20a11 11 0 0111 7l17 49a21 21 0 0020 15a19 19 0 004 0l23-4a21 21 0 0017-22l-1-52a11 11 0 018-10c8-3 13-5 18-7l1 0c6-2 9 0 11 3l34 41A21 21 0 00710 878l20-12a21 21 0 009-26l-18-49a11 11 0 013-12c5-4 10-8 15-12a11 11 0 0113-1l45 27a21 21 0 0027-4l15-18a21 21 0 00-1-28l-34-39a11 11 0 01-1-13c3-5 7-11 10-17a11 11 0 0112-6l51 10a21 21 0 0024-13l8-22a21 21 0 00-10-26l-46-25a11 11 0 01-5-12l0-3c1-6 2-11 3-16a11 11 0 019-9l51-8a21 21 0 0018-21v-23zm-565 188a32 32 0 01-51 5a270 270 0 011-363a32 32 0 0151 6l91 161a32 32 0 010 31zM512 782a270 270 0 01-57-6a32 32 0 01-20-47l92-160a32 32 0 0127-16h184a32 32 0 0130 41c-35 109-137 188-257 188zm15-328L436 294a32 32 0 0121-47a268 268 0 0155-6c120 0 222 79 257 188a32 32 0 01-30 41h-184a32 32 0 01-28-16z</Geometry>
<Geometry x:Key="Icon.Help">M550 627h-81v-21a142 142 0 0113-64a198 198 0 0152-57a390 390 0 0047-42a56 56 0 0012-34a58 58 0 00-21-45a81 81 0 00-56-19a85 85 0 00-57 20a103 103 0 00-32 59l-82-10a136 136 0 0149-96A172 172 0 01512 276a178 178 0 01123 40a122 122 0 0145 94a103 103 0 01-17 56a366 366 0 01-71 72A136 136 0 00556 576a128 128 0 00-6 51zm-81 120v-89h89v89zM512 64a448 448 0 10448 448A448 448 0 00512 64zm0 832a384 384 0 010-768a389 389 0 01384 384a389 389 0 01-384 384z</Geometry>
<Geometry x:Key="Icon.Folder">M64 864h896V288h-396a64 64 0 01-57-35L460 160H64v704zm-64 32V128a32 32 0 0132-32h448a32 32 0 0129 18L564 224H992a32 32 0 0132 32v640a32 32 0 01-32 32H32a32 32 0 01-32-32z</Geometry>

View file

@ -182,8 +182,9 @@
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid x:Name="BG" Background="Transparent">
<Path
x:Name="Icon"
Height="12"
x:Name="Icon"
Width="10"
Height="10"
Style="{DynamicResource Style.Icon}"
Fill="{DynamicResource Brush.FG1}"
Data="{DynamicResource Icon.Maximize}"/>

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();