mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-21 08:56:36 +08:00
demo提交
This commit is contained in:
@@ -8,17 +8,45 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ToolBoxData
|
||||
{
|
||||
public string Text { get; protected set; }
|
||||
public string Icon { get; protected set; }
|
||||
public Type Type { get; protected set; }
|
||||
public IColorViewModel ColorViewModel { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
public Size? DesiredSize{ get; set; }
|
||||
public string Text
|
||||
{
|
||||
get; protected set;
|
||||
}
|
||||
public string Icon
|
||||
{
|
||||
get; protected set;
|
||||
}
|
||||
public Type Type
|
||||
{
|
||||
get; protected set;
|
||||
}
|
||||
public IColorViewModel ColorViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public double Width
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public double Height
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public Size? DesiredSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public object Addition { get; set; }
|
||||
public object Addition
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null)
|
||||
public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null, string description = null)
|
||||
{
|
||||
this.Text = text;
|
||||
this.Icon = icon;
|
||||
@@ -27,6 +55,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.Height = height;
|
||||
this.DesiredSize = desiredSize;
|
||||
this.ColorViewModel = new ColorViewModel();
|
||||
this.Description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
100
AIStudio.Wpf.DiagramDesigner/Styles/TextBox.xaml
Normal file
100
AIStudio.Wpf.DiagramDesigner/Styles/TextBox.xaml
Normal file
@@ -0,0 +1,100 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner">
|
||||
<!--TextBox水印样式-->
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBox">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Grid x:Name="PART_Root">
|
||||
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<Grid x:Name="PART_InnerGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--内容区域-->
|
||||
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Grid.Column="1" IsTabStop="False" Margin="2"
|
||||
VerticalAlignment="Stretch" Background="{x:Null}" >
|
||||
</ScrollViewer>
|
||||
<!--水印-->
|
||||
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
|
||||
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
|
||||
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<!--显示水印-->
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
|
||||
<Setter TargetName="Message" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--TextBox水印,阴影样式-->
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBoxWithEffect">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Grid x:Name="PART_Root">
|
||||
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<Grid x:Name="PART_InnerGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--内容区域-->
|
||||
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Grid.Column="1" IsTabStop="False" Margin="2"
|
||||
VerticalAlignment="Stretch" Background="{x:Null}" >
|
||||
<ScrollViewer.Effect>
|
||||
<DropShadowEffect x:Name="effect" Color="{Binding FontViewModel.TextEffectColor}" ></DropShadowEffect>
|
||||
</ScrollViewer.Effect>
|
||||
</ScrollViewer>
|
||||
<!--水印-->
|
||||
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
|
||||
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
|
||||
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<!--显示水印-->
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
|
||||
<Setter TargetName="Message" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding FontViewModel.TextEffectColor}" Value="Transparent">
|
||||
<Setter TargetName="PART_ContentHost" Property="Effect" Value="{x:Null}"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -15,6 +15,12 @@
|
||||
<s:LineDashConverter x:Key="LineDashConverter"/>
|
||||
<s:ClipConverter x:Key="ClipConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type s:DefaultDesignerItemViewModel}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Rectangle StrokeThickness="1" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type s:TextDesignerItemViewModel}">
|
||||
<Grid >
|
||||
<Border Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" IsHitTestVisible="False"/>
|
||||
|
||||
@@ -9,5 +9,14 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.DiagramDesigner;component/Themes/DesignerItem.xaml" />
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.DiagramDesigner;component/Themes/ConnectorItem.xaml" />
|
||||
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ScrollBar.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/Expander.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/GroupBox.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ToolTip.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ScrollViewer.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/TextBox.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ZoomBox.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ComboBox.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -316,21 +316,41 @@
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding TopLeftConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="TopLeft"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding TopConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="Top"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding TopRightConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="TopRight"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding RightConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="Right"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding BottomRightConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="BottomRight"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding BottomConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="Bottom"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
<s:Connector DataContext="{Binding BottomLeftConnector}" Style="{Binding Style, Converter={StaticResource ConectorStyleConverter},ConverterParameter={StaticResource DefaultConnectorStyle}}"
|
||||
Orientation="BottomLeft"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Left"
|
||||
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -523,7 +543,7 @@
|
||||
<ContextMenu>
|
||||
<MenuItem Header="删除" Command="{Binding DeleteConnectionCommand}" CommandParameter="{Binding}"/>
|
||||
<MenuItem Header="添加文本" Command="{Binding AddLabelCommand}" CommandParameter="{Binding}"/>
|
||||
<MenuItem Header="插入点(按住ctrl可一直插入)" IsCheckable="True" IsChecked="{Binding ShouldInsertAnchor}" />
|
||||
<MenuItem Header="插入点(按住ctrl可一直插入)" IsCheckable="True" IsChecked="{Binding ShouldInsertAnchor}" IsEnabled="{Binding IsReadOnly,Converter={s:InvertBoolConverter}}" />
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
|
||||
|
||||
@@ -7,59 +7,15 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<s:TrueToFalseConverter x:Key="TrueToFalseConverter"/>
|
||||
<!--TextBox默认样式-->
|
||||
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBox">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Grid x:Name="PART_Root">
|
||||
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<Grid x:Name="PART_InnerGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--内容区域-->
|
||||
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Grid.Column="1" IsTabStop="False" Margin="2"
|
||||
VerticalAlignment="Stretch" Background="{x:Null}" >
|
||||
<ScrollViewer.Effect>
|
||||
<DropShadowEffect x:Name="effect" Color="{Binding FontViewModel.TextEffectColor}" ></DropShadowEffect>
|
||||
</ScrollViewer.Effect>
|
||||
</ScrollViewer>
|
||||
<!--水印-->
|
||||
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
|
||||
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
|
||||
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<!--显示水印-->
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
|
||||
<Setter TargetName="Message" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding FontViewModel.TextEffectColor}" Value="Transparent">
|
||||
<Setter TargetName="PART_ContentHost" Property="Effect" Value="{x:Null}"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.DiagramDesigner;component/Styles/TextBox.xaml" />
|
||||
<ResourceDictionary>
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
|
||||
<s:TrueToFalseConverter x:Key="TrueToFalseConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid IsHitTestVisible="{Binding IsHitTestVisible}">
|
||||
<TextBox x:Name="PART_TextBlock"
|
||||
@@ -76,7 +32,7 @@
|
||||
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"
|
||||
AcceptsReturn="True"
|
||||
s:ControlAttachProperty.Watermark="{Binding Path=(s:ControlAttachProperty.Watermark),RelativeSource={RelativeSource AncestorType={x:Type s:TextControl}}}"
|
||||
Style="{StaticResource WaterTextBox}" IsReadOnly="True">
|
||||
Style="{StaticResource WaterTextBoxWithEffect}" IsReadOnly="True">
|
||||
|
||||
</TextBox>
|
||||
<TextBox x:Name="PART_ShowText"
|
||||
@@ -94,7 +50,7 @@
|
||||
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"
|
||||
AcceptsReturn="True"
|
||||
s:ControlAttachProperty.Watermark="{Binding Path=(s:ControlAttachProperty.Watermark),RelativeSource={RelativeSource AncestorType={x:Type s:TextControl}}}"
|
||||
Style="{StaticResource WaterTextBox}" Visibility="Collapsed">
|
||||
Style="{StaticResource WaterTextBoxWithEffect}" Visibility="Collapsed">
|
||||
</TextBox>
|
||||
|
||||
</Grid>
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
}
|
||||
|
||||
public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode = DrawMode.ConnectingLineSmooth, RouterMode routerMode = AIStudio.Wpf.DiagramDesigner.RouterMode.RouterNormal) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectionViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, ConnectionItem designer) : base(root, designer)
|
||||
{
|
||||
PathMode = designer.PathMode;
|
||||
@@ -31,11 +36,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
}
|
||||
|
||||
public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
if (IsFullConnection)
|
||||
@@ -56,7 +56,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
if (Root != null && Root.ColorViewModel != null)
|
||||
{
|
||||
this.ColorViewModel = CopyHelper.Mapper(Root.ColorViewModel);
|
||||
this.ColorViewModel = CopyHelper.Mapper(Root.ColorViewModel);
|
||||
}
|
||||
this.ColorViewModel.FillColor.Color = Colors.Red;
|
||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||
@@ -74,9 +74,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
this.SourceConnectorInfo = sourceConnectorInfo;
|
||||
this.SinkConnectorInfo = sinkConnectorInfo;
|
||||
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
|
||||
AddVertexCommand = new SimpleCommand(AddVertex);
|
||||
AddLabelCommand = new SimpleCommand(AddLabel);
|
||||
DeleteConnectionCommand = new SimpleCommand(Command_Enable, DeleteConnection);
|
||||
AddVertexCommand = new SimpleCommand(Command_Enable, AddVertex);
|
||||
AddLabelCommand = new SimpleCommand(Command_Enable, AddLabel);
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
@@ -88,7 +88,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Vertices = new ObservableCollection<ConnectorVertexModel>(designer.Vertices.Select(p => new ConnectorVertexModel(this.Root, this, designer)));
|
||||
Labels = new ObservableCollection<ConnectorLabelModel>(designer.Labels.Select(p => new ConnectorLabelModel(this.Root, this, designer)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 属性
|
||||
private string _text;
|
||||
@@ -300,7 +300,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private LineAnimation _lineAnimation = LineAnimation.None;
|
||||
[Browsable(true)]
|
||||
[CanDo]
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.Init();
|
||||
|
||||
DeleteLabelCommand = new SimpleCommand(DeleteLabel);
|
||||
DeleteLabelCommand = new SimpleCommand(Command_Enable, DeleteLabel);
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.Init();
|
||||
|
||||
DeleteVertexCommand = new SimpleCommand(DeleteVertex);
|
||||
DeleteVertexCommand = new SimpleCommand(Command_Enable, DeleteVertex);
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
base.Init();
|
||||
|
||||
menuOptions = new List<CinchMenuItem>();
|
||||
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
||||
DeleteCommand = new SimpleCommand(ExecuteDeleteCommand);
|
||||
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
|
||||
DeleteCommand = new SimpleCommand(Command_Enable, ExecuteDeleteCommand);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -68,22 +68,66 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
#region 属性
|
||||
public FullyCreatedConnectorInfo TopConnector
|
||||
{
|
||||
get { return (connectors != null && connectors.Count >= 1) ? connectors[0] : null; }
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Top);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo BottomConnector
|
||||
{
|
||||
get { return (connectors != null && connectors.Count >= 2) ? connectors[1] : null; }
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo LeftConnector
|
||||
{
|
||||
get { return (connectors != null && connectors.Count >= 3) ? connectors[2] : null; }
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Left);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo RightConnector
|
||||
{
|
||||
get { return (connectors != null && connectors.Count >= 4) ? connectors[3] : null; }
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Right);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo TopLeftConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopLeft);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo TopRightConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopRight);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo BottomLeftConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomLeft);
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo BottomRightConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomRight);
|
||||
}
|
||||
}
|
||||
|
||||
public Style ConnectorStyle
|
||||
@@ -244,7 +288,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
[CanDo]
|
||||
[CanDo]
|
||||
public PointBase TopLeft
|
||||
{
|
||||
get
|
||||
@@ -317,13 +361,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
/// <summary>
|
||||
/// 连接点是否可以按偏移自定义
|
||||
/// </summary>
|
||||
public bool IsInnerConnector { get; set; }
|
||||
public bool IsInnerConnector
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private ObservableCollection<FullyCreatedConnectorInfo> connectors = new ObservableCollection<FullyCreatedConnectorInfo>();
|
||||
public IEnumerable<FullyCreatedConnectorInfo> Connectors { get { return connectors; } }
|
||||
protected ObservableCollection<FullyCreatedConnectorInfo> connectors = new ObservableCollection<FullyCreatedConnectorInfo>();
|
||||
public IEnumerable<FullyCreatedConnectorInfo> Connectors
|
||||
{
|
||||
get
|
||||
{
|
||||
return connectors;
|
||||
}
|
||||
}
|
||||
|
||||
protected ObservableCollection<CinchMenuItem> menuOptions;
|
||||
public IEnumerable<CinchMenuItem> MenuOptions { get { return menuOptions; } }
|
||||
public IEnumerable<CinchMenuItem> MenuOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowMenuOptions
|
||||
{
|
||||
@@ -336,7 +395,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public bool BeginDo { get; set; }
|
||||
public bool BeginDo
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public IObservable<NotifyCollectionChangedEventArgs> WhenConnectorsChanged
|
||||
{
|
||||
@@ -415,7 +477,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMarginSize.Height + (Root.GridCellSize.Height - this.ItemHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RaiseTopLeft()
|
||||
@@ -443,7 +505,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
var rightPort = RightConnector;
|
||||
var bottomPort = BottomConnector;
|
||||
|
||||
var left = leftPort == null ? Position.X: Math.Min(Position.X, leftPort.Position.X);
|
||||
var left = leftPort == null ? Position.X : Math.Min(Position.X, leftPort.Position.X);
|
||||
var top = topPort == null ? Position.Y : Math.Min(Position.Y, topPort.Position.Y);
|
||||
var right = rightPort == null ? Position.X + ItemWidth :
|
||||
Math.Max(rightPort.Position.X + rightPort.ConnectorWidth, Position.X + ItemWidth);
|
||||
|
||||
@@ -42,8 +42,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.Init();
|
||||
|
||||
SelectItemCommand = new SimpleCommand(ExecuteSelectItemCommand);
|
||||
EditCommand = new SimpleCommand(ExecuteEditCommand);
|
||||
SelectItemCommand = new SimpleCommand(Command_Enable, ExecuteSelectItemCommand);
|
||||
EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand);
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
}
|
||||
|
||||
public virtual bool InitData()
|
||||
@@ -62,7 +67,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public ICommand EditCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
[Browsable(false)]
|
||||
public override bool IsSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isSelected, value))
|
||||
{
|
||||
//如果没有文字,失去焦点自动清除
|
||||
if (_isSelected == false && string.IsNullOrEmpty(Text))
|
||||
{
|
||||
ShowText = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private string _text;
|
||||
[Browsable(true)]
|
||||
|
||||
@@ -261,6 +261,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
protected bool Command_Enable(object para)
|
||||
{
|
||||
return IsReadOnly == false;
|
||||
}
|
||||
|
||||
private void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "FontCase")
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner.Services;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class DefaultDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public DefaultDesignerItemViewModel() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DefaultDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DefaultDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new DesignerItemBase(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
AddItemCommand = new SimpleCommand(ExecuteAddItemCommand);
|
||||
ImageSwitchCommand = new SimpleCommand(ExecuteImageSwitchCommand);
|
||||
AddItemCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
|
||||
ImageSwitchCommand = new SimpleCommand(Command_Enable, ExecuteImageSwitchCommand);
|
||||
|
||||
base.Init();
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(ExecuteMenuItemCommand));
|
||||
return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
ShowRotate = false;
|
||||
ShowArrow = false;
|
||||
AddInputCommand = new SimpleCommand(para => ExecuteAddInput(para));
|
||||
AddOutputCommand = new SimpleCommand(para => ExecuteAddOutput(para));
|
||||
AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para));
|
||||
AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para));
|
||||
|
||||
base.Init();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(ExecuteMenuItemCommand));
|
||||
return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
||||
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
|
||||
base.Init();
|
||||
|
||||
this.ClearConnectors();
|
||||
|
||||
Reference in New Issue
Block a user