mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00: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
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue