mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-01 21:41:28 +08:00
@@ -18,21 +18,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
if (values[0] is double && values[2] is ValueType)
|
if (values[0] is double && values[2] is ConnectorValueType)
|
||||||
{
|
{
|
||||||
double connectorValue = (double)values[0];
|
double connectorValue = (double)values[0];
|
||||||
string connectorString = values[1] as string;
|
string connectorString = values[1] as string;
|
||||||
ValueType valueTypePoint = (ValueType)values[2];
|
ConnectorValueType valueTypePoint = (ConnectorValueType)values[2];
|
||||||
|
|
||||||
if (valueTypePoint == ValueType.Bool)
|
if (valueTypePoint == ConnectorValueType.Bool)
|
||||||
{
|
{
|
||||||
return (connectorValue == 0) ? "F" : "T";
|
return (connectorValue == 0) ? "F" : "T";
|
||||||
}
|
}
|
||||||
else if (valueTypePoint == ValueType.Int)
|
else if (valueTypePoint == ConnectorValueType.Int)
|
||||||
{
|
{
|
||||||
return connectorValue.ToString("0");
|
return connectorValue.ToString("0");
|
||||||
}
|
}
|
||||||
else if (valueTypePoint == ValueType.Real)
|
else if (valueTypePoint == ConnectorValueType.Real)
|
||||||
{
|
{
|
||||||
return connectorValue.ToString("f3");
|
return connectorValue.ToString("f3");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
public enum ValueType
|
public enum ConnectorValueType
|
||||||
{
|
{
|
||||||
Real = 0,
|
Real = 0,
|
||||||
Int = 1,
|
Int = 1,
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
|
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
|
||||||
{
|
{
|
||||||
ValueType = viewmodel.ValueType;
|
ConnectorValueType = viewmodel.ConnectorValueType;
|
||||||
ConnectorValue = viewmodel.ConnectorValue;
|
ConnectorValue = viewmodel.ConnectorValue;
|
||||||
ConnectorString = viewmodel.ConnectorString;
|
ConnectorString = viewmodel.ConnectorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public ValueType ValueType
|
public ConnectorValueType ConnectorValueType
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||||
<Binding Path="ConnectorValue" />
|
<Binding Path="ConnectorValue" />
|
||||||
<Binding Path="ConnectorString" />
|
<Binding Path="ConnectorString" />
|
||||||
<Binding Path="ValueType"/>
|
<Binding Path="ConnectorValueType"/>
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
<TextBlock.RenderTransform>
|
<TextBlock.RenderTransform>
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||||
<Binding Path="ConnectorValue" />
|
<Binding Path="ConnectorValue" />
|
||||||
<Binding Path="ConnectorString" />
|
<Binding Path="ConnectorString" />
|
||||||
<Binding Path="ValueType"/>
|
<Binding Path="ConnectorValueType"/>
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
<TextBlock.RenderTransform>
|
<TextBlock.RenderTransform>
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public class LogicalConnectorInfo : FullyCreatedConnectorInfo
|
public class LogicalConnectorInfo : FullyCreatedConnectorInfo
|
||||||
{
|
{
|
||||||
public LogicalConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueType valueTypePoint = ValueType.Real) : base(dataItem, orientation, isInnerPoint, isPortless)
|
public LogicalConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ConnectorValueType valueTypePoint = ConnectorValueType.Real) : base(dataItem, orientation, isInnerPoint, isPortless)
|
||||||
{
|
{
|
||||||
this.ValueType = valueTypePoint;
|
this.ConnectorValueType = valueTypePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueType valueTypePoint = ValueType.Real) : base(root, dataItem, orientation, isInnerPoint, isPortless)
|
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ConnectorValueType valueTypePoint = ConnectorValueType.Real) : base(root, dataItem, orientation, isInnerPoint, isPortless)
|
||||||
{
|
{
|
||||||
this.ValueType = valueTypePoint;
|
this.ConnectorValueType = valueTypePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, SelectableItemBase designer) : base(root, dataItem, designer)
|
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, SelectableItemBase designer) : base(root, dataItem, designer)
|
||||||
@@ -37,7 +37,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (designerbase is LogicalConnectorInfoItem designer)
|
if (designerbase is LogicalConnectorInfoItem designer)
|
||||||
{
|
{
|
||||||
ConnectorValue = designer.ConnectorValue;
|
ConnectorValue = designer.ConnectorValue;
|
||||||
ValueType = designer.ValueType;
|
ConnectorValueType = designer.ConnectorValueType;
|
||||||
ConnectorString = designer.ConnectorString;
|
ConnectorString = designer.ConnectorString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,8 +68,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueType _valueType;
|
public ConnectorValueType _valueType;
|
||||||
public ValueType ValueType
|
public ConnectorValueType ConnectorValueType
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -218,47 +218,47 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return connector;
|
return connector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ValueType> ValueTypeInput
|
public List<ConnectorValueType> ValueTypeInput
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (LogicalType == LogicalType.NOT)
|
if (LogicalType == LogicalType.NOT)
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Bool };
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
||||||
}
|
}
|
||||||
else if (LogicalType == LogicalType.AND || LogicalType == LogicalType.OR || LogicalType == LogicalType.XOR
|
else if (LogicalType == LogicalType.AND || LogicalType == LogicalType.OR || LogicalType == LogicalType.XOR
|
||||||
|| LogicalType == LogicalType.SHL || LogicalType == LogicalType.SHR || LogicalType == LogicalType.ROL || LogicalType == LogicalType.ROR)
|
|| LogicalType == LogicalType.SHL || LogicalType == LogicalType.SHR || LogicalType == LogicalType.ROL || LogicalType == LogicalType.ROR)
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Int };
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
||||||
}
|
}
|
||||||
else if (LogicalType == LogicalType.SEL)
|
else if (LogicalType == LogicalType.SEL)
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Bool, ValueType.Real, ValueType.Real };
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool, ConnectorValueType.Real, ConnectorValueType.Real };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Real };
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ValueType> ValueTypeOutput
|
public List<ConnectorValueType> ValueTypeOutput
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (LogicalType == LogicalType.GT || LogicalType == LogicalType.LT || LogicalType == LogicalType.GE || LogicalType == LogicalType.LE || LogicalType == LogicalType.EQ || LogicalType == LogicalType.NE
|
if (LogicalType == LogicalType.GT || LogicalType == LogicalType.LT || LogicalType == LogicalType.GE || LogicalType == LogicalType.LE || LogicalType == LogicalType.EQ || LogicalType == LogicalType.NE
|
||||||
|| LogicalType == LogicalType.NOT)
|
|| LogicalType == LogicalType.NOT)
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Bool };
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
||||||
}
|
}
|
||||||
else if (LogicalType == LogicalType.AND || LogicalType == LogicalType.OR || LogicalType == LogicalType.XOR
|
else if (LogicalType == LogicalType.AND || LogicalType == LogicalType.OR || LogicalType == LogicalType.XOR
|
||||||
|| LogicalType == LogicalType.SHL || LogicalType == LogicalType.SHR || LogicalType == LogicalType.ROL || LogicalType == LogicalType.ROR)
|
|| LogicalType == LogicalType.SHL || LogicalType == LogicalType.SHR || LogicalType == LogicalType.ROL || LogicalType == LogicalType.ROR)
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Int };
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new List<ValueType>() { ValueType.Real };
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,11 +289,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
if (LogicalType == LogicalType.Output)
|
if (LogicalType == LogicalType.Output)
|
||||||
{
|
{
|
||||||
input.Value.ValueType = (connector.SourceConnectorInfo as LogicalConnectorInfo).ValueType;
|
input.Value.ConnectorValueType = (connector.SourceConnectorInfo as LogicalConnectorInfo).ConnectorValueType;
|
||||||
}
|
}
|
||||||
else if (LogicalType == LogicalType.NOT)
|
else if (LogicalType == LogicalType.NOT)
|
||||||
{
|
{
|
||||||
input.Value.ValueType = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ValueType == ValueType.Bool) ? ValueType.Bool : ValueType.Int;
|
input.Value.ConnectorValueType = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ConnectorValueType == ConnectorValueType.Bool) ? ConnectorValueType.Bool : ConnectorValueType.Int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
foreach (var output in Output)
|
foreach (var output in Output)
|
||||||
{
|
{
|
||||||
if (output.Value.ValueType == ValueType.Bool)
|
if (output.Value.ConnectorValueType == ConnectorValueType.Bool)
|
||||||
{
|
{
|
||||||
if (output.Value.ConnectorValue == 0)
|
if (output.Value.ConnectorValue == 0)
|
||||||
{
|
{
|
||||||
@@ -331,14 +331,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
protected ConnectionViewModel GetSourceItem(FullyCreatedConnectorInfo sinkConnector)
|
protected ConnectionViewModel GetSourceItem(FullyCreatedConnectorInfo sinkConnector)
|
||||||
{
|
{
|
||||||
foreach (var connector in Root?.Items.OfType<ConnectionViewModel>())
|
return Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SinkConnectorInfo == sinkConnector);
|
||||||
{
|
|
||||||
if (connector.SinkConnectorInfo == sinkConnector)
|
|
||||||
{
|
|
||||||
return connector;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<!-- Project properties -->
|
<!-- Project properties -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
|
<TargetFrameworks>net6.0-windows</TargetFrameworks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -533,15 +533,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
foreach (var output in Output)
|
foreach (var output in Output)
|
||||||
{
|
{
|
||||||
if (Input[0].ValueType == DiagramDesigner.ValueType.Bool)
|
if (Input[0].ConnectorValueType == DiagramDesigner.ConnectorValueType.Bool)
|
||||||
{
|
{
|
||||||
output.Value.ConnectorValue = Convert.ToInt32(!Convert.ToBoolean(Input[0].ConnectorValue));
|
output.Value.ConnectorValue = Convert.ToInt32(!Convert.ToBoolean(Input[0].ConnectorValue));
|
||||||
output.Value.ValueType = DiagramDesigner.ValueType.Bool;
|
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Bool;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output.Value.ConnectorValue = ~Convert.ToInt32(Input[0].ConnectorValue);
|
output.Value.ConnectorValue = ~Convert.ToInt32(Input[0].ConnectorValue);
|
||||||
output.Value.ValueType = DiagramDesigner.ValueType.Int;
|
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.CalculateOutput();
|
base.CalculateOutput();
|
||||||
@@ -1807,7 +1807,7 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
foreach (var output in Output)
|
foreach (var output in Output)
|
||||||
{
|
{
|
||||||
output.Value.ConnectorValue = first.ConnectorValue;
|
output.Value.ConnectorValue = first.ConnectorValue;
|
||||||
output.Value.ValueType = first.ValueType;
|
output.Value.ConnectorValueType = first.ConnectorValueType;
|
||||||
}
|
}
|
||||||
base.CalculateOutput();
|
base.CalculateOutput();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user