mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +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
+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