Merge branch 'development' into feature/avalonia

Code cleanup
This commit is contained in:
Robert committed 2022-05-14 00:14:03 +02:00
1 parent 6f75683c4d
commit 35f83e58e5
22 files changed
+176 -95

No files matched your search

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
@@ -13,9 +13,6 @@
<DocumentationFile>bin\Artemis.UI.Avalonia.Shared.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Remove="Artemis.UI.Avalonia.Shared.csproj.DotSettings" />
<None Remove="Artemis.UI.Shared.csproj.DotSettings" />
<None Remove="DefaultTypes\DataModel\Display\DefaultDataModelDisplayView.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.13" />
@@ -12,6 +12,9 @@ namespace Artemis.UI.Shared.Behaviors;
/// </summary>
public class LostFocusNumberBoxBindingBehavior : Behavior<NumberBox>
{
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public static readonly StyledProperty<double> ValueProperty = AvaloniaProperty.Register<LostFocusTextBoxBindingBehavior, double>(
nameof(Value), defaultBindingMode: BindingMode.TwoWay);
@@ -20,6 +23,9 @@ public class LostFocusNumberBoxBindingBehavior : Behavior<NumberBox>
ValueProperty.Changed.Subscribe(e => ((LostFocusNumberBoxBindingBehavior) e.Sender).OnBindingValueChanged());
}
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public double Value
{
get => GetValue(ValueProperty);
@@ -12,6 +12,9 @@ namespace Artemis.UI.Shared.Behaviors;
/// </summary>
public class LostFocusTextBoxBindingBehavior : Behavior<TextBox>
{
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public static readonly StyledProperty<string> TextProperty = AvaloniaProperty.Register<LostFocusTextBoxBindingBehavior, string>(
"Text", defaultBindingMode: BindingMode.TwoWay);
@@ -20,6 +23,9 @@ public class LostFocusTextBoxBindingBehavior : Behavior<TextBox>
TextProperty.Changed.Subscribe(e => ((LostFocusTextBoxBindingBehavior) e.Sender).OnBindingValueChanged());
}
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public string Text
{
get => GetValue(TextProperty);
@@ -13,6 +13,9 @@ namespace Artemis.UI.Shared.Behaviors;
/// </summary>
public class SliderPointerReleasedBindingBehavior : Behavior<Slider>
{
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public static readonly StyledProperty<double> ValueProperty = AvaloniaProperty.Register<LostFocusTextBoxBindingBehavior, double>(
nameof(Value), defaultBindingMode: BindingMode.TwoWay);
@@ -21,6 +24,9 @@ public class SliderPointerReleasedBindingBehavior : Behavior<Slider>
ValueProperty.Changed.Subscribe(e => ((SliderPointerReleasedBindingBehavior) e.Sender).OnBindingValueChanged());
}
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public double Value
{
get => GetValue(ValueProperty);
@@ -24,7 +24,7 @@ namespace Artemis.UI.Shared
private readonly ObservableCollection<(Enum, string)> _currentValues = new();
private ComboBox? _enumComboBox;
private Type _currentType;
private Type? _currentType;
/// <summary>
/// Creates a new instance of the <see cref="EnumComboBox" /> class.
@@ -70,6 +70,9 @@ public class GradientPicker : TemplatedControl
private ColorGradient? _lastColorGradient;
private ColorPicker? _colorPicker;
/// <summary>
/// Creates a new instance of the <see cref="GradientPicker"/> class.
/// </summary>
public GradientPicker()
{
_deleteStop = ReactiveCommand.Create<ColorGradientStop>(s =>
@@ -127,14 +127,14 @@ public class GradientPickerColorStop : TemplatedControl
{
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed || !ReferenceEquals(e.Pointer.Captured, this) || PositionReference == null)
{
if (_draggingStop != ColorStop)
if (!Equals(_draggingStop, ColorStop))
return;
_dragOffset = e.GetCurrentPoint(PositionReference).Position.X - GetPixelPosition();
}
double position = e.GetCurrentPoint(PositionReference).Position.X - _dragOffset;
ColorStop.Position = MathF.Round((float) Math.Clamp(position / PositionReference.Bounds.Width, 0, 1), 3, MidpointRounding.AwayFromZero);
ColorStop.Position = MathF.Round((float) Math.Clamp(position / PositionReference?.Bounds.Width ?? 0, 0, 1), 3, MidpointRounding.AwayFromZero);
e.Handled = true;
}
-36
View File
@@ -1,36 +0,0 @@
using System;
using System.Windows.Input;
namespace Artemis.UI.Shared;
/// <summary>
/// Represents a placeholder command that does nothing and can't be executed.
/// </summary>
public class NullCommand : ICommand
{
private static readonly Lazy<NullCommand> _instance = new(() => new NullCommand());
private NullCommand()
{
}
/// <summary>
/// Gets the static instance of this command.
/// </summary>
public static ICommand Instance => _instance.Value;
/// <inheritdoc />
public event EventHandler? CanExecuteChanged;
/// <inheritdoc />
public void Execute(object? parameter)
{
throw new InvalidOperationException("NullCommand cannot be executed");
}
/// <inheritdoc />
public bool CanExecute(object? parameter)
{
return false;
}
}
@@ -9,8 +9,8 @@ namespace Artemis.UI.Shared.Services.ProfileEditor.Commands;
public class ChangeConditionType : IProfileEditorCommand, IDisposable
{
private readonly RenderProfileElement _profileElement;
private readonly ICondition? _condition;
private readonly ICondition? _oldCondition;
private readonly ICondition _condition;
private readonly ICondition _oldCondition;
private bool _executed;
/// <summary>
@@ -18,7 +18,7 @@ public class ChangeConditionType : IProfileEditorCommand, IDisposable
/// </summary>
/// <param name="profileElement">The profile element whose condition type to change.</param>
/// <param name="condition">The new condition type.</param>
public ChangeConditionType(RenderProfileElement profileElement, ICondition? condition)
public ChangeConditionType(RenderProfileElement profileElement, ICondition condition)
{
_profileElement = profileElement;
_condition = condition;
@@ -8,8 +8,8 @@ namespace Artemis.UI.Shared.Services.ProfileEditor.Commands;
/// </summary>
public class ChangeElementDisplayCondition : IProfileEditorCommand, IDisposable
{
private readonly ICondition? _condition;
private readonly ICondition? _oldCondition;
private readonly ICondition _condition;
private readonly ICondition _oldCondition;
private readonly RenderProfileElement _profileElement;
private bool _executed;
@@ -18,7 +18,7 @@ public class ChangeElementDisplayCondition : IProfileEditorCommand, IDisposable
/// </summary>
/// <param name="profileElement">The render profile element whose display condition to change.</param>
/// <param name="condition">The new display condition.</param>
public ChangeElementDisplayCondition(RenderProfileElement profileElement, ICondition? condition)
public ChangeElementDisplayCondition(RenderProfileElement profileElement, ICondition condition)
{
_profileElement = profileElement;
_condition = condition;