mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Display conditions - Events UI WIP
This commit is contained in:
1 parent
d115d41a80
commit
5b4188ed12
14 files changed
+591
-290
No files matched your search
@@ -62,6 +62,9 @@
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Nodes\DataModel\CustomViews\DataModelEventNodeCustomView.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
</Page>
|
||||
<Page Update="Nodes\CustomViews\StaticFloatValueNodeCustomView.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
</Page>
|
||||
|
||||
@@ -198,8 +198,6 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
_canvas.RenderTransform = _canvasViewPortTransform = new TranslateTransform(0, 0);
|
||||
_canvas.MouseLeftButtonDown += OnCanvasMouseLeftButtonDown;
|
||||
_canvas.MouseLeftButtonUp += OnCanvasMouseLeftButtonUp;
|
||||
_canvas.MouseRightButtonDown += OnCanvasMouseRightButtonDown;
|
||||
_canvas.MouseRightButtonUp += OnCanvasMouseRightButtonUp;
|
||||
_canvas.PreviewMouseRightButtonDown += OnCanvasPreviewMouseRightButtonDown;
|
||||
_canvas.MouseMove += OnCanvasMouseMove;
|
||||
_canvas.MouseWheel += OnCanvasMouseWheel;
|
||||
@@ -292,6 +290,27 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
|
||||
private void OnCanvasMouseLeftButtonDown(object sender, MouseButtonEventArgs args)
|
||||
{
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
||||
{
|
||||
if (AutoFitScript)
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_dragCanvas = true;
|
||||
_dragCanvasStartLocation = args.GetPosition(this);
|
||||
_dragCanvasStartOffset = _viewportCenter;
|
||||
|
||||
_movedDuringDrag = false;
|
||||
|
||||
_canvas.CaptureMouse();
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VisualScript.DeselectAllNodes();
|
||||
|
||||
_boxSelect = true;
|
||||
@@ -317,29 +336,7 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
SelectWithinRectangle(new Rect(Canvas.GetLeft(_selectionBorder), Canvas.GetTop(_selectionBorder), _selectionBorder.Width, _selectionBorder.Height));
|
||||
args.Handled = _movedDuringDrag;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCanvasMouseRightButtonDown(object sender, MouseButtonEventArgs args)
|
||||
{
|
||||
if (AutoFitScript)
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_dragCanvas = true;
|
||||
_dragCanvasStartLocation = args.GetPosition(this);
|
||||
_dragCanvasStartOffset = _viewportCenter;
|
||||
|
||||
_movedDuringDrag = false;
|
||||
|
||||
_canvas.CaptureMouse();
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnCanvasMouseRightButtonUp(object sender, MouseButtonEventArgs args)
|
||||
{
|
||||
if (_dragCanvas)
|
||||
{
|
||||
_dragCanvas = false;
|
||||
@@ -353,7 +350,7 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
{
|
||||
if (_dragCanvas)
|
||||
{
|
||||
if (args.RightButton == MouseButtonState.Pressed)
|
||||
if (args.LeftButton == MouseButtonState.Pressed && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
|
||||
{
|
||||
Vector newLocation = _dragCanvasStartOffset - (((args.GetPosition(this) - _dragCanvasStartLocation)) * (1.0 / Scale));
|
||||
CenterAt(newLocation);
|
||||
@@ -541,7 +538,7 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
List<IPin> pins = node.Pins.ToList();
|
||||
pins.AddRange(node.PinCollections.SelectMany(c => c));
|
||||
pins = pins.Where(p => p.Type == typeof(object) || p.Type == SourcePin.Pin.Type).OrderBy(p => p.Type != typeof(object)).ToList();
|
||||
|
||||
|
||||
IPin preferredPin = SourcePin.Pin.Direction == PinDirection.Input
|
||||
? pins.FirstOrDefault(p => p.Direction == PinDirection.Output)
|
||||
: pins.FirstOrDefault(p => p.Direction == PinDirection.Input);
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Core.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly DataModelEventNode _node;
|
||||
private BindableCollection<Module> _modules;
|
||||
|
||||
public DataModelEventNodeCustomViewModel(DataModelEventNode node, ISettingsService settingsService) : base(node)
|
||||
{
|
||||
_node = node;
|
||||
|
||||
ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
||||
ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
}
|
||||
|
||||
public PluginSetting<bool> ShowFullPaths { get; }
|
||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||
public BindableCollection<Type> FilterTypes { get; } = new() { typeof(DataModelEvent) };
|
||||
|
||||
public BindableCollection<Module> Modules
|
||||
{
|
||||
get => _modules;
|
||||
set => SetAndNotify(ref _modules, value);
|
||||
}
|
||||
|
||||
public DataModelPath DataModelPath
|
||||
{
|
||||
get => _node.DataModelPath;
|
||||
set
|
||||
{
|
||||
if (ReferenceEquals(_node.DataModelPath, value))
|
||||
return;
|
||||
|
||||
_node.DataModelPath?.Dispose();
|
||||
_node.DataModelPath = value;
|
||||
_node.DataModelPath.Save();
|
||||
|
||||
_node.Storage = _node.DataModelPath.Entity;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActivate()
|
||||
{
|
||||
if (Modules != null)
|
||||
return;
|
||||
|
||||
Modules = new BindableCollection<Module>();
|
||||
if (_node.Script.Context is Profile scriptProfile && scriptProfile.Configuration.Module != null)
|
||||
Modules.Add(scriptProfile.Configuration.Module);
|
||||
else if (_node.Script.Context is ProfileConfiguration profileConfiguration && profileConfiguration.Module != null)
|
||||
Modules.Add(profileConfiguration.Module);
|
||||
|
||||
_node.PropertyChanged += NodeOnPropertyChanged;
|
||||
}
|
||||
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
_node.PropertyChanged -= NodeOnPropertyChanged;
|
||||
}
|
||||
|
||||
private void NodeOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(DataModelNode.DataModelPath))
|
||||
OnPropertyChanged(nameof(DataModelPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+22
@@ -0,0 +1,22 @@
|
||||
<UserControl x:Class="Artemis.VisualScripting.Nodes.CustomViews.DataModelEventNodeCustomView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.VisualScripting.Nodes.CustomViews"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
|
||||
xmlns:editor="clr-namespace:Artemis.VisualScripting.Editor.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<controls:DataModelPicker DataModelPath="{Binding DataModelPath}"
|
||||
Modules="{Binding Modules}"
|
||||
ShowFullPath="{Binding ShowFullPaths.Value}"
|
||||
ShowDataModelValues="{Binding ShowDataModelValues.Value}"
|
||||
FilterTypes="{Binding FilterTypes}"
|
||||
ButtonBrush="#434343"/>
|
||||
<editor:VisualScriptPresenter Script="{Binding ChildScript}" IsEnabled="False" ></editor:VisualScriptPresenter>
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
File renamed without changes.
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.VisualScripting.Nodes.CustomViewModels;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes
|
||||
{
|
||||
[Node("Data Model-Event", "Responds to a data model event trigger", "External", OutputType = typeof(bool))]
|
||||
public class DataModelEventNode : Node<DataModelEventNodeCustomViewModel>, IDisposable
|
||||
{
|
||||
private DataModelPath _dataModelPath;
|
||||
|
||||
public DataModelEventNode() : base("Data Model-Event", "Responds to a data model event trigger")
|
||||
{
|
||||
Output = CreateOutputPin<bool>();
|
||||
}
|
||||
|
||||
public OutputPin<bool> Output { get; }
|
||||
public INodeScript Script { get; set; }
|
||||
|
||||
public DataModelPath DataModelPath
|
||||
{
|
||||
get => _dataModelPath;
|
||||
set => SetAndNotify(ref _dataModelPath, value);
|
||||
}
|
||||
|
||||
public override void Initialize(INodeScript script)
|
||||
{
|
||||
Script = script;
|
||||
|
||||
if (Storage is not DataModelPathEntity pathEntity)
|
||||
return;
|
||||
|
||||
DataModelPath = new DataModelPath(null, pathEntity);
|
||||
DataModelPath.PathValidated += DataModelPathOnPathValidated;
|
||||
}
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
}
|
||||
|
||||
private void DataModelPathOnPathValidated(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace Artemis.VisualScripting.Nodes
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DataModelPath.Dispose();
|
||||
DataModelPath?.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user