mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
UI - Use PropertyChanged.SourceGenerator everywhere else
This commit is contained in:
1 parent
d656c6960d
commit
190d797f1a
40 files changed
+223
-934
No files matched your search
@@ -11,23 +11,23 @@ using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class CableViewModel : ActivatableViewModelBase
|
||||
public partial class CableViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IPin _from;
|
||||
private readonly NodeScriptViewModel _nodeScriptViewModel;
|
||||
private readonly IPin _to;
|
||||
private ObservableAsPropertyHelper<Color>? _cableColor;
|
||||
private ObservableAsPropertyHelper<bool>? _connected;
|
||||
private bool _displayValue;
|
||||
private ObservableAsPropertyHelper<Point>? _fromPoint;
|
||||
|
||||
private PinViewModel? _fromViewModel;
|
||||
private ObservableAsPropertyHelper<Point>? _toPoint;
|
||||
private PinViewModel? _toViewModel;
|
||||
[Notify] private PinViewModel? _fromViewModel;
|
||||
[Notify] private PinViewModel? _toViewModel;
|
||||
[Notify] private bool _displayValue;
|
||||
|
||||
public CableViewModel(NodeScriptViewModel nodeScriptViewModel, IPin from, IPin to, ISettingsService settingsService)
|
||||
{
|
||||
@@ -79,28 +79,8 @@ public class CableViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public PluginSetting<bool> AlwaysShowValues { get; }
|
||||
|
||||
public PinViewModel? FromViewModel
|
||||
{
|
||||
get => _fromViewModel;
|
||||
set => RaiseAndSetIfChanged(ref _fromViewModel, value);
|
||||
}
|
||||
|
||||
public PinViewModel? ToViewModel
|
||||
{
|
||||
get => _toViewModel;
|
||||
set => RaiseAndSetIfChanged(ref _toViewModel, value);
|
||||
}
|
||||
|
||||
public bool DisplayValue
|
||||
{
|
||||
get => _displayValue;
|
||||
set => RaiseAndSetIfChanged(ref _displayValue, value);
|
||||
}
|
||||
|
||||
public bool Connected => _connected?.Value ?? false;
|
||||
public bool IsFirst => _from.ConnectedTo.FirstOrDefault() == _to;
|
||||
|
||||
public Point FromPoint => _fromPoint?.Value ?? new Point();
|
||||
public Point ToPoint => _toPoint?.Value ?? new Point();
|
||||
public Color CableColor => _cableColor?.Value ?? new Color(255, 255, 255, 255);
|
||||
|
||||
@@ -3,16 +3,16 @@ using Artemis.Core;
|
||||
using Artemis.UI.Screens.VisualScripting.Pins;
|
||||
using Artemis.UI.Shared;
|
||||
using Avalonia;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class DragCableViewModel : ActivatableViewModelBase
|
||||
public partial class DragCableViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private Point _dragPoint;
|
||||
|
||||
private ObservableAsPropertyHelper<Point>? _fromPoint;
|
||||
private ObservableAsPropertyHelper<Point>? _toPoint;
|
||||
[Notify] private Point _dragPoint;
|
||||
|
||||
public DragCableViewModel(PinViewModel pinViewModel)
|
||||
{
|
||||
@@ -35,10 +35,4 @@ public class DragCableViewModel : ActivatableViewModelBase
|
||||
public PinViewModel PinViewModel { get; }
|
||||
public Point FromPoint => _fromPoint?.Value ?? new Point(0, 0);
|
||||
public Point ToPoint => _toPoint?.Value ?? new Point(0, 0);
|
||||
|
||||
public Point DragPoint
|
||||
{
|
||||
get => _dragPoint;
|
||||
set => RaiseAndSetIfChanged(ref _dragPoint, value);
|
||||
}
|
||||
}
|
||||
@@ -11,20 +11,20 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Avalonia;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class NodePickerViewModel : ActivatableViewModelBase
|
||||
public partial class NodePickerViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private readonly NodeScript _nodeScript;
|
||||
|
||||
private bool _isVisible;
|
||||
private Point _position;
|
||||
private string? _searchText;
|
||||
private object? _selectedNode;
|
||||
private IPin? _targetPin;
|
||||
[Notify] private bool _isVisible;
|
||||
[Notify] private Point _position;
|
||||
[Notify] private string? _searchText;
|
||||
[Notify] private object? _selectedNode;
|
||||
[Notify] private IPin? _targetPin;
|
||||
|
||||
public NodePickerViewModel(NodeScript nodeScript, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
{
|
||||
@@ -67,37 +67,7 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public ReadOnlyObservableCollection<NodeCategoryViewModel> Categories { get; }
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get => _isVisible;
|
||||
set => RaiseAndSetIfChanged(ref _isVisible, value);
|
||||
}
|
||||
|
||||
public Point Position
|
||||
{
|
||||
get => _position;
|
||||
set => RaiseAndSetIfChanged(ref _position, value);
|
||||
}
|
||||
|
||||
public string? SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set => RaiseAndSetIfChanged(ref _searchText, value);
|
||||
}
|
||||
|
||||
public IPin? TargetPin
|
||||
{
|
||||
get => _targetPin;
|
||||
set => RaiseAndSetIfChanged(ref _targetPin, value);
|
||||
}
|
||||
|
||||
public object? SelectedNode
|
||||
{
|
||||
get => _selectedNode;
|
||||
set => RaiseAndSetIfChanged(ref _selectedNode, value);
|
||||
}
|
||||
|
||||
|
||||
public void CreateNode(NodeData data)
|
||||
{
|
||||
INode node = data.CreateNode(_nodeScript, null);
|
||||
|
||||
@@ -21,11 +21,12 @@ using Avalonia;
|
||||
using Avalonia.Input;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
public partial class NodeScriptViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public const string CLIPBOARD_DATA_FORMAT = "Artemis.Nodes";
|
||||
|
||||
@@ -34,11 +35,10 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
private readonly SourceList<NodeViewModel> _nodeViewModels;
|
||||
private readonly INodeVmFactory _nodeVmFactory;
|
||||
private readonly Subject<Point> _requestedPickerPositionSubject;
|
||||
|
||||
private DragCableViewModel? _dragViewModel;
|
||||
private List<NodeViewModel>? _initialNodeSelection;
|
||||
private Matrix _panMatrix;
|
||||
private Point _pastePosition;
|
||||
[Notify] private DragCableViewModel? _dragViewModel;
|
||||
[Notify] private Matrix _panMatrix;
|
||||
[Notify] private Point _pastePosition;
|
||||
|
||||
public NodeScriptViewModel(NodeScript nodeScript, bool isPreview, INodeVmFactory nodeVmFactory, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
{
|
||||
@@ -111,25 +111,7 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
public ReactiveCommand<Unit, Unit> DuplicateSelected { get; }
|
||||
public ReactiveCommand<Unit, Unit> CopySelected { get; }
|
||||
public ReactiveCommand<Unit, Unit> PasteSelected { get; }
|
||||
|
||||
public DragCableViewModel? DragViewModel
|
||||
{
|
||||
get => _dragViewModel;
|
||||
set => RaiseAndSetIfChanged(ref _dragViewModel, value);
|
||||
}
|
||||
|
||||
public Matrix PanMatrix
|
||||
{
|
||||
get => _panMatrix;
|
||||
set => RaiseAndSetIfChanged(ref _panMatrix, value);
|
||||
}
|
||||
|
||||
public Point PastePosition
|
||||
{
|
||||
get => _pastePosition;
|
||||
set => RaiseAndSetIfChanged(ref _pastePosition, value);
|
||||
}
|
||||
|
||||
|
||||
public void DeleteSelectedNodes()
|
||||
{
|
||||
List<NodeViewModel> toRemove = NodeViewModels.Where(vm => vm.IsSelected && !vm.Node.IsDefaultNode && !vm.Node.IsExitNode).ToList();
|
||||
|
||||
@@ -16,29 +16,28 @@ using Avalonia;
|
||||
using Avalonia.Layout;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class NodeViewModel : ActivatableViewModelBase
|
||||
public partial class NodeViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private readonly IWindowService _windowService;
|
||||
|
||||
private ICustomNodeViewModel? _customNodeViewModel;
|
||||
private double _dragOffsetX;
|
||||
private double _dragOffsetY;
|
||||
private ObservableAsPropertyHelper<bool>? _hasInputPins;
|
||||
private ObservableAsPropertyHelper<bool>? _hasOutputPins;
|
||||
private bool _isSelected;
|
||||
|
||||
private ObservableAsPropertyHelper<bool>? _isStaticNode;
|
||||
private double _dragOffsetX;
|
||||
private double _dragOffsetY;
|
||||
private double _startX;
|
||||
private double _startY;
|
||||
private bool _displayCustomViewModelAbove;
|
||||
private bool _displayCustomViewModelBetween;
|
||||
private bool _displayCustomViewModelBelow;
|
||||
private VerticalAlignment _customViewModelVerticalAlignment;
|
||||
[Notify] private bool _isSelected;
|
||||
[Notify] private ICustomNodeViewModel? _customNodeViewModel;
|
||||
[Notify] private bool _displayCustomViewModelAbove;
|
||||
[Notify] private bool _displayCustomViewModelBetween;
|
||||
[Notify] private bool _displayCustomViewModelBelow;
|
||||
[Notify] private VerticalAlignment _customViewModelVerticalAlignment;
|
||||
|
||||
public NodeViewModel(NodeScriptViewModel nodeScriptViewModel, INode node, INodeVmFactory nodeVmFactory, INodeEditorService nodeEditorService, IWindowService windowService)
|
||||
{
|
||||
@@ -170,43 +169,6 @@ public class NodeViewModel : ActivatableViewModelBase
|
||||
public ReadOnlyObservableCollection<PinViewModel> OutputPinViewModels { get; }
|
||||
public ReadOnlyObservableCollection<PinCollectionViewModel> OutputPinCollectionViewModels { get; }
|
||||
public ReadOnlyObservableCollection<PinViewModel> PinViewModels { get; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => RaiseAndSetIfChanged(ref _isSelected, value);
|
||||
}
|
||||
|
||||
public ICustomNodeViewModel? CustomNodeViewModel
|
||||
{
|
||||
get => _customNodeViewModel;
|
||||
set => RaiseAndSetIfChanged(ref _customNodeViewModel, value);
|
||||
}
|
||||
|
||||
public bool DisplayCustomViewModelAbove
|
||||
{
|
||||
get => _displayCustomViewModelAbove;
|
||||
set => RaiseAndSetIfChanged(ref _displayCustomViewModelAbove, value);
|
||||
}
|
||||
|
||||
public bool DisplayCustomViewModelBetween
|
||||
{
|
||||
get => _displayCustomViewModelBetween;
|
||||
set => RaiseAndSetIfChanged(ref _displayCustomViewModelBetween, value);
|
||||
}
|
||||
|
||||
public bool DisplayCustomViewModelBelow
|
||||
{
|
||||
get => _displayCustomViewModelBelow;
|
||||
set => RaiseAndSetIfChanged(ref _displayCustomViewModelBelow, value);
|
||||
}
|
||||
|
||||
public VerticalAlignment CustomViewModelVerticalAlignment
|
||||
{
|
||||
get => _customViewModelVerticalAlignment;
|
||||
set => RaiseAndSetIfChanged(ref _customViewModelVerticalAlignment, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> ShowBrokenState { get; }
|
||||
public ReactiveCommand<Unit, Unit> DeleteNode { get; }
|
||||
|
||||
|
||||
@@ -13,17 +13,18 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
using Avalonia;
|
||||
using Avalonia.Media;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
public abstract class PinViewModel : ActivatableViewModelBase
|
||||
public abstract partial class PinViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly INodeService _nodeService;
|
||||
private Color _darkenedPinColor;
|
||||
private Color _pinColor;
|
||||
private Point _position;
|
||||
private ReactiveCommand<IPin, Unit>? _removePin;
|
||||
[Notify] private Color _darkenedPinColor;
|
||||
[Notify] private Color _pinColor;
|
||||
[Notify] private Point _position;
|
||||
[Notify] private ReactiveCommand<IPin, Unit>? _removePin;
|
||||
|
||||
protected PinViewModel(IPin pin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
{
|
||||
@@ -49,33 +50,7 @@ public abstract class PinViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public IObservableList<IPin> Connections { get; }
|
||||
|
||||
public IPin Pin { get; }
|
||||
|
||||
public Color PinColor
|
||||
{
|
||||
get => _pinColor;
|
||||
set => RaiseAndSetIfChanged(ref _pinColor, value);
|
||||
}
|
||||
|
||||
public Color DarkenedPinColor
|
||||
{
|
||||
get => _darkenedPinColor;
|
||||
set => RaiseAndSetIfChanged(ref _darkenedPinColor, value);
|
||||
}
|
||||
|
||||
public Point Position
|
||||
{
|
||||
get => _position;
|
||||
set => RaiseAndSetIfChanged(ref _position, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<IPin, Unit>? RemovePin
|
||||
{
|
||||
get => _removePin;
|
||||
set => RaiseAndSetIfChanged(ref _removePin, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> DisconnectPin { get; }
|
||||
|
||||
public bool IsCompatibleWith(PinViewModel pinViewModel)
|
||||
|
||||
Reference in new issue
Block a user