|
@@ -1,5 +1,7 @@
|
|
|
using System.Collections.ObjectModel;
|
|
|
using Avalonia;
|
|
|
+using Avalonia.Media;
|
|
|
+using Avalonia.Styling;
|
|
|
using PixiEditor.AvaloniaUI.Models.DocumentModels;
|
|
|
using PixiEditor.AvaloniaUI.Models.Handlers;
|
|
|
using PixiEditor.AvaloniaUI.ViewModels.Nodes.Properties;
|
|
@@ -13,6 +15,7 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
|
|
|
private object value;
|
|
|
private INodeHandler node;
|
|
|
private bool isInput;
|
|
|
+ private IBrush socketBrush;
|
|
|
|
|
|
private ObservableCollection<INodePropertyHandler> connectedInputs = new();
|
|
|
private INodePropertyHandler? connectedOutput;
|
|
@@ -58,10 +61,37 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
|
|
|
get => propertyName;
|
|
|
set => SetProperty(ref propertyName, value);
|
|
|
}
|
|
|
+
|
|
|
+ public IBrush SocketBrush
|
|
|
+ {
|
|
|
+ get => socketBrush;
|
|
|
+ set => SetProperty(ref socketBrush, value);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Type PropertyType { get; }
|
|
|
|
|
|
- public NodePropertyViewModel(INodeHandler node)
|
|
|
+ public NodePropertyViewModel(INodeHandler node, Type propertyType)
|
|
|
{
|
|
|
Node = node;
|
|
|
+ PropertyType = propertyType;
|
|
|
+ if (Application.Current.Styles.TryGetResource($"{PropertyType.Name}SocketBrush", App.Current.ActualThemeVariant, out object brush))
|
|
|
+ {
|
|
|
+ if (brush is IBrush brushValue)
|
|
|
+ {
|
|
|
+ SocketBrush = brushValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(SocketBrush == null)
|
|
|
+ {
|
|
|
+ if(Application.Current.Styles.TryGetResource($"DefaultSocketBrush", App.Current.ActualThemeVariant, out object defaultBrush))
|
|
|
+ {
|
|
|
+ if (defaultBrush is IBrush defaultBrushValue)
|
|
|
+ {
|
|
|
+ SocketBrush = defaultBrushValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static NodePropertyViewModel? CreateFromType(Type type, INodeHandler node)
|
|
@@ -72,10 +102,10 @@ internal abstract class NodePropertyViewModel : ViewModelBase, INodePropertyHand
|
|
|
Type viewModelType = Type.GetType($"PixiEditor.AvaloniaUI.ViewModels.Nodes.Properties.{name}");
|
|
|
if (viewModelType == null)
|
|
|
{
|
|
|
- return new GenericPropertyViewModel(node);
|
|
|
+ return new GenericPropertyViewModel(node, type);
|
|
|
}
|
|
|
|
|
|
- return (NodePropertyViewModel)Activator.CreateInstance(viewModelType, node);
|
|
|
+ return (NodePropertyViewModel)Activator.CreateInstance(viewModelType, node, type);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -89,7 +119,7 @@ internal abstract class NodePropertyViewModel<T> : NodePropertyViewModel
|
|
|
set => SetProperty(ref nodeValue, value);
|
|
|
}
|
|
|
|
|
|
- public NodePropertyViewModel(NodeViewModel node) : base(node)
|
|
|
+ public NodePropertyViewModel(NodeViewModel node, Type valueType) : base(node, valueType)
|
|
|
{
|
|
|
}
|
|
|
}
|