mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profile tree - Fixed moving layers into folders leaving a copy behind
Profile tree - Added rename/delete hotkeys to elements Profile tree - Moved dialogs to the tree panel Layer properties - Auto-select transform tool when modifying transform properties
This commit is contained in:
1 parent
375c04090b
commit
a3290c40f8
25 files changed
+239
-146
No files matched your search
@@ -65,6 +65,7 @@
|
||||
KeyDown="InputKeyDown"
|
||||
Visibility="Collapsed"
|
||||
RequestBringIntoView="Input_OnRequestBringIntoView"
|
||||
PreviewTextInput="Input_PreviewTextInput" />
|
||||
PreviewTextInput="Input_PreviewTextInput"
|
||||
DataObject.Pasting="Input_OnPasting"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -18,6 +16,8 @@ namespace Artemis.UI.Shared
|
||||
new FrameworkPropertyMetadata(default(float), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, FloatPropertyChangedCallback));
|
||||
|
||||
public static readonly DependencyProperty StepSizeProperty = DependencyProperty.Register(nameof(StepSize), typeof(float), typeof(DraggableFloat));
|
||||
public static readonly DependencyProperty MinProperty = DependencyProperty.Register(nameof(Min), typeof(float?), typeof(DraggableFloat));
|
||||
public static readonly DependencyProperty MaxProperty = DependencyProperty.Register(nameof(Max), typeof(float?), typeof(DraggableFloat));
|
||||
|
||||
public static readonly RoutedEvent ValueChangedEvent =
|
||||
EventManager.RegisterRoutedEvent(
|
||||
@@ -49,6 +49,18 @@ namespace Artemis.UI.Shared
|
||||
set => SetValue(StepSizeProperty, value);
|
||||
}
|
||||
|
||||
public float? Min
|
||||
{
|
||||
get => (float?) GetValue(MinProperty);
|
||||
set => SetValue(MinProperty, value);
|
||||
}
|
||||
|
||||
public float? Max
|
||||
{
|
||||
get => (float?) GetValue(MaxProperty);
|
||||
set => SetValue(MaxProperty, value);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public event EventHandler DragStarted;
|
||||
@@ -126,7 +138,16 @@ namespace Artemis.UI.Shared
|
||||
if (stepSize == 0)
|
||||
stepSize = 0.1m;
|
||||
|
||||
Value = (float) UltimateRoundingFunction(startValue + stepSize * (x - startX), stepSize, 0.5m);
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||
stepSize = stepSize * 10;
|
||||
|
||||
var value = (float) UltimateRoundingFunction(startValue + stepSize * (x - startX), stepSize, 0.5m);
|
||||
if (Min != null)
|
||||
value = Math.Max(value, Min.Value);
|
||||
if (Max != null)
|
||||
value = Math.Min(value, Max.Value);
|
||||
|
||||
Value = value;
|
||||
}
|
||||
|
||||
private void InputLostFocus(object sender, RoutedEventArgs e)
|
||||
@@ -166,9 +187,34 @@ namespace Artemis.UI.Shared
|
||||
|
||||
private void Input_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
var seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
var regex = new Regex("^[" + seperator + "][-|0-9]+$|^-?[0-9]*[" + seperator + "]{0,1}[0-9]*$");
|
||||
e.Handled = !regex.IsMatch(e.Text);
|
||||
e.Handled = !ValidateInput(sender, e);
|
||||
}
|
||||
|
||||
private void Input_OnPasting(object sender, DataObjectPastingEventArgs e)
|
||||
{
|
||||
if (e.DataObject.GetDataPresent(typeof(string)))
|
||||
{
|
||||
var text = (string) e.DataObject.GetData(typeof(string));
|
||||
if (!float.TryParse(text, out _))
|
||||
e.CancelCommand();
|
||||
}
|
||||
else
|
||||
e.CancelCommand();
|
||||
}
|
||||
|
||||
// Borrowed from https://stackoverflow.com/a/48082972/5015269 because a regex approach has bad compatibility with
|
||||
// different locales
|
||||
private bool ValidateInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
if (!(sender is TextBox textBox))
|
||||
return false;
|
||||
|
||||
// Use SelectionStart property to find the caret position.
|
||||
// Insert the previewed text into the existing text in the textbox.
|
||||
var fullText = textBox.Text.Insert(textBox.SelectionStart, e.Text);
|
||||
|
||||
// If parsing is successful, set Handled to false
|
||||
return float.TryParse(fullText, out _);
|
||||
}
|
||||
|
||||
private static decimal UltimateRoundingFunction(decimal amountToRound, decimal nearstOf, decimal fairness)
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Artemis.UI.Shared
|
||||
LayerProperty = layerProperty;
|
||||
ProfileEditorService = profileEditorService;
|
||||
LayerProperty.Updated += LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
|
||||
LayerProperty.CurrentValueSet += LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled += LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled += LayerPropertyOnDataBindingChange;
|
||||
UpdateInputValue();
|
||||
@@ -26,7 +26,7 @@ namespace Artemis.UI.Shared
|
||||
LayerProperty = layerProperty;
|
||||
ProfileEditorService = profileEditorService;
|
||||
LayerProperty.Updated += LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
|
||||
LayerProperty.CurrentValueSet += LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled += LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled += LayerPropertyOnDataBindingChange;
|
||||
UpdateInputValue();
|
||||
@@ -56,7 +56,7 @@ namespace Artemis.UI.Shared
|
||||
public override void Dispose()
|
||||
{
|
||||
LayerProperty.Updated -= LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged -= LayerPropertyOnUpdated;
|
||||
LayerProperty.CurrentValueSet -= LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled -= LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled -= LayerPropertyOnDataBindingChange;
|
||||
Dispose(true);
|
||||
|
||||
@@ -13,11 +13,19 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}" Text="{Binding Header}" TextWrapping="Wrap" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Margin="0 20 0 20" Text="{Binding Text}" TextWrapping="Wrap" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0"
|
||||
Command="{s:Action Cancel}" Content="{Binding CancelText}" />
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 0 0"
|
||||
Command="{s:Action Confirm}" Content="{Binding ConfirmText}" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 8 0 0">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Focusable="False"
|
||||
IsCancel="True"
|
||||
Command="{s:Action Cancel}"
|
||||
Content="{Binding CancelText}" />
|
||||
<Button x:Name="ConfirmButton"
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
IsDefault="True"
|
||||
Focusable="True"
|
||||
Command="{s:Action Confirm}"
|
||||
Content="{Binding ConfirmText}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -12,7 +12,7 @@ namespace Artemis.UI.Shared.Services
|
||||
public interface IDialogService : IArtemisSharedUIService
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows a confirm dialog on the dialog host provided
|
||||
/// Shows a confirm dialog on the main dialog host
|
||||
/// </summary>
|
||||
/// <param name="header">The title of the dialog</param>
|
||||
/// <param name="text">The body text of the dialog</param>
|
||||
|
||||
Reference in new issue
Block a user