From 239901d0b17cfb9f63aa6918b9e7a90e2ac6c212 Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Fri, 11 Jul 2025 13:52:37 +0800 Subject: [PATCH] fix: fix nullable annotations in popconfirm. --- src/Ursa/Controls/PopConfirm/PopConfirm.cs | 10 +++++----- src/Ursa/Controls/TitleBar/WindowThumb.cs | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Ursa/Controls/PopConfirm/PopConfirm.cs b/src/Ursa/Controls/PopConfirm/PopConfirm.cs index cd4c6b6..8609d93 100644 --- a/src/Ursa/Controls/PopConfirm/PopConfirm.cs +++ b/src/Ursa/Controls/PopConfirm/PopConfirm.cs @@ -182,7 +182,7 @@ public class PopConfirm : ContentControl Button.ClickEvent.AddHandler(OnButtonClicked, _closeButton, _cancelButton, _confirmButton); } - private void OnButtonClicked(object sender, RoutedEventArgs e) + private void OnButtonClicked(object? sender, RoutedEventArgs e) { if (!HandleAsyncCommand) _popup?.SetValue(Popup.IsOpenProperty, false); // This is a hack for MVVM toolkit and Prism that uses INotifyPropertyChanged for async command. It counts the number of @@ -243,7 +243,7 @@ public class PopConfirm : ContentControl } } - private void OnMainElementLostFocus(object sender, RoutedEventArgs e) + private void OnMainElementLostFocus(object? sender, RoutedEventArgs e) { var newFocus = TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement(); if (newFocus is Visual v && _popup?.IsInsidePopup(v) == true) return; @@ -251,7 +251,7 @@ public class PopConfirm : ContentControl } private bool _suppressButtonClickEvent; - private void OnMainElementGotFocus(object sender, GotFocusEventArgs e) + private void OnMainElementGotFocus(object? sender, GotFocusEventArgs e) { Debug.WriteLine("Got Focus"); if (TriggerMode.HasFlag(PopConfirmTriggerMode.Click) && TriggerMode.HasFlag(PopConfirmTriggerMode.Focus)) @@ -270,7 +270,7 @@ public class PopConfirm : ContentControl LostFocusEvent.RemoveHandler(OnMainElementLostFocus, child); } - private void OnMainButtonClicked(object sender, RoutedEventArgs e) + private void OnMainButtonClicked(object? sender, RoutedEventArgs e) { Debug.WriteLine("Main Button Clicked"); if (!_suppressButtonClickEvent) @@ -281,7 +281,7 @@ public class PopConfirm : ContentControl } - private void OnMainElementPressed(object sender, PointerPressedEventArgs e) + private void OnMainElementPressed(object? sender, PointerPressedEventArgs e) { SetCurrentValue(IsDropdownOpenProperty, !IsDropdownOpen); } diff --git a/src/Ursa/Controls/TitleBar/WindowThumb.cs b/src/Ursa/Controls/TitleBar/WindowThumb.cs index 60a3e1c..c29d255 100644 --- a/src/Ursa/Controls/TitleBar/WindowThumb.cs +++ b/src/Ursa/Controls/TitleBar/WindowThumb.cs @@ -2,7 +2,6 @@ using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Input; -using Avalonia.Interactivity; using Avalonia.Media; namespace Ursa.Controls; @@ -28,7 +27,7 @@ public class WindowThumb: Control this.AddHandler(DoubleTappedEvent, OnTapped); } - private void OnTapped(object sender, TappedEventArgs e) + private void OnTapped(object? sender, TappedEventArgs e) { if (this.VisualRoot is not Window window) return; if (!window.CanResize) return; @@ -36,7 +35,7 @@ public class WindowThumb: Control window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; } - private void OnPressed(object sender, PointerPressedEventArgs e) + private void OnPressed(object? sender, PointerPressedEventArgs e) { if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return; if (e.ClickCount > 1) return;