mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
@@ -6,7 +6,6 @@
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:skiaSharp="clr-namespace:SkiaSharp;assembly=SkiaSharp"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.VisualScripting.CableView"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
@@ -17,18 +16,18 @@ namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class CableViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly NodeScriptViewModel _nodeScriptViewModel;
|
||||
private readonly IPin _from;
|
||||
private readonly NodeScriptViewModel _nodeScriptViewModel;
|
||||
private readonly IPin _to;
|
||||
private ObservableAsPropertyHelper<Color>? _cableColor;
|
||||
private ObservableAsPropertyHelper<Point>? _fromPoint;
|
||||
private ObservableAsPropertyHelper<Point>? _toPoint;
|
||||
private ObservableAsPropertyHelper<Point>? _valuePoint;
|
||||
private ObservableAsPropertyHelper<bool>? _connected;
|
||||
private bool _displayValue;
|
||||
private ObservableAsPropertyHelper<Point>? _fromPoint;
|
||||
|
||||
private PinViewModel? _fromViewModel;
|
||||
private ObservableAsPropertyHelper<Point>? _toPoint;
|
||||
private PinViewModel? _toViewModel;
|
||||
private bool _displayValue;
|
||||
private ObservableAsPropertyHelper<Point>? _valuePoint;
|
||||
|
||||
public CableViewModel(NodeScriptViewModel nodeScriptViewModel, IPin from, IPin to, ISettingsService settingsService)
|
||||
{
|
||||
@@ -112,11 +111,6 @@ public class CableViewModel : ActivatableViewModelBase
|
||||
public Point ValuePoint => _valuePoint?.Value ?? new Point();
|
||||
public Color CableColor => _cableColor?.Value ?? new Color(255, 255, 255, 255);
|
||||
|
||||
private void AlwaysShowValuesOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateDisplayValue(false);
|
||||
}
|
||||
|
||||
public void UpdateDisplayValue(bool hoveringOver)
|
||||
{
|
||||
if (_nodeScriptViewModel.IsPreview)
|
||||
@@ -127,4 +121,9 @@ public class CableViewModel : ActivatableViewModelBase
|
||||
else
|
||||
DisplayValue = AlwaysShowValues.Value && IsFirst;
|
||||
}
|
||||
|
||||
private void AlwaysShowValuesOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateDisplayValue(false);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Screens.VisualScripting.Pins;
|
||||
using Artemis.UI.Shared;
|
||||
@@ -22,19 +21,13 @@ public class DragCableViewModel : ActivatableViewModelBase
|
||||
// If the pin is output, the pin is the from-point and the drag position is the to-point
|
||||
if (PinViewModel.Pin.Direction == PinDirection.Output)
|
||||
{
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_fromPoint = PinViewModel.WhenAnyValue(vm => vm.Position).ToProperty(this, vm => vm.FromPoint).DisposeWith(d);
|
||||
});
|
||||
this.WhenActivated(d => { _fromPoint = PinViewModel.WhenAnyValue(vm => vm.Position).ToProperty(this, vm => vm.FromPoint).DisposeWith(d); });
|
||||
_toPoint = this.WhenAnyValue(vm => vm.DragPoint).ToProperty(this, vm => vm.ToPoint);
|
||||
}
|
||||
// If the pin is input, the pin is the to-point and the drag position is the from-point;
|
||||
else
|
||||
{
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_toPoint = PinViewModel.WhenAnyValue(vm => vm.Position).ToProperty(this, vm => vm.ToPoint).DisposeWith(d);
|
||||
});
|
||||
this.WhenActivated(d => { _toPoint = PinViewModel.WhenAnyValue(vm => vm.Position).ToProperty(this, vm => vm.ToPoint).DisposeWith(d); });
|
||||
_fromPoint = this.WhenAnyValue(vm => vm.DragPoint).ToProperty(this, vm => vm.FromPoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
node.Y = Math.Round(Position.Y / 10d, 0, MidpointRounding.AwayFromZero) * 10d;
|
||||
|
||||
if (TargetPin != null)
|
||||
{
|
||||
using (_nodeEditorService.CreateCommandScope(_nodeScript, "Create node for pin"))
|
||||
{
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new AddNode(_nodeScript, node));
|
||||
@@ -108,7 +107,6 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
if (source != null)
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new ConnectPins(source, TargetPin));
|
||||
}
|
||||
}
|
||||
else
|
||||
_nodeEditorService.ExecuteCommand(_nodeScript, new AddNode(_nodeScript, node));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Events;
|
||||
using Avalonia;
|
||||
@@ -25,10 +21,10 @@ namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class NodeScriptView : ReactiveUserControl<NodeScriptViewModel>
|
||||
{
|
||||
private readonly Grid _grid;
|
||||
private readonly ItemsControl _nodesContainer;
|
||||
private readonly SelectionRectangle _selectionRectangle;
|
||||
private readonly ZoomBorder _zoomBorder;
|
||||
private readonly Grid _grid;
|
||||
|
||||
public NodeScriptView()
|
||||
{
|
||||
@@ -58,6 +54,12 @@ public class NodeScriptView : ReactiveUserControl<NodeScriptViewModel>
|
||||
});
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
AutoFitIfPreview();
|
||||
return base.MeasureOverride(availableSize);
|
||||
}
|
||||
|
||||
private void ZoomOnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
|
||||
{
|
||||
// If scroll events aren't handled here the ZoomBorder does some random panning when at the zoom limit
|
||||
@@ -65,12 +67,6 @@ public class NodeScriptView : ReactiveUserControl<NodeScriptViewModel>
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
AutoFitIfPreview();
|
||||
return base.MeasureOverride(availableSize);
|
||||
}
|
||||
|
||||
private void ShowPickerAt(Point point)
|
||||
{
|
||||
if (ViewModel == null)
|
||||
|
||||
@@ -232,6 +232,13 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestAutoFit()
|
||||
{
|
||||
AutoFitRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler? AutoFitRequested;
|
||||
|
||||
private void ExecuteClearSelection()
|
||||
{
|
||||
ClearNodeSelection();
|
||||
@@ -250,7 +257,7 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
int nodeCount = NodeViewModels.Count;
|
||||
List<INode> nodes = NodeViewModels.Where(vm => vm.IsSelected).Select(vm => vm.Node).ToList();
|
||||
using NodeEditorCommandScope scope = _nodeEditorService.CreateCommandScope(NodeScript, "Duplicate nodes");
|
||||
foreach (INode node in nodes.Where(n => !n.IsDefaultNode && !n.IsExitNode))
|
||||
foreach (INode node in nodes.Where(n => !n.IsDefaultNode && !n.IsExitNode))
|
||||
_nodeEditorService.ExecuteCommand(NodeScript, new DuplicateNode(NodeScript, node, false, _nodeService));
|
||||
|
||||
// Select only the new nodes
|
||||
@@ -280,11 +287,4 @@ public class NodeScriptViewModel : ActivatableViewModelBase
|
||||
if (toRemove != null)
|
||||
_nodeViewModels.Remove(toRemove);
|
||||
}
|
||||
|
||||
public void RequestAutoFit()
|
||||
{
|
||||
AutoFitRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event EventHandler? AutoFitRequested;
|
||||
}
|
||||
@@ -2,21 +2,20 @@ using Artemis.UI.Shared;
|
||||
using Avalonia;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting
|
||||
{
|
||||
public partial class NodeScriptWindowView : ReactiveCoreWindow<NodeScriptWindowViewModel>
|
||||
{
|
||||
public NodeScriptWindowView()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class NodeScriptWindowView : ReactiveCoreWindow<NodeScriptWindowViewModel>
|
||||
{
|
||||
public NodeScriptWindowView()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ namespace Artemis.UI.Screens.VisualScripting;
|
||||
|
||||
public class NodeScriptWindowViewModel : DialogViewModelBase<bool>
|
||||
{
|
||||
private readonly INodeService _nodeService;
|
||||
private readonly INodeEditorService _nodeEditorService;
|
||||
private readonly INodeService _nodeService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
@@ -25,13 +24,13 @@ public class NodeViewModel : ActivatableViewModelBase
|
||||
private ReactiveCommand<Unit, Unit>? _deleteNode;
|
||||
private double _dragOffsetX;
|
||||
private double _dragOffsetY;
|
||||
private bool _isSelected;
|
||||
private double _startX;
|
||||
private double _startY;
|
||||
|
||||
private ObservableAsPropertyHelper<bool>? _isStaticNode;
|
||||
private ObservableAsPropertyHelper<bool>? _hasInputPins;
|
||||
private ObservableAsPropertyHelper<bool>? _hasOutputPins;
|
||||
private bool _isSelected;
|
||||
|
||||
private ObservableAsPropertyHelper<bool>? _isStaticNode;
|
||||
private double _startX;
|
||||
private double _startY;
|
||||
|
||||
public NodeViewModel(NodeScriptViewModel nodeScriptViewModel, INode node, INodeVmFactory nodeVmFactory, INodeEditorService nodeEditorService)
|
||||
{
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting.Pins
|
||||
{
|
||||
public partial class InputPinCollectionView : ReactiveUserControl<PinCollectionViewModel>
|
||||
{
|
||||
public InputPinCollectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class InputPinCollectionView : ReactiveUserControl<PinCollectionViewModel>
|
||||
{
|
||||
public InputPinCollectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ public class InputPinCollectionViewModel : PinCollectionViewModel
|
||||
{
|
||||
private readonly NodeScriptViewModel _nodeScriptViewModel;
|
||||
private readonly INodeVmFactory _nodeVmFactory;
|
||||
public IPinCollection InputPinCollection { get; }
|
||||
|
||||
public InputPinCollectionViewModel(IPinCollection inputPinCollection, NodeScriptViewModel nodeScriptViewModel, INodeVmFactory nodeVmFactory, INodeEditorService nodeEditorService)
|
||||
: base(inputPinCollection, nodeScriptViewModel, nodeEditorService)
|
||||
@@ -17,7 +16,9 @@ public class InputPinCollectionViewModel : PinCollectionViewModel
|
||||
_nodeVmFactory = nodeVmFactory;
|
||||
InputPinCollection = inputPinCollection;
|
||||
}
|
||||
|
||||
|
||||
public IPinCollection InputPinCollection { get; }
|
||||
|
||||
protected override PinViewModel CreatePinViewModel(IPin pin)
|
||||
{
|
||||
PinViewModel vm = _nodeVmFactory.InputPinViewModel(pin, _nodeScriptViewModel);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
public class InputPinViewModel : PinViewModel
|
||||
{
|
||||
public InputPinViewModel(IPin inputPin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
public InputPinViewModel(IPin inputPin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
: base(inputPin, nodeScriptViewModel, nodeService, nodeEditorService)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.VisualScripting.Pins
|
||||
{
|
||||
public partial class OutputPinCollectionView : ReactiveUserControl<PinCollectionViewModel>
|
||||
{
|
||||
public OutputPinCollectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class OutputPinCollectionView : ReactiveUserControl<PinCollectionViewModel>
|
||||
{
|
||||
public OutputPinCollectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ public class OutputPinCollectionViewModel : PinCollectionViewModel
|
||||
{
|
||||
private readonly NodeScriptViewModel _nodeScriptViewModel;
|
||||
private readonly INodeVmFactory _nodeVmFactory;
|
||||
public IPinCollection OutputPinCollection { get; }
|
||||
|
||||
public OutputPinCollectionViewModel(IPinCollection outputPinCollection, NodeScriptViewModel nodeScriptViewModel, INodeVmFactory nodeVmFactory, INodeEditorService nodeEditorService)
|
||||
: base(outputPinCollection, nodeScriptViewModel, nodeEditorService)
|
||||
@@ -18,6 +17,8 @@ public class OutputPinCollectionViewModel : PinCollectionViewModel
|
||||
OutputPinCollection = outputPinCollection;
|
||||
}
|
||||
|
||||
public IPinCollection OutputPinCollection { get; }
|
||||
|
||||
protected override PinViewModel CreatePinViewModel(IPin pin)
|
||||
{
|
||||
PinViewModel vm = _nodeVmFactory.OutputPinViewModel(pin, _nodeScriptViewModel);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
public class OutputPinViewModel : PinViewModel
|
||||
{
|
||||
public OutputPinViewModel(IPin outputPin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
public OutputPinViewModel(IPin outputPin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
: base(outputPin, nodeScriptViewModel, nodeService, nodeEditorService)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.NodeEditor;
|
||||
using Artemis.UI.Shared.Services.NodeEditor.Commands;
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
|
||||
public class PinView : ReactiveUserControl<PinViewModel>
|
||||
{
|
||||
private bool _dragging;
|
||||
private Canvas? _container;
|
||||
private bool _dragging;
|
||||
private Border? _pinPoint;
|
||||
|
||||
protected void InitializePin(Border pinPoint)
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace Artemis.UI.Screens.VisualScripting.Pins;
|
||||
public abstract class PinViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly INodeService _nodeService;
|
||||
private ReactiveCommand<IPin, Unit>? _removePin;
|
||||
private Point _position;
|
||||
private Color _pinColor;
|
||||
private Color _darkenedPinColor;
|
||||
private Color _pinColor;
|
||||
private Point _position;
|
||||
private ReactiveCommand<IPin, Unit>? _removePin;
|
||||
|
||||
protected PinViewModel(IPin pin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ public abstract class PinViewModel : ActivatableViewModelBase
|
||||
|
||||
Pin = pin;
|
||||
DisconnectPin = ReactiveCommand.Create(() => nodeEditorService.ExecuteCommand(nodeScriptViewModel.NodeScript, new DisconnectPins(Pin)));
|
||||
|
||||
|
||||
SourceList<IPin> connectedPins = new();
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
@@ -47,13 +47,6 @@ public abstract class PinViewModel : ActivatableViewModelBase
|
||||
connectedPins.AddRange(Pin.ConnectedTo);
|
||||
}
|
||||
|
||||
private void UpdatePinColor()
|
||||
{
|
||||
TypeColorRegistration registration = _nodeService.GetTypeColorRegistration(Pin.Type);
|
||||
PinColor = registration.Color.ToColor();
|
||||
DarkenedPinColor = registration.DarkenedColor.ToColor();
|
||||
}
|
||||
|
||||
public IObservableList<IPin> Connections { get; }
|
||||
|
||||
public IPin Pin { get; }
|
||||
@@ -91,4 +84,11 @@ public abstract class PinViewModel : ActivatableViewModelBase
|
||||
|
||||
return Pin.IsTypeCompatible(pinViewModel.Pin.Type);
|
||||
}
|
||||
|
||||
private void UpdatePinColor()
|
||||
{
|
||||
TypeColorRegistration registration = _nodeService.GetTypeColorRegistration(Pin.Type);
|
||||
PinColor = registration.Color.ToColor();
|
||||
DarkenedPinColor = registration.DarkenedColor.ToColor();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user