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

Fixed compile errors in Artemis.UI

This commit is contained in:
Robert 2023-03-30 23:13:39 +02:00
parent 81e83e59f6
commit d171b947b7
160 changed files with 407 additions and 521 deletions

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Artemis.Core.Properties; using JetBrains.Annotations;
namespace Artemis.Core; namespace Artemis.Core;

View File

@ -1,6 +1,4 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Artemis.Core.Properties;
using Artemis.Storage.Entities.Plugins; using Artemis.Storage.Entities.Plugins;
using Artemis.Storage.Repositories.Interfaces; using Artemis.Storage.Repositories.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -36,9 +34,7 @@ public class PluginSetting<T> : CorePropertyChanged, IPluginSetting
/// <summary> /// <summary>
/// The value of the setting /// The value of the setting
/// </summary> /// </summary>
[AllowNull] public T? Value
[CanBeNull]
public T Value
{ {
get => _value; get => _value;
set set

View File

@ -4,8 +4,8 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Internal; using Artemis.Core.Internal;
using Artemis.Core.Properties;
using Artemis.Storage.Entities.Profile.Nodes; using Artemis.Storage.Entities.Profile.Nodes;
using JetBrains.Annotations;
namespace Artemis.Core; namespace Artemis.Core;

View File

@ -122,7 +122,7 @@ public class DeviceVisualizer : Control
private Rect MeasureDevice() private Rect MeasureDevice()
{ {
if (Device == null) if (Device == null)
return new Rect(0, 0, 0, 0); return new Rect();
Rect deviceRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); Rect deviceRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
Geometry geometry = new RectangleGeometry(deviceRect); Geometry geometry = new RectangleGeometry(deviceRect);

View File

@ -56,7 +56,6 @@ public partial class DraggableNumberBox : UserControl
/// </summary> /// </summary>
public static readonly StyledProperty<string?> SuffixProperty = AvaloniaProperty.Register<DraggableNumberBox, string?>(nameof(Suffix)); public static readonly StyledProperty<string?> SuffixProperty = AvaloniaProperty.Register<DraggableNumberBox, string?>(nameof(Suffix));
private readonly NumberBox _numberBox;
private TextBox? _inputTextBox; private TextBox? _inputTextBox;
private double _lastX; private double _lastX;
private bool _moved; private bool _moved;
@ -69,8 +68,7 @@ public partial class DraggableNumberBox : UserControl
public DraggableNumberBox() public DraggableNumberBox()
{ {
InitializeComponent(); InitializeComponent();
_numberBox = this.Get<NumberBox>("NumberBox"); NumberBox.Value = Value;
_numberBox.Value = Value;
PointerPressed += OnPointerPressed; PointerPressed += OnPointerPressed;
PointerMoved += OnPointerMoved; PointerMoved += OnPointerMoved;
@ -167,11 +165,11 @@ public partial class DraggableNumberBox : UserControl
private void SetNumberBoxValue(double value) private void SetNumberBoxValue(double value)
{ {
if (!(Math.Abs(_numberBox.Value - Value) > 0.00001)) if (!(Math.Abs(NumberBox.Value - Value) > 0.00001))
return; return;
_updating = true; _updating = true;
_numberBox.Value = Value; NumberBox.Value = Value;
_updating = false; _updating = false;
} }
@ -189,7 +187,7 @@ public partial class DraggableNumberBox : UserControl
private void OnPointerPressed(object? sender, PointerPressedEventArgs e) private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
{ {
PointerPoint point = e.GetCurrentPoint(this); PointerPoint point = e.GetCurrentPoint(this);
_inputTextBox = _numberBox.FindDescendantOfType<TextBox>(); _inputTextBox = NumberBox.FindDescendantOfType<TextBox>();
_moved = false; _moved = false;
_startX = point.Position.X; _startX = point.Position.X;
_lastX = point.Position.X; _lastX = point.Position.X;
@ -261,17 +259,17 @@ public partial class DraggableNumberBox : UserControl
if (args.NewValue < Minimum) if (args.NewValue < Minimum)
{ {
_numberBox.Value = Minimum; NumberBox.Value = Minimum;
return; return;
} }
if (args.NewValue > Maximum) if (args.NewValue > Maximum)
{ {
_numberBox.Value = Maximum; NumberBox.Value = Maximum;
return; return;
} }
if (Math.Abs(Value - _numberBox.Value) > 0.00001) if (Math.Abs(Value - NumberBox.Value) > 0.00001)
Value = _numberBox.Value; Value = NumberBox.Value;
} }
} }

View File

@ -138,8 +138,8 @@ public class TreeItemDragBehavior : Behavior<Control>
if (_itemsControl is not null) if (_itemsControl is not null)
{ {
for (int i = 0; i < _itemsControl.ItemCount; i++) foreach (Control realizedContainer in _itemsControl.GetRealizedContainers())
SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), true); SetDraggingPseudoClasses(realizedContainer, true);
} }
if (_dragStarted) if (_dragStarted)
@ -147,8 +147,10 @@ public class TreeItemDragBehavior : Behavior<Control>
MoveDraggedItem(_itemsControl, _draggedIndex, _targetIndex); MoveDraggedItem(_itemsControl, _draggedIndex, _targetIndex);
if (_itemsControl is not null) if (_itemsControl is not null)
for (int i = 0; i < _itemsControl.ItemCount; i++) {
SetDraggingPseudoClasses(_itemsControl.ContainerFromIndex(i), false); foreach (Control realizedContainer in _itemsControl.GetRealizedContainers())
SetDraggingPseudoClasses(realizedContainer, false);
}
if (_draggedContainer is not null) if (_draggedContainer is not null)
SetDraggingPseudoClasses(_draggedContainer, false); SetDraggingPseudoClasses(_draggedContainer, false);
@ -166,17 +168,9 @@ public class TreeItemDragBehavior : Behavior<Control>
{ {
if (itemsControl?.Items is null) if (itemsControl?.Items is null)
return; return;
int i = 0; foreach (Control container in itemsControl.GetRealizedContainers())
SetTranslateTransform(container, 0, 0);
foreach (object? _ in itemsControl.Items)
{
Control? container = itemsControl.ContainerFromIndex(i);
if (container is not null)
SetTranslateTransform(container, 0, 0);
i++;
}
} }
private void RemoveTransforms(ItemsControl? itemsControl) private void RemoveTransforms(ItemsControl? itemsControl)
@ -184,16 +178,8 @@ public class TreeItemDragBehavior : Behavior<Control>
if (itemsControl?.Items is null) if (itemsControl?.Items is null)
return; return;
int i = 0; foreach (Control container in itemsControl.GetRealizedContainers())
SetTranslateTransform(container, 0, 0);
foreach (object? _ in itemsControl.Items)
{
Control? container = itemsControl.ContainerFromIndex(i);
if (container is not null)
SetTranslateTransform(container, 0, 0);
i++;
}
} }
private void MoveDraggedItem(ItemsControl? itemsControl, int draggedIndex, int targetIndex) private void MoveDraggedItem(ItemsControl? itemsControl, int draggedIndex, int targetIndex)
@ -264,17 +250,11 @@ public class TreeItemDragBehavior : Behavior<Control>
double draggedDeltaEnd = orientation == Orientation.Horizontal double draggedDeltaEnd = orientation == Orientation.Horizontal
? draggedBounds.X + delta + draggedBounds.Width ? draggedBounds.X + delta + draggedBounds.Width
: draggedBounds.Y + delta + draggedBounds.Height; : draggedBounds.Y + delta + draggedBounds.Height;
int i = 0; foreach (Control targetContainer in _itemsControl.GetRealizedContainers())
foreach (object? _ in _itemsControl.Items)
{ {
Control? targetContainer = _itemsControl.ContainerFromIndex(i); if (targetContainer.RenderTransform is null || ReferenceEquals(targetContainer, _draggedContainer))
if (targetContainer?.RenderTransform is null || ReferenceEquals(targetContainer, _draggedContainer))
{
i++;
continue; continue;
}
// If the target container has children, there are two options // If the target container has children, there are two options
// Move into the top of the container // Move into the top of the container
@ -287,7 +267,7 @@ public class TreeItemDragBehavior : Behavior<Control>
? targetBounds.X + targetBounds.Width / 2 ? targetBounds.X + targetBounds.Width / 2
: targetBounds.Y + targetBounds.Height / 2; : targetBounds.Y + targetBounds.Height / 2;
int targetIndex = _itemsControl.ItemContainerGenerator.IndexFromContainer(targetContainer); int targetIndex = _itemsControl.IndexFromContainer(targetContainer);
if (targetStart > draggedStart && draggedDeltaEnd >= targetMid) if (targetStart > draggedStart && draggedDeltaEnd >= targetMid)
{ {
@ -316,8 +296,6 @@ public class TreeItemDragBehavior : Behavior<Control>
else else
SetTranslateTransform(targetContainer, 0, 0); SetTranslateTransform(targetContainer, 0, 0);
} }
i++;
} }
} }
} }

