mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Fix draggable number box clamping the value to 0-100 when unloading
This commit is contained in:
parent
ec594f02b1
commit
dc8147d5a7
@ -32,8 +32,7 @@
|
|||||||
SimpleNumberFormat="{CompiledBinding $parent[sharedControls:DraggableNumberBox].SimpleNumberFormat}"
|
SimpleNumberFormat="{CompiledBinding $parent[sharedControls:DraggableNumberBox].SimpleNumberFormat}"
|
||||||
attachedProperties:NumberBoxAssist.PrefixText="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Prefix}"
|
attachedProperties:NumberBoxAssist.PrefixText="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Prefix}"
|
||||||
attachedProperties:NumberBoxAssist.SuffixText="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Suffix}"
|
attachedProperties:NumberBoxAssist.SuffixText="{CompiledBinding $parent[sharedControls:DraggableNumberBox].Suffix}"
|
||||||
HorizontalAlignment="{CompiledBinding $parent[sharedControls:DraggableNumberBox].HorizontalAlignment}"
|
HorizontalAlignment="{CompiledBinding $parent[sharedControls:DraggableNumberBox].HorizontalAlignment}"/>
|
||||||
ValueChanged="NumberBox_OnValueChanged"/>
|
|
||||||
<Rectangle Name="DragCollider" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Fill="Transparent"></Rectangle>
|
<Rectangle Name="DragCollider" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Fill="Transparent"></Rectangle>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Data;
|
using Avalonia.Data;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.LogicalTree;
|
||||||
using Avalonia.VisualTree;
|
using Avalonia.VisualTree;
|
||||||
using FluentAvalonia.Core;
|
using FluentAvalonia.Core;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
@ -68,13 +68,12 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
public DraggableNumberBox()
|
public DraggableNumberBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InnerNumberBox.Value = Value;
|
|
||||||
|
|
||||||
PointerPressed += OnPointerPressed;
|
PointerPressed += OnPointerPressed;
|
||||||
PointerMoved += OnPointerMoved;
|
PointerMoved += OnPointerMoved;
|
||||||
PointerReleased += OnPointerReleased;
|
PointerReleased += OnPointerReleased;
|
||||||
PropertyChanged += OnPropertyChanged;
|
PropertyChanged += OnPropertyChanged;
|
||||||
|
|
||||||
AddHandler(KeyUpEvent, HandleKeyUp, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
|
AddHandler(KeyUpEvent, HandleKeyUp, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +158,22 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
/// Occurs when the user finishes dragging over the control.
|
/// Occurs when the user finishes dragging over the control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event TypedEventHandler<DraggableNumberBox, EventArgs>? DragFinished;
|
public event TypedEventHandler<DraggableNumberBox, EventArgs>? DragFinished;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
InnerNumberBox.Value = Value;
|
||||||
|
InnerNumberBox.ValueChanged += InnerNumberBoxOnValueChanged;
|
||||||
|
base.OnAttachedToLogicalTree(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
InnerNumberBox.ValueChanged -= InnerNumberBoxOnValueChanged;
|
||||||
|
base.OnDetachedFromLogicalTree(e);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetNumberBoxValue(double value)
|
private void SetNumberBoxValue(double value)
|
||||||
{
|
{
|
||||||
if (!(Math.Abs(InnerNumberBox.Value - Value) > 0.00001))
|
if (!(Math.Abs(InnerNumberBox.Value - Value) > 0.00001))
|
||||||
@ -243,14 +257,14 @@ public partial class DraggableNumberBox : UserControl
|
|||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Property == ValueProperty)
|
if (e.Property == ValueProperty)
|
||||||
SetNumberBoxValue(Value);
|
SetNumberBoxValue(Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NumberBox_OnValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
|
private void InnerNumberBoxOnValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (_updating)
|
if (_updating)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user