mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Clean up
This commit is contained in:
parent
49ed0205b7
commit
bcf0b74fcc
@ -16,9 +16,9 @@ public interface INode : INotifyPropertyChanged, IBreakableModel
|
|||||||
Guid Id { get; set; }
|
Guid Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets
|
/// Gets or sets the node data with information about this node
|
||||||
/// </summary>
|
/// </summary>
|
||||||
NodeData NodeData { get; set; }
|
NodeData? NodeData { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the node
|
/// Gets the name of the node
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public abstract class Node : BreakableModel, INode
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public NodeData NodeData { get; set; }
|
public NodeData? NodeData { get; set; }
|
||||||
|
|
||||||
private string _name;
|
private string _name;
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,8 @@ public abstract class Node<TStorage, TViewModel> : Node<TStorage>, ICustomViewMo
|
|||||||
/// <param name="nodeScript"></param>
|
/// <param name="nodeScript"></param>
|
||||||
public virtual TViewModel GetViewModel(NodeScript nodeScript)
|
public virtual TViewModel GetViewModel(NodeScript nodeScript)
|
||||||
{
|
{
|
||||||
|
if (NodeData == null)
|
||||||
|
throw new ArtemisCoreException("Nodes without node data (default nodes or exit nodes) cannot have custom view models");
|
||||||
return NodeData.Provider.Plugin.Container.Resolve<TViewModel>(args: new object[] {this, nodeScript});
|
return NodeData.Provider.Plugin.Container.Resolve<TViewModel>(args: new object[] {this, nodeScript});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -141,41 +141,9 @@ public partial class NodeViewModel : ActivatableViewModelBase
|
|||||||
|
|
||||||
// Set up the custom node VM if needed
|
// Set up the custom node VM if needed
|
||||||
SetupCustomNodeViewModel();
|
SetupCustomNodeViewModel();
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupCustomNodeViewModel()
|
|
||||||
{
|
|
||||||
if (Node is not ICustomViewModelNode customViewModelNode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
CustomNodeViewModel = customViewModelNode.GetCustomViewModel(NodeScriptViewModel.NodeScript);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.Error(e, "Failed to instantiate custom node view model");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.AbovePins)
|
|
||||||
DisplayCustomViewModelAbove = true;
|
|
||||||
else if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BelowPins)
|
|
||||||
DisplayCustomViewModelBelow = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DisplayCustomViewModelBetween = true;
|
|
||||||
|
|
||||||
if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BetweenPinsTop)
|
|
||||||
CustomViewModelVerticalAlignment = VerticalAlignment.Top;
|
|
||||||
else if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BetweenPinsTop)
|
|
||||||
CustomViewModelVerticalAlignment = VerticalAlignment.Center;
|
|
||||||
else
|
|
||||||
CustomViewModelVerticalAlignment = VerticalAlignment.Bottom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsStaticNode => _isStaticNode?.Value ?? true;
|
public bool IsStaticNode => _isStaticNode?.Value ?? true;
|
||||||
public bool HasInputPins => _hasInputPins?.Value ?? false;
|
public bool HasInputPins => _hasInputPins?.Value ?? false;
|
||||||
public bool HasOutputPins => _hasOutputPins?.Value ?? false;
|
public bool HasOutputPins => _hasOutputPins?.Value ?? false;
|
||||||
@ -226,4 +194,35 @@ public partial class NodeViewModel : ActivatableViewModelBase
|
|||||||
if (Node.BrokenState != null && Node.BrokenStateException != null)
|
if (Node.BrokenState != null && Node.BrokenStateException != null)
|
||||||
_windowService.ShowExceptionDialog(Node.BrokenState, Node.BrokenStateException);
|
_windowService.ShowExceptionDialog(Node.BrokenState, Node.BrokenStateException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetupCustomNodeViewModel()
|
||||||
|
{
|
||||||
|
if (Node is not ICustomViewModelNode customViewModelNode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CustomNodeViewModel = customViewModelNode.GetCustomViewModel(NodeScriptViewModel.NodeScript);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Error(e, "Failed to instantiate custom node view model");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.AbovePins)
|
||||||
|
DisplayCustomViewModelAbove = true;
|
||||||
|
else if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BelowPins)
|
||||||
|
DisplayCustomViewModelBelow = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DisplayCustomViewModelBetween = true;
|
||||||
|
|
||||||
|
if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BetweenPinsTop)
|
||||||
|
CustomViewModelVerticalAlignment = VerticalAlignment.Top;
|
||||||
|
else if (customViewModelNode.ViewModelPosition == CustomNodeViewModelPosition.BetweenPinsTop)
|
||||||
|
CustomViewModelVerticalAlignment = VerticalAlignment.Center;
|
||||||
|
else
|
||||||
|
CustomViewModelVerticalAlignment = VerticalAlignment.Bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user