mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
refactor<*>: add Controls.Window to replace System.Windows.Window
This commit is contained in:
parent
31dd0eb832
commit
4b9923b84c
15 changed files with 842 additions and 879 deletions
|
@ -4,7 +4,7 @@
|
|||
<SolidColorBrush x:Key="Brush.Logo" Color="#FFF05133"/>
|
||||
|
||||
<SolidColorBrush x:Key="Brush.Window" Color="#FFF8F8F8"/>
|
||||
<SolidColorBrush x:Key="Brush.WindowBorder" Color="#FF505050"/>
|
||||
<SolidColorBrush x:Key="Brush.WindowBorder" Color="#FF4295FF"/>
|
||||
|
||||
<SolidColorBrush x:Key="Brush.TitleBar" Color="White"/>
|
||||
<SolidColorBrush x:Key="Brush.NewPageHover" Color="#1D000000"/>
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
<Window x:Class="SourceGit.Views.About"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.About"
|
||||
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"
|
||||
UseLayoutRounding="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="{StaticResource Text.About}"
|
||||
Height="280" Width="400"
|
||||
ResizeMode="NoResize">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -93,5 +88,4 @@
|
|||
HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 关于对话框
|
||||
/// </summary>
|
||||
public partial class About : Window {
|
||||
public partial class About : Controls.Window {
|
||||
|
||||
public About() {
|
||||
InitializeComponent();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<Window x:Class="SourceGit.Views.Blame"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Blame"
|
||||
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"
|
||||
|
@ -6,17 +7,8 @@
|
|||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
Title="{StaticResource Text.Blame}"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
RenderOptions.ClearTypeHint="Enabled"
|
||||
UseLayoutRounding="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Height="600" Width="800">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -144,5 +136,4 @@
|
|||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 逐行追溯
|
||||
/// </summary>
|
||||
public partial class Blame : Window {
|
||||
public partial class Blame : Controls.Window {
|
||||
private static readonly Brush[] BG = new Brush[] {
|
||||
Brushes.Transparent,
|
||||
new SolidColorBrush(Color.FromArgb(128, 0, 0, 0))
|
||||
|
|
41
src/Views/Controls/Window.cs
Normal file
41
src/Views/Controls/Window.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shell;
|
||||
|
||||
namespace SourceGit.Views.Controls {
|
||||
/// <summary>
|
||||
/// 项目使用的窗体基类
|
||||
/// </summary>
|
||||
public class Window : System.Windows.Window {
|
||||
|
||||
public Window() {
|
||||
Background = FindResource("Brush.Window") as Brush;
|
||||
BorderBrush = FindResource("Brush.WindowBorder") as Brush;
|
||||
BorderThickness = new Thickness(1);
|
||||
|
||||
SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
|
||||
SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType);
|
||||
SetValue(TextOptions.TextHintingModeProperty, TextHintingMode.Animated);
|
||||
UseLayoutRounding = true;
|
||||
|
||||
var chrome = new WindowChrome();
|
||||
chrome.ResizeBorderThickness = new Thickness(4);
|
||||
chrome.UseAeroCaptionButtons = false;
|
||||
chrome.CornerRadius = new CornerRadius(0);
|
||||
chrome.CaptionHeight = 28;
|
||||
WindowChrome.SetWindowChrome(this, chrome);
|
||||
|
||||
StateChanged += (_, __) => {
|
||||
var content = Content as FrameworkElement;
|
||||
|
||||
if (WindowState == WindowState.Maximized) {
|
||||
BorderThickness = new Thickness(0);
|
||||
content.Margin = new Thickness((SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.WorkArea.Width) / 2);
|
||||
} else {
|
||||
BorderThickness = new Thickness(1);
|
||||
content.Margin = new Thickness(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGit.Views.Controls {
|
||||
|
||||
/// <summary>
|
||||
/// 主窗体Border
|
||||
/// </summary>
|
||||
public class WindowBorder : Border {
|
||||
|
||||
public WindowBorder() {
|
||||
Background = FindResource("Brush.Window") as Brush;
|
||||
BorderBrush = FindResource("Brush.WindowBorder") as Brush;
|
||||
BorderThickness = new Thickness(1);
|
||||
Margin = new Thickness(0);
|
||||
|
||||
Loaded += (o, e) => {
|
||||
var owner = Parent as Window;
|
||||
if (owner != null) {
|
||||
owner.StateChanged += (o1, e1) => {
|
||||
if (owner.WindowState == WindowState.Maximized) {
|
||||
BorderThickness = new Thickness(0);
|
||||
Margin = new Thickness(
|
||||
(SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.WorkArea.Width) / 2
|
||||
);
|
||||
} else {
|
||||
BorderThickness = new Thickness(1);
|
||||
Margin = new Thickness(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<Window x:Class="SourceGit.Views.Histories"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Histories"
|
||||
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"
|
||||
|
@ -8,17 +9,8 @@
|
|||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||
mc:Ignorable="d"
|
||||
Title="{StaticResource Text.FileHistory}"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
RenderOptions.ClearTypeHint="Enabled"
|
||||
UseLayoutRounding="True"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
MinHeight="600" MinWidth="800">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -143,5 +135,4 @@
|
|||
<widgets:DiffViewer Grid.Column="2" x:Name="diffViewer" Padding="4"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 文件历史
|
||||
/// </summary>
|
||||
public partial class Histories : Window {
|
||||
public partial class Histories : Controls.Window {
|
||||
private string repo = null;
|
||||
private string file = null;
|
||||
private bool isLFSEnabled = false;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<Window x:Class="SourceGit.Views.Launcher"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Launcher"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -8,20 +9,11 @@
|
|||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||
xmlns:models="clr-namespace:SourceGit.Models"
|
||||
mc:Ignorable="d"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
RenderOptions.ClearTypeHint="Enabled"
|
||||
UseLayoutRounding="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
MinWidth="1280" MinHeight="720"
|
||||
Title="{StaticResource Text.About.Title}"
|
||||
Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}"
|
||||
Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<controls:DragDropAdornerLayer>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -65,5 +57,4 @@
|
|||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
Width="330" Height="Auto"/>
|
||||
</controls:DragDropAdornerLayer>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 主窗体
|
||||
/// </summary>
|
||||
public partial class Launcher : Window {
|
||||
public partial class Launcher : Controls.Window {
|
||||
|
||||
public Launcher() {
|
||||
Models.Watcher.Opened += OpenRepository;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<Window x:Class="SourceGit.Views.Preference"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Preference"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -9,14 +10,8 @@
|
|||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
UseLayoutRounding="True"
|
||||
Title="{StaticResource Text.Preference}"
|
||||
Width="500" SizeToContent="Height">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
|
@ -310,5 +305,4 @@
|
|||
Foreground="{StaticResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 设置面板
|
||||
/// </summary>
|
||||
public partial class Preference : Window {
|
||||
public partial class Preference : Controls.Window {
|
||||
|
||||
public string User { get; set; }
|
||||
public string Email { get; set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<Window x:Class="SourceGit.Views.Upgrade"
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Upgrade"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
|
@ -6,19 +7,14 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
UseLayoutRounding="True"
|
||||
Title="{StaticResource Text.UpdateAvailable}"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Height="400" Width="500"
|
||||
ResizeMode="NoResize">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome UseAeroCaptionButtons="False" CornerRadius="0" CaptionHeight="28" ResizeBorderThickness="1"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<controls:WindowBorder>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="1"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="32"/>
|
||||
|
@ -49,8 +45,10 @@
|
|||
WindowChrome.IsHitTestVisibleInChrome="True"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle Grid.Row="1" Fill="{StaticResource Brush.Border0}" HorizontalAlignment="Stretch" Height="1"/>
|
||||
|
||||
<!-- Body -->
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="8,16,8,0">
|
||||
<StackPanel Grid.Row="2" Orientation="Vertical" Margin="8,16,8,0">
|
||||
<!-- Title -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Path Width="20" Height="20" Data="{StaticResource Icon.Git}" Fill="{StaticResource Brush.Logo}"/>
|
||||
|
@ -82,7 +80,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<!-- CHANGELOG -->
|
||||
<Border Grid.Row="2" Margin="8" Background="{StaticResource Brush.Contents}" BorderBrush="{StaticResource Brush.Border1}" BorderThickness="1">
|
||||
<Border Grid.Row="3" Margin="8" Background="{StaticResource Brush.Contents}" BorderBrush="{StaticResource Brush.Border1}" BorderThickness="1">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock
|
||||
FontSize="10pt"
|
||||
|
@ -111,5 +109,4 @@
|
|||
Content="{StaticResource Text.Cancel}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</controls:WindowBorder>
|
||||
</Window>
|
||||
</controls:Window>
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace SourceGit.Views {
|
|||
/// <summary>
|
||||
/// 新版本提示窗口
|
||||
/// </summary>
|
||||
public partial class Upgrade : Window {
|
||||
public partial class Upgrade : Controls.Window {
|
||||
public Models.Version Version { get; set; } = new Models.Version();
|
||||
|
||||
public Upgrade(Models.Version ver) {
|
||||
|
|
Loading…
Reference in a new issue