1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Fixed Artemis.UI.Shared compile errors

This commit is contained in:
Robert 2023-03-29 21:36:56 +02:00
parent 1d6a30c447
commit 81e83e59f6
61 changed files with 343 additions and 1746 deletions

View File

@ -39,6 +39,7 @@
<PackageReference Include="EmbedIO" Version="3.5.0" />
<PackageReference Include="HidSharp" Version="2.1.0" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="LiteDB" Version="5.0.12" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
@ -49,7 +50,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />

File diff suppressed because it is too large Load Diff

View File

@ -16,12 +16,12 @@
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />

View File

@ -15,12 +15,12 @@
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />

View File

@ -10,18 +10,18 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.18" />
<PackageReference Include="DynamicData" Version="7.9.14" />
<PackageReference Include="FluentAvaloniaUI" Version="1.4.1" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview6" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview6" />
<PackageReference Include="Material.Icons.Avalonia" Version="1.1.10" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Include="ReactiveUI.Validation" Version="2.2.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="RGB.NET.Core" Version="2.0.0-prerelease.17" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />

View File

@ -15,7 +15,7 @@ public class LostFocusNumericUpDownBindingBehavior : Behavior<NumericUpDown>
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public static readonly StyledProperty<double> ValueProperty = AvaloniaProperty.Register<LostFocusNumericUpDownBindingBehavior, double>(
public static readonly StyledProperty<decimal?> ValueProperty = AvaloniaProperty.Register<LostFocusNumericUpDownBindingBehavior, decimal?>(
nameof(Value), defaultBindingMode: BindingMode.TwoWay);
static LostFocusNumericUpDownBindingBehavior()
@ -26,7 +26,7 @@ public class LostFocusNumericUpDownBindingBehavior : Behavior<NumericUpDown>
/// <summary>
/// Gets or sets the value of the binding.
/// </summary>
public double Value
public decimal? Value
{
get => GetValue(ValueProperty);
set => SetValue(ValueProperty, value);

View File

@ -2,12 +2,12 @@ using System;
using System.Text.RegularExpressions;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Documents;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Visuals.Media.Imaging;
using Material.Icons;
using Material.Icons.Avalonia;
@ -16,9 +16,9 @@ namespace Artemis.UI.Shared;
/// <summary>
/// Represents a control that can display an arbitrary kind of icon.
/// </summary>
public class ArtemisIcon : UserControl
public partial class ArtemisIcon : UserControl
{
private static readonly Regex _imageRegex = new(@"[\/.](gif|jpg|jpeg|tiff|png)$", RegexOptions.Compiled);
private static readonly Regex ImageRegex = new(@"[\/.](gif|jpg|jpeg|tiff|png)$", RegexOptions.Compiled);
/// <summary>
/// Creates a new instance of the <see cref="ArtemisIcon" /> class.
@ -30,12 +30,6 @@ public class ArtemisIcon : UserControl
LayoutUpdated += OnLayoutUpdated;
}
private static void IconChanging(IAvaloniaObject sender, bool before)
{
if (before)
((ArtemisIcon) sender).Update();
}
private void Update()
{
try
@ -54,7 +48,7 @@ public class ArtemisIcon : UserControl
Content = new MaterialIcon {Kind = parsedIcon, Width = Bounds.Width, Height = Bounds.Height};
}
// An URI pointing to an image
else if (_imageRegex.IsMatch(iconString))
else if (ImageRegex.IsMatch(iconString))
{
if (!Fill)
Content = new Image
@ -66,7 +60,7 @@ public class ArtemisIcon : UserControl
else
Content = new Border
{
Background = TextBlock.GetForeground(this),
Background = TextElement.GetForeground(this),
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
OpacityMask = new ImageBrush(new Bitmap(iconString)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality}
@ -110,8 +104,7 @@ public class ArtemisIcon : UserControl
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" />
/// pointing to an SVG
/// </summary>
public static readonly StyledProperty<object?> IconProperty =
AvaloniaProperty.Register<ArtemisIcon, object?>(nameof(Icon), notifying: IconChanging);
public static readonly StyledProperty<object?> IconProperty = AvaloniaProperty.Register<ArtemisIcon, object?>(nameof(Icon));
/// <summary>
@ -121,15 +114,18 @@ public class ArtemisIcon : UserControl
public object? Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
set
{
SetValue(IconProperty, value);
Update();
}
}
/// <summary>
/// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the
/// theme
/// </summary>
public static readonly StyledProperty<bool> FillProperty =
AvaloniaProperty.Register<ArtemisIcon, bool>(nameof(Icon), false, notifying: IconChanging);
public static readonly StyledProperty<bool> FillProperty = AvaloniaProperty.Register<ArtemisIcon, bool>(nameof(Icon));
/// <summary>
/// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the
@ -138,7 +134,11 @@ public class ArtemisIcon : UserControl
public bool Fill
{
get => GetValue(FillProperty);
set => SetValue(FillProperty, value);
set
{
SetValue(FillProperty, value);
Update();
}
}
#endregion

View File

@ -46,8 +46,8 @@ public class DataModelPickerButton : TemplatedControl
/// <summary>
/// Gets or sets the desired flyout placement.
/// </summary>
public static readonly StyledProperty<FlyoutPlacementMode> PlacementProperty =
AvaloniaProperty.Register<FlyoutBase, FlyoutPlacementMode>(nameof(Placement));
public static readonly StyledProperty<PlacementMode> PlacementProperty =
AvaloniaProperty.Register<FlyoutBase, PlacementMode>(nameof(Placement));
/// <summary>
/// Gets or sets data model path.
@ -133,7 +133,7 @@ public class DataModelPickerButton : TemplatedControl
/// <summary>
/// Gets or sets the desired flyout placement.
/// </summary>
public FlyoutPlacementMode Placement
public PlacementMode Placement
{
get => GetValue(PlacementProperty);
set => SetValue(PlacementProperty, value);

View File

@ -15,7 +15,6 @@ using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Rendering;
using Avalonia.Threading;
using Avalonia.Visuals.Media.Imaging;
namespace Artemis.UI.Shared;
@ -123,7 +122,7 @@ public class DeviceVisualizer : Control
private Rect MeasureDevice()
{
if (Device == null)
return Rect.Empty;
return new Rect(0, 0, 0, 0);
Rect deviceRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
Geometry geometry = new RectangleGeometry(deviceRect);
@ -171,13 +170,7 @@ public class DeviceVisualizer : Control
/// Gets or sets the <see cref="ArtemisDevice" /> to display
/// </summary>
public static readonly StyledProperty<ArtemisDevice?> DeviceProperty =
AvaloniaProperty.Register<DeviceVisualizer, ArtemisDevice?>(nameof(Device), notifying: DeviceUpdated);
private static void DeviceUpdated(IAvaloniaObject sender, bool before)
{
if (!before)
((DeviceVisualizer) sender).SetupForDevice();
}
AvaloniaProperty.Register<DeviceVisualizer, ArtemisDevice?>(nameof(Device));
/// <summary>
/// Gets or sets the <see cref="ArtemisDevice" /> to display
@ -185,7 +178,11 @@ public class DeviceVisualizer : Control
public ArtemisDevice? Device
{
get => GetValue(DeviceProperty);
set => SetValue(DeviceProperty, value);
set
{
SetValue(DeviceProperty, value);
SetupForDevice();
}
}
/// <summary>
@ -302,9 +299,9 @@ public class DeviceVisualizer : Control
// Render 4 times the actual size of the device to make sure things look sharp when zoomed in
RenderTargetBitmap renderTargetBitmap = new(new PixelSize((int) device.RgbDevice.ActualSize.Width * 2, (int) device.RgbDevice.ActualSize.Height * 2));
using IDrawingContextImpl context = renderTargetBitmap.CreateDrawingContext(new ImmediateRenderer(this));
using DrawingContext context = renderTargetBitmap.CreateDrawingContext();
using Bitmap bitmap = new(device.Layout.Image.LocalPath);
context.DrawBitmap(bitmap.PlatformImpl, 1, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size), BitmapInterpolationMode.HighQuality);
context.DrawImage(bitmap, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size), BitmapInterpolationMode.HighQuality);
lock (_deviceVisualizerLeds)
{

View File

@ -4,8 +4,6 @@ using Artemis.Core;
using Avalonia;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Visuals.Media.Imaging;
using RGB.NET.Core;
using Color = Avalonia.Media.Color;
using Point = Avalonia.Point;
@ -40,7 +38,7 @@ internal class DeviceVisualizerLed
public Rect LedRect { get; set; }
public Geometry? DisplayGeometry { get; private set; }
public void DrawBitmap(IDrawingContextImpl drawingContext, double scale)
public void DrawBitmap(DrawingContext drawingContext, double scale)
{
if (Led.Layout?.Image == null || !File.Exists(Led.Layout.Image.LocalPath))
return;
@ -48,9 +46,8 @@ internal class DeviceVisualizerLed
try
{
using Bitmap bitmap = new(Led.Layout.Image.LocalPath);
drawingContext.DrawBitmap(
bitmap.PlatformImpl,
1,
drawingContext.DrawImage(
bitmap,
new Rect(bitmap.Size),
new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, Led.RgbLed.Size.Width * scale, Led.RgbLed.Size.Height * scale),
BitmapInterpolationMode.HighQuality

View File

@ -14,12 +14,12 @@ namespace Artemis.UI.Shared.Controls;
/// <summary>
/// Represents a number box that can be mutated by dragging over it horizontally
/// </summary>
public class DraggableNumberBox : UserControl
public partial class DraggableNumberBox : UserControl
{
/// <summary>
/// Defines the <see cref="Value" /> property.
/// </summary>
public static readonly StyledProperty<double> ValueProperty = AvaloniaProperty.Register<DraggableNumberBox, double>(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged);
public static readonly StyledProperty<double> ValueProperty = AvaloniaProperty.Register<DraggableNumberBox, double>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
/// <summary>
/// Defines the <see cref="Minimum" /> property.
@ -85,7 +85,11 @@ public class DraggableNumberBox : UserControl
public double Value
{
get => GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
set
{
SetValue(ValueProperty, value);
SetNumberBoxValue(value);
}
}
/// <summary>
@ -161,24 +165,20 @@ public class DraggableNumberBox : UserControl
/// </summary>
public event TypedEventHandler<DraggableNumberBox, EventArgs>? DragFinished;
private static void ValueChanged(IAvaloniaObject sender, bool before)
private void SetNumberBoxValue(double value)
{
if (before)
if (!(Math.Abs(_numberBox.Value - Value) > 0.00001))
return;
DraggableNumberBox draggable = (DraggableNumberBox) sender;
if (!(Math.Abs(draggable._numberBox.Value - draggable.Value) > 0.00001))
return;
draggable._updating = true;
draggable._numberBox.Value = draggable.Value;
draggable._updating = false;
_updating = true;
_numberBox.Value = Value;
_updating = false;
}
private void HandleKeyUp(object? sender, KeyEventArgs e)
{
if (e.Key == Key.Enter || e.Key == Key.Escape)
Parent?.Focus();
FocusManager.Instance?.Focus(Parent as IInputElement);
}
private void InitializeComponent()
@ -211,7 +211,7 @@ public class DraggableNumberBox : UserControl
if (!_moved)
{
// Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider
Parent?.Focus();
FocusManager.Instance?.Focus(Parent as IInputElement);
_moved = true;
e.Pointer.Capture(this);
DragStarted?.Invoke(this, EventArgs.Empty);

View File

@ -13,13 +13,12 @@ namespace Artemis.UI.Shared;
/// <summary>
/// Represents a combobox that can display the values of an enum.
/// </summary>
public class EnumComboBox : UserControl
public partial class EnumComboBox : UserControl
{
/// <summary>
/// Gets or sets the currently selected value
/// </summary>
public static readonly StyledProperty<object?> ValueProperty =
AvaloniaProperty.Register<EnumComboBox, object?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged);
public static readonly StyledProperty<object?> ValueProperty = AvaloniaProperty.Register<EnumComboBox, object?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
private readonly ObservableCollection<(Enum, string)> _currentValues = new();
private Type? _currentType;
@ -40,15 +39,11 @@ public class EnumComboBox : UserControl
public object? Value
{
get => GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
private static void ValueChanged(IAvaloniaObject sender, bool before)
set
{
if (sender is EnumComboBox enumCombo && !before)
{
enumCombo.UpdateValues();
enumCombo.UpdateSelection();
SetValue(ValueProperty, value);
UpdateValues();
UpdateSelection();
}
}

View File

@ -27,7 +27,7 @@ public class GradientPicker : TemplatedControl
/// Gets or sets the color gradient.
/// </summary>
public static readonly StyledProperty<ColorGradient> ColorGradientProperty =
AvaloniaProperty.Register<GradientPicker, ColorGradient>(nameof(ColorGradient), notifying: ColorGradientChanged, defaultValue: ColorGradient.GetUnicornBarf());
AvaloniaProperty.Register<GradientPicker, ColorGradient>(nameof(ColorGradient), defaultValue: ColorGradient.GetUnicornBarf());
/// <summary>
/// Gets or sets the currently selected color stop.
@ -45,7 +45,7 @@ public class GradientPicker : TemplatedControl
/// Gets or sets a storage provider to use for storing and loading gradients.
/// </summary>
public static readonly StyledProperty<IColorGradientStorageProvider?> StorageProviderProperty =
AvaloniaProperty.Register<GradientPicker, IColorGradientStorageProvider?>(nameof(StorageProvider), notifying: StorageProviderChanged);
AvaloniaProperty.Register<GradientPicker, IColorGradientStorageProvider?>(nameof(StorageProvider));
/// <summary>
/// Gets the linear gradient brush representing the color gradient.
@ -66,7 +66,7 @@ public class GradientPicker : TemplatedControl
AvaloniaProperty.RegisterDirect<GradientPicker, ColorGradient>(nameof(EditingColorGradient), g => g.EditingColorGradient);
private readonly ICommand _deleteStop;
private ColorPicker? _colorPicker;
private FAColorPicker? _colorPicker;
private Button? _flipStops;
private Border? _gradient;
private Button? _randomize;
@ -102,7 +102,11 @@ public class GradientPicker : TemplatedControl
public ColorGradient ColorGradient
{
get => GetValue(ColorGradientProperty);
set => SetValue(ColorGradientProperty, value);
set
{
SetValue(ColorGradientProperty, value);
ApplyToField();
}
}
/// <summary>
@ -176,7 +180,7 @@ public class GradientPicker : TemplatedControl
if (_randomize != null)
_randomize.Click -= RandomizeOnClick;
_colorPicker = e.NameScope.Find<ColorPicker>("ColorPicker");
_colorPicker = e.NameScope.Find<FAColorPicker>("ColorPicker");
_gradient = e.NameScope.Find<Border>("Gradient");
_spreadStops = e.NameScope.Find<Button>("SpreadStops");
_toggleSeamless = e.NameScope.Find<Button>("ToggleSeamless");
@ -220,16 +224,6 @@ public class GradientPicker : TemplatedControl
_shiftDown = false;
}
private static void ColorGradientChanged(IAvaloniaObject sender, bool before)
{
(sender as GradientPicker)?.ApplyToField();
}
private static void StorageProviderChanged(IAvaloniaObject sender, bool before)
{
}
private void ApplyToField()
{
EditingColorGradient = new ColorGradient(ColorGradient);

View File

@ -12,7 +12,6 @@ using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Threading;
using FluentAvalonia.Core;
using Button = FluentAvalonia.UI.Controls.Button;
namespace Artemis.UI.Shared.Controls.GradientPicker;
@ -25,7 +24,7 @@ public class GradientPickerButton : TemplatedControl
/// Gets or sets the color gradient.
/// </summary>
public static readonly StyledProperty<ColorGradient?> ColorGradientProperty =
AvaloniaProperty.Register<GradientPickerButton, ColorGradient?>(nameof(ColorGradient), notifying: ColorGradientChanged);
AvaloniaProperty.Register<GradientPickerButton, ColorGradient?>(nameof(ColorGradient));
/// <summary>
/// Gets or sets a boolean indicating whether the gradient picker should be in compact mode or not.
@ -54,7 +53,11 @@ public class GradientPickerButton : TemplatedControl
public ColorGradient? ColorGradient
{
get => GetValue(ColorGradientProperty);
set => SetValue(ColorGradientProperty, value);
set
{
SetValue(ColorGradientProperty, value);
Subscribe();
}
}
/// <summary>
@ -105,12 +108,6 @@ public class GradientPickerButton : TemplatedControl
#endregion
private static void ColorGradientChanged(IAvaloniaObject sender, bool before)
{
if (!before)
(sender as GradientPickerButton)?.Subscribe();
}
private void Subscribe()
{
Unsubscribe();

View File

@ -16,7 +16,7 @@ internal class GradientPickerColorStop : TemplatedControl
/// Gets or sets the gradient picker.
/// </summary>
public static readonly StyledProperty<GradientPicker?> GradientPickerProperty =
AvaloniaProperty.Register<GradientPickerColorStop, GradientPicker?>(nameof(GradientPicker), notifying: Notifying);
AvaloniaProperty.Register<GradientPickerColorStop, GradientPicker?>(nameof(GradientPicker));
/// <summary>
/// Gets or sets the color stop.
@ -28,8 +28,8 @@ internal class GradientPickerColorStop : TemplatedControl
/// Gets or sets the position reference to use when positioning and dragging this color stop.
/// <para>If <see langword="null" /> then dragging is not enabled.</para>
/// </summary>
public static readonly StyledProperty<IControl?> PositionReferenceProperty =
AvaloniaProperty.Register<GradientPickerColorStop, IControl?>(nameof(PositionReference));
public static readonly StyledProperty<Control?> PositionReferenceProperty =
AvaloniaProperty.Register<GradientPickerColorStop, Control?>(nameof(PositionReference));
/// <summary>
/// Gets the linear gradient brush representing the color gradient.
@ -47,7 +47,16 @@ internal class GradientPickerColorStop : TemplatedControl
public GradientPicker? GradientPicker
{
get => GetValue(GradientPickerProperty);
set => SetValue(GradientPickerProperty, value);
set
{
if (GradientPicker != null)
GradientPicker.PropertyChanged -= GradientPickerOnPropertyChanged;
SetValue(GradientPickerProperty, value);
if (GradientPicker != null)
GradientPicker.PropertyChanged += GradientPickerOnPropertyChanged;
IsSelected = ReferenceEquals(GradientPicker?.SelectedColorStop, ColorStop);
}
}
/// <summary>
@ -63,7 +72,7 @@ internal class GradientPickerColorStop : TemplatedControl
/// Gets or sets the position reference to use when positioning and dragging this color stop.
/// <para>If <see langword="null" /> then dragging is not enabled.</para>
/// </summary>
public IControl? PositionReference
public Control? PositionReference
{
get => GetValue(PositionReferenceProperty);
set => SetValue(PositionReferenceProperty, value);
@ -85,19 +94,6 @@ internal class GradientPickerColorStop : TemplatedControl
}
}
private static void Notifying(IAvaloniaObject sender, bool before)
{
if (sender is not GradientPickerColorStop self)
return;
if (before && self.GradientPicker != null)
self.GradientPicker.PropertyChanged -= self.GradientPickerOnPropertyChanged;
else if (self.GradientPicker != null)
self.GradientPicker.PropertyChanged += self.GradientPickerOnPropertyChanged;
self.IsSelected = ReferenceEquals(self.GradientPicker?.SelectedColorStop, self.ColorStop);
}
private void GradientPickerOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (GradientPicker != null && e.Property == GradientPicker.SelectedColorStopProperty)

View File

@ -17,7 +17,7 @@ namespace Artemis.UI.Shared;
/// <summary>
/// Represents a control that can be used to display or edit <see cref="Core.Hotkey" /> instances.
/// </summary>
public class HotkeyBox : UserControl
public partial class HotkeyBox : UserControl
{
private readonly TextBox _displayTextBox;
@ -34,11 +34,6 @@ public class HotkeyBox : UserControl
UpdateDisplayTextBox();
}
private static void HotkeyChanging(IAvaloniaObject sender, bool before)
{
((HotkeyBox) sender).UpdateDisplayTextBox();
}
private void DisplayTextBoxOnKeyDown(object? sender, KeyEventArgs e)
{
if (e.Key >= Key.LeftShift && e.Key <= Key.RightAlt)
@ -92,20 +87,17 @@ public class HotkeyBox : UserControl
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" />
/// pointing to an SVG
/// </summary>
public static readonly StyledProperty<Hotkey?> HotkeyProperty =
AvaloniaProperty.Register<HotkeyBox, Hotkey?>(nameof(Hotkey), defaultBindingMode: BindingMode.TwoWay, notifying: HotkeyChanging);
public static readonly StyledProperty<Hotkey?> HotkeyProperty = AvaloniaProperty.Register<HotkeyBox, Hotkey?>(nameof(Hotkey), defaultBindingMode: BindingMode.TwoWay);
/// <summary>
/// Gets or sets the watermark of the hotkey box when it is empty.
/// </summary>
public static readonly StyledProperty<string?> WatermarkProperty =
AvaloniaProperty.Register<HotkeyBox, string?>(nameof(Watermark));
public static readonly StyledProperty<string?> WatermarkProperty = AvaloniaProperty.Register<HotkeyBox, string?>(nameof(Watermark));
/// <summary>
/// Gets or sets a boolean indicating whether the watermark should float above the hotkey box when it is not empty.
/// </summary>
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty =
AvaloniaProperty.Register<HotkeyBox, bool>(nameof(UseFloatingWatermark));
public static readonly StyledProperty<bool> UseFloatingWatermarkProperty = AvaloniaProperty.Register<HotkeyBox, bool>(nameof(UseFloatingWatermark));
/// <summary>
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" />
@ -114,7 +106,11 @@ public class HotkeyBox : UserControl
public Hotkey? Hotkey
{
get => GetValue(HotkeyProperty);
set => SetValue(HotkeyProperty, value);
set
{
SetValue(HotkeyProperty, value);
UpdateDisplayTextBox();
}
}
/// <summary>

View File

@ -3,13 +3,13 @@ using System.IO;
using Artemis.Core;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Documents;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
using Avalonia.Visuals.Media.Imaging;
using Material.Icons;
using Material.Icons.Avalonia;
@ -18,7 +18,7 @@ namespace Artemis.UI.Shared;
/// <summary>
/// Represents a control that can display the icon of a specific <see cref="ProfileConfiguration" />.
/// </summary>
public class ProfileConfigurationIcon : UserControl, IDisposable
public partial class ProfileConfigurationIcon : UserControl, IDisposable
{
private Stream? _stream;
@ -72,7 +72,7 @@ public class ProfileConfigurationIcon : UserControl, IDisposable
Content = new Border
{
Background = TextBlock.GetForeground(this),
Background = TextElement.GetForeground(this),
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
OpacityMask = new ImageBrush(new Bitmap(stream)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality}

View File

@ -40,8 +40,8 @@ public class SelectionRectangle : Control
/// <summary>
/// Defines the <see cref="InputElement" /> property.
/// </summary>
public static readonly StyledProperty<IControl?> InputElementProperty =
AvaloniaProperty.Register<SelectionRectangle, IControl?>(nameof(InputElement), notifying: OnInputElementChanged);
public static readonly StyledProperty<InputElement?> InputElementProperty =
AvaloniaProperty.Register<SelectionRectangle, InputElement?>(nameof(InputElement));
/// <summary>
/// Defines the <see cref="ZoomRatio" /> property.
@ -61,7 +61,7 @@ public class SelectionRectangle : Control
private Rect? _displayRect;
private bool _isSelecting;
private Point _lastPosition;
private IControl? _oldInputElement;
private InputElement? _oldInputElement;
private Point _startPosition;
/// <inheritdoc />
@ -110,10 +110,14 @@ public class SelectionRectangle : Control
/// <summary>
/// Gets or sets the element that captures input for the selection rectangle.
/// </summary>
public IControl? InputElement
public InputElement? InputElement
{
get => GetValue(InputElementProperty);
set => SetValue(InputElementProperty, value);
set
{
SetValue(InputElementProperty, value);
SubscribeToInputElement();
}
}
/// <summary>
@ -162,11 +166,6 @@ public class SelectionRectangle : Control
SelectionFinished?.Invoke(this, e);
}
private static void OnInputElementChanged(IAvaloniaObject sender, bool before)
{
((SelectionRectangle) sender).SubscribeToInputElement();
}
private void ParentOnPointerMoved(object? sender, PointerEventArgs e)
{
// Point moved seems to trigger when the element under the mouse changes?
@ -185,13 +184,13 @@ public class SelectionRectangle : Control
{
e.Pointer.Capture(this);
_startPosition = e.GetPosition(Parent);
_absoluteStartPosition = e.GetPosition(VisualRoot);
_startPosition = e.GetPosition(Parent as Visual);
_absoluteStartPosition = e.GetPosition(VisualRoot as Visual);
_displayRect = null;
}
Point currentPosition = e.GetPosition(Parent);
Point absoluteCurrentPosition = e.GetPosition(VisualRoot);
Point currentPosition = e.GetPosition(Parent as Visual);
Point absoluteCurrentPosition = e.GetPosition(VisualRoot as Visual);
_displayRect = new Rect(
new Point(Math.Min(_startPosition.X, currentPosition.X), Math.Min(_startPosition.Y, currentPosition.Y)),

View File

@ -15,7 +15,7 @@ public class ParentWidthPercentageConverter : IValueConverter
/// <inheritdoc />
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (parameter is not IControl parent || value is not double percentage)
if (parameter is not Control parent || value is not double percentage)
return value;
return parent.Width / 100.0 * percentage;
@ -24,7 +24,7 @@ public class ParentWidthPercentageConverter : IValueConverter
/// <inheritdoc />
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (parameter is not IControl parent || value is not double real)
if (parameter is not Control parent || value is not double real)
return value;
return real / parent.Width * 100.0;

View File

@ -6,7 +6,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display;
/// <summary>
/// Represents a default data model display view.
/// </summary>
public class DefaultDataModelDisplayView : UserControl
public partial class DefaultDataModelDisplayView : UserControl
{
/// <summary>
/// Creates a new instance of the <see cref="DefaultDataModelDisplayView" /> class.

View File

@ -7,7 +7,7 @@ namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display;
/// <summary>
/// Represents a data model display view used to display <see cref="SKColor" /> values.
/// </summary>
public class SKColorDataModelDisplayView : UserControl
public partial class SKColorDataModelDisplayView : UserControl
{
/// <summary>
/// Creates a new instance of the <see cref="SKColorDataModelDisplayView" /> class.

View File

@ -6,7 +6,7 @@ using Avalonia.VisualTree;
namespace Artemis.UI.Shared.Extensions;
/// <summary>
/// Provides extension methods for Avalonia's <see cref="IVisual" /> type
/// Provides extension methods for Avalonia's <see cref="Visual" /> type
/// </summary>
public static class VisualExtensions
{
@ -16,15 +16,15 @@ public static class VisualExtensions
/// <typeparam name="T">The type the children should have.</typeparam>
/// <param name="root">The root visual at which to start searching.</param>
/// <returns>A recursive list of all visual children of type <typeparamref name="T" />.</returns>
public static List<T> GetVisualChildrenOfType<T>(this IVisual root)
public static List<T> GetVisualChildrenOfType<T>(this Visual root)
{
List<T> result = new();
List<IVisual>? visualChildren = root.GetVisualChildren()?.ToList();
List<Visual>? visualChildren = root.GetVisualChildren()?.ToList();
if (visualChildren == null || !visualChildren.Any())
return result;
foreach (IVisual visualChild in visualChildren)
foreach (Visual visualChild in visualChildren)
{
if (visualChild is T toFind)
result.Add(toFind);
@ -41,15 +41,15 @@ public static class VisualExtensions
/// <typeparam name="T">The type of data context the children should have.</typeparam>
/// <param name="root">The root visual at which to start searching.</param>
/// <returns>A recursive list of all visual children with a data context of type <typeparamref name="T" />.</returns>
public static List<T> GetVisualChildrenOfDataContextType<T>(this IVisual root)
public static List<T> GetVisualChildrenOfDataContextType<T>(this Visual root)
{
List<T> result = new();
List<IVisual>? visualChildren = root.GetVisualChildren()?.ToList();
List<Visual>? visualChildren = root.GetVisualChildren()?.ToList();
if (visualChildren == null || !visualChildren.Any())
return result;
foreach (IVisual visualChild in visualChildren)
foreach (Visual visualChild in visualChildren)
{
if (visualChild is IDataContextProvider dataContextProvider && dataContextProvider.DataContext is T toFind)
result.Add(toFind);

View File

@ -4,8 +4,8 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Immutable;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Media;
using FluentAvalonia.UI.Windowing;
using ReactiveUI;
namespace Artemis.UI.Shared;
@ -17,18 +17,18 @@ namespace Artemis.UI.Shared;
/// and vice versa.
/// </summary>
/// <typeparam name="TViewModel">ViewModel type.</typeparam>
public class ReactiveCoreWindow<TViewModel> : CoreWindow, IViewFor<TViewModel> where TViewModel : class
public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel> where TViewModel : class
{
/// <summary>
/// The ViewModel.
/// </summary>
public static readonly StyledProperty<TViewModel?> ViewModelProperty = AvaloniaProperty
.Register<ReactiveCoreWindow<TViewModel>, TViewModel?>(nameof(ViewModel));
.Register<ReactiveAppWindow<TViewModel>, TViewModel?>(nameof(ViewModel));
/// <summary>
/// Initializes a new instance of the <see cref="ReactiveCoreWindow{TViewModel}" /> class.
/// Initializes a new instance of the <see cref="ReactiveAppWindow{TViewModel}" /> class.
/// </summary>
public ReactiveCoreWindow()
public ReactiveAppWindow()
{
// This WhenActivated block calls ViewModel's WhenActivated
// block if the ViewModel implements IActivatableViewModel.

View File

@ -116,7 +116,7 @@ public class NotificationBuilder
/// <exception cref="ArtemisSharedUIException" />
public Action Show()
{
IPanel? panel = _parent.Find<IPanel>("NotificationContainer");
Panel? panel = _parent.Find<Panel>("NotificationContainer");
if (panel == null)
throw new ArtemisSharedUIException("Can't display a notification on a window without a NotificationContainer.");
@ -202,7 +202,7 @@ public class NotificationButtonBuilder
return this;
}
internal IControl Build()
internal Control Build()
{
if (_action != null)
return new Button {Content = _text, Command = ReactiveCommand.Create(() => _action()), Classes = new Classes("AppBarButton")};

View File

@ -4,7 +4,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Shared.Services;
internal class ExceptionDialogView : ReactiveWindow<ExceptionDialogViewModel>
internal partial class ExceptionDialogView : ReactiveWindow<ExceptionDialogViewModel>
{
public ExceptionDialogView()
{

View File

@ -9,7 +9,7 @@
Padding="2 2 30 2">
</TextBox>
<controls:ColorPickerButton Classes="contained-color-picker-button"
ShowAcceptDismissButtons="False"/>
ShowAcceptDismissButtons="False" />
</Grid>
</Border>
</Design.PreviewWith>
@ -27,7 +27,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<controls:Button Name="MainButton"
<Button Name="MainButton"
Padding="0"
BorderThickness="0"
CornerRadius="{TemplateBinding CornerRadius}">
@ -37,9 +37,9 @@
MinWidth="18" MinHeight="18"
Background="{TemplateBinding Color, Converter={StaticResource ColorBrushConv}}"
CornerRadius="{TemplateBinding CornerRadius}">
<controls:ColorPicker Name="ColorPicker" IsVisible="False" />
<controls:FAColorPicker Name="ColorPicker" IsVisible="False" />
</Border>
</controls:Button>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>

View File

@ -102,7 +102,7 @@
<Setter Property="MinHeight" Value="24" />
</Style>
<Style Selector="dataModelPicker|DataModelPickerButton.condensed /template/ controls|Button">
<Style Selector="dataModelPicker|DataModelPickerButton.condensed /template/ Button">
<Setter Property="Padding" Value="6 3 11 3" />
<Setter Property="Height" Value="24" />
</Style>

View File

@ -27,7 +27,7 @@
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template">
<ControlTemplate>
<controls:Button Name="MainButton"
<Button Name="MainButton"
CornerRadius="{TemplateBinding CornerRadius}"
BorderBrush="{TemplateBinding BorderBrush}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
@ -40,7 +40,7 @@
Grid.Column="0"
VerticalAlignment="Center"
TextAlignment="Left"
TextTrimming="CharacterEllipsis"/>
TextTrimming="CharacterEllipsis" />
<TextBlock Name="ChevronTextBlock"
Grid.Column="1"
FontFamily="{DynamicResource SymbolThemeFontFamily}"
@ -51,7 +51,7 @@
Padding="2 2 2 0"
Margin="5 0" />
</Grid>
</controls:Button>
</Button>
</ControlTemplate>
</Setter>
</Style>

View File

@ -168,7 +168,7 @@
BorderBrush="{DynamicResource ButtonBorderBrush}"
BorderThickness="0 0 1 0"
Padding="0 0 10 0">
<fluent:ColorPicker Name="ColorPicker"
<fluent:FAColorPicker Name="ColorPicker"
ColorTextType="HexAlpha"
UseColorWheel="True"
UseColorTriangle="True"

View File

@ -1,15 +1,13 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:gradientPicker="clr-namespace:Artemis.UI.Shared.Controls.GradientPicker">
<Design.PreviewWith>
<Border Padding="20" Width="200">
<StackPanel Spacing="5">
<gradientPicker:GradientPickerButton IsCompact="True" />
<ComboBox HorizontalAlignment="Stretch"></ComboBox>
<controls:DropDownButton HorizontalAlignment="Stretch"></controls:DropDownButton>
<DropDownButton HorizontalAlignment="Stretch"></DropDownButton>
</StackPanel>
</Border>
</Design.PreviewWith>
@ -31,7 +29,7 @@
<Setter Property="Template">
<ControlTemplate>
<controls:Button
<Button
Name="MainButton"
Padding="0 0 12 0"
CornerRadius="{TemplateBinding CornerRadius}"
@ -54,7 +52,7 @@
Margin="4,0,0,0" />
</Grid>
</controls:Button>
</Button>
</ControlTemplate>

View File

@ -32,7 +32,7 @@
<TreeViewItem Header="SubItem Item3" />
</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Item3" IsEnabled="False"/>
<TreeViewItem Header="Item3" IsEnabled="False" />
<TreeViewItem Header="Item4" />
</TreeView>
</Border>
@ -53,20 +53,23 @@
TemplatedControl.IsTemplateFocusTarget="True"
Margin="2 2 0 2">
<Panel>
<Border Name="SelectionIndicator"
<Rectangle Name="SelectionIndicator"
Width="3"
Height="16"
HorizontalAlignment="Left"
VerticalAlignment="Center"
CornerRadius="2" />
RadiusX="2"
RadiusY="2"
IsVisible="False"
Fill="{DynamicResource TreeViewItemSelectionIndicatorForeground}" />
<Grid Name="PART_Header"
ColumnDefinitions="Auto, *"
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}">
<Panel Name="PART_ExpandCollapseChevronContainer"
Margin="8 0 4 0">
Margin="{StaticResource TreeViewItemExpandCollapseChevronMargin}">
<ToggleButton Name="PART_ExpandCollapseChevron"
Classes="ExpandCollapseChevron"
Theme="{StaticResource TreeViewChevronButton}"
Focusable="False"
IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}" />
</Panel>
@ -74,6 +77,7 @@
Grid.Column="1"
Focusable="False"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Margin="{TemplateBinding Padding}" />
@ -82,7 +86,6 @@
</Border>
<ItemsPresenter Name="PART_ItemsPresenter"
IsVisible="{TemplateBinding IsExpanded}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
Margin="2 2 0 2"/>
</StackPanel>
@ -95,7 +98,7 @@
</Style>
<Style Selector="TreeView TreeViewItem[IsEnabled=False]">
<Setter Property="Foreground" Value="{DynamicResource ButtonDisabledForegroundThemeBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ButtonDisabledForegroundThemeBrush}" />
</Style>
<!-- <Style Selector="TreeView.no-right-margin TreeViewItem /template/ Border#TreeViewItemLayoutRoot"> -->

View File

@ -21,18 +21,18 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="Avalonia.Win32" Version="0.10.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Win32" Version="11.0.0-preview6" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageReference Include="Microsoft.Win32" Version="2.0.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="RawInput.Sharp" Version="0.0.4" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Include="SkiaSharp.Vulkan.SharpVk" Version="2.88.1-preview.108" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="SkiaSharp.Vulkan.SharpVk" Version="2.88.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />

View File

@ -15,28 +15,28 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="0.10.12.2" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="10.14.0" />
<PackageReference Include="Avalonia.Controls.Skia" Version="0.10.16" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Controls.Skia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.18" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview6" />
<PackageReference Include="DryIoc.dll" Version="5.3.1" />
<PackageReference Include="DynamicData" Version="7.9.14" />
<PackageReference Include="FluentAvaloniaUI" Version="1.4.1" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview6" />
<PackageReference Include="Flurl.Http" Version="3.2.4" />
<PackageReference Include="Live.Avalonia" Version="1.3.1" />
<PackageReference Include="Markdown.Avalonia.Tight" Version="0.10.13" />
<PackageReference Include="Material.Icons.Avalonia" Version="1.1.10" />
<PackageReference Include="Octopus.Octodiff" Version="2.0.100" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Include="ReactiveUI.Validation" Version="2.2.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="RGB.NET.Core" Version="2.0.0-prerelease.17" />
<PackageReference Include="RGB.NET.Layout" Version="2.0.0-prerelease.17" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="Splat.DryIoc" Version="14.6.1" />
</ItemGroup>

View File

@ -106,7 +106,7 @@ public class SimpleContextDragBehavior : Behavior<Control>
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox)
return;
if (e.Source is not IControl control || AssociatedObject?.DataContext != control.DataContext)
if (e.Source is not Control control || AssociatedObject?.DataContext != control.DataContext)
return;
_dragStartPoint = e.GetPosition(null);

View File

@ -2,7 +2,6 @@
using System.Collections;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Generators;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
@ -14,7 +13,7 @@ namespace Artemis.UI.Behaviors;
/// <summary>
/// </summary>
public class TreeItemDragBehavior : Behavior<IControl>
public class TreeItemDragBehavior : Behavior<Control>
{
/// <summary>
/// </summary>
@ -31,7 +30,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
public static readonly StyledProperty<double> VerticalDragThresholdProperty =
AvaloniaProperty.Register<TreeItemDragBehavior, double>(nameof(VerticalDragThreshold), 3);
private IControl? _draggedContainer;
private Control? _draggedContainer;
private int _draggedIndex;
private bool _dragStarted;
private bool _enableDrag;
@ -69,12 +68,12 @@ public class TreeItemDragBehavior : Behavior<IControl>
{
base.OnAttached();
if (AssociatedObject is { })
if (AssociatedObject is not null)
{
AssociatedObject.AddHandler(InputElement.PointerReleasedEvent, Released, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerPressedEvent, Pressed, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerMovedEvent, Moved, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerCaptureLostEvent, CaptureLost, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerReleasedEvent, ReleasedHandler, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerPressedEvent, PressedHandler, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerMovedEvent, MovedHandler, RoutingStrategies.Tunnel);
AssociatedObject.AddHandler(InputElement.PointerCaptureLostEvent, CaptureLostHandler, RoutingStrategies.Tunnel);
}
}
@ -84,16 +83,16 @@ public class TreeItemDragBehavior : Behavior<IControl>
{
base.OnDetaching();
if (AssociatedObject is { })
if (AssociatedObject is not null)
{
AssociatedObject.RemoveHandler(InputElement.PointerReleasedEvent, Released);
AssociatedObject.RemoveHandler(InputElement.PointerPressedEvent, Pressed);
AssociatedObject.RemoveHandler(InputElement.PointerMovedEvent, Moved);
AssociatedObject.RemoveHandler(InputElement.PointerCaptureLostEvent, CaptureLost);
AssociatedObject.RemoveHandler(InputElement.PointerReleasedEvent, ReleasedHandler);
AssociatedObject.RemoveHandler(InputElement.PointerPressedEvent, PressedHandler);
AssociatedObject.RemoveHandler(InputElement.PointerMovedEvent, MovedHandler);
AssociatedObject.RemoveHandler(InputElement.PointerCaptureLostEvent, CaptureLostHandler);
}
}
private void Pressed(object? sender, PointerPressedEventArgs e)
private void PressedHandler(object? sender, PointerPressedEventArgs e)
{
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
if (properties.IsLeftButtonPressed
@ -101,20 +100,20 @@ public class TreeItemDragBehavior : Behavior<IControl>
{
_enableDrag = true;
_dragStarted = false;
_start = e.GetPosition(AssociatedObject.Parent);
_start = e.GetPosition(AssociatedObject.Parent as Visual);
_draggedIndex = -1;
_targetIndex = -1;
_itemsControl = itemsControl;
_draggedContainer = AssociatedObject;
if (_draggedContainer is { })
if (_draggedContainer is not null)
SetDraggingPseudoClasses(_draggedContainer, true);
AddTransforms(_itemsControl);
}
}
private void Released(object? sender, PointerReleasedEventArgs e)
private void ReleasedHandler(object? sender, PointerReleasedEventArgs e)
{
if (_dragStarted)
{
@ -125,7 +124,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
}
}
private void CaptureLost(object? sender, PointerCaptureLostEventArgs e)
private void CaptureLostHandler(object? sender, PointerCaptureLostEventArgs e)
{
Released();
}
@ -137,19 +136,21 @@ public class TreeItemDragBehavior : Behavior<IControl>
RemoveTransforms(_itemsControl);
if (_itemsControl is { })
foreach (ItemContainerInfo? container in _itemsControl.ItemContainerGenerator.Containers)
SetDraggingPseudoClasses(container.ContainerControl, true);
if (_itemsControl is not null)
{
for (int i = 0; i < _itemsControl.ItemCount; i++)
SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), true);
}
if (_dragStarted)
if (_draggedIndex >= 0 && _targetIndex >= 0 && _draggedIndex != _targetIndex)
MoveDraggedItem(_itemsControl, _draggedIndex, _targetIndex);
if (_itemsControl is { })
foreach (ItemContainerInfo? container in _itemsControl.ItemContainerGenerator.Containers)
SetDraggingPseudoClasses(container.ContainerControl, false);
if (_itemsControl is not null)
for (int i = 0; i < _itemsControl.ItemCount; i++)
SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), false);
if (_draggedContainer is { })
if (_draggedContainer is not null)
SetDraggingPseudoClasses(_draggedContainer, false);
_draggedIndex = -1;
@ -170,7 +171,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
foreach (object? _ in itemsControl.Items)
{
IControl? container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i);
Control? container = itemsControl.ContainerFromIndex(i);
if (container is not null)
SetTranslateTransform(container, 0, 0);
@ -187,7 +188,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
foreach (object? _ in itemsControl.Items)
{
IControl? container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i);
Control? container = itemsControl.ContainerFromIndex(i);
if (container is not null)
SetTranslateTransform(container, 0, 0);
@ -208,7 +209,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
selectingItemsControl.SelectedIndex = targetIndex;
}
private void Moved(object? sender, PointerEventArgs e)
private void MovedHandler(object? sender, PointerEventArgs e)
{
PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties;
if (properties.IsLeftButtonPressed)
@ -249,7 +250,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
else
SetTranslateTransform(_draggedContainer, 0, delta);
_draggedIndex = _itemsControl.ItemContainerGenerator.IndexFromContainer(_draggedContainer);
_draggedIndex = _itemsControl.IndexFromContainer(_draggedContainer);
_targetIndex = -1;
Rect draggedBounds = _draggedContainer.Bounds;
@ -268,7 +269,7 @@ public class TreeItemDragBehavior : Behavior<IControl>
foreach (object? _ in _itemsControl.Items)
{
IControl? targetContainer = _itemsControl.ItemContainerGenerator.ContainerFromIndex(i);
Control? targetContainer = _itemsControl.ContainerFromIndex(i);
if (targetContainer?.RenderTransform is null || ReferenceEquals(targetContainer, _draggedContainer))
{
i++;
@ -321,16 +322,20 @@ public class TreeItemDragBehavior : Behavior<IControl>
}
}
private void SetDraggingPseudoClasses(IControl control, bool isDragging)
private void SetDraggingPseudoClasses(Control? control, bool isDragging)
{
if (control == null)
return;
if (isDragging)
((IPseudoClasses) control.Classes).Add(":dragging");
else
((IPseudoClasses) control.Classes).Remove(":dragging");
}
private void SetTranslateTransform(IControl control, double x, double y)
private void SetTranslateTransform(Control? control, double x, double y)
{
if (control == null)
return;
TransformOperations.Builder transformBuilder = new(1);
transformBuilder.AppendTranslate(x, y);
control.RenderTransform = transformBuilder.Build();

View File

@ -1,4 +1,5 @@
using System;
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
@ -137,47 +138,47 @@ public class TimelineHeader : Control
private void RenderLabel(DrawingContext drawingContext, string text, double x)
{
Typeface typeFace = new(FontFamily);
FormattedText formattedText = new(text, typeFace, 9, TextAlignment.Left, TextWrapping.NoWrap, Bounds.Size);
FormattedText formattedText = new(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeFace, 9, Foreground);
if (x == 0 && OffsetFirstValue)
drawingContext.DrawText(Foreground, new Point(2, 5), formattedText);
drawingContext.DrawText(formattedText, new Point(2, 5));
else
drawingContext.DrawText(Foreground, new Point(x - formattedText.Bounds.Width / 2, 5), formattedText);
drawingContext.DrawText(formattedText, new Point(x - formattedText.Width / 2, 5));
}
private void UpdateTimeScale()
{
object[] subds;
double[] subds;
if (PixelsPerSecond > 350)
subds = new object[] {12d, 12d, 60d};
subds = new[] {12d, 12d, 60d};
else if (PixelsPerSecond > 250)
subds = new object[] {6d, 12d, 60d};
subds = new[] {6d, 12d, 60d};
else if (PixelsPerSecond > 200)
subds = new object[] {6d, 6d, 30d};
subds = new[] {6d, 6d, 30d};
else if (PixelsPerSecond > 150)
subds = new object[] {4d, 4d, 20d};
subds = new[] {4d, 4d, 20d};
else if (PixelsPerSecond > 140)
subds = new object[] {4d, 4d, 20d};
subds = new[] {4d, 4d, 20d};
else if (PixelsPerSecond > 90)
subds = new object[] {2d, 4d, 20d};
subds = new[] {2d, 4d, 20d};
else if (PixelsPerSecond > 60)
subds = new object[] {2d, 4d, 8d};
subds = new[] {2d, 4d, 8d};
else if (PixelsPerSecond > 40)
subds = new object[] {1d, 2d, 10d};
subds = new[] {1d, 2d, 10d};
else if (PixelsPerSecond > 30)
subds = new object[] {1d, 2d, 10d};
subds = new[] {1d, 2d, 10d};
else if (PixelsPerSecond > 10)
subds = new object[] {1d / 2d, 1d / 2d, 1d / 2d};
subds = new[] {1d / 2d, 1d / 2d, 1d / 2d};
else if (PixelsPerSecond > 4)
subds = new object[] {1d / 5d, 1d / 5d, 1d / 5d};
subds = new[] {1d / 5d, 1d / 5d, 1d / 5d};
else if (PixelsPerSecond > 3)
subds = new object[] {1d / 10d, 1d / 10d, 1d / 5d};
subds = new[] {1d / 10d, 1d / 10d, 1d / 5d};
else if (PixelsPerSecond > 1)
subds = new object[] {1d / 20d, 1d / 20d, 1d / 10d};
subds = new[] {1d / 20d, 1d / 20d, 1d / 10d};
else if (PixelsPerSecond >= 1)
subds = new object[] {1d / 30d, 1d / 30d, 1d / 15d};
subds = new[] {1d / 30d, 1d / 30d, 1d / 15d};
else
// 1s per pixel
subds = new object[] {1d / 60d, 1d / 60d, 1d / 15d};
subds = new[] {1d / 60d, 1d / 60d, 1d / 15d};
_subd1 = (double) subds[0]; // big ticks / labels
_subd2 = (double) subds[1]; // medium ticks

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class BoolPropertyInputView : ReactiveUserControl<BoolPropertyInputViewModel>
public partial class BoolPropertyInputView : ReactiveUserControl<BoolPropertyInputViewModel>
{
public BoolPropertyInputView()
{

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class BrushPropertyInputView : ReactiveUserControl<BrushPropertyInputViewModel>
public partial class BrushPropertyInputView : ReactiveUserControl<BrushPropertyInputViewModel>
{
public BrushPropertyInputView()
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Artemis.Core;
using Artemis.Core.LayerBrushes;
@ -11,7 +12,6 @@ using Artemis.UI.Shared.Services.Builders;
using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Artemis.UI.Shared.Services.PropertyInput;
using Avalonia.Controls.Mixins;
using Avalonia.Threading;
using ReactiveUI;

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class ColorGradientPropertyInputView : ReactiveUserControl<ColorGradientPropertyInputViewModel>
public partial class ColorGradientPropertyInputView : ReactiveUserControl<ColorGradientPropertyInputViewModel>
{
public ColorGradientPropertyInputView()
{

View File

@ -4,7 +4,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class EnumPropertyInputView : ReactiveUserControl<PropertyInputViewModel>
public partial class EnumPropertyInputView : ReactiveUserControl<PropertyInputViewModel>
{
public EnumPropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class FloatPropertyInputView : ReactiveUserControl<FloatPropertyInputViewModel>
public partial class FloatPropertyInputView : ReactiveUserControl<FloatPropertyInputViewModel>
{
public FloatPropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class FloatRangePropertyInputView : ReactiveUserControl<FloatRangePropertyInputViewModel>
public partial class FloatRangePropertyInputView : ReactiveUserControl<FloatRangePropertyInputViewModel>
{
public FloatRangePropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class IntPropertyInputView : ReactiveUserControl<IntPropertyInputViewModel>
public partial class IntPropertyInputView : ReactiveUserControl<IntPropertyInputViewModel>
{
public IntPropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class IntRangePropertyInputView : ReactiveUserControl<IntRangePropertyInputViewModel>
public partial class IntRangePropertyInputView : ReactiveUserControl<IntRangePropertyInputViewModel>
{
public IntRangePropertyInputView()
{

View File

@ -5,7 +5,7 @@ using FluentAvalonia.UI.Controls;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class SKColorPropertyInputView : ReactiveUserControl<SKColorPropertyInputViewModel>
public partial class SKColorPropertyInputView : ReactiveUserControl<SKColorPropertyInputViewModel>
{
public SKColorPropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class SKPointPropertyInputView : ReactiveUserControl<SKPointPropertyInputViewModel>
public partial class SKPointPropertyInputView : ReactiveUserControl<SKPointPropertyInputViewModel>
{
public SKPointPropertyInputView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class SKSizePropertyInputView : ReactiveUserControl<SKSizePropertyInputViewModel>
public partial class SKSizePropertyInputView : ReactiveUserControl<SKSizePropertyInputViewModel>
{
public SKSizePropertyInputView()
{

View File

@ -4,7 +4,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.DefaultTypes.PropertyInput;
public class StringPropertyInputView : ReactiveUserControl<FloatPropertyInputViewModel>
public partial class StringPropertyInputView : ReactiveUserControl<FloatPropertyInputViewModel>
{
public StringPropertyInputView()
{

View File

@ -13,7 +13,7 @@ using ReactiveUI;
namespace Artemis.UI;
public class MainWindow : ReactiveCoreWindow<RootViewModel>
public class MainWindow : ReactiveAppWindow<RootViewModel>
{
private readonly Panel _rootPanel;
private readonly ContentControl _sidebarContentControl;

View File

@ -10,7 +10,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.Debugger;
public class DebugView : ReactiveCoreWindow<DebugViewModel>
public class DebugView : ReactiveAppWindow<DebugViewModel>
{
public DebugView()
{

View File

@ -7,7 +7,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Device;
public class DevicePropertiesView : ReactiveCoreWindow<DevicePropertiesViewModel>
public class DevicePropertiesView : ReactiveAppWindow<DevicePropertiesViewModel>
{
public DevicePropertiesView()
{

View File

@ -8,7 +8,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
public class PluginSettingsWindowView : ReactiveCoreWindow<PluginSettingsWindowViewModel>
public class PluginSettingsWindowView : ReactiveAppWindow<PluginSettingsWindowViewModel>
{
public PluginSettingsWindowView()
{

View File

@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
public class LayerHintsDialogView : ReactiveCoreWindow<LayerHintsDialogViewModel>
public class LayerHintsDialogView : ReactiveAppWindow<LayerHintsDialogViewModel>
{
public LayerHintsDialogView()
{

View File

@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
public class BrushConfigurationWindowView : ReactiveCoreWindow<BrushConfigurationWindowViewModel>
public class BrushConfigurationWindowView : ReactiveAppWindow<BrushConfigurationWindowViewModel>
{
private bool _canClose;

View File

@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
public class EffectConfigurationWindowView : ReactiveCoreWindow<EffectConfigurationWindowViewModel>
public class EffectConfigurationWindowView : ReactiveAppWindow<EffectConfigurationWindowViewModel>
{
private bool _canClose;

View File

@ -5,7 +5,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Scripting;
public class ScriptsDialogView : ReactiveCoreWindow<ScriptsDialogViewModel>
public class ScriptsDialogView : ReactiveAppWindow<ScriptsDialogViewModel>
{
private bool _canClose;

View File

@ -8,7 +8,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.Sidebar;
public class ProfileConfigurationEditView : ReactiveCoreWindow<ProfileConfigurationEditViewModel>
public class ProfileConfigurationEditView : ReactiveAppWindow<ProfileConfigurationEditViewModel>
{
public ProfileConfigurationEditView()
{

View File

@ -11,7 +11,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.StartupWizard;
public class StartupWizardView : ReactiveCoreWindow<StartupWizardViewModel>
public class StartupWizardView : ReactiveAppWindow<StartupWizardViewModel>
{
private readonly Frame _frame;

View File

@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.VisualScripting;
public class NodeScriptWindowView : ReactiveCoreWindow<NodeScriptWindowViewModel>
public class NodeScriptWindowView : ReactiveAppWindow<NodeScriptWindowViewModel>
{
public NodeScriptWindowView()
{

View File

@ -8,14 +8,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview6" />
<PackageReference Include="DryIoc.dll" Version="5.3.1" />
<PackageReference Include="NoStringEvaluating" Version="2.4.0" />
<PackageReference Include="ReactiveUI" Version="17.1.50" />
<PackageReference Include="ReactiveUI.Validation" Version="2.2.1" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
</ItemGroup>
<ItemGroup>