mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Conditions - Removed old systems
Data bindings - Removed old systems Data bindings - Implemented node system
This commit is contained in:
1 parent
32d4ec2812
commit
5675d1895b
157 files changed
+784
-8802
No files matched your search
@@ -50,5 +50,8 @@
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="ResourceDictionaries\DataModelConditions.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Artemis.Core;
|
||||
using Artemis.VisualScripting.Editor.Controls.Wrapper;
|
||||
|
||||
namespace Artemis.VisualScripting.Editor.Controls
|
||||
@@ -48,7 +51,7 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
|
||||
public Point ValuePosition
|
||||
{
|
||||
get => (Point) GetValue(ValuePositionProperty);
|
||||
get => (Point)GetValue(ValuePositionProperty);
|
||||
set => SetValue(ValuePositionProperty, value);
|
||||
}
|
||||
|
||||
@@ -60,7 +63,7 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
{
|
||||
_path = GetTemplateChild(PART_PATH) as Path ?? throw new NullReferenceException($"The Path '{PART_PATH}' is missing.");
|
||||
_path.MouseDown += OnPathMouseDown;
|
||||
|
||||
|
||||
Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
@@ -104,25 +107,31 @@ namespace Artemis.VisualScripting.Editor.Controls
|
||||
newCable.To.PropertyChanged += OnPinPropertyChanged;
|
||||
}
|
||||
|
||||
UpdateBorderBrush();
|
||||
UpdateValuePosition();
|
||||
}
|
||||
|
||||
|
||||
private void OnPinPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
UpdateValuePosition();
|
||||
if (e.PropertyName == nameof(VisualScriptPin.AbsolutePosition))
|
||||
UpdateValuePosition();
|
||||
}
|
||||
|
||||
private void UpdateBorderBrush()
|
||||
{
|
||||
// if (Cable.From.Pin.Type.IsAssignableTo(typeof(IList)))
|
||||
// BorderBrush = new SolidColorBrush(Colors.MediumPurple);
|
||||
}
|
||||
|
||||
private void UpdateValuePosition()
|
||||
{
|
||||
if (Cable.From == null || Cable.To == null)
|
||||
ValuePosition = new Point();
|
||||
else
|
||||
{
|
||||
ValuePosition = new Point(
|
||||
Cable.From.AbsolutePosition.X + ((Cable.To.AbsolutePosition.X - Cable.From.AbsolutePosition.X) / 2),
|
||||
Cable.From.AbsolutePosition.Y + ((Cable.To.AbsolutePosition.Y - Cable.From.AbsolutePosition.Y) / 2)
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
ValuePosition = new Point(
|
||||
Cable.From.AbsolutePosition.X + ((Cable.To.AbsolutePosition.X - Cable.From.AbsolutePosition.X) / 2),
|
||||
Cable.From.AbsolutePosition.Y + ((Cable.To.AbsolutePosition.Y - Cable.From.AbsolutePosition.Y) / 2)
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
xmlns:controls="clr-namespace:Artemis.VisualScripting.Editor.Controls"
|
||||
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters">
|
||||
xmlns:converters="clr-namespace:Artemis.VisualScripting.Converters"
|
||||
xmlns:collections="clr-namespace:System.Collections;assembly=System.Runtime">
|
||||
<converters:CenterTranslateConverter x:Key="CenterTranslateConverter"/>
|
||||
|
||||
<ControlTemplate x:Key="TemplateVisualScriptCablePresenter"
|
||||
@@ -77,6 +78,10 @@
|
||||
<DataTrigger Binding="{Binding Cable.From.Pin.Type, RelativeSource={RelativeSource Self}}" Value="{x:Type system:String}">
|
||||
<Setter Property="BorderBrush" Value="Gold" />
|
||||
</DataTrigger>
|
||||
|
||||
<DataTrigger Binding="{Binding Cable.From.Pin.Type, RelativeSource={RelativeSource Self}}" Value="{x:Type collections:IList}">
|
||||
<Setter Property="BorderBrush" Value="MediumPurple" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Grid x:Name="PART_CreationBoxParent"
|
||||
ClipToBounds="True"
|
||||
ClipToBounds="True"
|
||||
Tag="{Binding RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
|
||||
<ContextMenu.Template>
|
||||
<ControlTemplate>
|
||||
<Border Width="700" Height="300">
|
||||
<controls:VisualScriptNodeCreationBox AvailableNodes="{Binding AvailableNodes}"
|
||||
<controls:VisualScriptNodeCreationBox AvailableNodes="{Binding AvailableNodes}"
|
||||
CreateNodeCommand="{Binding CreateNodeCommand}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
@@ -27,14 +27,14 @@
|
||||
Height="{Binding SurfaceSize, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Background="{TemplateBinding Background}">
|
||||
|
||||
<Border x:Name="PART_SelectionBorder"
|
||||
Background="#3300FF00"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#FF00CC00"
|
||||
<Border x:Name="PART_SelectionBorder"
|
||||
Background="#3300FF00"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#FF00CC00"
|
||||
CornerRadius="1"
|
||||
Visibility="Hidden" />
|
||||
|
||||
<ItemsControl x:Name="PART_NodeList"
|
||||
<ItemsControl x:Name="PART_NodeList"
|
||||
Panel.ZIndex="0">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -50,10 +50,10 @@
|
||||
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Panel.ZIndex" Value="0"/>
|
||||
<Setter Property="Panel.ZIndex" Value="0" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSelected}" Value="True">
|
||||
<Setter Property="Panel.ZIndex" Value="1"/>
|
||||
<Setter Property="Panel.ZIndex" Value="1" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
@@ -79,7 +79,7 @@
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="StyleVisualScriptPresenter"
|
||||
<Style x:Key="StyleVisualScriptPresenter"
|
||||
TargetType="{x:Type controls:VisualScriptPresenter}">
|
||||
<Setter Property="Template" Value="{StaticResource TemplateVisualScriptPresenter}" />
|
||||
|
||||
@@ -87,18 +87,16 @@
|
||||
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<DrawingBrush TileMode="Tile" Viewport="0,0,24,24" ViewportUnits="Absolute">
|
||||
<DrawingBrush.Drawing>
|
||||
<GeometryDrawing>
|
||||
<GeometryDrawing.Geometry>
|
||||
<RectangleGeometry Rect="0,0,24,24"/>
|
||||
</GeometryDrawing.Geometry>
|
||||
<GeometryDrawing.Pen>
|
||||
<Pen Brush="#FF808080" Thickness="0.5"/>
|
||||
</GeometryDrawing.Pen>
|
||||
</GeometryDrawing>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="0 0 20 20" ViewportUnits="Absolute">
|
||||
<VisualBrush.Visual>
|
||||
<Canvas>
|
||||
<Rectangle Width="10" Height="10" Canvas.Top="0" Canvas.Left="0" Fill="Black" Opacity="0.15" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Top="0" Canvas.Left="10" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Top="10" Canvas.Left="0" />
|
||||
<Rectangle Width="10" Height="10" Canvas.Top="10" Canvas.Left="10" Fill="Black" Opacity="0.15" />
|
||||
</Canvas>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
|
||||
+18
-24
@@ -1,8 +1,4 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Input;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
@@ -10,33 +6,31 @@ namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
private readonly DataModelNode _node;
|
||||
|
||||
public DataModelNodeCustomViewModel(DataModelNode node, IDataModelUIService dataModelUIService) : base(node)
|
||||
public DataModelNodeCustomViewModel(DataModelNode node) : base(node)
|
||||
{
|
||||
_node = node;
|
||||
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
SelectionViewModel = dataModelUIService.GetDynamicSelectionViewModel(module: null);
|
||||
SelectionViewModel.PropertySelected += SelectionViewModelOnPropertySelected;
|
||||
});
|
||||
}
|
||||
|
||||
public DataModelDynamicViewModel SelectionViewModel { get; set; }
|
||||
|
||||
private void SelectionViewModelOnPropertySelected(object? sender, DataModelInputDynamicEventArgs e)
|
||||
public DataModelPath DataModelPath
|
||||
{
|
||||
_node.DataModelPath = SelectionViewModel.DataModelPath;
|
||||
if (_node.DataModelPath != null)
|
||||
get => _node.DataModelPath;
|
||||
set
|
||||
{
|
||||
_node.DataModelPath.Save();
|
||||
_node.Storage = _node.DataModelPath.Entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
_node.Storage = null;
|
||||
}
|
||||
_node.DataModelPath = value;
|
||||
OnPropertyChanged(nameof(DataModelPath));
|
||||
|
||||
_node.UpdateOutputPin();
|
||||
if (_node.DataModelPath != null)
|
||||
{
|
||||
_node.DataModelPath.Save();
|
||||
_node.Storage = _node.DataModelPath.Entity;
|
||||
}
|
||||
else
|
||||
{
|
||||
_node.Storage = null;
|
||||
}
|
||||
|
||||
_node.UpdateOutputPin();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ContentControl s:View.Model="{Binding SelectionViewModel}"></ContentControl>
|
||||
<controls:DataModelPicker DataModelPath="{Binding DataModelPath}" ButtonBrush="#434343"/>
|
||||
</UserControl>
|
||||
@@ -22,7 +22,6 @@ namespace Artemis.VisualScripting.Nodes
|
||||
return;
|
||||
|
||||
DataModelPath = new DataModelPath(null, pathEntity);
|
||||
CustomViewModel.SelectionViewModel.ChangeDataModelPath(DataModelPath);
|
||||
UpdateOutputPin();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:dataModel="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared">
|
||||
<Style x:Key="DataModelConditionButton" TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignFlatAccentBgButton}">
|
||||
<Setter Property="Margin" Value="3 0" />
|
||||
<Setter Property="Padding" Value="6 4" />
|
||||
<Setter Property="Height" Value="22" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidForegroundBrush}" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DataModelConditionButtonLeftClickMenu" TargetType="{x:Type Button}" BasedOn="{StaticResource DataModelConditionButton}">
|
||||
<Style.Triggers>
|
||||
<EventTrigger RoutedEvent="Click">
|
||||
<EventTrigger.Actions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="ContextMenu.IsOpen">
|
||||
<DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True" />
|
||||
</BooleanAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger.Actions>
|
||||
</EventTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="DataModelSelectionTemplate">
|
||||
<StackPanel>
|
||||
<StackPanel.Resources>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}">
|
||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True"/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelListViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="FormatListBulleted" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="LightningBolt" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="Trigger layer on event" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
|
||||
<Grid>
|
||||
<!-- Value description -->
|
||||
<TextBlock Grid.Column="0" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</StackPanel.Resources>
|
||||
<ContentPresenter Content="{Binding}" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="DataModelSelectionTemplateWithValues">
|
||||
<StackPanel>
|
||||
<StackPanel.Resources>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}">
|
||||
<Grid ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Value description -->
|
||||
<TextBlock Grid.Column="0" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True"/>
|
||||
|
||||
<!-- Value display -->
|
||||
<TextBlock Grid.Column="1" Text="{Binding DisplayValue}" HorizontalAlignment="Right" FontFamily="Consolas" Margin="15 0.5 0 0"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelListViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="FormatListBulleted" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="LightningBolt" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
|
||||
<Grid ToolTip="{Binding PropertyDescription.Description}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Value description -->
|
||||
<TextBlock Grid.Column="0" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True"/>
|
||||
|
||||
<!-- Value display -->
|
||||
<StackPanel Grid.Column="1">
|
||||
<ContentControl s:View.Model="{Binding DisplayViewModel}" FontFamily="Consolas" Margin="15 0.5 0 0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</StackPanel.Resources>
|
||||
<ContentPresenter Content="{Binding}" />
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</ResourceDictionary>
|
||||
Reference in new issue
Block a user