mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-02 15:50:51 +08:00
添加逻辑节点支持字符串值
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -14,27 +14,32 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (values == null || values.Length < 1)
|
||||
if (values == null || values.Length < 2)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (values[0] is double && values[1] is ValueTypePoint)
|
||||
if (values[0] is double && values[2] is ValueType)
|
||||
{
|
||||
double connectorValue = (double)values[0];
|
||||
ValueTypePoint valueTypePoint = (ValueTypePoint)values[1];
|
||||
string connectorString = values[1] as string;
|
||||
ValueType valueTypePoint = (ValueType)values[2];
|
||||
|
||||
if (valueTypePoint == ValueTypePoint.Bool)
|
||||
if (valueTypePoint == ValueType.Bool)
|
||||
{
|
||||
return (connectorValue == 0) ? "F" : "T";
|
||||
}
|
||||
else if (valueTypePoint == ValueTypePoint.Int)
|
||||
else if (valueTypePoint == ValueType.Int)
|
||||
{
|
||||
return connectorValue.ToString("0");
|
||||
}
|
||||
else
|
||||
else if (valueTypePoint == ValueType.Real)
|
||||
{
|
||||
return connectorValue.ToString("f3");
|
||||
}
|
||||
else
|
||||
{
|
||||
return connectorString;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public enum ValueTypePoint
|
||||
public enum ValueType
|
||||
{
|
||||
Real = 0,
|
||||
Int = 1,
|
||||
Bool = 2,
|
||||
String = 3,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
|
||||
{
|
||||
ValueTypePoint = viewmodel.ValueTypePoint;
|
||||
ValueType = viewmodel.ValueType;
|
||||
ConnectorValue = viewmodel.ConnectorValue;
|
||||
ConnectorString = viewmodel.ConnectorString;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public ValueTypePoint ValueTypePoint
|
||||
public ValueType ValueType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
@@ -35,6 +36,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string ConnectorString
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||
<Binding Path="ConnectorValue" />
|
||||
<Binding Path="ValueTypePoint"/>
|
||||
<Binding Path="ConnectorString" />
|
||||
<Binding Path="ValueType"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
<TextBlock.RenderTransform>
|
||||
@@ -85,7 +86,8 @@
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
||||
<Binding Path="ConnectorValue" />
|
||||
<Binding Path="ValueTypePoint"/>
|
||||
<Binding Path="ConnectorString" />
|
||||
<Binding Path="ValueType"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
<TextBlock.RenderTransform>
|
||||
|
||||
@@ -8,11 +8,6 @@
|
||||
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<dd:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
|
||||
<dd:ConectorValueConverter x:Key="ConectorValueConverter"/>
|
||||
<dd:ArrowPathConverter x:Key="ArrowPathConverter"/>
|
||||
<dd:ArrowSizeConverter x:Key="ArrowSizeConverter"/>
|
||||
<dd:LineDashConverter x:Key="LineDashConverter"/>
|
||||
<dd:ClipConverter x:Key="ClipConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type dd:DefaultDesignerItemViewModel}">
|
||||
|
||||
@@ -15,15 +15,8 @@
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.DiagramDesigner;component/Themes/Generic.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<dd:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
|
||||
<dd:ConectorValueConverter x:Key="ConectorValueConverter"/>
|
||||
<dd:ArrowPathConverter x:Key="ArrowPathConverter"/>
|
||||
<dd:ArrowSizeConverter x:Key="ArrowSizeConverter"/>
|
||||
<dd:LineDashConverter x:Key="LineDashConverter"/>
|
||||
<dd:ClipConverter x:Key="ClipConverter"/>
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<dd:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||
<dd:ConectorStyleConverter x:Key="ConectorStyleConverter"/>
|
||||
<dd:NotNullOrEmptyToBoolConverter x:Key="NotNullOrEmptyToBoolConverter"/>
|
||||
|
||||
<!-- ResizeDecorator Default Template -->
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class LogicalConnectorInfo : FullyCreatedConnectorInfo
|
||||
{
|
||||
public LogicalConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueTypePoint valueTypePoint = ValueTypePoint.Real) : base(dataItem, orientation, isInnerPoint, isPortless)
|
||||
public LogicalConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueType valueTypePoint = ValueType.Real) : base(dataItem, orientation, isInnerPoint, isPortless)
|
||||
{
|
||||
this.ValueTypePoint = valueTypePoint;
|
||||
this.ValueType = valueTypePoint;
|
||||
}
|
||||
|
||||
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueTypePoint valueTypePoint = ValueTypePoint.Real) : base(root, dataItem, orientation, isInnerPoint, isPortless)
|
||||
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueType valueTypePoint = ValueType.Real) : base(root, dataItem, orientation, isInnerPoint, isPortless)
|
||||
{
|
||||
this.ValueTypePoint = valueTypePoint;
|
||||
this.ValueType = valueTypePoint;
|
||||
}
|
||||
|
||||
public LogicalConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, SelectableItemBase designer) : base(root, dataItem, designer)
|
||||
@@ -37,7 +37,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (designerbase is LogicalConnectorInfoItem designer)
|
||||
{
|
||||
ConnectorValue = designer.ConnectorValue;
|
||||
ValueTypePoint = designer.ValueTypePoint;
|
||||
ValueType = designer.ValueType;
|
||||
ConnectorString = designer.ConnectorString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,16 +55,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public ValueTypePoint _valueTypePoint;
|
||||
public ValueTypePoint ValueTypePoint
|
||||
public string _connectorString;
|
||||
public string ConnectorString
|
||||
{
|
||||
get
|
||||
{
|
||||
return _valueTypePoint;
|
||||
return _connectorString;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _valueTypePoint, value);
|
||||
SetProperty(ref _connectorString, value);
|
||||
}
|
||||
}
|
||||
|
||||
public ValueType _valueType;
|
||||
public ValueType ValueType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _valueType;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _valueType, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,47 +262,47 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public List<ValueTypePoint> ValueTypeInput
|
||||
public List<ValueType> ValueTypeInput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LogicalType == LogicalType.NOT)
|
||||
{
|
||||
return new List<ValueTypePoint>() { ValueTypePoint.Bool };
|
||||
return new List<ValueType>() { ValueType.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<ValueTypePoint>() { ValueTypePoint.Int };
|
||||
return new List<ValueType>() { ValueType.Int };
|
||||
}
|
||||
else if (LogicalType == LogicalType.SEL)
|
||||
{
|
||||
return new List<ValueTypePoint>() { ValueTypePoint.Bool, ValueTypePoint.Real, ValueTypePoint.Real };
|
||||
return new List<ValueType>() { ValueType.Bool, ValueType.Real, ValueType.Real };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<ValueTypePoint>() { ValueTypePoint.Real };
|
||||
return new List<ValueType>() { ValueType.Real };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<ValueTypePoint> ValueTypeOutput
|
||||
public List<ValueType> 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<ValueTypePoint>() { ValueTypePoint.Bool };
|
||||
return new List<ValueType>() { ValueType.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<ValueTypePoint>() { ValueTypePoint.Int };
|
||||
return new List<ValueType>() { ValueType.Int };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<ValueTypePoint>() { ValueTypePoint.Real };
|
||||
return new List<ValueType>() { ValueType.Real };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,11 +332,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
if (LogicalType == LogicalType.Output)
|
||||
{
|
||||
input.Value.ValueTypePoint = (connector.SourceConnectorInfo as LogicalConnectorInfo).ValueTypePoint;
|
||||
input.Value.ValueType = (connector.SourceConnectorInfo as LogicalConnectorInfo).ValueType;
|
||||
}
|
||||
else if (LogicalType == LogicalType.NOT)
|
||||
{
|
||||
input.Value.ValueTypePoint = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ValueTypePoint == ValueTypePoint.Bool) ? ValueTypePoint.Bool : ValueTypePoint.Int;
|
||||
input.Value.ValueType = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ValueType == ValueType.Bool) ? ValueType.Bool : ValueType.Int;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,7 +346,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
foreach (var output in Output)
|
||||
{
|
||||
if (output.Value.ValueTypePoint == ValueTypePoint.Bool)
|
||||
if (output.Value.ValueType == ValueType.Bool)
|
||||
{
|
||||
if (output.Value.ConnectorValue == 0)
|
||||
{
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
protected IUIVisualizerService visualiserService;
|
||||
public LogicalGateItemViewModel(LogicalType logicalType) : this(null, logicalType)
|
||||
{
|
||||
ColorViewModel.FillColor.Color = Colors.Orange;
|
||||
|
||||
}
|
||||
|
||||
public LogicalGateItemViewModel(IDiagramViewModel root, LogicalType logicalType) : base(root, logicalType)
|
||||
{
|
||||
ColorViewModel.FillColor.Color = Colors.Orange;
|
||||
|
||||
}
|
||||
|
||||
public LogicalGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
@@ -46,6 +46,8 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
ColorViewModel.FillColor.Color = Colors.Orange;
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
@@ -392,15 +394,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
{
|
||||
foreach (var output in Output)
|
||||
{
|
||||
if (Input[0].ValueTypePoint == ValueTypePoint.Bool)
|
||||
if (Input[0].ValueType == DiagramDesigner.ValueType.Bool)
|
||||
{
|
||||
output.Value.ConnectorValue = Convert.ToInt32(!Convert.ToBoolean(Input[0].ConnectorValue));
|
||||
output.Value.ValueTypePoint = ValueTypePoint.Bool;
|
||||
output.Value.ValueType = DiagramDesigner.ValueType.Bool;
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Value.ConnectorValue = ~Convert.ToInt32(Input[0].ConnectorValue);
|
||||
output.Value.ValueTypePoint = ValueTypePoint.Int;
|
||||
output.Value.ValueType = DiagramDesigner.ValueType.Int;
|
||||
}
|
||||
}
|
||||
base.CalculateOutput();
|
||||
@@ -1393,7 +1395,7 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
||||
foreach (var output in Output)
|
||||
{
|
||||
output.Value.ConnectorValue = first.ConnectorValue;
|
||||
output.Value.ValueTypePoint = first.ValueTypePoint;
|
||||
output.Value.ValueType = first.ValueType;
|
||||
}
|
||||
base.CalculateOutput();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user