mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: replace all window with custom ChromelessWindow
This commit is contained in:
parent
68061f82b1
commit
f5b35d3db2
23 changed files with 414 additions and 649 deletions
|
@ -7,8 +7,17 @@ using Avalonia.Interactivity;
|
|||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class Launcher : Window, Models.INotificationReceiver
|
||||
public partial class Launcher : ChromelessWindow, Models.INotificationReceiver
|
||||
{
|
||||
public static readonly StyledProperty<GridLength> TitleBarHeightProperty =
|
||||
AvaloniaProperty.Register<Launcher, GridLength>(nameof(TitleBarHeight), new GridLength(38, GridUnitType.Pixel));
|
||||
|
||||
public GridLength TitleBarHeight
|
||||
{
|
||||
get => GetValue(TitleBarHeightProperty);
|
||||
set => SetValue(TitleBarHeightProperty, value);
|
||||
}
|
||||
|
||||
public Launcher()
|
||||
{
|
||||
DataContext = new ViewModels.Launcher();
|
||||
|
@ -34,6 +43,20 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
||||
if (change.Property == WindowStateProperty)
|
||||
{
|
||||
var state = (WindowState)change.NewValue;
|
||||
if (state == WindowState.Maximized)
|
||||
SetCurrentValue(TitleBarHeightProperty, new GridLength(OperatingSystem.IsMacOS() ? 34 : 30));
|
||||
else
|
||||
SetCurrentValue(TitleBarHeightProperty, new GridLength(38, GridUnitType.Pixel));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ViewModels.Launcher;
|
||||
|
@ -136,36 +159,20 @@ namespace SourceGit.Views
|
|||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private void MaximizeOrRestoreWindow(object sender, TappedEventArgs e)
|
||||
private void OnTitleBarDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (WindowState == WindowState.Maximized)
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = WindowState.Maximized;
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void CustomResizeWindow(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (sender is Border border)
|
||||
{
|
||||
if (border.Tag is WindowEdge edge)
|
||||
{
|
||||
BeginResizeDrag(edge, e);
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void BeginMoveWindow(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.ClickCount != 2)
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollTabs(object sender, PointerWheelEventArgs e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue