mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
connect
This commit is contained in:
@@ -18,21 +18,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
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];
|
||||
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";
|
||||
}
|
||||
else if (valueTypePoint == ValueType.Int)
|
||||
else if (valueTypePoint == ConnectorValueType.Int)
|
||||
{
|
||||
return connectorValue.ToString("0");
|
||||
}
|
||||
else if (valueTypePoint == ValueType.Real)
|
||||
else if (valueTypePoint == ConnectorValueType.Real)
|
||||
{
|
||||
return connectorValue.ToString("f3");
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public enum ValueType
|
||||
public enum ConnectorValueType
|
||||
{
|
||||
Real = 0,
|
||||
Int = 1,
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
|
||||
{
|
||||
ValueType = viewmodel.ValueType;
|
||||
ConnectorValueType = viewmodel.ConnectorValueType;
|
||||
ConnectorValue = viewmodel.ConnectorValue;
|
||||
ConnectorString = viewmodel.ConnectorString;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public ValueType ValueType
|
||||
public ConnectorValueType ConnectorValueType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||
<Binding Path="ConnectorValue" />
|
||||
<Binding Path="ConnectorString" />
|
||||
<Binding Path="ValueType"/>
|
||||
<Binding Path="ConnectorValueType"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
<TextBlock.RenderTransform>
|
||||
@@ -87,7 +87,7 @@
|
||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||
<Binding Path="ConnectorValue" />
|
||||
<Binding Path="ConnectorString" />
|
||||
<Binding Path="ValueType"/>
|
||||
<Binding Path="ConnectorValueType"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
<TextBlock.RenderTransform>
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
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)
|
||||
@@ -37,7 +37,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (designerbase is LogicalConnectorInfoItem designer)
|
||||
{
|
||||
ConnectorValue = designer.ConnectorValue;
|
||||
ValueType = designer.ValueType;
|
||||
ConnectorValueType = designer.ConnectorValueType;
|
||||
ConnectorString = designer.ConnectorString;
|
||||
}
|
||||
}
|
||||
@@ -68,8 +68,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public ValueType _valueType;
|
||||
public ValueType ValueType
|
||||
public ConnectorValueType _valueType;
|
||||
public ConnectorValueType ConnectorValueType
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -209,47 +209,47 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return connector;
|
||||
}
|
||||
|
||||
public List<ValueType> ValueTypeInput
|
||||
public List<ConnectorValueType> ValueTypeInput
|
||||
{
|
||||
get
|
||||
{
|
||||
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
|
||||
|| 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)
|
||||
{
|
||||
return new List<ValueType>() { ValueType.Bool, ValueType.Real, ValueType.Real };
|
||||
return new List<ConnectorValueType>() { ConnectorValueType.Bool, ConnectorValueType.Real, ConnectorValueType.Real };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<ValueType>() { ValueType.Real };
|
||||
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ValueType> ValueTypeOutput
|
||||
public List<ConnectorValueType> ValueTypeOutput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LogicalType == LogicalType.GT || LogicalType == LogicalType.LT || LogicalType == LogicalType.GE || LogicalType == LogicalType.LE || LogicalType == LogicalType.EQ || LogicalType == LogicalType.NE
|
||||
|| 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
|
||||
|| 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
|
||||
{
|
||||
return new List<ValueType>() { ValueType.Real };
|
||||
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,11 +280,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
foreach (var output in Output)
|
||||
{
|
||||
if (output.Value.ValueType == ValueType.Bool)
|
||||
if (output.Value.ConnectorValueType == ConnectorValueType.Bool)
|
||||
{
|
||||
if (output.Value.ConnectorValue == 0)
|
||||
{
|
||||
@@ -322,14 +322,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
protected ConnectionViewModel GetSourceItem(FullyCreatedConnectorInfo sinkConnector)
|
||||
{
|
||||
foreach (var connector in Root?.Items.OfType<ConnectionViewModel>())
|
||||
{
|
||||
if (connector.SinkConnectorInfo == sinkConnector)
|
||||
{
|
||||
return connector;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SinkConnectorInfo == sinkConnector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<!-- Project properties -->
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -533,15 +533,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
{
|
||||
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.ValueType = DiagramDesigner.ValueType.Bool;
|
||||
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Bool;
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Value.ConnectorValue = ~Convert.ToInt32(Input[0].ConnectorValue);
|
||||
output.Value.ValueType = DiagramDesigner.ValueType.Int;
|
||||
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Int;
|
||||
}
|
||||
}
|
||||
base.CalculateOutput();
|
||||
@@ -1807,7 +1807,7 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
foreach (var output in Output)
|
||||
{
|
||||
output.Value.ConnectorValue = first.ConnectorValue;
|
||||
output.Value.ValueType = first.ValueType;
|
||||
output.Value.ConnectorValueType = first.ConnectorValueType;
|
||||
}
|
||||
base.CalculateOutput();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user