mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Node editor - Added static input nodes, easing type node
Data model picker - Added initial control
This commit is contained in:
parent
d9d237e0eb
commit
81ca8c1425
@ -0,0 +1,16 @@
|
|||||||
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:controls="using:Artemis.UI.Shared.Controls">
|
||||||
|
<Design.PreviewWith>
|
||||||
|
<controls:DataModelPicker />
|
||||||
|
</Design.PreviewWith>
|
||||||
|
|
||||||
|
<Style Selector="controls|DataModelPicker">
|
||||||
|
<!-- Set Defaults -->
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<TextBlock Text="Templated Control" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
290
src/Avalonia/Artemis.UI.Shared/Controls/DataModelPicker.axaml.cs
Normal file
290
src/Avalonia/Artemis.UI.Shared/Controls/DataModelPicker.axaml.cs
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Modules;
|
||||||
|
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||||
|
using Artemis.UI.Shared.Events;
|
||||||
|
using Artemis.UI.Shared.Services.Interfaces;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Data;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.Controls;
|
||||||
|
|
||||||
|
public class DataModelPicker : TemplatedControl
|
||||||
|
{
|
||||||
|
private static IDataModelUIService? _dataModelUIService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets data model path.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<DataModelPath?> DataModelPathProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, DataModelPath?>(nameof(DataModelPath), defaultBindingMode: BindingMode.TwoWay, notifying: DataModelPathPropertyChanged);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the placeholder to show when nothing is selected.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<string> PlaceholderProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, string>(nameof(Placeholder), "Click to select");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether the data model picker should show current values when selecting a path.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<bool> ShowDataModelValuesProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, bool>(nameof(ShowDataModelValues));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether the data model picker should show the full path of the selected value.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<bool> ShowFullPathProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, bool>(nameof(ShowFullPath), notifying: ShowFullPathPropertyChanged);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the brush to use when drawing the button.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<Brush> ButtonBrushProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, Brush>(nameof(ButtonBrush));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of extra modules to show data models of.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<ObservableCollection<Module>?> ModulesProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Module>?>(nameof(Modules), new ObservableCollection<Module>(), notifying: ModulesPropertyChanged);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data model view model to show, if not provided one will be retrieved by the control.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<DataModelPropertiesViewModel?> DataModelViewModelProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, DataModelPropertiesViewModel?>(nameof(DataModelViewModel), notifying: DataModelViewModelPropertyChanged);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of data model view models to show
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<ObservableCollection<DataModelPropertiesViewModel>?> ExtraDataModelViewModelsProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<DataModelPropertiesViewModel>?>(
|
||||||
|
nameof(ExtraDataModelViewModels),
|
||||||
|
new ObservableCollection<DataModelPropertiesViewModel>(),
|
||||||
|
notifying: ExtraDataModelViewModelsPropertyChanged
|
||||||
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of types to filter the selectable paths on.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly StyledProperty<ObservableCollection<Type>?> FilterTypesProperty =
|
||||||
|
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Type>?>(nameof(FilterTypes), new ObservableCollection<Type>());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DataModelPicker" /> class.
|
||||||
|
/// </summary>
|
||||||
|
public DataModelPicker()
|
||||||
|
{
|
||||||
|
SelectPropertyCommand = ReactiveCommand.Create<DataModelVisualizationViewModel>(selected => ExecuteSelectPropertyCommand(selected));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a command that selects the path by it's view model.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveCommand<DataModelVisualizationViewModel, Unit> SelectPropertyCommand { get; }
|
||||||
|
|
||||||
|
internal static IDataModelUIService DataModelUIService
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_dataModelUIService != null)
|
||||||
|
throw new AccessViolationException("This is not for you to touch");
|
||||||
|
_dataModelUIService = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets data model path.
|
||||||
|
/// </summary>
|
||||||
|
public DataModelPath? DataModelPath
|
||||||
|
{
|
||||||
|
get => GetValue(DataModelPathProperty);
|
||||||
|
set => SetValue(DataModelPathProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the placeholder to show when nothing is selected.
|
||||||
|
/// </summary>
|
||||||
|
public string Placeholder
|
||||||
|
{
|
||||||
|
get => GetValue(PlaceholderProperty);
|
||||||
|
set => SetValue(PlaceholderProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether the data model picker should show the full path of the selected value.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowFullPath
|
||||||
|
{
|
||||||
|
get => GetValue(ShowFullPathProperty);
|
||||||
|
set => SetValue(ShowFullPathProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether the data model picker should show current values when selecting a path.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowDataModelValues
|
||||||
|
{
|
||||||
|
get => GetValue(ShowDataModelValuesProperty);
|
||||||
|
set => SetValue(ShowDataModelValuesProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the brush to use when drawing the button.
|
||||||
|
/// </summary>
|
||||||
|
public Brush ButtonBrush
|
||||||
|
{
|
||||||
|
get => GetValue(ButtonBrushProperty);
|
||||||
|
set => SetValue(ButtonBrushProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of extra modules to show data models of.
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<Module>? Modules
|
||||||
|
{
|
||||||
|
get => GetValue(ModulesProperty);
|
||||||
|
set => SetValue(ModulesProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data model view model to show, if not provided one will be retrieved by the control.
|
||||||
|
/// </summary>
|
||||||
|
public DataModelPropertiesViewModel? DataModelViewModel
|
||||||
|
{
|
||||||
|
get => GetValue(DataModelViewModelProperty);
|
||||||
|
set => SetValue(DataModelViewModelProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of data model view models to show.
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<DataModelPropertiesViewModel>? ExtraDataModelViewModels
|
||||||
|
{
|
||||||
|
get => GetValue(ExtraDataModelViewModelsProperty);
|
||||||
|
set => SetValue(ExtraDataModelViewModelsProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of types to filter the selectable paths on.
|
||||||
|
/// </summary>
|
||||||
|
public ObservableCollection<Type>? FilterTypes
|
||||||
|
{
|
||||||
|
get => GetValue(FilterTypesProperty);
|
||||||
|
set => SetValue(FilterTypesProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a new path has been selected
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<DataModelSelectedEventArgs>? DataModelPathSelected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invokes the <see cref="DataModelPathSelected" /> event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected virtual void OnDataModelPathSelected(DataModelSelectedEventArgs e)
|
||||||
|
{
|
||||||
|
DataModelPathSelected?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSelectPropertyCommand(DataModelVisualizationViewModel selected)
|
||||||
|
{
|
||||||
|
if (selected.DataModelPath == null)
|
||||||
|
return;
|
||||||
|
if (selected.DataModelPath.Equals(DataModelPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
DataModelPath = new DataModelPath(selected.DataModelPath);
|
||||||
|
OnDataModelPathSelected(new DataModelSelectedEventArgs(DataModelPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetDataModel()
|
||||||
|
{
|
||||||
|
if (_dataModelUIService == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ChangeDataModel(_dataModelUIService.GetPluginDataModelVisualization(Modules?.ToList() ?? new List<Module>(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeDataModel(DataModelPropertiesViewModel? dataModel)
|
||||||
|
{
|
||||||
|
if (DataModelViewModel != null)
|
||||||
|
{
|
||||||
|
DataModelViewModel.Dispose();
|
||||||
|
DataModelViewModel.UpdateRequested -= DataModelOnUpdateRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataModelViewModel = dataModel;
|
||||||
|
if (DataModelViewModel != null)
|
||||||
|
DataModelViewModel.UpdateRequested += DataModelOnUpdateRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Overrides of Visual
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnAttachedToVisualTree(e);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDetachedFromVisualTree(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void UpdateValueDisplay()
|
||||||
|
{
|
||||||
|
ValueDisplay.Visibility = DataModelPath == null || DataModelPath.IsValid ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
ValuePlaceholder.Visibility = DataModelPath == null || DataModelPath.IsValid ? Visibility.Collapsed : Visibility.Visible;
|
||||||
|
|
||||||
|
string? formattedPath = null;
|
||||||
|
if (DataModelPath != null && DataModelPath.IsValid)
|
||||||
|
formattedPath = string.Join(" › ", DataModelPath.Segments.Where(s => s.GetPropertyDescription() != null).Select(s => s.GetPropertyDescription()!.Name));
|
||||||
|
|
||||||
|
DataModelButton.ToolTip = formattedPath;
|
||||||
|
ValueDisplayTextBlock.Text = ShowFullPath
|
||||||
|
? formattedPath
|
||||||
|
: DataModelPath?.Segments.LastOrDefault()?.GetPropertyDescription()?.Name ?? DataModelPath?.Segments.LastOrDefault()?.Identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DataModelOnUpdateRequested(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DataModelViewModel?.ApplyTypeFilter(true, FilterTypes?.ToArray() ?? Type.EmptyTypes);
|
||||||
|
if (ExtraDataModelViewModels == null) return;
|
||||||
|
foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels)
|
||||||
|
extraDataModelViewModel.ApplyTypeFilter(true, FilterTypes?.ToArray() ?? Type.EmptyTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DataModelPathPropertyChanged(IAvaloniaObject sender, bool before)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ShowFullPathPropertyChanged(IAvaloniaObject sender, bool before)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ModulesPropertyChanged(IAvaloniaObject sender, bool before)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DataModelViewModelPropertyChanged(IAvaloniaObject sender, bool before)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ExtraDataModelViewModelsPropertyChanged(IAvaloniaObject sender, bool before)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -174,6 +174,7 @@ public class SelectionRectangle : Control
|
|||||||
Point position = e.GetCurrentPoint(null).Position;
|
Point position = e.GetCurrentPoint(null).Position;
|
||||||
if (position == _lastPosition)
|
if (position == _lastPosition)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_lastPosition = position;
|
_lastPosition = position;
|
||||||
|
|
||||||
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.UI.Shared.Controls;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.Events
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides data about selection events raised by <see cref="DataModelPicker" />
|
||||||
|
/// </summary>
|
||||||
|
public class DataModelSelectedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the data model path that was selected
|
||||||
|
/// </summary>
|
||||||
|
public DataModelPath? Path { get; }
|
||||||
|
|
||||||
|
internal DataModelSelectedEventArgs(DataModelPath? path)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -26,11 +26,8 @@
|
|||||||
<Style Selector="Border.node-container-selected">
|
<Style Selector="Border.node-container-selected">
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ContentControl#CustomViewModelContainer">
|
|
||||||
<Setter Property="Margin" Value="20 0"></Setter>
|
|
||||||
</Style>
|
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
<Border Classes="node-container" Classes.node-container-selected="{CompiledBinding IsSelected}">
|
<Border Classes="node-container" Classes.node-container-selected="{CompiledBinding IsSelected}" PointerMoved="NodeContainer_OnPointerMoved">
|
||||||
<Grid RowDefinitions="Auto,*">
|
<Grid RowDefinitions="Auto,*">
|
||||||
<Border Grid.Row="0"
|
<Border Grid.Row="0"
|
||||||
CornerRadius="6 6 0 0"
|
CornerRadius="6 6 0 0"
|
||||||
@ -44,7 +41,6 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
ColumnDefinitions="*,Auto">
|
ColumnDefinitions="*,Auto">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
TextAlignment="Center"
|
|
||||||
Margin="5"
|
Margin="5"
|
||||||
Text="{CompiledBinding Node.Name}"
|
Text="{CompiledBinding Node.Name}"
|
||||||
ToolTip.Tip="{CompiledBinding Node.Description}">
|
ToolTip.Tip="{CompiledBinding Node.Description}">
|
||||||
@ -69,7 +65,7 @@
|
|||||||
|
|
||||||
<ContentControl Grid.Column="1" Name="CustomViewModelContainer" Content="{CompiledBinding CustomNodeViewModel}" IsVisible="{CompiledBinding CustomNodeViewModel}" />
|
<ContentControl Grid.Column="1" Name="CustomViewModelContainer" Content="{CompiledBinding CustomNodeViewModel}" IsVisible="{CompiledBinding CustomNodeViewModel}" />
|
||||||
|
|
||||||
<StackPanel Grid.Column="2" IsVisible="{CompiledBinding HasInputPins}">
|
<StackPanel Grid.Column="2" IsVisible="{CompiledBinding HasOutputPins}">
|
||||||
<ItemsControl Items="{CompiledBinding OutputPinViewModels}" Margin="4 0" />
|
<ItemsControl Items="{CompiledBinding OutputPinViewModels}" Margin="4 0" />
|
||||||
<ItemsControl Items="{CompiledBinding OutputPinCollectionViewModels}" />
|
<ItemsControl Items="{CompiledBinding OutputPinCollectionViewModels}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -85,4 +85,9 @@ public class NodeView : ReactiveUserControl<NodeViewModel>
|
|||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NodeContainer_OnPointerMoved(object? sender, PointerEventArgs e)
|
||||||
|
{
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -71,4 +71,10 @@
|
|||||||
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
|
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Nodes\CustomViews\StaticStringValueNodeCustomView.axaml.cs">
|
||||||
|
<DependentUpon>StaticStringValueNodeCustomView.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -4,11 +4,16 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.CustomViewModels"
|
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.CustomViewModels"
|
||||||
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters"
|
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters"
|
||||||
|
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticNumericValueNodeCustomView"
|
x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticNumericValueNodeCustomView"
|
||||||
x:DataType="customViewModels:StaticNumericValueNodeCustomViewModel">
|
x:DataType="customViewModels:StaticNumericValueNodeCustomViewModel">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:NumericConverter x:Key="NumericConverter" />
|
<converters:NumericConverter x:Key="NumericConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<NumericUpDown VerticalAlignment="Center" Value="{Binding Node.Storage, Converter={StaticResource NumericConverter}}"></NumericUpDown>
|
<controls:NumberBox VerticalAlignment="Center"
|
||||||
|
MinWidth="75"
|
||||||
|
Value="{Binding Node.Storage, Converter={StaticResource NumericConverter}}"
|
||||||
|
SimpleNumberFormat="F3"
|
||||||
|
Classes="condensed"/>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:customViewModels="clr-namespace:Artemis.VisualScripting.Nodes.CustomViewModels"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.VisualScripting.Nodes.CustomViews.StaticStringValueNodeCustomView"
|
||||||
|
x:DataType="customViewModels:StaticStringValueNodeCustomViewModel">
|
||||||
|
<TextBox VerticalAlignment="Center" MinWidth="75" Text="{Binding Node.Storage}" Classes="condensed" />
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Artemis.VisualScripting.Nodes.CustomViews
|
||||||
|
{
|
||||||
|
public partial class StaticStringValueNodeCustomView : UserControl
|
||||||
|
{
|
||||||
|
public StaticStringValueNodeCustomView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,18 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Modules;
|
using Artemis.Core.Modules;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.VisualScripting;
|
using Artemis.UI.Shared.VisualScripting;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||||
|
|
||||||
public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
||||||
{
|
{
|
||||||
private readonly DataModelEventNode _node;
|
private readonly DataModelEventNode _node;
|
||||||
private ObservableCollection<Module> _modules;
|
private ObservableCollection<Module>? _modules;
|
||||||
|
|
||||||
public DataModelEventNodeCustomViewModel(DataModelEventNode node, ISettingsService settingsService) : base(node)
|
public DataModelEventNodeCustomViewModel(DataModelEventNode node, ISettingsService settingsService) : base(node)
|
||||||
{
|
{
|
||||||
@ -17,17 +20,32 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
|||||||
|
|
||||||
ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
||||||
ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||||
|
|
||||||
|
this.WhenActivated(d =>
|
||||||
|
{
|
||||||
|
if (Modules != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Modules = new ObservableCollection<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;
|
||||||
|
Disposable.Create(() => _node.PropertyChanged -= NodeOnPropertyChanged).DisposeWith(d);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginSetting<bool> ShowFullPaths { get; }
|
public PluginSetting<bool> ShowFullPaths { get; }
|
||||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||||
public ObservableCollection<Type> FilterTypes { get; } = new() {typeof(IDataModelEvent)};
|
public ObservableCollection<Type> FilterTypes { get; } = new() {typeof(IDataModelEvent)};
|
||||||
|
|
||||||
// public ObservableCollection<Module> Modules
|
public ObservableCollection<Module>? Modules
|
||||||
// {
|
{
|
||||||
// get => _modules;
|
get => _modules;
|
||||||
// set => SetAndNotify(ref _modules, value);
|
set => RaiseAndSetIfChanged(ref _modules, value);
|
||||||
// }
|
}
|
||||||
|
|
||||||
public DataModelPath DataModelPath
|
public DataModelPath DataModelPath
|
||||||
{
|
{
|
||||||
@ -45,28 +63,9 @@ public class DataModelEventNodeCustomViewModel : CustomNodeViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public override void OnActivate()
|
private void NodeOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
// {
|
{
|
||||||
// if (Modules != null)
|
if (e.PropertyName == nameof(DataModelNode.DataModelPath))
|
||||||
// return;
|
this.RaisePropertyChanged(nameof(DataModelPath));
|
||||||
//
|
}
|
||||||
// Modules = new ObservableCollection<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));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
@ -1,15 +1,18 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Modules;
|
using Artemis.Core.Modules;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.VisualScripting;
|
using Artemis.UI.Shared.VisualScripting;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViewModels;
|
||||||
|
|
||||||
public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
||||||
{
|
{
|
||||||
private readonly DataModelNode _node;
|
private readonly DataModelNode _node;
|
||||||
private ObservableCollection<Module> _modules;
|
private ObservableCollection<Module>? _modules;
|
||||||
|
|
||||||
public DataModelNodeCustomViewModel(DataModelNode node, ISettingsService settingsService) : base(node)
|
public DataModelNodeCustomViewModel(DataModelNode node, ISettingsService settingsService) : base(node)
|
||||||
{
|
{
|
||||||
@ -17,16 +20,31 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
|||||||
|
|
||||||
ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
ShowFullPaths = settingsService.GetSetting("ProfileEditor.ShowFullPaths", true);
|
||||||
ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
ShowDataModelValues = settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||||
|
|
||||||
|
this.WhenActivated(d =>
|
||||||
|
{
|
||||||
|
if (Modules != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Modules = new ObservableCollection<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;
|
||||||
|
Disposable.Create(() => _node.PropertyChanged -= NodeOnPropertyChanged).DisposeWith(d);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginSetting<bool> ShowFullPaths { get; }
|
public PluginSetting<bool> ShowFullPaths { get; }
|
||||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||||
|
|
||||||
// public ObservableCollection<Module> Modules
|
public ObservableCollection<Module>? Modules
|
||||||
// {
|
{
|
||||||
// get => _modules;
|
get => _modules;
|
||||||
// set => SetAndNotify(ref _modules, value);
|
set => RaiseAndSetIfChanged(ref _modules, value);
|
||||||
// }
|
}
|
||||||
|
|
||||||
public DataModelPath DataModelPath
|
public DataModelPath DataModelPath
|
||||||
{
|
{
|
||||||
@ -45,28 +63,9 @@ public class DataModelNodeCustomViewModel : CustomNodeViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public override void OnActivate()
|
private void NodeOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
// {
|
{
|
||||||
// if (Modules != null)
|
if (e.PropertyName == nameof(DataModelNode.DataModelPath))
|
||||||
// return;
|
this.RaisePropertyChanged(nameof(DataModelPath));
|
||||||
//
|
}
|
||||||
// Modules = new ObservableCollection<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));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.VisualScripting.Nodes.DataModel.CustomViews.DataModelEventNodeCustomView">
|
||||||
|
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Artemis.VisualScripting.Nodes.DataModel.CustomViews
|
||||||
|
{
|
||||||
|
public partial class DataModelEventNodeCustomView : UserControl
|
||||||
|
{
|
||||||
|
public DataModelEventNodeCustomView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.VisualScripting.Nodes.Easing.CustomViews.EasingTypeNodeCustomView">
|
||||||
|
<controls:EnumComboBox Classes="condensed" MinWidth="75" Value="{Binding Node.Storage}"/>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Artemis.VisualScripting.Nodes.Easing.CustomViews
|
||||||
|
{
|
||||||
|
public partial class EasingTypeNodeCustomView : UserControl
|
||||||
|
{
|
||||||
|
public EasingTypeNodeCustomView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,34 +0,0 @@
|
|||||||
<UserControl x:Class="Artemis.VisualScripting.Nodes.Easing.CustomViews.EasingTypeNodeCustomView"
|
|
||||||
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:viewModels="clr-namespace:Artemis.VisualScripting.Nodes.Easing.CustomViewModels"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
|
||||||
<ComboBox VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
ItemsSource="{Binding EasingViewModels}"
|
|
||||||
SelectedItem="{Binding SelectedEasingViewModel}">
|
|
||||||
<ComboBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<VirtualizingStackPanel />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ComboBox.ItemsPanel>
|
|
||||||
<ComboBox.ItemTemplate>
|
|
||||||
<DataTemplate DataType="{x:Type viewModels:NodeEasingViewModel}">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Polyline Stroke="{DynamicResource MaterialDesignBody}"
|
|
||||||
StrokeThickness="1.5"
|
|
||||||
Points="{Binding EasingPoints}"
|
|
||||||
Stretch="Uniform"
|
|
||||||
Width="14"
|
|
||||||
Height="14"
|
|
||||||
Margin="0 0 10 0" />
|
|
||||||
<TextBlock Text="{Binding Description}" />
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ComboBox.ItemTemplate>
|
|
||||||
</ComboBox>
|
|
||||||
|
|
||||||
</UserControl>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user