View File

@ -1,7 +1,6 @@
using System.Reflection; using System.Reflection;
using Artemis.UI.DryIoc.Factories; using Artemis.UI.DryIoc.Factories;
using Artemis.UI.DryIoc.InstanceProviders; using Artemis.UI.DryIoc.InstanceProviders;
using Artemis.UI.Screens;
using Artemis.UI.Screens.VisualScripting; using Artemis.UI.Screens.VisualScripting;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Services.Updating; using Artemis.UI.Services.Updating;
@ -9,7 +8,6 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.NodeEditor; using Artemis.UI.Shared.Services.NodeEditor;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport;
using DryIoc; using DryIoc;
namespace Artemis.UI.DryIoc; namespace Artemis.UI.DryIoc;

View File

@ -1,4 +1,4 @@
<controls:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -6,6 +6,7 @@
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:debugger="clr-namespace:Artemis.UI.Screens.Debugger" xmlns:debugger="clr-namespace:Artemis.UI.Screens.Debugger"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared" xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800" mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
x:Class="Artemis.UI.Screens.Debugger.DebugView" x:Class="Artemis.UI.Screens.Debugger.DebugView"
x:DataType="debugger:DebugViewModel" x:DataType="debugger:DebugViewModel"
@ -38,4 +39,4 @@
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" /> <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Grid> </Grid>
</controls:CoreWindow> </windowing:AppWindow>

