From 74252df5b69ac320bd1f14e33dbcfe452dbd49a6 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 31 Oct 2024 21:36:51 +0800 Subject: [PATCH] code_style: move `BeginMoveWindow` to `ChromelessWindow` Signed-off-by: leo --- src/Resources/Icons.axaml | 3 - src/Views/AIAssistant.axaml | 19 +-- src/Views/AIAssistant.axaml.cs | 6 - src/Views/About.axaml | 19 +-- src/Views/About.axaml.cs | 5 - src/Views/Askpass.axaml | 19 +-- src/Views/Askpass.axaml.cs | 6 - src/Views/AssumeUnchangedManager.axaml | 19 +-- src/Views/AssumeUnchangedManager.axaml.cs | 6 - src/Views/Blame.axaml | 23 +-- src/Views/Blame.axaml.cs | 28 ++- src/Views/BranchCompare.axaml | 23 +-- src/Views/BranchCompare.axaml.cs | 31 +++- src/Views/CaptionButtonsMacOS.axaml | 159 ------------------ src/Views/CaptionButtonsMacOS.axaml.cs | 49 ------ src/Views/ChromelessWindow.cs | 19 ++- src/Views/ConfigureWorkspace.axaml | 23 +-- src/Views/ConfigureWorkspace.axaml.cs | 6 - src/Views/ConfirmCommitWithoutFiles.axaml | 21 +-- src/Views/ConfirmCommitWithoutFiles.axaml.cs | 6 - src/Views/ConfirmRestart.axaml | 19 +-- src/Views/ConfirmRestart.axaml.cs | 7 - .../ConventionalCommitMessageBuilder.axaml | 22 +-- .../ConventionalCommitMessageBuilder.axaml.cs | 6 - src/Views/FileHistories.axaml | 25 ++- src/Views/FileHistories.axaml.cs | 31 +++- src/Views/Hotkeys.axaml | 19 +-- src/Views/Hotkeys.axaml.cs | 7 - src/Views/InteractiveRebase.axaml | 19 +-- src/Views/InteractiveRebase.axaml.cs | 5 - src/Views/LFSLocks.axaml | 19 +-- src/Views/LFSLocks.axaml.cs | 6 - src/Views/Launcher.axaml | 4 +- src/Views/Launcher.axaml.cs | 34 ++-- src/Views/Preference.axaml | 21 +-- src/Views/Preference.axaml.cs | 6 - src/Views/RepositoryConfigure.axaml | 21 +-- src/Views/RepositoryConfigure.axaml.cs | 6 - src/Views/SelfUpdate.axaml | 19 +-- src/Views/SelfUpdate.axaml.cs | 6 - src/Views/StandaloneCommitMessageEditor.axaml | 19 +-- .../StandaloneCommitMessageEditor.axaml.cs | 6 - src/Views/Statistics.axaml | 19 +-- src/Views/Statistics.axaml.cs | 7 - 44 files changed, 234 insertions(+), 609 deletions(-) delete mode 100644 src/Views/CaptionButtonsMacOS.axaml delete mode 100644 src/Views/CaptionButtonsMacOS.axaml.cs diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index cc56d33d..bf664de2 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -71,9 +71,6 @@ M512 0C233 0 7 223 0 500C6 258 190 64 416 64c230 0 416 200 416 448c0 53 43 96 96 96s96-43 96-96c0-283-229-512-512-512zm0 1023c279 0 505-223 512-500c-6 242-190 436-416 436c-230 0-416-200-416-448c0-53-43-96-96-96s-96 43-96 96c0 283 229 512 512 512z M976 0h-928A48 48 0 000 48v652a48 48 0 0048 48h416V928H200a48 48 0 000 96h624a48 48 0 000-96H560v-180h416a48 48 0 0048-48V48A48 48 0 00976 0zM928 652H96V96h832v556z M832 464h-68V240a128 128 0 00-128-128h-248a128 128 0 00-128 128v224H192c-18 0-32 14-32 32v384c0 18 14 32 32 32h640c18 0 32-14 32-32v-384c0-18-14-32-32-32zm-292 237v53a8 8 0 01-8 8h-40a8 8 0 01-8-8v-53a48 48 0 1156 0zm152-237H332V240a56 56 0 0156-56h248a56 56 0 0156 56v224z - M887 774 625 511l263-260c11-11 11-28 0-39l-75-75c-5-5-12-8-20-8-7 0-14 3-20 8L512 396 250 137c-5-5-12-8-20-8-7 0-14 3-20 8L136 212c-11 11-11 28 0 39l263 260L137 774c-5 5-8 12-8 20 0 7 3 14 8 20l75 75c5 5 12 8 20 8 7 0 14-3 20-8L512 626l261 262c5 5 12 8 20 8 7 0 14-3 20-8l75-75c5-5 8-12 8-20C895 786 892 779 887 774z - M1024 750v110c0 50-41 91-91 91h-841A92 92 0 010 859v-110C0 699 41 658 91 658h841c50 0 91 41 91 91z - M0 4 0 20 16 20 0 4M4 0 20 0 20 16 4 0z M192 192m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM864 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 480H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 800H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32z M824 645V307c0-56-46-102-102-102h-102V102l-154 154 154 154V307h102v338c-46 20-82 67-82 123 0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123zm-51 195c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72zM384 256c0-72-61-133-133-133-72 0-133 61-133 133 0 56 36 102 82 123v266C154 666 118 712 118 768c0 72 61 133 133 133 72 0 133-61 133-133 0-56-36-102-82-123V379C348 358 384 312 384 256zM323 768c0 41-31 72-72 72-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72zM251 328c-41 0-72-31-72-72s31-72 72-72c41 0 72 31 72 72s-31 72-72 72z M896 64H128C96 64 64 96 64 128v768c0 32 32 64 64 64h768c32 0 64-32 64-64V128c0-32-32-64-64-64z m-64 736c0 16-17 32-32 32H224c-18 0-32-12-32-32V224c0-16 16-32 32-32h576c15 0 32 16 32 32v576zM512 384c-71 0-128 57-128 128s57 128 128 128 128-57 128-128-57-128-128-128z diff --git a/src/Views/AIAssistant.axaml b/src/Views/AIAssistant.axaml index 1c266715..528d0e5b 100644 --- a/src/Views/AIAssistant.axaml +++ b/src/Views/AIAssistant.axaml @@ -15,30 +15,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/AIAssistant.axaml.cs b/src/Views/AIAssistant.axaml.cs index 331d380d..d81335eb 100644 --- a/src/Views/AIAssistant.axaml.cs +++ b/src/Views/AIAssistant.axaml.cs @@ -4,7 +4,6 @@ using System.Threading; using System.Threading.Tasks; using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Threading; namespace SourceGit.Views @@ -55,11 +54,6 @@ namespace SourceGit.Views _cancel.Cancel(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void SetDescription(string message) { Dispatcher.UIThread.Invoke(() => ProgressMessage.Text = message); diff --git a/src/Views/About.axaml b/src/Views/About.axaml index 159a34a9..d781ee9e 100644 --- a/src/Views/About.axaml +++ b/src/Views/About.axaml @@ -13,30 +13,23 @@ WindowStartupLocation="CenterScreen"> - - + - - - - - diff --git a/src/Views/About.axaml.cs b/src/Views/About.axaml.cs index 4f7f953f..b02cd13f 100644 --- a/src/Views/About.axaml.cs +++ b/src/Views/About.axaml.cs @@ -21,11 +21,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e) { Native.OS.OpenBrowser("https://www.avaloniaui.net/"); diff --git a/src/Views/Askpass.axaml b/src/Views/Askpass.axaml index e3e9a499..9a38c58f 100644 --- a/src/Views/Askpass.axaml +++ b/src/Views/Askpass.axaml @@ -13,30 +13,23 @@ WindowStartupLocation="CenterScreen"> - - + - - - - - diff --git a/src/Views/Askpass.axaml.cs b/src/Views/Askpass.axaml.cs index 305e9843..673fd8ef 100644 --- a/src/Views/Askpass.axaml.cs +++ b/src/Views/Askpass.axaml.cs @@ -1,7 +1,6 @@ using System; using Avalonia; -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -42,11 +41,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void CloseWindow(object _1, RoutedEventArgs _2) { Console.Out.WriteLine("No passphrase entered."); diff --git a/src/Views/AssumeUnchangedManager.axaml b/src/Views/AssumeUnchangedManager.axaml index 2503d586..28e4d3bd 100644 --- a/src/Views/AssumeUnchangedManager.axaml +++ b/src/Views/AssumeUnchangedManager.axaml @@ -16,30 +16,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/AssumeUnchangedManager.axaml.cs b/src/Views/AssumeUnchangedManager.axaml.cs index ae9c7fe6..a0a5a352 100644 --- a/src/Views/AssumeUnchangedManager.axaml.cs +++ b/src/Views/AssumeUnchangedManager.axaml.cs @@ -1,5 +1,4 @@ using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -11,11 +10,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void OnRemoveButtonClicked(object sender, RoutedEventArgs e) { if (DataContext is ViewModels.AssumeUnchangedManager vm && sender is Button button) diff --git a/src/Views/Blame.axaml b/src/Views/Blame.axaml index 9cf8b78a..af98021c 100644 --- a/src/Views/Blame.axaml +++ b/src/Views/Blame.axaml @@ -19,29 +19,24 @@ - + - - - - - - - + - - + + + + + - - - + diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs index f96870e0..df41ec71 100644 --- a/src/Views/Blame.axaml.cs +++ b/src/Views/Blame.axaml.cs @@ -430,11 +430,31 @@ namespace SourceGit.Views public partial class Blame : ChromelessWindow { + public static readonly StyledProperty HasLeftCaptionButtonProperty = + AvaloniaProperty.Register(nameof(HasLeftCaptionButton)); + + public bool HasLeftCaptionButton + { + get => GetValue(HasLeftCaptionButtonProperty); + set => SetValue(HasLeftCaptionButtonProperty, value); + } + public Blame() { + if (OperatingSystem.IsMacOS()) + HasLeftCaptionButton = true; + InitializeComponent(); } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == WindowStateProperty) + HasLeftCaptionButton = WindowState != WindowState.FullScreen; + } + private void MaximizeOrRestoreWindow(object _, TappedEventArgs e) { if (WindowState == WindowState.Maximized) @@ -445,14 +465,6 @@ namespace SourceGit.Views e.Handled = true; } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - if (e.ClickCount == 1) - BeginMoveDrag(e); - - e.Handled = true; - } - protected override void OnClosed(EventArgs e) { base.OnClosed(e); diff --git a/src/Views/BranchCompare.axaml b/src/Views/BranchCompare.axaml index a8bbc4af..28209b6d 100644 --- a/src/Views/BranchCompare.axaml +++ b/src/Views/BranchCompare.axaml @@ -21,29 +21,24 @@ - + - - - - - - - + - - + + + + + - - - + diff --git a/src/Views/BranchCompare.axaml.cs b/src/Views/BranchCompare.axaml.cs index 844a1b6b..b2fd36be 100644 --- a/src/Views/BranchCompare.axaml.cs +++ b/src/Views/BranchCompare.axaml.cs @@ -1,3 +1,6 @@ +using System; + +using Avalonia; using Avalonia.Controls; using Avalonia.Input; @@ -5,10 +8,30 @@ namespace SourceGit.Views { public partial class BranchCompare : ChromelessWindow { + public static readonly StyledProperty HasLeftCaptionButtonProperty = + AvaloniaProperty.Register(nameof(HasLeftCaptionButton)); + + public bool HasLeftCaptionButton + { + get => GetValue(HasLeftCaptionButtonProperty); + set => SetValue(HasLeftCaptionButtonProperty, value); + } + public BranchCompare() { + if (OperatingSystem.IsMacOS()) + HasLeftCaptionButton = true; + InitializeComponent(); } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == WindowStateProperty) + HasLeftCaptionButton = WindowState != WindowState.FullScreen; + } private void MaximizeOrRestoreWindow(object _, TappedEventArgs e) { @@ -20,14 +43,6 @@ namespace SourceGit.Views e.Handled = true; } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - if (e.ClickCount == 1) - BeginMoveDrag(e); - - e.Handled = true; - } - private void OnChangeContextRequested(object sender, ContextRequestedEventArgs e) { if (DataContext is ViewModels.BranchCompare vm && sender is ChangeCollectionView view) diff --git a/src/Views/CaptionButtonsMacOS.axaml b/src/Views/CaptionButtonsMacOS.axaml deleted file mode 100644 index 59c12e8d..00000000 --- a/src/Views/CaptionButtonsMacOS.axaml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - #FFED6A5E - #FF69110A - #FFB24F46 - #FF2E0402 - #FFF4BF4F - #FF8F591D - #FFB78F3A - #FF522A0A - #FF61C554 - #FF296017 - #FF48943F - #FF102F07 - - - #FFED6A5E - #FF8C1A10 - #FFF09389 - #FF69120A - #FFF4BF4F - #FF8F591D - #FFFBEB74 - #FF705F1B - #FF61C554 - #FF296017 - #FF86F37F - #FF2C681A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Views/CaptionButtonsMacOS.axaml.cs b/src/Views/CaptionButtonsMacOS.axaml.cs deleted file mode 100644 index 98bbb88f..00000000 --- a/src/Views/CaptionButtonsMacOS.axaml.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Interactivity; -using Avalonia.VisualTree; - -namespace SourceGit.Views -{ - public partial class CaptionButtonsMacOS : UserControl - { - public static readonly StyledProperty IsCloseButtonOnlyProperty = - AvaloniaProperty.Register(nameof(IsCloseButtonOnly)); - - public bool IsCloseButtonOnly - { - get => GetValue(IsCloseButtonOnlyProperty); - set => SetValue(IsCloseButtonOnlyProperty, value); - } - - public CaptionButtonsMacOS() - { - InitializeComponent(); - } - - private void MinimizeWindow(object _, RoutedEventArgs e) - { - var window = this.FindAncestorOfType(); - if (window != null) - window.WindowState = WindowState.Minimized; - - e.Handled = true; - } - - private void MaximizeOrRestoreWindow(object _, RoutedEventArgs e) - { - var window = this.FindAncestorOfType(); - if (window != null) - window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; - - e.Handled = true; - } - - private void CloseWindow(object _, RoutedEventArgs e) - { - var window = this.FindAncestorOfType(); - window?.Close(); - e.Handled = true; - } - } -} diff --git a/src/Views/ChromelessWindow.cs b/src/Views/ChromelessWindow.cs index a9b9f259..95f28ff8 100644 --- a/src/Views/ChromelessWindow.cs +++ b/src/Views/ChromelessWindow.cs @@ -32,14 +32,25 @@ namespace SourceGit.Views Classes.Add("custom_window_frame"); } } - else + else if (OperatingSystem.IsWindows()) { ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome; ExtendClientAreaToDecorationsHint = true; - - if (OperatingSystem.IsWindows()) - Classes.Add("fix_maximized_padding"); + Classes.Add("fix_maximized_padding"); } + else + { + ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome; + ExtendClientAreaToDecorationsHint = true; + } + } + + public void BeginMoveWindow(object _, PointerPressedEventArgs e) + { + if (e.ClickCount == 1) + BeginMoveDrag(e); + + e.Handled = true; } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) diff --git a/src/Views/ConfigureWorkspace.axaml b/src/Views/ConfigureWorkspace.axaml index c7ed900b..9c18ad04 100644 --- a/src/Views/ConfigureWorkspace.axaml +++ b/src/Views/ConfigureWorkspace.axaml @@ -2,10 +2,8 @@ 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:m="using:SourceGit.Models" xmlns:vm="using:SourceGit.ViewModels" xmlns:v="using:SourceGit.Views" - xmlns:c="using:SourceGit.Converters" mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="450" x:Class="SourceGit.Views.ConfigureWorkspace" x:DataType="vm:ConfigureWorkspace" @@ -17,30 +15,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/ConfigureWorkspace.axaml.cs b/src/Views/ConfigureWorkspace.axaml.cs index 82d8cd30..e2cc1cb2 100644 --- a/src/Views/ConfigureWorkspace.axaml.cs +++ b/src/Views/ConfigureWorkspace.axaml.cs @@ -1,5 +1,4 @@ using Avalonia.Controls; -using Avalonia.Input; namespace SourceGit.Views { @@ -15,10 +14,5 @@ namespace SourceGit.Views ViewModels.Preference.Instance.Save(); base.OnClosing(e); } - - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } } } diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml b/src/Views/ConfirmCommitWithoutFiles.axaml index 0b457531..a056f016 100644 --- a/src/Views/ConfirmCommitWithoutFiles.axaml +++ b/src/Views/ConfirmCommitWithoutFiles.axaml @@ -15,30 +15,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml.cs b/src/Views/ConfirmCommitWithoutFiles.axaml.cs index 0be18902..342600fc 100644 --- a/src/Views/ConfirmCommitWithoutFiles.axaml.cs +++ b/src/Views/ConfirmCommitWithoutFiles.axaml.cs @@ -1,4 +1,3 @@ -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -10,11 +9,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void Sure(object _1, RoutedEventArgs _2) { if (DataContext is ViewModels.ConfirmCommitWithoutFiles vm) diff --git a/src/Views/ConfirmRestart.axaml b/src/Views/ConfirmRestart.axaml index 9aafda7e..de2ddd4f 100644 --- a/src/Views/ConfirmRestart.axaml +++ b/src/Views/ConfirmRestart.axaml @@ -13,30 +13,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/ConfirmRestart.axaml.cs b/src/Views/ConfirmRestart.axaml.cs index d0647731..ea49bea1 100644 --- a/src/Views/ConfirmRestart.axaml.cs +++ b/src/Views/ConfirmRestart.axaml.cs @@ -1,8 +1,6 @@ using System; using System.Diagnostics; -using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -14,11 +12,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void CloseWindow(object _1, RoutedEventArgs _2) { Console.Out.WriteLine("No passphrase entered."); diff --git a/src/Views/ConventionalCommitMessageBuilder.axaml b/src/Views/ConventionalCommitMessageBuilder.axaml index ab2ae37f..4fe8b8f9 100644 --- a/src/Views/ConventionalCommitMessageBuilder.axaml +++ b/src/Views/ConventionalCommitMessageBuilder.axaml @@ -5,7 +5,6 @@ xmlns:m="using:SourceGit.Models" xmlns:vm="using:SourceGit.ViewModels" xmlns:v="using:SourceGit.Views" - xmlns:c="using:SourceGit.Converters" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.ConventionalCommitMessageBuilder" x:DataType="vm:ConventionalCommitMessageBuilder" @@ -18,30 +17,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/ConventionalCommitMessageBuilder.axaml.cs b/src/Views/ConventionalCommitMessageBuilder.axaml.cs index dfe56f0d..955450ed 100644 --- a/src/Views/ConventionalCommitMessageBuilder.axaml.cs +++ b/src/Views/ConventionalCommitMessageBuilder.axaml.cs @@ -1,4 +1,3 @@ -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -10,11 +9,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void OnApplyClicked(object _, RoutedEventArgs e) { if (DataContext is ViewModels.ConventionalCommitMessageBuilder builder) diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index bc048706..73f98e73 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -20,29 +20,24 @@ - + - - + - - - - - - + - - + + + + + - - - + diff --git a/src/Views/FileHistories.axaml.cs b/src/Views/FileHistories.axaml.cs index 6a2ee7c9..8675d148 100644 --- a/src/Views/FileHistories.axaml.cs +++ b/src/Views/FileHistories.axaml.cs @@ -1,3 +1,6 @@ +using System; + +using Avalonia; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; @@ -6,10 +9,30 @@ namespace SourceGit.Views { public partial class FileHistories : ChromelessWindow { + public static readonly StyledProperty HasLeftCaptionButtonProperty = + AvaloniaProperty.Register(nameof(HasLeftCaptionButton)); + + public bool HasLeftCaptionButton + { + get => GetValue(HasLeftCaptionButtonProperty); + set => SetValue(HasLeftCaptionButtonProperty, value); + } + public FileHistories() { + if (OperatingSystem.IsMacOS()) + HasLeftCaptionButton = true; + InitializeComponent(); } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == WindowStateProperty) + HasLeftCaptionButton = WindowState != WindowState.FullScreen; + } private void MaximizeOrRestoreWindow(object _, TappedEventArgs e) { @@ -21,14 +44,6 @@ namespace SourceGit.Views e.Handled = true; } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - if (e.ClickCount == 1) - BeginMoveDrag(e); - - e.Handled = true; - } - private void OnPressCommitSHA(object sender, PointerPressedEventArgs e) { if (sender is TextBlock { DataContext: Models.Commit commit } && diff --git a/src/Views/Hotkeys.axaml b/src/Views/Hotkeys.axaml index 5d98238d..a28bc566 100644 --- a/src/Views/Hotkeys.axaml +++ b/src/Views/Hotkeys.axaml @@ -15,30 +15,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/Hotkeys.axaml.cs b/src/Views/Hotkeys.axaml.cs index 2a21fef9..d8b5e1a8 100644 --- a/src/Views/Hotkeys.axaml.cs +++ b/src/Views/Hotkeys.axaml.cs @@ -1,5 +1,3 @@ -using Avalonia.Input; - namespace SourceGit.Views { public partial class Hotkeys : ChromelessWindow @@ -8,10 +6,5 @@ namespace SourceGit.Views { InitializeComponent(); } - - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } } } diff --git a/src/Views/InteractiveRebase.axaml b/src/Views/InteractiveRebase.axaml index e1161a2b..c008193b 100644 --- a/src/Views/InteractiveRebase.axaml +++ b/src/Views/InteractiveRebase.axaml @@ -16,30 +16,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/InteractiveRebase.axaml.cs b/src/Views/InteractiveRebase.axaml.cs index 8f75cc26..a31b8a23 100644 --- a/src/Views/InteractiveRebase.axaml.cs +++ b/src/Views/InteractiveRebase.axaml.cs @@ -81,11 +81,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void CloseWindow(object _1, RoutedEventArgs _2) { Close(); diff --git a/src/Views/LFSLocks.axaml b/src/Views/LFSLocks.axaml index ccbe9fe2..ac495bf1 100644 --- a/src/Views/LFSLocks.axaml +++ b/src/Views/LFSLocks.axaml @@ -16,30 +16,23 @@ WindowStartupLocation="CenterOwner"> - - + - - - - - diff --git a/src/Views/LFSLocks.axaml.cs b/src/Views/LFSLocks.axaml.cs index ee4b6ff1..695341f4 100644 --- a/src/Views/LFSLocks.axaml.cs +++ b/src/Views/LFSLocks.axaml.cs @@ -1,5 +1,4 @@ using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Interactivity; namespace SourceGit.Views @@ -11,11 +10,6 @@ namespace SourceGit.Views InitializeComponent(); } - private void BeginMoveWindow(object _, PointerPressedEventArgs e) - { - BeginMoveDrag(e); - } - private void OnUnlockButtonClicked(object sender, RoutedEventArgs e) { if (DataContext is ViewModels.LFSLocks vm && sender is Button button) diff --git a/src/Views/Launcher.axaml b/src/Views/Launcher.axaml index 285ea72c..22d13935 100644 --- a/src/Views/Launcher.axaml +++ b/src/Views/Launcher.axaml @@ -29,9 +29,7 @@ PointerPressed="BeginMoveWindow"/> - - - +