mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-19 16:06:35 +08:00
支持动画使用不同的形状
This commit is contained in:
@@ -79,6 +79,37 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private bool _repeat = true;
|
||||
public bool Repeat
|
||||
{
|
||||
get
|
||||
{
|
||||
return _repeat;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _repeat, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _start;
|
||||
public bool Start
|
||||
{
|
||||
get
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _start, value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Completed
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private void AnimationViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender == AnimationPath)
|
||||
|
||||
@@ -26,6 +26,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
bool Repeat
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
bool Start
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
int Completed
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public static SharpPath Arrow { get; } = new SharpPath("M 0 -5 10 0 0 5 z", 10, 10, PathStyle.Arrow, SizeStyle.Middle);
|
||||
public static SharpPath Circle { get; } = new SharpPath("M 0, 0 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0", 10, 10, PathStyle.Circle, SizeStyle.Middle);
|
||||
public static SharpPath Square { get; } = new SharpPath("M 0 -5 10 -5 10 5 0 5 z", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
public static SharpPath Triangle { get; } = new SharpPath("M1,21H23L12,2", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
public static SharpPath Rhombus { get; } = new SharpPath("M 0,20 L 30 0 L 60,20 L 30,40 Z", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
public static SharpPath Trapezoid { get; } = new SharpPath("M 0 0 H 60 L 50 40 H 10 Z", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
public static SharpPath Pentagram { get; } = new SharpPath("M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
public static SharpPath Hexagon { get; } = new SharpPath("M 0,20 L 10,0 H 50 L 60,20 L 50,40 H10 Z", 10, 10, PathStyle.Square, SizeStyle.Middle);
|
||||
|
||||
public static readonly Dictionary<PathStyle, string> ArrowDictionary = new Dictionary<PathStyle, string>()
|
||||
{
|
||||
|
||||
@@ -144,6 +144,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (logical.ConnectorValueType == ConnectorValueType.JsonString && this.ConnectorValueType == logical.ConnectorValueType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (logical.ConnectorValueType <= ConnectorValueType.ValueType && this.ConnectorValueType <= ConnectorValueType.ValueType)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1403,9 +1403,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
var logical = item as LogicalGateItemViewModelBase;
|
||||
if (logical != null && logical.LogicalType > 0)
|
||||
if (logical != null)
|
||||
{
|
||||
logical.OrderNumber = Items.OfType<LogicalGateItemViewModelBase>().Count(p => (int)p.LogicalType > 0) + 1;
|
||||
logical.OrderNumber = Items.OfType<LogicalGateItemViewModelBase>().Count() + 1;
|
||||
}
|
||||
|
||||
var designerItemViewModelBase = item as DesignerItemViewModelBase;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Enums;
|
||||
@@ -253,14 +254,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
continue;
|
||||
}
|
||||
|
||||
if (connector.SourceConnectorInfo.DataItem is LogicalGateItemViewModelBase)
|
||||
if (connector.SourceConnectorInfo.DataItem is LogicalGateItemViewModelBase sourceItem)
|
||||
{
|
||||
var output = (connector.SourceConnectorInfo as LogicalConnectorInfo);
|
||||
connector.ColorViewModel.LineColor.Color = output.ColorViewModel.FillColor.Color;
|
||||
connector.ColorViewModel.FillColor.Color = output.ColorViewModel.FillColor.Color;
|
||||
|
||||
if (input.Value.CanAttachTo(output))
|
||||
if (EnableInputValue(connector, input.Value, output))
|
||||
{
|
||||
connector.ColorViewModel.LineColor.Color = output.ColorViewModel.FillColor.Color;
|
||||
connector.ColorViewModel.FillColor.Color = output.ColorViewModel.FillColor.Color;
|
||||
connector.AnimationViewModel.Color = output.ColorViewModel.FillColor.Color;
|
||||
|
||||
input.Value.ConnectorValue = output.ConnectorValue;
|
||||
input.Value.ConnectorString = output.ConnectorString;
|
||||
input.Value.ColorViewModel.FillColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;
|
||||
@@ -272,13 +275,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
input.Value.ConnectorValueType = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ConnectorValueType == ConnectorValueType.Bool) ? ConnectorValueType.Bool : ConnectorValueType.Int;
|
||||
}
|
||||
|
||||
sourceItem.ClearOutputValue(connector, output);
|
||||
}
|
||||
else
|
||||
{
|
||||
input.Value.ErrorCode = ConnectorErrorCode.ConnErr;
|
||||
input.Value.ErrorMessage = "连接类型不匹配";
|
||||
input.Value.ColorViewModel.FillColor.Color = Colors.DarkRed;
|
||||
}
|
||||
sourceItem.StartAnimation(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,16 +310,44 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (output.Value.ConnectorValueType <= ConnectorValueType.ValueType)
|
||||
{
|
||||
output.Value.ColorViewModel.FillColor.Color = Colors.Green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool EnableInputValue(ConnectionViewModel connector, LogicalConnectorInfo input, LogicalConnectorInfo output)
|
||||
{
|
||||
if (!input.CanAttachTo(output))
|
||||
{
|
||||
input.ErrorCode = ConnectorErrorCode.ConnErr;
|
||||
input.ErrorMessage = "连接类型不匹配";
|
||||
input.ColorViewModel.FillColor.Color = Colors.DarkRed;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void ClearOutputValue(ConnectionViewModel connector, LogicalConnectorInfo output)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void StartAnimation(LogicalConnectorInfo output)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected ConnectionViewModel GetSourceItem(FullyCreatedConnectorInfo sinkConnector)
|
||||
{
|
||||
return Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SinkConnectorInfo == sinkConnector);
|
||||
}
|
||||
|
||||
protected ConnectionViewModel GetSinkItem(FullyCreatedConnectorInfo sourceConnector)
|
||||
{
|
||||
return Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo == sourceConnector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user