View File

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

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.DataModel; namespace Artemis.UI.Screens.Debugger.DataModel;
public class DataModelDebugView : ReactiveUserControl<DataModelDebugViewModel> public partial class DataModelDebugView : ReactiveUserControl<DataModelDebugViewModel>
{ {
public DataModelDebugView() public DataModelDebugView()
{ {

View File

@ -8,7 +8,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Debugger.Logs.LogsDebugView" x:Class="Artemis.UI.Screens.Debugger.Logs.LogsDebugView"
x:DataType="logs:LogsDebugViewModel"> x:DataType="logs:LogsDebugViewModel">
<aedit:TextEditor Name="log" <aedit:TextEditor Name="LogTextEditor"
Document="{ CompiledBinding Document }" Document="{ CompiledBinding Document }"
IsReadOnly="True" IsReadOnly="True"
FontFamily="Consolas" FontFamily="Consolas"

View File

@ -1,20 +1,13 @@
using System; using System;
using System.Diagnostics;
using System.Reflection;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
using Avalonia.Threading; using Avalonia.Threading;
using AvaloniaEdit;
namespace Artemis.UI.Screens.Debugger.Logs; namespace Artemis.UI.Screens.Debugger.Logs;
public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel> public partial class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
{ {
private int _lineCount; private int _lineCount;
private TextEditor? _textEditor;
public LogsDebugView() public LogsDebugView()
{ {
@ -25,25 +18,22 @@ public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
_textEditor = this.FindControl<TextEditor>("log");
} }
protected override void OnInitialized() protected override void OnInitialized()
{ {
base.OnInitialized(); base.OnInitialized();
Dispatcher.UIThread.Post(() => _textEditor?.ScrollToEnd(), DispatcherPriority.ApplicationIdle); Dispatcher.UIThread.Post(() => LogTextEditor.ScrollToEnd(), DispatcherPriority.ApplicationIdle);
} }
private void OnTextChanged(object? sender, EventArgs e) private void OnTextChanged(object? sender, EventArgs e)
{ {
if (_textEditor is null) if (LogTextEditor.ExtentHeight == 0)
return;
if (_textEditor.ExtentHeight == 0)
return; return;
int linesAdded = _textEditor.LineCount - _lineCount; int linesAdded = LogTextEditor.LineCount - _lineCount;
double lineHeight = _textEditor.ExtentHeight / _textEditor.LineCount; double lineHeight = LogTextEditor.ExtentHeight / LogTextEditor.LineCount;
double outOfScreenTextHeight = _textEditor.ExtentHeight - _textEditor.VerticalOffset - _textEditor.ViewportHeight; double outOfScreenTextHeight = LogTextEditor.ExtentHeight - LogTextEditor.VerticalOffset - LogTextEditor.ViewportHeight;
double outOfScreenLines = outOfScreenTextHeight / lineHeight; double outOfScreenLines = outOfScreenTextHeight / lineHeight;
//we need this help distance because of rounding. //we need this help distance because of rounding.
@ -61,8 +51,8 @@ public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
//mess with anything. //mess with anything.
if (_lineCount == 0 || linesAdded + GRACE_DISTANCE > outOfScreenLines) if (_lineCount == 0 || linesAdded + GRACE_DISTANCE > outOfScreenLines)
{ {
Dispatcher.UIThread.Post(() => _textEditor.ScrollToEnd(), DispatcherPriority.ApplicationIdle); Dispatcher.UIThread.Post(() => LogTextEditor.ScrollToEnd(), DispatcherPriority.ApplicationIdle);
_lineCount = _textEditor.LineCount; _lineCount = LogTextEditor.LineCount;
} }
} }
} }

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Debugger.Performance; namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugPluginView : UserControl public partial class PerformanceDebugPluginView : UserControl
{ {
public PerformanceDebugPluginView() public PerformanceDebugPluginView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Debugger.Performance; namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugProfilerView : UserControl public partial class PerformanceDebugProfilerView : UserControl
{ {
public PerformanceDebugProfilerView() public PerformanceDebugProfilerView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Performance; namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugView : ReactiveUserControl<PerformanceDebugViewModel> public partial class PerformanceDebugView : ReactiveUserControl<PerformanceDebugViewModel>
{ {
public PerformanceDebugView() public PerformanceDebugView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Render; namespace Artemis.UI.Screens.Debugger.Render;
public class RenderDebugView : ReactiveUserControl<RenderDebugViewModel> public partial class RenderDebugView : ReactiveUserControl<RenderDebugViewModel>
{ {
public RenderDebugView() public RenderDebugView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Settings; namespace Artemis.UI.Screens.Debugger.Settings;
public class DebugSettingsView : ReactiveUserControl<DebugSettingsViewModel> public partial class DebugSettingsView : ReactiveUserControl<DebugSettingsViewModel>
{ {
public DebugSettingsView() public DebugSettingsView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DeviceDetectInputView : ReactiveUserControl<DeviceDetectInputViewModel> public partial class DeviceDetectInputView : ReactiveUserControl<DeviceDetectInputViewModel>
{ {
public DeviceDetectInputView() public DeviceDetectInputView()
{ {

View File

@ -1,10 +1,10 @@
<controls1:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared" xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:device="clr-namespace:Artemis.UI.Screens.Device" xmlns:device="clr-namespace:Artemis.UI.Screens.Device"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800" mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
x:Class="Artemis.UI.Screens.Device.DevicePropertiesView" x:Class="Artemis.UI.Screens.Device.DevicePropertiesView"
x:DataType="device:DevicePropertiesViewModel" x:DataType="device:DevicePropertiesViewModel"
@ -13,9 +13,9 @@
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
Width="1250" Width="1250"
Height="900"> Height="900">
<controls1:CoreWindow.KeyBindings> <windowing:AppWindow.KeyBindings>
<KeyBinding Gesture="Escape" Command="{CompiledBinding ClearSelectedLeds}" /> <KeyBinding Gesture="Escape" Command="{CompiledBinding ClearSelectedLeds}" />
</controls1:CoreWindow.KeyBindings> </windowing:AppWindow.KeyBindings>
<Grid ColumnDefinitions="*,0,1.5*"> <Grid ColumnDefinitions="*,0,1.5*">
<Grid.Background> <Grid.Background>
<VisualBrush TileMode="Tile" Stretch="Uniform" DestinationRect="0,0,25,25"> <VisualBrush TileMode="Tile" Stretch="Uniform" DestinationRect="0,0,25,25">
@ -71,5 +71,4 @@
<StackPanel Grid.Column="0" Grid.ColumnSpan="3" Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" /> <StackPanel Grid.Column="0" Grid.ColumnSpan="3" Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Grid> </Grid>
</windowing:AppWindow>
</controls1:CoreWindow>

View File

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

View File

@ -36,8 +36,8 @@
<Grid Grid.Row="2" Margin="10" ColumnDefinitions="25,*"> <Grid Grid.Row="2" Margin="10" ColumnDefinitions="25,*">
<CheckBox IsChecked="{Binding IsDeviceEnabled}" /> <CheckBox IsChecked="{Binding IsDeviceEnabled}" />
<controls:SplitButton Grid.Column="1" Content="Properties" Command="{Binding ViewProperties}" HorizontalAlignment="Right"> <SplitButton Grid.Column="1" Content="Properties" Command="{Binding ViewProperties}" HorizontalAlignment="Right">
<controls:SplitButton.Flyout> <SplitButton.Flyout>
<MenuFlyout Placement="Bottom"> <MenuFlyout Placement="Bottom">
<MenuItem Header="Open plugin directory" Command="{Binding OpenPluginDirectory}"> <MenuItem Header="Open plugin directory" Command="{Binding OpenPluginDirectory}">
<MenuItem.Icon> <MenuItem.Icon>
@ -50,8 +50,8 @@
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</MenuFlyout> </MenuFlyout>
</controls:SplitButton.Flyout> </SplitButton.Flyout>
</controls:SplitButton> </SplitButton>
</Grid> </Grid>
</Grid> </Grid>
</Border> </Border>

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DeviceSettingsView : ReactiveUserControl<DeviceSettingsViewModel> public partial class DeviceSettingsView : ReactiveUserControl<DeviceSettingsViewModel>
{ {
public DeviceSettingsView() public DeviceSettingsView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DeviceInfoTabView : ReactiveUserControl<DeviceInfoTabViewModel> public partial class DeviceInfoTabView : ReactiveUserControl<DeviceInfoTabViewModel>
{ {
public DeviceInfoTabView() public DeviceInfoTabView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DeviceLedsTabView : ReactiveUserControl<DeviceLedsTabViewModel> public partial class DeviceLedsTabView : ReactiveUserControl<DeviceLedsTabViewModel>
{ {
public DeviceLedsTabView() public DeviceLedsTabView()
{ {

View File

@ -8,17 +8,15 @@ using Avalonia.Threading;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DeviceLogicalLayoutDialogView : ReactiveUserControl<DeviceLogicalLayoutDialogViewModel> public partial class DeviceLogicalLayoutDialogView : ReactiveUserControl<DeviceLogicalLayoutDialogViewModel>
{ {
private readonly AutoCompleteBox _autoCompleteBox; private readonly AutoCompleteBox _autoCompleteBox;
public DeviceLogicalLayoutDialogView() public DeviceLogicalLayoutDialogView()
{ {
InitializeComponent(); InitializeComponent();
_autoCompleteBox = this.Get<AutoCompleteBox>("RegionsAutoCompleteBox"); RegionsAutoCompleteBox.ItemFilter += SearchRegions;
_autoCompleteBox.ItemFilter += SearchRegions;
Dispatcher.UIThread.InvokeAsync(DelayedAutoFocus); Dispatcher.UIThread.InvokeAsync(DelayedAutoFocus);
} }

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DevicePhysicalLayoutDialogView : ReactiveUserControl<DevicePhysicalLayoutDialogViewModel> public partial class DevicePhysicalLayoutDialogView : ReactiveUserControl<DevicePhysicalLayoutDialogViewModel>
{ {
public DevicePhysicalLayoutDialogView() public DevicePhysicalLayoutDialogView()
{ {

View File

@ -4,7 +4,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class DevicePropertiesTabView : ReactiveUserControl<DevicePropertiesTabViewModel> public partial class DevicePropertiesTabView : ReactiveUserControl<DevicePropertiesTabViewModel>
{ {
public DevicePropertiesTabView() public DevicePropertiesTabView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Device; namespace Artemis.UI.Screens.Device;
public class InputMappingsTabView : ReactiveUserControl<InputMappingsTabViewModel> public partial class InputMappingsTabView : ReactiveUserControl<InputMappingsTabViewModel>
{ {
public InputMappingsTabView() public InputMappingsTabView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Home; namespace Artemis.UI.Screens.Home;
public class HomeView : ReactiveUserControl<HomeViewModel> public partial class HomeView : ReactiveUserControl<HomeViewModel>
{ {
public HomeView() public HomeView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginPrerequisitesInstallDialogView : ReactiveUserControl<PluginPrerequisitesInstallDialogViewModel> public partial class PluginPrerequisitesInstallDialogView : ReactiveUserControl<PluginPrerequisitesInstallDialogViewModel>
{ {
public PluginPrerequisitesInstallDialogView() public PluginPrerequisitesInstallDialogView()
{ {

View File

@ -11,6 +11,7 @@ using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Avalonia.Threading; using Avalonia.Threading;
using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using ReactiveUI; using ReactiveUI;
using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton; using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton;
@ -98,7 +99,7 @@ public class PluginPrerequisitesInstallDialogViewModel : ContentDialogViewModelB
private async Task ExecuteInstall() private async Task ExecuteInstall()
{ {
ContentDialogClosingDeferral? deferral = null; Deferral? deferral = null;
if (ContentDialog != null) if (ContentDialog != null)
ContentDialog.Closing += (_, args) => deferral = args.GetDeferral(); ContentDialog.Closing += (_, args) => deferral = args.GetDeferral();

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginPrerequisitesUninstallDialogView : ReactiveUserControl<PluginPrerequisitesUninstallDialogViewModel> public partial class PluginPrerequisitesUninstallDialogView : ReactiveUserControl<PluginPrerequisitesUninstallDialogViewModel>
{ {
public PluginPrerequisitesUninstallDialogView() public PluginPrerequisitesUninstallDialogView()
{ {

View File

@ -12,6 +12,7 @@ using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Avalonia.Threading; using Avalonia.Threading;
using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using ReactiveUI; using ReactiveUI;
using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton; using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton;
@ -83,7 +84,7 @@ public class PluginPrerequisitesUninstallDialogViewModel : ContentDialogViewMode
private async Task ExecuteUninstall() private async Task ExecuteUninstall()
{ {
ContentDialogClosingDeferral? deferral = null; Deferral? deferral = null;
if (ContentDialog != null) if (ContentDialog != null)
ContentDialog.Closing += (_, args) => deferral = args.GetDeferral(); ContentDialog.Closing += (_, args) => deferral = args.GetDeferral();

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginFeatureView : ReactiveUserControl<PluginFeatureViewModel> public partial class PluginFeatureView : ReactiveUserControl<PluginFeatureViewModel>
{ {
public PluginFeatureView() public PluginFeatureView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginPlatformView : UserControl public partial class PluginPlatformView : UserControl
{ {
public PluginPlatformView() public PluginPlatformView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginPrerequisiteActionView : UserControl public partial class PluginPrerequisiteActionView : UserControl
{ {
public PluginPrerequisiteActionView() public PluginPrerequisiteActionView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginPrerequisiteView : ReactiveUserControl<PluginPrerequisiteViewModel> public partial class PluginPrerequisiteView : ReactiveUserControl<PluginPrerequisiteViewModel>
{ {
public PluginPrerequisiteView() public PluginPrerequisiteView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginSettingsView : ReactiveUserControl<PluginSettingsViewModel> public partial class PluginSettingsView : ReactiveUserControl<PluginSettingsViewModel>
{ {
public PluginSettingsView() public PluginSettingsView()
{ {

View File

@ -1,17 +1,17 @@
<controls:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginSettingsWindowView" x:Class="Artemis.UI.Screens.Plugins.PluginSettingsWindowView"
Icon="/Assets/Images/Logo/application.ico" Icon="/Assets/Images/Logo/application.ico"
Title="{Binding DisplayName}" Title="{Binding DisplayName}"
Width="800" Width="800"
Height="800" Height="800"
WindowStartupLocation="CenterOwner"> WindowStartupLocation="CenterOwner">
<Panel> <Panel>
<ContentControl Content="{Binding ConfigurationViewModel}"></ContentControl> <ContentControl Content="{Binding ConfigurationViewModel}"></ContentControl>
<StackPanel Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right"/> <StackPanel Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Panel> </Panel>
</controls:CoreWindow> </windowing:AppWindow>

View File

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

View File

@ -47,8 +47,8 @@
<Grid Grid.Row="1" ColumnDefinitions="*,Auto"> <Grid Grid.Row="1" ColumnDefinitions="*,Auto">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<controls:SplitButton Content="Settings" Command="{CompiledBinding OpenSettings}"> <SplitButton Content="Settings" Command="{CompiledBinding OpenSettings}">
<controls:SplitButton.Flyout> <SplitButton.Flyout>
<MenuFlyout Placement="Bottom" Opening="FlyoutBase_OnOpening"> <MenuFlyout Placement="Bottom" Opening="FlyoutBase_OnOpening">
<MenuItem Header="Open plugin directory" Command="{CompiledBinding OpenPluginDirectory}"> <MenuItem Header="Open plugin directory" Command="{CompiledBinding OpenPluginDirectory}">
<MenuItem.Icon> <MenuItem.Icon>
@ -81,8 +81,8 @@
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</MenuFlyout> </MenuFlyout>
</controls:SplitButton.Flyout> </SplitButton.Flyout>
</controls:SplitButton> </SplitButton>
<controls:HyperlinkButton Classes="icon-button icon-button-large" <controls:HyperlinkButton Classes="icon-button icon-button-large"
Margin="5 0" Margin="5 0"

View File

@ -7,15 +7,12 @@ using Avalonia.Threading;
namespace Artemis.UI.Screens.Plugins; namespace Artemis.UI.Screens.Plugins;
public class PluginView : ReactiveUserControl<PluginViewModel> public partial class PluginView : ReactiveUserControl<PluginViewModel>
{ {
private readonly CheckBox _enabledToggle;
public PluginView() public PluginView()
{ {
InitializeComponent(); InitializeComponent();
_enabledToggle = this.Find<CheckBox>("EnabledToggle"); EnabledToggle.Click += EnabledToggleOnClick;
_enabledToggle.Click += EnabledToggleOnClick;
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;
public class AlwaysOnConditionView : UserControl public partial class AlwaysOnConditionView : UserControl
{ {
public AlwaysOnConditionView() public AlwaysOnConditionView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;
public class EventConditionView : ReactiveUserControl<EventConditionViewModel> public partial class EventConditionView : ReactiveUserControl<EventConditionViewModel>
{ {
public EventConditionView() public EventConditionView()
{ {

View File

@ -1,4 +1,5 @@
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
@ -8,7 +9,6 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;
public class PlayOnceConditionView : UserControl public partial class PlayOnceConditionView : UserControl
{ {
public PlayOnceConditionView() public PlayOnceConditionView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;
public class StaticConditionView : ReactiveUserControl<StaticConditionViewModel> public partial class StaticConditionView : ReactiveUserControl<StaticConditionViewModel>
{ {
public StaticConditionView() public StaticConditionView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition;
public class DisplayConditionScriptView : ReactiveUserControl<DisplayConditionScriptViewModel> public partial class DisplayConditionScriptView : ReactiveUserControl<DisplayConditionScriptViewModel>
{ {
public DisplayConditionScriptView() public DisplayConditionScriptView()
{ {

View File

@ -1,12 +1,12 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.DryIoc.Factories; using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition; namespace Artemis.UI.Screens.ProfileEditor.DisplayCondition;

View File

@ -6,7 +6,7 @@ using Avalonia.VisualTree;
namespace Artemis.UI.Screens.ProfileEditor.MenuBar; namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
public class MenuBarView : ReactiveUserControl<MenuBarViewModel> public partial class MenuBarView : ReactiveUserControl<MenuBarViewModel>
{ {
public MenuBarView() public MenuBarView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Playback; namespace Artemis.UI.Screens.ProfileEditor.Playback;
public class PlaybackView : ReactiveUserControl<PlaybackViewModel> public partial class PlaybackView : ReactiveUserControl<PlaybackViewModel>
{ {
public PlaybackView() public PlaybackView()
{ {

View File

@ -15,7 +15,7 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
{ {
public override bool Validate(object? sender, DragEventArgs e, object? sourceContext, object? targetContext, object? state) public override bool Validate(object? sender, DragEventArgs e, object? sourceContext, object? targetContext, object? state)
{ {
if (e.Source is IControl && sender is TreeView treeView) if (e.Source is Control && sender is TreeView treeView)
return Validate<TreeItemViewModel>(treeView, e, sourceContext, targetContext, false); return Validate<TreeItemViewModel>(treeView, e, sourceContext, targetContext, false);
return false; return false;
@ -24,7 +24,7 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
public override bool Execute(object? sender, DragEventArgs e, object? sourceContext, object? targetContext, object? state) public override bool Execute(object? sender, DragEventArgs e, object? sourceContext, object? targetContext, object? state)
{ {
bool result = false; bool result = false;
if (e.Source is IControl && sender is TreeView treeView) if (e.Source is Control && sender is TreeView treeView)
result = Validate<TreeItemViewModel>(treeView, e, sourceContext, targetContext, true); result = Validate<TreeItemViewModel>(treeView, e, sourceContext, targetContext, true);
if (sender is ItemsControl itemsControl) if (sender is ItemsControl itemsControl)
@ -46,8 +46,8 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
private bool Validate<T>(TreeView treeView, DragEventArgs e, object? sourceContext, object? targetContext, bool bExecute) where T : TreeItemViewModel private bool Validate<T>(TreeView treeView, DragEventArgs e, object? sourceContext, object? targetContext, bool bExecute) where T : TreeItemViewModel
{ {
Point position = e.GetPosition(treeView); Point position = e.GetPosition(treeView);
IVisual? targetVisual = treeView.GetVisualAt(position).FindAncestorOfType<TreeViewItem>(); TreeViewItem? targetVisual = treeView.GetVisualAt(position).FindAncestorOfType<TreeViewItem>();
if (sourceContext is not T sourceNode || targetContext is not ProfileTreeViewModel vm || targetVisual is not IControl {DataContext: T targetNode}) if (sourceContext is not T sourceNode || targetContext is not ProfileTreeViewModel vm || targetVisual is not Control {DataContext: T targetNode})
return false; return false;
if (bExecute && targetNode == sourceNode) if (bExecute && targetNode == sourceNode)
return false; return false;
@ -69,7 +69,7 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
} }
else else
{ {
IVisual? header = targetVisual.GetVisualDescendants().FirstOrDefault(d => d is Border b && b.Name == "PART_LayoutRoot"); Visual? header = targetVisual.GetVisualDescendants().FirstOrDefault(d => d is Border b && b.Name == "PART_LayoutRoot");
if (header != null) if (header != null)
{ {
position = e.GetPosition(header); position = e.GetPosition(header);
@ -119,7 +119,7 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
} }
else else
{ {
SetDraggingPseudoClasses((IControl) targetVisual, dropType); SetDraggingPseudoClasses(targetVisual, dropType);
} }
return true; return true;
@ -129,12 +129,12 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
{ {
List<TreeViewItem> result = new(); List<TreeViewItem> result = new();
foreach (ItemContainerInfo containerInfo in currentNode.ItemContainerGenerator.Containers) foreach (Control containerControl in currentNode.GetRealizedContainers())
{ {
if (containerInfo.ContainerControl is TreeViewItem treeViewItem && containerInfo.Item is TreeItemViewModel) if (containerControl is TreeViewItem treeViewItem && containerControl.DataContext is TreeItemViewModel)
{ {
result.Add(treeViewItem); result.Add(treeViewItem);
if (treeViewItem.ItemContainerGenerator.Containers.Any()) if (treeViewItem.ItemCount > 0)
result.AddRange(GetFlattenedTreeView(treeViewItem)); result.AddRange(GetFlattenedTreeView(treeViewItem));
} }
} }
@ -142,7 +142,7 @@ public class ProfileTreeViewDropHandler : DropHandlerBase
return result; return result;
} }
private void SetDraggingPseudoClasses(IControl control, TreeDropType type) private void SetDraggingPseudoClasses(TreeViewItem control, TreeDropType type)
{ {
if (type == TreeDropType.None) if (type == TreeDropType.None)
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints;
public class CategoryAdaptionHintView : UserControl public partial class CategoryAdaptionHintView : UserControl
{ {
public CategoryAdaptionHintView() public CategoryAdaptionHintView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints;
public class DeviceAdaptionHintView : UserControl public partial class DeviceAdaptionHintView : UserControl
{ {
public DeviceAdaptionHintView() public DeviceAdaptionHintView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints;
public class KeyboardSectionAdaptionHintView : UserControl public partial class KeyboardSectionAdaptionHintView : UserControl
{ {
public KeyboardSectionAdaptionHintView() public KeyboardSectionAdaptionHintView()
{ {

View File

@ -1,10 +1,11 @@
<controls:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:dialogs="clr-namespace:Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs" xmlns:dialogs="clr-namespace:Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" mc:Ignorable="d"
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.LayerHintsDialogView" x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.LayerHintsDialogView"
x:DataType="dialogs:LayerHintsDialogViewModel" x:DataType="dialogs:LayerHintsDialogViewModel"
@ -68,8 +69,8 @@
<Grid Grid.Row="2" ColumnDefinitions="*,Auto"> <Grid Grid.Row="2" ColumnDefinitions="*,Auto">
<Button Grid.Row="0" Grid.Column="0" Command="{Binding AutoDetermineHints}">Auto-determine hints</Button> <Button Grid.Row="0" Grid.Column="0" Command="{Binding AutoDetermineHints}">Auto-determine hints</Button>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Spacing="5"> <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Spacing="5">
<controls:DropDownButton> <DropDownButton>
<controls:DropDownButton.Flyout> <DropDownButton.Flyout>
<MenuFlyout Placement="Top"> <MenuFlyout Placement="Top">
<MenuItem Header="Category hint" Command="{Binding AddCategoryHint}"> <MenuItem Header="Category hint" Command="{Binding AddCategoryHint}">
<MenuItem.Icon> <MenuItem.Icon>
@ -87,12 +88,12 @@
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</MenuFlyout> </MenuFlyout>
</controls:DropDownButton.Flyout> </DropDownButton.Flyout>
Add hint Add hint
</controls:DropDownButton> </DropDownButton>
<Button Command="{Binding Finish}">Close</Button> <Button Command="{Binding Finish}">Close</Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </Grid>
</controls:CoreWindow> </windowing:AppWindow>

View File

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

View File

@ -1,13 +1,13 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.UI.DryIoc.Factories; using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints; using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs.AdaptionHints;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Avalonia.Controls.Mixins;
using DynamicData; using DynamicData;
using ReactiveUI; using ReactiveUI;

View File

@ -9,7 +9,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
public class FolderTreeItemView : ReactiveUserControl<FolderTreeItemViewModel> public partial class FolderTreeItemView : ReactiveUserControl<FolderTreeItemViewModel>
{ {
public FolderTreeItemView() public FolderTreeItemView()
{ {
@ -18,8 +18,8 @@ public class FolderTreeItemView : ReactiveUserControl<FolderTreeItemViewModel>
{ {
ViewModel?.Rename.Subscribe(_ => ViewModel?.Rename.Subscribe(_ =>
{ {
this.Get<TextBox>("Input").Focus(); Input.Focus();
this.Get<TextBox>("Input").SelectAll(); Input.SelectAll();
}).DisposeWith(d); }).DisposeWith(d);
}); });
} }

View File

@ -9,7 +9,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
public class LayerTreeItemView : ReactiveUserControl<LayerTreeItemViewModel> public partial class LayerTreeItemView : ReactiveUserControl<LayerTreeItemViewModel>
{ {
public LayerTreeItemView() public LayerTreeItemView()
{ {
@ -18,8 +18,8 @@ public class LayerTreeItemView : ReactiveUserControl<LayerTreeItemViewModel>
{ {
ViewModel?.Rename.Subscribe(_ => ViewModel?.Rename.Subscribe(_ =>
{ {
this.Get<TextBox>("Input").Focus(); Input.Focus();
this.Get<TextBox>("Input").SelectAll(); Input.SelectAll();
}).DisposeWith(d); }).DisposeWith(d);
}); });
} }

View File

@ -13,9 +13,8 @@ using Avalonia.VisualTree;
namespace Artemis.UI.Screens.ProfileEditor.ProfileTree; namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel> public partial class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
{ {
private readonly TreeView _treeView;
private Image? _dragAdorner; private Image? _dragAdorner;
private Point _dragStartPosition; private Point _dragStartPosition;
private Point _elementDragOffset; private Point _elementDragOffset;
@ -23,11 +22,10 @@ public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
public ProfileTreeView() public ProfileTreeView()
{ {
InitializeComponent(); InitializeComponent();
_treeView = this.Get<TreeView>("ProfileTreeView");
AddHandler(DragDrop.DragEnterEvent, HandleDragEnterEvent, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true); AddHandler(DragDrop.DragEnterEvent, HandleDragEnterEvent, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
AddHandler(DragDrop.DragOverEvent, HandleDragOver, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true); AddHandler(DragDrop.DragOverEvent, HandleDragOver, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
AddHandler(PointerEnterEvent, HandlePointerEnter, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true); AddHandler(PointerEnteredEvent, HandlePointerEnter, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
} }
private void HandlePointerEnter(object? sender, PointerEventArgs e) private void HandlePointerEnter(object? sender, PointerEventArgs e)
@ -122,6 +120,6 @@ public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
private void ProfileTreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) private void ProfileTreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{ {
_treeView.Focus(); ProfileTreeView.Focus();
} }
} }

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding; namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding;
public class DataBindingView : ReactiveUserControl<DataBindingViewModel> public partial class DataBindingView : ReactiveUserControl<DataBindingViewModel>
{ {
public DataBindingView() public DataBindingView()
{ {

View File

@ -6,7 +6,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs; namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
public class AddEffectView : ReactiveUserControl<AddEffectViewModel> public partial class AddEffectView : ReactiveUserControl<AddEffectViewModel>
{ {
public AddEffectView() public AddEffectView()
{ {

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs; namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
public class TimelineSegmentEditView : ReactiveUserControl<TimelineSegmentEditViewModel> public partial class TimelineSegmentEditView : ReactiveUserControl<TimelineSegmentEditViewModel>
{ {
public TimelineSegmentEditView() public TimelineSegmentEditView()
{ {

View File

@ -1,8 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Controls; using Avalonia;
using Avalonia.Controls.Shapes;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
@ -10,16 +9,11 @@ using Avalonia.VisualTree;
namespace Artemis.UI.Screens.ProfileEditor.Properties; namespace Artemis.UI.Screens.ProfileEditor.Properties;
public class PropertiesView : ReactiveUserControl<PropertiesViewModel> public partial class PropertiesView : ReactiveUserControl<PropertiesViewModel>
{ {
private readonly Polygon _timelineCaret;
private readonly Line _timelineLine;
public PropertiesView() public PropertiesView()
{ {
InitializeComponent(); InitializeComponent();
_timelineCaret = this.Get<Polygon>("TimelineCaret");
_timelineLine = this.Get<Line>("TimelineLine");
} }
private void InitializeComponent() private void InitializeComponent()
@ -58,12 +52,12 @@ public class PropertiesView : ReactiveUserControl<PropertiesViewModel>
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed || ViewModel == null) if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed || ViewModel == null)
return; return;
IInputElement? senderElement = (IInputElement?) sender; Visual? senderElement = (Visual?) sender;
if (senderElement == null) if (senderElement == null)
return; return;
// Get the parent grid, need that for our position // Get the parent grid, need that for our position
IVisual? parent = senderElement.VisualParent; Visual? parent = senderElement.GetVisualParent();
double x = Math.Max(0, e.GetPosition(parent).X); double x = Math.Max(0, e.GetPosition(parent).X);
TimeSpan newTime = TimeSpan.FromSeconds(x / ViewModel.PixelsPerSecond); TimeSpan newTime = TimeSpan.FromSeconds(x / ViewModel.PixelsPerSecond);
newTime = RoundTime(newTime); newTime = RoundTime(newTime);
@ -84,11 +78,11 @@ public class PropertiesView : ReactiveUserControl<PropertiesViewModel>
private void TimelineHeader_OnPointerReleased(object? sender, PointerReleasedEventArgs e) private void TimelineHeader_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{ {
if (ViewModel == null || sender is not IInputElement senderElement) if (ViewModel == null || sender is not Visual senderElement)
return; return;
// Get the parent grid, need that for our position // Get the parent grid, need that for our position
double x = Math.Max(0, e.GetPosition(senderElement.VisualParent).X); double x = Math.Max(0, e.GetPosition(senderElement.GetVisualParent()).X);
TimeSpan newTime = TimeSpan.FromSeconds(x / ViewModel.PixelsPerSecond); TimeSpan newTime = TimeSpan.FromSeconds(x / ViewModel.PixelsPerSecond);
ViewModel.TimelineViewModel.ChangeTime(RoundTime(newTime)); ViewModel.TimelineViewModel.ChangeTime(RoundTime(newTime));

View File

@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
public class TimelineEasingView : UserControl public partial class TimelineEasingView : UserControl
{ {
public TimelineEasingView() public TimelineEasingView()
{ {

View File

@ -6,7 +6,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
public class TimelineKeyframeView : ReactiveUserControl<ITimelineKeyframeViewModel> public partial class TimelineKeyframeView : ReactiveUserControl<ITimelineKeyframeViewModel>
{ {
private bool _moved; private bool _moved;
private TimelinePropertyView? _timelinePropertyView; private TimelinePropertyView? _timelinePropertyView;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
@ -13,7 +14,6 @@ using Artemis.UI.Shared.Extensions;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia; using Avalonia;
using Avalonia.Controls.Mixins;
using Avalonia.Input; using Avalonia.Input;
using DynamicData; using DynamicData;
using DynamicData.Binding; using DynamicData.Binding;

View File

@ -6,15 +6,13 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class EndSegmentView : ReactiveUserControl<EndSegmentViewModel> public partial class EndSegmentView : ReactiveUserControl<EndSegmentViewModel>
{ {
private readonly Rectangle _keyframeDragAnchor;
private double _dragOffset; private double _dragOffset;
public EndSegmentView() public EndSegmentView()
{ {
InitializeComponent(); InitializeComponent();
_keyframeDragAnchor = this.Get<Rectangle>("KeyframeDragAnchor");
} }
private void InitializeComponent() private void InitializeComponent()
@ -26,7 +24,7 @@ public class EndSegmentView : ReactiveUserControl<EndSegmentViewModel>
{ {
if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
return; return;
e.Pointer.Capture(_keyframeDragAnchor); e.Pointer.Capture(KeyframeDragAnchor);
_dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X; _dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X;
ViewModel.StartResize(); ViewModel.StartResize();
@ -34,14 +32,14 @@ public class EndSegmentView : ReactiveUserControl<EndSegmentViewModel>
private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e) private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
} }
private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e) private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
e.Pointer.Capture(null); e.Pointer.Capture(null);
ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;

View File

@ -6,15 +6,13 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class MainSegmentView : ReactiveUserControl<MainSegmentViewModel> public partial class MainSegmentView : ReactiveUserControl<MainSegmentViewModel>
{ {
private readonly Rectangle _keyframeDragAnchor;
private double _dragOffset; private double _dragOffset;
public MainSegmentView() public MainSegmentView()
{ {
InitializeComponent(); InitializeComponent();
_keyframeDragAnchor = this.Get<Rectangle>("KeyframeDragAnchor");
} }
private void InitializeComponent() private void InitializeComponent()
@ -26,7 +24,7 @@ public class MainSegmentView : ReactiveUserControl<MainSegmentViewModel>
{ {
if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
return; return;
e.Pointer.Capture(_keyframeDragAnchor); e.Pointer.Capture(KeyframeDragAnchor);
_dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X; _dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X;
ViewModel.StartResize(); ViewModel.StartResize();
@ -34,14 +32,14 @@ public class MainSegmentView : ReactiveUserControl<MainSegmentViewModel>
private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e) private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
} }
private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e) private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
e.Pointer.Capture(null); e.Pointer.Capture(null);
ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));

View File

@ -1,10 +1,10 @@
using System; using System;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;

View File

@ -6,15 +6,13 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class StartSegmentView : ReactiveUserControl<StartSegmentViewModel> public partial class StartSegmentView : ReactiveUserControl<StartSegmentViewModel>
{ {
private readonly Rectangle _keyframeDragAnchor;
private double _dragOffset; private double _dragOffset;
public StartSegmentView() public StartSegmentView()
{ {
InitializeComponent(); InitializeComponent();
_keyframeDragAnchor = this.Get<Rectangle>("KeyframeDragAnchor");
} }
private void InitializeComponent() private void InitializeComponent()
@ -26,7 +24,7 @@ public class StartSegmentView : ReactiveUserControl<StartSegmentViewModel>
{ {
if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) if (ViewModel == null || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
return; return;
e.Pointer.Capture(_keyframeDragAnchor); e.Pointer.Capture(KeyframeDragAnchor);
_dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X; _dragOffset = ViewModel.Width - e.GetCurrentPoint(this).Position.X;
ViewModel.StartResize(); ViewModel.StartResize();
@ -34,14 +32,14 @@ public class StartSegmentView : ReactiveUserControl<StartSegmentViewModel>
private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e) private void KeyframeDragAnchor_OnPointerMoved(object? sender, PointerEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.UpdateResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
} }
private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e) private void KeyframeDragAnchor_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{ {
if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, _keyframeDragAnchor)) if (ViewModel == null || !ReferenceEquals(e.Pointer.Captured, KeyframeDragAnchor))
return; return;
e.Pointer.Capture(null); e.Pointer.Capture(null);
ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.FinishResize(e.GetCurrentPoint(this).Position.X + _dragOffset, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
public class TimelineGroupView : ReactiveUserControl<TimelineGroupViewModel> public partial class TimelineGroupView : ReactiveUserControl<TimelineGroupViewModel>
{ {
public TimelineGroupView() public TimelineGroupView()
{ {

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Reactive.Disposables;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia.Controls.Mixins;
using DynamicData; using DynamicData;
using DynamicData.Binding; using DynamicData.Binding;
using ReactiveUI; using ReactiveUI;

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
public class TimelinePropertyView : ReactiveUserControl<ITimelinePropertyViewModel> public partial class TimelinePropertyView : ReactiveUserControl<ITimelinePropertyViewModel>
{ {
public TimelinePropertyView() public TimelinePropertyView()
{ {

View File

@ -2,12 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes; using Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia.Controls.Mixins;
using DynamicData; using DynamicData;
using ReactiveUI; using ReactiveUI;

View File

@ -9,17 +9,15 @@ using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
using Avalonia.VisualTree;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
public class TimelineView : ReactiveUserControl<TimelineViewModel> public partial class TimelineView : ReactiveUserControl<TimelineViewModel>
{ {
private readonly SelectionRectangle _selectionRectangle;
public TimelineView() public TimelineView()
{ {
InitializeComponent(); InitializeComponent();
_selectionRectangle = this.Get<SelectionRectangle>("SelectionRectangle");
} }
private void InitializeComponent() private void InitializeComponent()
@ -34,7 +32,8 @@ public class TimelineView : ReactiveUserControl<TimelineViewModel>
List<TimelineKeyframeView> keyframeViews = this.GetVisualChildrenOfType<TimelineKeyframeView>().Where(k => List<TimelineKeyframeView> keyframeViews = this.GetVisualChildrenOfType<TimelineKeyframeView>().Where(k =>
{ {
Rect hitTestRect = k.TransformedBounds != null ? k.TransformedBounds.Value.Bounds.TransformToAABB(k.TransformedBounds.Value.Transform) : Rect.Empty; TransformedBounds? transformedBounds = k.GetTransformedBounds();
Rect hitTestRect = transformedBounds != null ? transformedBounds.Value.Bounds.TransformToAABB(transformedBounds.Value.Transform) : new Rect();
return e.AbsoluteRectangle.Intersects(hitTestRect); return e.AbsoluteRectangle.Intersects(hitTestRect);
}).ToList(); }).ToList();
@ -43,7 +42,7 @@ public class TimelineView : ReactiveUserControl<TimelineViewModel>
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e) private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
{ {
if (_selectionRectangle.IsSelecting) if (SelectionRectangle.IsSelecting)
return; return;
ViewModel?.SelectKeyframes(new List<ITimelineKeyframeViewModel>(), false); ViewModel?.SelectKeyframes(new List<ITimelineKeyframeViewModel>(), false);

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
@ -14,7 +15,6 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Extensions; using Artemis.UI.Shared.Extensions;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia; using Avalonia;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;

View File

@ -1,6 +1,5 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.Shared.Extensions; using Artemis.UI.Shared.Extensions;
using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
using Avalonia.Threading; using Avalonia.Threading;
@ -8,7 +7,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs; namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs;
public class LayerEffectRenameView : ReactiveUserControl<LayerEffectRenameViewModel> public partial class LayerEffectRenameView : ReactiveUserControl<LayerEffectRenameViewModel>
{ {
public LayerEffectRenameView() public LayerEffectRenameView()
{ {
@ -24,8 +23,8 @@ public class LayerEffectRenameView : ReactiveUserControl<LayerEffectRenameViewMo
{ {
// Don't ask // Don't ask
await Task.Delay(200); await Task.Delay(200);
this.Get<TextBox>("NameTextBox").SelectAll(); NameTextBox.SelectAll();
this.Get<TextBox>("NameTextBox").Focus(); NameTextBox.Focus();
} }
private void InitializeComponent() private void InitializeComponent()

View File

@ -6,7 +6,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.Dialogs; namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.Dialogs;
public class LayerBrushPresetView : ReactiveUserControl<LayerBrushPresetViewModel> public partial class LayerBrushPresetView : ReactiveUserControl<LayerBrushPresetViewModel>
{ {
public LayerBrushPresetView() public LayerBrushPresetView()
{ {

View File

@ -4,7 +4,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree; namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree;
public class TreeGroupView : ReactiveUserControl<TreeGroupViewModel> public partial class TreeGroupView : ReactiveUserControl<TreeGroupViewModel>
{ {
public TreeGroupView() public TreeGroupView()
{ {

View File

@ -1,9 +1,8 @@
using System; using System;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Mixins;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI; using Avalonia.ReactiveUI;
@ -11,7 +10,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree; namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree;
public class TreePropertyView : ReactiveUserControl<ITreePropertyViewModel> public partial class TreePropertyView : ReactiveUserControl<ITreePropertyViewModel>
{ {
public TreePropertyView() public TreePropertyView()
{ {
@ -32,6 +31,6 @@ public class TreePropertyView : ReactiveUserControl<ITreePropertyViewModel>
private void DataBindingToggleButton_OnClick(object? sender, RoutedEventArgs e) private void DataBindingToggleButton_OnClick(object? sender, RoutedEventArgs e)
{ {
ViewModel?.ToggleCurrentLayerProperty(); ViewModel?.ToggleCurrentLayerProperty();
this.Find<ToggleButton>("DataBindingToggleButton").IsChecked = !this.Find<ToggleButton>("DataBindingToggleButton").IsChecked; DataBindingToggleButton.IsChecked = !DataBindingToggleButton.IsChecked;
} }
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Extensions; using Artemis.UI.Extensions;
@ -7,7 +8,6 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Artemis.UI.Shared.Services.PropertyInput; using Artemis.UI.Shared.Services.PropertyInput;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree; namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree;

View File

@ -1,8 +1,8 @@
<controls:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="800" d:DesignWidth="800"
d:DesignHeight="450" d:DesignHeight="450"
@ -15,4 +15,4 @@
<Panel> <Panel>
<ContentControl Content="{Binding ConfigurationViewModel}" /> <ContentControl Content="{Binding ConfigurationViewModel}" />
</Panel> </Panel>
</controls:CoreWindow> </windowing:AppWindow>

View File

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

View File

@ -1,8 +1,8 @@
<controls:CoreWindow xmlns="https://github.com/avaloniaui" <windowing:AppWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="800" d:DesignWidth="800"
d:DesignHeight="450" d:DesignHeight="450"
@ -15,4 +15,4 @@
<Panel> <Panel>
<ContentControl Content="{Binding ConfigurationViewModel}" /> <ContentControl Content="{Binding ConfigurationViewModel}" />
</Panel> </Panel>
</controls:CoreWindow> </windowing:AppWindow>

View File

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

View File

@ -3,7 +3,7 @@ using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.StatusBar; namespace Artemis.UI.Screens.ProfileEditor.StatusBar;
public class StatusBarView : ReactiveUserControl<StatusBarViewModel> public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
{ {
public StatusBarView() public StatusBarView()
{ {

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared; using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia.Controls.Mixins;
using ReactiveUI; using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.StatusBar; namespace Artemis.UI.Screens.ProfileEditor.StatusBar;

View File

@ -6,7 +6,7 @@ using Avalonia.Skia;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools; namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools;
public class SelectionAddToolView : ReactiveUserControl<SelectionAddToolViewModel> public partial class SelectionAddToolView : ReactiveUserControl<SelectionAddToolViewModel>
{ {
public SelectionAddToolView() public SelectionAddToolView()
{ {

View File

@ -1,12 +1,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using Material.Icons; using Material.Icons;
using ReactiveUI; using ReactiveUI;
using SkiaSharp; using SkiaSharp;

View File

@ -5,7 +5,7 @@ using Avalonia.Skia;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools; namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools;
public class SelectionRemoveToolView : ReactiveUserControl<SelectionRemoveToolViewModel> public partial class SelectionRemoveToolView : ReactiveUserControl<SelectionRemoveToolViewModel>
{ {
public SelectionRemoveToolView() public SelectionRemoveToolView()
{ {

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Controls.Mixins;
using Material.Icons; using Material.Icons;
using ReactiveUI; using ReactiveUI;
using SkiaSharp; using SkiaSharp;

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Shared.Extensions; using Artemis.UI.Shared.Extensions;
using Avalonia; using Avalonia;
@ -21,19 +22,9 @@ using SkiaSharp;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools; namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools;
public class TransformToolView : ReactiveUserControl<TransformToolViewModel> public partial class TransformToolView : ReactiveUserControl<TransformToolViewModel>
{ {
private readonly Grid _handleGrid;
private readonly List<Control> _handles = new(); private readonly List<Control> _handles = new();
private readonly Panel _resizeBottomCenter;
private readonly Panel _resizeBottomLeft;
private readonly Panel _resizeBottomRight;
private readonly Panel _resizeLeftCenter;
private readonly Panel _resizeRightCenter;
private readonly Panel _resizeTopCenter;
private readonly Panel _resizeTopLeft;
private readonly Panel _resizeTopRight;
private SKPoint _dragOffset; private SKPoint _dragOffset;
private ZoomBorder? _zoomBorder; private ZoomBorder? _zoomBorder;
@ -41,31 +32,21 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
{ {
InitializeComponent(); InitializeComponent();
_handleGrid = this.Get<Grid>("HandleGrid"); _handles.Add(RotateTopLeft);
_handles.Add(RotateTopRight);
_handles.Add(RotateBottomRight);
_handles.Add(RotateBottomLeft);
_handles.Add(this.Get<Ellipse>("RotateTopLeft")); _handles.Add(ResizeTopCenter);
_handles.Add(this.Get<Ellipse>("RotateTopRight")); _handles.Add(ResizeRightCenter);
_handles.Add(this.Get<Ellipse>("RotateBottomRight")); _handles.Add(ResizeBottomCenter);
_handles.Add(this.Get<Ellipse>("RotateBottomLeft")); _handles.Add(ResizeLeftCenter);
_handles.Add(ResizeTopLeft);
_handles.Add(ResizeTopRight);
_handles.Add(ResizeBottomRight);
_handles.Add(ResizeBottomLeft);
_resizeTopCenter = this.Get<Panel>("ResizeTopCenter"); _handles.Add(AnchorPoint);
_handles.Add(_resizeTopCenter);
_resizeRightCenter = this.Get<Panel>("ResizeRightCenter");
_handles.Add(_resizeRightCenter);
_resizeBottomCenter = this.Get<Panel>("ResizeBottomCenter");
_handles.Add(_resizeBottomCenter);
_resizeLeftCenter = this.Get<Panel>("ResizeLeftCenter");
_handles.Add(_resizeLeftCenter);
_resizeTopLeft = this.Get<Panel>("ResizeTopLeft");
_handles.Add(_resizeTopLeft);
_resizeTopRight = this.Get<Panel>("ResizeTopRight");
_handles.Add(_resizeTopRight);
_resizeBottomRight = this.Get<Panel>("ResizeBottomRight");
_handles.Add(_resizeBottomRight);
_resizeBottomLeft = this.Get<Panel>("ResizeBottomLeft");
_handles.Add(_resizeBottomLeft);
_handles.Add(this.Get<Panel>("AnchorPoint"));
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Rotation).Subscribe(_ => UpdateTransforms()).DisposeWith(d)); this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Rotation).Subscribe(_ => UpdateTransforms()).DisposeWith(d));
} }
@ -83,10 +64,10 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
RotateTransform counterRotate = new(ViewModel.Rotation * -1); RotateTransform counterRotate = new(ViewModel.Rotation * -1);
// Apply the counter rotation to the containers // Apply the counter rotation to the containers
foreach (Panel panel in _handleGrid.Children.Where(c => c is Panel and not Canvas).Cast<Panel>()) foreach (Panel panel in HandleGrid.Children.Where(c => c is Panel and not Canvas).Cast<Panel>())
panel.RenderTransform = counterRotate; panel.RenderTransform = counterRotate;
foreach (Control control in _handleGrid.GetVisualDescendants().Where(d => d is Control c && c.Classes.Contains("unscaled")).Cast<Control>()) foreach (Control control in HandleGrid.GetVisualDescendants().Where(d => d is Control c && c.Classes.Contains("unscaled")).Cast<Control>())
control.RenderTransform = counterScale; control.RenderTransform = counterScale;
} }
@ -117,21 +98,21 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
private TransformToolViewModel.ResizeSide GetResizeDirection(Ellipse element) private TransformToolViewModel.ResizeSide GetResizeDirection(Ellipse element)
{ {
if (ReferenceEquals(element.Parent, _resizeTopLeft)) if (ReferenceEquals(element.Parent, ResizeTopLeft))
return TransformToolViewModel.ResizeSide.Top | TransformToolViewModel.ResizeSide.Left; return TransformToolViewModel.ResizeSide.Top | TransformToolViewModel.ResizeSide.Left;
if (ReferenceEquals(element.Parent, _resizeTopRight)) if (ReferenceEquals(element.Parent, ResizeTopRight))
return TransformToolViewModel.ResizeSide.Top | TransformToolViewModel.ResizeSide.Right; return TransformToolViewModel.ResizeSide.Top | TransformToolViewModel.ResizeSide.Right;
if (ReferenceEquals(element.Parent, _resizeBottomRight)) if (ReferenceEquals(element.Parent, ResizeBottomRight))
return TransformToolViewModel.ResizeSide.Bottom | TransformToolViewModel.ResizeSide.Right; return TransformToolViewModel.ResizeSide.Bottom | TransformToolViewModel.ResizeSide.Right;
if (ReferenceEquals(element.Parent, _resizeBottomLeft)) if (ReferenceEquals(element.Parent, ResizeBottomLeft))
return TransformToolViewModel.ResizeSide.Bottom | TransformToolViewModel.ResizeSide.Left; return TransformToolViewModel.ResizeSide.Bottom | TransformToolViewModel.ResizeSide.Left;
if (ReferenceEquals(element.Parent, _resizeTopCenter)) if (ReferenceEquals(element.Parent, ResizeTopCenter))
return TransformToolViewModel.ResizeSide.Top; return TransformToolViewModel.ResizeSide.Top;
if (ReferenceEquals(element.Parent, _resizeRightCenter)) if (ReferenceEquals(element.Parent, ResizeRightCenter))
return TransformToolViewModel.ResizeSide.Right; return TransformToolViewModel.ResizeSide.Right;
if (ReferenceEquals(element.Parent, _resizeBottomCenter)) if (ReferenceEquals(element.Parent, ResizeBottomCenter))
return TransformToolViewModel.ResizeSide.Bottom; return TransformToolViewModel.ResizeSide.Bottom;
if (ReferenceEquals(element.Parent, _resizeLeftCenter)) if (ReferenceEquals(element.Parent, ResizeLeftCenter))
return TransformToolViewModel.ResizeSide.Left; return TransformToolViewModel.ResizeSide.Left;
throw new ArgumentException("Given element is not a child of a resize container"); throw new ArgumentException("Given element is not a child of a resize container");
@ -310,14 +291,14 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
private void UpdateCursors() private void UpdateCursors()
{ {
_resizeTopCenter.Cursor = GetCursorAtAngle(0f); ResizeTopCenter.Cursor = GetCursorAtAngle(0f);
_resizeTopRight.Cursor = GetCursorAtAngle(45f); ResizeTopRight.Cursor = GetCursorAtAngle(45f);
_resizeRightCenter.Cursor = GetCursorAtAngle(90f); ResizeRightCenter.Cursor = GetCursorAtAngle(90f);
_resizeBottomRight.Cursor = GetCursorAtAngle(135f); ResizeBottomRight.Cursor = GetCursorAtAngle(135f);
_resizeBottomCenter.Cursor = GetCursorAtAngle(180f); ResizeBottomCenter.Cursor = GetCursorAtAngle(180f);
_resizeBottomLeft.Cursor = GetCursorAtAngle(225f); ResizeBottomLeft.Cursor = GetCursorAtAngle(225f);
_resizeLeftCenter.Cursor = GetCursorAtAngle(270f); ResizeLeftCenter.Cursor = GetCursorAtAngle(270f);
_resizeTopLeft.Cursor = GetCursorAtAngle(315f); ResizeTopLeft.Cursor = GetCursorAtAngle(315f);
} }
private Cursor GetCursorAtAngle(float angle, bool includeLayerRotation = true) private Cursor GetCursorAtAngle(float angle, bool includeLayerRotation = true)

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Artemis.Core; using Artemis.Core;
using Artemis.UI.Exceptions; using Artemis.UI.Exceptions;
@ -7,7 +8,6 @@ using Artemis.UI.Shared.Extensions;
using Artemis.UI.Shared.Services.ProfileEditor; using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands; using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia; using Avalonia;
using Avalonia.Controls.Mixins;
using Material.Icons; using Material.Icons;
using ReactiveUI; using ReactiveUI;
using SkiaSharp; using SkiaSharp;

View File

@ -2,7 +2,6 @@ using System;
using System.Linq; using System.Linq;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using Avalonia; using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.PanAndZoom; using Avalonia.Controls.PanAndZoom;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
@ -13,19 +12,17 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor; namespace Artemis.UI.Screens.ProfileEditor.VisualEditor;
public class VisualEditorView : ReactiveUserControl<VisualEditorViewModel> public partial class VisualEditorView : ReactiveUserControl<VisualEditorViewModel>
{ {
private readonly ZoomBorder _zoomBorder;
private bool _movedByUser; private bool _movedByUser;
public VisualEditorView() public VisualEditorView()
{ {
InitializeComponent(); InitializeComponent();
_zoomBorder = this.Find<ZoomBorder>("ZoomBorder"); ZoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged;
_zoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged; ZoomBorder.PointerMoved += ZoomBorderOnPointerMoved;
_zoomBorder.PointerMoved += ZoomBorderOnPointerMoved; ZoomBorder.PointerWheelChanged += ZoomBorderOnPointerWheelChanged;
_zoomBorder.PointerWheelChanged += ZoomBorderOnPointerWheelChanged;
UpdateZoomBorderBackground(); UpdateZoomBorderBackground();
this.WhenActivated(d => this.WhenActivated(d =>
@ -48,7 +45,7 @@ public class VisualEditorView : ReactiveUserControl<VisualEditorViewModel>
private void ZoomBorderOnPointerMoved(object? sender, PointerEventArgs e) private void ZoomBorderOnPointerMoved(object? sender, PointerEventArgs e)
{ {
if (e.GetCurrentPoint(_zoomBorder).Properties.IsMiddleButtonPressed) if (e.GetCurrentPoint(ZoomBorder).Properties.IsMiddleButtonPressed)
_movedByUser = true; _movedByUser = true;
} }
@ -59,14 +56,14 @@ public class VisualEditorView : ReactiveUserControl<VisualEditorViewModel>
private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{ {
if (e.Property.Name == nameof(_zoomBorder.Background)) if (e.Property.Name == nameof(ZoomBorder.Background))
UpdateZoomBorderBackground(); UpdateZoomBorderBackground();
} }
private void UpdateZoomBorderBackground() private void UpdateZoomBorderBackground()
{ {
if (_zoomBorder.Background is VisualBrush visualBrush) if (ZoomBorder.Background is VisualBrush visualBrush)
visualBrush.DestinationRect = new RelativeRect(_zoomBorder.OffsetX * -1, _zoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute); visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX * -1, ZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
} }
private void InitializeComponent() private void InitializeComponent()
@ -96,8 +93,8 @@ public class VisualEditorView : ReactiveUserControl<VisualEditorViewModel>
double scale = Math.Min(3, Math.Min(Bounds.Width / scriptRect.Width, Bounds.Height / scriptRect.Height)); double scale = Math.Min(3, Math.Min(Bounds.Width / scriptRect.Width, Bounds.Height / scriptRect.Height));
// Pan and zoom to make the script fit // Pan and zoom to make the script fit
_zoomBorder.Zoom(scale, 0, 0, skipTransitions); ZoomBorder.Zoom(scale, 0, 0, skipTransitions);
_zoomBorder.Pan(Bounds.Center.X - scriptRect.Center.X * scale, Bounds.Center.Y - scriptRect.Center.Y * scale, skipTransitions); ZoomBorder.Pan(Bounds.Center.X - scriptRect.Center.X * scale, Bounds.Center.Y - scriptRect.Center.Y * scale, skipTransitions);
_movedByUser = false; _movedByUser = false;
} }

View File

@ -1,8 +1,8 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Reactive.Disposables;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Mixins;
using Avalonia.Controls.PanAndZoom; using Avalonia.Controls.PanAndZoom;
using Avalonia.Controls.Shapes; using Avalonia.Controls.Shapes;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
@ -12,18 +12,13 @@ using ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers;
public class LayerShapeVisualizerView : ReactiveUserControl<LayerShapeVisualizerViewModel> public partial class LayerShapeVisualizerView : ReactiveUserControl<LayerShapeVisualizerViewModel>
{ {
private readonly Path _layerVisualizer;
private readonly Path _layerVisualizerUnbound;
private ZoomBorder? _zoomBorder; private ZoomBorder? _zoomBorder;
public LayerShapeVisualizerView() public LayerShapeVisualizerView()
{ {
InitializeComponent(); InitializeComponent();
_layerVisualizer = this.Get<Path>("LayerVisualizer");
_layerVisualizerUnbound = this.Get<Path>("LayerVisualizerUnbound");
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Selected).Subscribe(_ => UpdateStrokeThickness()).DisposeWith(d)); this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Selected).Subscribe(_ => UpdateStrokeThickness()).DisposeWith(d));
} }
@ -66,13 +61,13 @@ public class LayerShapeVisualizerView : ReactiveUserControl<LayerShapeVisualizer
if (ViewModel != null && ViewModel.Selected) if (ViewModel != null && ViewModel.Selected)
{ {
_layerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX); LayerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX);
_layerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX); LayerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX);
} }
else else
{ {
_layerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2; LayerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2;
_layerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2; LayerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2;
} }
} }

Some files were not shown because too many files have changed in this diff Show More