From 603f92ab21dfb17a2ebf2a031c2355ebbc8242f4 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sun, 28 Jan 2024 20:13:44 +0800 Subject: [PATCH] feat: quick fix and rename. --- demo/Ursa.Demo/App.axaml | 2 +- demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs | 8 ++++---- src/Ursa/Controls/Dialog/DialogControl.cs | 6 +++--- src/Ursa/Controls/Dialog/DialogWindow.cs | 6 +++--- src/Ursa/Controls/Dialog/IDialogContext.cs | 2 +- src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs | 9 ++++++++- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/demo/Ursa.Demo/App.axaml b/demo/Ursa.Demo/App.axaml index cb38ace..342fcd6 100644 --- a/demo/Ursa.Demo/App.axaml +++ b/demo/Ursa.Demo/App.axaml @@ -5,6 +5,6 @@ xmlns:u-semi="https://irihi.tech/ursa/themes/semi"> - + \ No newline at end of file diff --git a/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs b/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs index 5f43a7f..5f5aa45 100644 --- a/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs +++ b/demo/Ursa.Demo/Dialogs/DialogWithActionViewModel.cs @@ -14,10 +14,10 @@ public partial class DialogWithActionViewModel: ObservableObject, IDialogContext public void Close() { - Closed?.Invoke(this, false); + RequestClose?.Invoke(this, false); } - public event EventHandler? Closed; + public event EventHandler? RequestClose; public ICommand OKCommand { get; set; } public ICommand CancelCommand { get; set; } @@ -35,12 +35,12 @@ public partial class DialogWithActionViewModel: ObservableObject, IDialogContext private void OK() { - Closed?.Invoke(this, true); + RequestClose?.Invoke(this, true); } private void Cancel() { - Closed?.Invoke(this, false); + RequestClose?.Invoke(this, false); } private async Task ShowDialog() diff --git a/src/Ursa/Controls/Dialog/DialogControl.cs b/src/Ursa/Controls/Dialog/DialogControl.cs index 80f5c35..1d3c1f5 100644 --- a/src/Ursa/Controls/Dialog/DialogControl.cs +++ b/src/Ursa/Controls/Dialog/DialogControl.cs @@ -31,12 +31,12 @@ public class DialogControl: ContentControl { if (args.OldValue.Value is IDialogContext oldContext) { - oldContext.Closed-= CloseFromContext; + oldContext.RequestClose-= OnContextRequestClose; } if (args.NewValue.Value is IDialogContext newContext) { - newContext.Closed += CloseFromContext; + newContext.RequestClose += OnContextRequestClose; } } @@ -102,7 +102,7 @@ public class DialogControl: ContentControl } } - private void CloseFromContext(object sender, object? args) + private void OnContextRequestClose(object sender, object? args) { if (this.DataContext is IDialogContext context) { diff --git a/src/Ursa/Controls/Dialog/DialogWindow.cs b/src/Ursa/Controls/Dialog/DialogWindow.cs index c3313a2..f76504c 100644 --- a/src/Ursa/Controls/Dialog/DialogWindow.cs +++ b/src/Ursa/Controls/Dialog/DialogWindow.cs @@ -26,12 +26,12 @@ public class DialogWindow: Window { if (args.OldValue.Value is IDialogContext oldContext) { - oldContext.Closed-= OnDialogContextClose; + oldContext.RequestClose-= OnContextRequestClose; } if (args.NewValue.Value is IDialogContext newContext) { - newContext.Closed += OnDialogContextClose; + newContext.RequestClose += OnContextRequestClose; } } @@ -43,7 +43,7 @@ public class DialogWindow: Window EventHelper.RegisterClickEvent(OnDefaultClose, _closeButton); } - private void OnDialogContextClose(object? sender, object? args) + private void OnContextRequestClose(object? sender, object? args) { Close(args); } diff --git a/src/Ursa/Controls/Dialog/IDialogContext.cs b/src/Ursa/Controls/Dialog/IDialogContext.cs index 84fc8f7..8adf3d0 100644 --- a/src/Ursa/Controls/Dialog/IDialogContext.cs +++ b/src/Ursa/Controls/Dialog/IDialogContext.cs @@ -3,5 +3,5 @@ namespace Ursa.Controls; public interface IDialogContext { void Close(); - event EventHandler Closed; + event EventHandler RequestClose; } \ No newline at end of file diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs index 6166268..f13aa37 100644 --- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs +++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs @@ -194,6 +194,7 @@ public abstract class NumericUpDown : TemplatedControl if (AllowDrag && _dragPanel is not null) { _dragPanel.IsVisible = true; + _dragPanel.Focus(); } } } @@ -204,8 +205,14 @@ public abstract class NumericUpDown : TemplatedControl if (e.ClickCount == 2 && _dragPanel is not null && AllowDrag) { _dragPanel.IsVisible = false; + _textBox.IsReadOnly = false; } - _textBox?.Focus(); + else + { + _textBox?.Focus(); + _textBox!.IsReadOnly = true; + } + } private void OnDragPanelPointerReleased(object sender, PointerReleasedEventArgs e)