mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-23 01:46:36 +08:00
FlowchartEditor完成
This commit is contained in:
@@ -14,8 +14,6 @@
|
|||||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ZoomBox.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ZoomBox.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/DesignerItems.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/DesignerItems.xaml" />
|
||||||
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramHelper;component/Controls/ComboBox.xaml" />
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
@@ -5,15 +5,14 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Test"
|
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Test"
|
||||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls;assembly=AIStudio.Wpf.DiagramHelper"
|
|
||||||
xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
|
|
||||||
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Themes/FlowNode.xaml"/>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramHelper;component/Controls/ComboBox.xaml" />
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<!-- Accent colors -->
|
<!-- Accent colors -->
|
||||||
<Color x:Key="Fluent.Ribbon.Colors.AccentBaseColor">#FF0078D7</Color>
|
<Color x:Key="Fluent.Ribbon.Colors.AccentBaseColor">#FF0078D7</Color>
|
||||||
@@ -69,69 +68,77 @@
|
|||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid>
|
<TabControl>
|
||||||
<Grid.ColumnDefinitions>
|
<TabItem Header="Custom">
|
||||||
<ColumnDefinition Width="Auto"/>
|
<Grid x:Name="grid">
|
||||||
<ColumnDefinition/>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
<ColumnDefinition/>
|
||||||
<!-- ToolBox Control -->
|
<ColumnDefinition Width="Auto"/>
|
||||||
<local:ToolBoxControl Grid.Column="0" DataContext="{Binding ToolBoxViewModel}" />
|
</Grid.ColumnDefinitions>
|
||||||
|
<!-- ToolBox Control -->
|
||||||
|
<dd:ToolBoxControl Grid.Column="0" />
|
||||||
|
|
||||||
<GridSplitter Grid.Column="1"
|
<GridSplitter Grid.Column="1"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Width="3" />
|
Width="3" />
|
||||||
|
|
||||||
<!-- Diagram Control -->
|
<!-- Diagram Control -->
|
||||||
<dd:DiagramControl Grid.Column="1" x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
<dd:DiagramControl Grid.Column="1" x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||||
|
|
||||||
<controls:PropertiesView Grid.Column="2" CustomSetting="True" SelectedObject="{Binding SelectedItem}" Width="200">
|
<dd:PropertiesView Grid.Column="2" CustomSetting="True" SelectedObject="{Binding SelectedItem}" Width="200">
|
||||||
<controls:PropertiesView.Resources>
|
<dd:PropertiesView.Resources>
|
||||||
|
|
||||||
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
|
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
|
||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
<ComboBox BorderThickness="0" Text="{Binding ActType}" Style="{StaticResource ComboBoxStyle}">
|
<ComboBox BorderThickness="0" Text="{Binding ActType}" Style="{StaticResource ComboBoxStyle}">
|
||||||
<ComboBoxItem Content="or"/>
|
<ComboBoxItem Content="or"/>
|
||||||
<ComboBoxItem Content="and"/>
|
<ComboBoxItem Content="and"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="UserIdsStyle" TargetType="{x:Type ContentControl}">
|
<Style x:Key="UserIdsStyle" TargetType="{x:Type ContentControl}">
|
||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
<controls:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
<dd:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||||
SelectedValues="{Binding UserIds}"
|
SelectedValues="{Binding UserIds}"
|
||||||
ItemsSource="{Binding Path=DataContext.Users,RelativeSource={RelativeSource AncestorType={x:Type Window}}}" ></controls:MultiSelectComboBox>
|
ItemsSource="{Binding Path=DataContext.Users,RelativeSource={RelativeSource AncestorType={x:Type Window}}}" ></dd:MultiSelectComboBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="RoleIdsStyle" TargetType="{x:Type ContentControl}">
|
<Style x:Key="RoleIdsStyle" TargetType="{x:Type ContentControl}">
|
||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
<controls:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
<dd:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||||
SelectedValues="{Binding RoleIds}"
|
SelectedValues="{Binding RoleIds}"
|
||||||
ItemsSource="{Binding Path=DataContext.Roles,RelativeSource={RelativeSource AncestorType={x:Type Window}}}"></controls:MultiSelectComboBox>
|
ItemsSource="{Binding Path=DataContext.Roles,RelativeSource={RelativeSource AncestorType={x:Type Window}}}"></dd:MultiSelectComboBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</controls:PropertiesView.Resources>
|
</dd:PropertiesView.Resources>
|
||||||
</controls:PropertiesView>
|
</dd:PropertiesView>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Flowchart">
|
||||||
|
<dd:FlowchartEditor Users="{Binding Users}" Roles="{Binding Roles}">
|
||||||
|
</dd:FlowchartEditor>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using AIStudio.Wpf.Flowchart;
|
using AIStudio.Wpf.Flowchart;
|
||||||
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||||
{
|
{
|
||||||
|
|||||||
69
AIStudio.Wpf.DiagramDesigner/Styles/DesignerItems.xaml
Normal file
69
AIStudio.Wpf.DiagramDesigner/Styles/DesignerItems.xaml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<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"
|
||||||
|
xmlns:c="clr-namespace:AIStudio.Wpf.DiagramDesigner.Controls">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Connector Style -->
|
||||||
|
<Style TargetType="{x:Type s:Connector}">
|
||||||
|
<Setter Property="Width"
|
||||||
|
Value="8" />
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="8" />
|
||||||
|
<Setter Property="Cursor"
|
||||||
|
Value="Cross" />
|
||||||
|
<Setter Property="SnapsToDevicePixels"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type s:Connector}">
|
||||||
|
<Grid>
|
||||||
|
<!-- transparent extra space makes connector easier to hit -->
|
||||||
|
<Rectangle Fill="Transparent"
|
||||||
|
Margin="-2" />
|
||||||
|
<Rectangle Fill="Lavender"
|
||||||
|
StrokeThickness="1"
|
||||||
|
Stroke="#AA000080" />
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<!-- ConnectorDecoratorTemplate Default Template -->
|
||||||
|
<ControlTemplate x:Key="ConnectorDecoratorTemplate"
|
||||||
|
TargetType="{x:Type Control}">
|
||||||
|
<Grid Margin="-5">
|
||||||
|
<s:Connector x:Name="Left"
|
||||||
|
Orientation="Left"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
|
<s:Connector x:Name="Top"
|
||||||
|
Orientation="Top"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
<s:Connector x:Name="Right"
|
||||||
|
Orientation="Right"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
|
<s:Connector x:Name="Bottom"
|
||||||
|
Orientation="Bottom"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- DragThumb Default Template -->
|
||||||
|
<Style TargetType="{x:Type c:DragThumb}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type c:DragThumb}">
|
||||||
|
<Rectangle Fill="Transparent" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
117
AIStudio.Wpf.DiagramDesigner/Styles/Expander.xaml
Normal file
117
AIStudio.Wpf.DiagramDesigner/Styles/Expander.xaml
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Shared.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<!-- SimpleStyles: Expander -->
|
||||||
|
|
||||||
|
<ControlTemplate x:Key="ExpanderToggleButton" TargetType="ToggleButton">
|
||||||
|
<Border
|
||||||
|
Name="Border"
|
||||||
|
CornerRadius="2,0,0,0"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderBrush="{StaticResource NormalBorderBrush}"
|
||||||
|
BorderThickness="0,0,0,0">
|
||||||
|
<Path
|
||||||
|
Name="Arrow"
|
||||||
|
Fill="{StaticResource GlyphBrush}"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Data="M 0 0 L 4 4 L 8 0 Z"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="ToggleButton.IsMouseOver" Value="true">
|
||||||
|
<Setter TargetName="Border" Property="Background"
|
||||||
|
Value="{StaticResource DarkBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="true">
|
||||||
|
<Setter TargetName="Border" Property="Background"
|
||||||
|
Value="{StaticResource PressedBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsChecked" Value="true">
|
||||||
|
<Setter TargetName="Arrow" Property="Data"
|
||||||
|
Value="M 0 4 L 4 0 L 8 4 Z" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter TargetName="Border" Property="Background"
|
||||||
|
Value="{StaticResource DisabledBackgroundBrush}" />
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush"
|
||||||
|
Value="{StaticResource DisabledBorderBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{StaticResource DisabledForegroundBrush}"/>
|
||||||
|
<Setter TargetName="Arrow" Property="Fill"
|
||||||
|
Value="{StaticResource DisabledForegroundBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<Style TargetType="Expander">
|
||||||
|
<Setter Property="FontFamily" Value="SegoeUI"/>
|
||||||
|
<Setter Property="FontSize" Value="12"/>
|
||||||
|
<Setter Property="Foreground" Value="#4C4C4C"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Expander">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Name="ContentRow" Height="0"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Border
|
||||||
|
Name="Border"
|
||||||
|
Grid.Row="0"
|
||||||
|
Background="{StaticResource LightBrush}"
|
||||||
|
BorderBrush="{StaticResource NormalBorderBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
CornerRadius="2,2,0,0" >
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="20" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ToggleButton
|
||||||
|
IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,
|
||||||
|
RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
OverridesDefaultStyle="True"
|
||||||
|
Template="{StaticResource ExpanderToggleButton}"
|
||||||
|
Background="{StaticResource NormalBrush}" />
|
||||||
|
<ContentPresenter
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="4"
|
||||||
|
ContentSource="Header"
|
||||||
|
RecognizesAccessKey="True" />
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<Border
|
||||||
|
Name="Content"
|
||||||
|
Grid.Row="1"
|
||||||
|
Background="{StaticResource WindowBackgroundBrush}"
|
||||||
|
BorderBrush="{StaticResource SolidBorderBrush}"
|
||||||
|
BorderThickness="1,0,1,1"
|
||||||
|
CornerRadius="0,0,2,2" >
|
||||||
|
<ContentPresenter Margin="4" />
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsExpanded" Value="True">
|
||||||
|
<Setter TargetName="ContentRow" Property="Height"
|
||||||
|
Value="{Binding ElementName=Content,Path=DesiredHeight}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter TargetName="Border" Property="Background"
|
||||||
|
Value="{StaticResource DisabledBackgroundBrush}" />
|
||||||
|
<Setter TargetName="Border" Property="BorderBrush"
|
||||||
|
Value="{StaticResource DisabledBorderBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{StaticResource DisabledForegroundBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
47
AIStudio.Wpf.DiagramDesigner/Styles/GroupBox.xaml
Normal file
47
AIStudio.Wpf.DiagramDesigner/Styles/GroupBox.xaml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Shared.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<!-- SimpleStyles: GroupBox -->
|
||||||
|
<Style TargetType="GroupBox">
|
||||||
|
<Setter Property="FontFamily" Value="SegoeUI"/>
|
||||||
|
<Setter Property="FontSize" Value="12"/>
|
||||||
|
<Setter Property="Foreground" Value="#4C4C4C"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="GroupBox">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Background="{StaticResource LightBrush}"
|
||||||
|
BorderBrush="{StaticResource NormalBorderBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
CornerRadius="2,2,0,0" >
|
||||||
|
<ContentPresenter
|
||||||
|
Margin="4"
|
||||||
|
ContentSource="Header"
|
||||||
|
RecognizesAccessKey="True" />
|
||||||
|
</Border>
|
||||||
|
<Border
|
||||||
|
Grid.Row="1"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{StaticResource SolidBorderBrush}"
|
||||||
|
BorderThickness="1,0,1,1"
|
||||||
|
CornerRadius="0,0,2,2" >
|
||||||
|
<ContentPresenter
|
||||||
|
Margin="4" />
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
186
AIStudio.Wpf.DiagramDesigner/Styles/ScrollBar.xaml
Normal file
186
AIStudio.Wpf.DiagramDesigner/Styles/ScrollBar.xaml
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Shared.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="Focusable" Value="false"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||||
|
<Border
|
||||||
|
Name="Border"
|
||||||
|
Margin="1"
|
||||||
|
CornerRadius="2"
|
||||||
|
Background="{StaticResource NormalBrush}"
|
||||||
|
BorderBrush="{StaticResource NormalBorderBrush}"
|
||||||
|
BorderThickness="1">
|
||||||
|
<Path
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Fill="{StaticResource GlyphBrush}"
|
||||||
|
Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsPressed" Value="true">
|
||||||
|
<Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="false">
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="IsTabStop" Value="false"/>
|
||||||
|
<Setter Property="Focusable" Value="false"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||||
|
<Border Background="Transparent" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="IsTabStop" Value="false"/>
|
||||||
|
<Setter Property="Focusable" Value="false"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||||
|
<Border
|
||||||
|
CornerRadius="2"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="1" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||||
|
<Grid >
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition MaxHeight="18"/>
|
||||||
|
<RowDefinition Height="0.00001*"/>
|
||||||
|
<RowDefinition MaxHeight="18"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Border
|
||||||
|
Grid.RowSpan="3"
|
||||||
|
CornerRadius="2"
|
||||||
|
Background="#F0F0F0" />
|
||||||
|
<RepeatButton
|
||||||
|
Grid.Row="0"
|
||||||
|
Style="{StaticResource ScrollBarLineButton}"
|
||||||
|
Height="18"
|
||||||
|
Command="ScrollBar.LineUpCommand"
|
||||||
|
Content="M 0 4 L 8 4 L 4 0 Z" />
|
||||||
|
<Track
|
||||||
|
Name="PART_Track"
|
||||||
|
Grid.Row="1"
|
||||||
|
IsDirectionReversed="true">
|
||||||
|
<Track.DecreaseRepeatButton>
|
||||||
|
<RepeatButton
|
||||||
|
Style="{StaticResource ScrollBarPageButton}"
|
||||||
|
Command="ScrollBar.PageUpCommand" />
|
||||||
|
</Track.DecreaseRepeatButton>
|
||||||
|
<Track.Thumb>
|
||||||
|
<Thumb
|
||||||
|
Style="{StaticResource ScrollBarThumb}"
|
||||||
|
Margin="1,0,1,0"
|
||||||
|
Background="{StaticResource HorizontalNormalBrush}"
|
||||||
|
BorderBrush="{StaticResource HorizontalNormalBorderBrush}" />
|
||||||
|
</Track.Thumb>
|
||||||
|
<Track.IncreaseRepeatButton>
|
||||||
|
<RepeatButton
|
||||||
|
Style="{StaticResource ScrollBarPageButton}"
|
||||||
|
Command="ScrollBar.PageDownCommand" />
|
||||||
|
</Track.IncreaseRepeatButton>
|
||||||
|
</Track>
|
||||||
|
<RepeatButton
|
||||||
|
Grid.Row="3"
|
||||||
|
Style="{StaticResource ScrollBarLineButton}"
|
||||||
|
Height="18"
|
||||||
|
Command="ScrollBar.LineDownCommand"
|
||||||
|
Content="M 0 0 L 4 4 L 8 0 Z"/>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||||
|
<Grid >
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition MaxWidth="18"/>
|
||||||
|
<ColumnDefinition Width="0.00001*"/>
|
||||||
|
<ColumnDefinition MaxWidth="18"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Border
|
||||||
|
Grid.ColumnSpan="3"
|
||||||
|
CornerRadius="2"
|
||||||
|
Background="#F0F0F0" />
|
||||||
|
<RepeatButton
|
||||||
|
Grid.Column="0"
|
||||||
|
Style="{StaticResource ScrollBarLineButton}"
|
||||||
|
Width="18"
|
||||||
|
Command="ScrollBar.LineLeftCommand"
|
||||||
|
Content="M 4 0 L 4 8 L 0 4 Z" />
|
||||||
|
<Track
|
||||||
|
Name="PART_Track"
|
||||||
|
Grid.Column="1"
|
||||||
|
IsDirectionReversed="False">
|
||||||
|
<Track.DecreaseRepeatButton>
|
||||||
|
<RepeatButton
|
||||||
|
Style="{StaticResource ScrollBarPageButton}"
|
||||||
|
Command="ScrollBar.PageLeftCommand" />
|
||||||
|
</Track.DecreaseRepeatButton>
|
||||||
|
<Track.Thumb>
|
||||||
|
<Thumb
|
||||||
|
Style="{StaticResource ScrollBarThumb}"
|
||||||
|
Margin="0,1,0,1"
|
||||||
|
Background="{StaticResource NormalBrush}"
|
||||||
|
BorderBrush="{StaticResource NormalBorderBrush}" />
|
||||||
|
</Track.Thumb>
|
||||||
|
<Track.IncreaseRepeatButton>
|
||||||
|
<RepeatButton
|
||||||
|
Style="{StaticResource ScrollBarPageButton}"
|
||||||
|
Command="ScrollBar.PageRightCommand" />
|
||||||
|
</Track.IncreaseRepeatButton>
|
||||||
|
</Track>
|
||||||
|
<RepeatButton
|
||||||
|
Grid.Column="3"
|
||||||
|
Style="{StaticResource ScrollBarLineButton}"
|
||||||
|
Width="18"
|
||||||
|
Command="ScrollBar.LineRightCommand"
|
||||||
|
Content="M 0 0 L 4 4 L 0 8 Z"/>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="Orientation" Value="Horizontal">
|
||||||
|
<Setter Property="Width" Value="Auto"/>
|
||||||
|
<Setter Property="Height" Value="18" />
|
||||||
|
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="Orientation" Value="Vertical">
|
||||||
|
<Setter Property="Width" Value="18"/>
|
||||||
|
<Setter Property="Height" Value="Auto" />
|
||||||
|
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
43
AIStudio.Wpf.DiagramDesigner/Styles/ScrollViewer.xaml
Normal file
43
AIStudio.Wpf.DiagramDesigner/Styles/ScrollViewer.xaml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||||
|
|
||||||
|
<!-- SimpleStyles: ScrollViewer -->
|
||||||
|
|
||||||
|
<Style x:Key="LeftScrollViewer" TargetType="{x:Type ScrollViewer}">
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ScrollContentPresenter Grid.Column="1"/>
|
||||||
|
|
||||||
|
<ScrollBar Name="PART_VerticalScrollBar"
|
||||||
|
Value="{TemplateBinding VerticalOffset}"
|
||||||
|
Maximum="{TemplateBinding ScrollableHeight}"
|
||||||
|
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||||
|
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
|
||||||
|
<ScrollBar Name="PART_HorizontalScrollBar"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Value="{TemplateBinding HorizontalOffset}"
|
||||||
|
Maximum="{TemplateBinding ScrollableWidth}"
|
||||||
|
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||||
|
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
118
AIStudio.Wpf.DiagramDesigner/Styles/Shared.xaml
Normal file
118
AIStudio.Wpf.DiagramDesigner/Styles/Shared.xaml
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<!-- Fill Brushes -->
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#CCC" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="HorizontalNormalBrush" StartPoint="0,0" EndPoint="1,0">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#CCC" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#EEE" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#EEE" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#FFF" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#AAA" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#BBB" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#EEE" Offset="0.1"/>
|
||||||
|
<GradientStop Color="#EEE" Offset="0.9"/>
|
||||||
|
<GradientStop Color="#FFF" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" />
|
||||||
|
|
||||||
|
<!-- Border Brushes -->
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#CCC" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#444" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#CCC" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#444" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#777" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#000" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1">
|
||||||
|
<GradientBrush.GradientStops>
|
||||||
|
<GradientStopCollection>
|
||||||
|
<GradientStop Color="#444" Offset="0.0"/>
|
||||||
|
<GradientStop Color="#888" Offset="1.0"/>
|
||||||
|
</GradientStopCollection>
|
||||||
|
</GradientBrush.GradientStops>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="LightBorderBrush" Color="#AAA" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
|
||||||
|
|
||||||
|
<SolidColorBrush x:Key="LightColorBrush" Color="#DDD" />
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
38
AIStudio.Wpf.DiagramDesigner/Styles/ToolTip.xaml
Normal file
38
AIStudio.Wpf.DiagramDesigner/Styles/ToolTip.xaml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Shared.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<!-- SimpleStyles: ToolTip -->
|
||||||
|
<Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="HasDropShadow" Value="True"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ToolTip">
|
||||||
|
<Border Name="Border"
|
||||||
|
Background="{StaticResource LightBrush}"
|
||||||
|
BorderBrush="{StaticResource SolidBorderBrush}"
|
||||||
|
BorderThickness="1"
|
||||||
|
Width="{TemplateBinding Width}"
|
||||||
|
Height="{TemplateBinding Height}">
|
||||||
|
<ContentPresenter
|
||||||
|
Margin="4"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="HasDropShadow" Value="true">
|
||||||
|
<Setter TargetName="Border" Property="CornerRadius" Value="4"/>
|
||||||
|
<Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
245
AIStudio.Wpf.DiagramDesigner/Styles/ZoomBox.xaml
Normal file
245
AIStudio.Wpf.DiagramDesigner/Styles/ZoomBox.xaml
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
<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">
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Shared.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<Style TargetType="{x:Type s:ZoomBox}">
|
||||||
|
|
||||||
|
<Style.Resources>
|
||||||
|
|
||||||
|
<VisualBrush x:Key="AlphaBrush"
|
||||||
|
Stretch="None"
|
||||||
|
TileMode="Tile"
|
||||||
|
ViewportUnits="Absolute"
|
||||||
|
Viewport="0,0,8,8">
|
||||||
|
<VisualBrush.Visual>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="4" />
|
||||||
|
<ColumnDefinition Width="4" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="4" />
|
||||||
|
<RowDefinition Height="4" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Rectangle Fill="#EEE"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0" />
|
||||||
|
<Rectangle Fill="#AAA"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1" />
|
||||||
|
<Rectangle Fill="#AAA"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0" />
|
||||||
|
<Rectangle Fill="#EEE"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1" />
|
||||||
|
</Grid>
|
||||||
|
</VisualBrush.Visual>
|
||||||
|
</VisualBrush>
|
||||||
|
|
||||||
|
<Style x:Key="ToggleButtonStyle"
|
||||||
|
TargetType="ToggleButton">
|
||||||
|
<Setter Property="SnapsToDevicePixels"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="OverridesDefaultStyle"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ToggleButton">
|
||||||
|
<Border x:Name="Border"
|
||||||
|
Background="{StaticResource NormalBrush}">
|
||||||
|
<ContentPresenter />
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver"
|
||||||
|
Value="true">
|
||||||
|
<Setter TargetName="Border"
|
||||||
|
Property="Background"
|
||||||
|
Value="{StaticResource DarkBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="Expander">
|
||||||
|
<Setter Property="SnapsToDevicePixels"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="OverridesDefaultStyle"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Expander">
|
||||||
|
<DockPanel>
|
||||||
|
<ToggleButton Style="{StaticResource ToggleButtonStyle}"
|
||||||
|
DockPanel.Dock="Top"
|
||||||
|
IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
VerticalContentAlignment="Center">
|
||||||
|
<ToggleButton.Content>
|
||||||
|
<Grid Margin="4">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="20" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Path Grid.Column="0"
|
||||||
|
SnapsToDevicePixels="True"
|
||||||
|
Name="Arrow"
|
||||||
|
Fill="{TemplateBinding Foreground}"
|
||||||
|
Stroke="{TemplateBinding Foreground}"
|
||||||
|
StrokeThickness="0.5"
|
||||||
|
RenderTransformOrigin="0.5,0.5"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Data="M 0 0 L 0 8 L 5 4 Z">
|
||||||
|
<Path.RenderTransform>
|
||||||
|
<RotateTransform Angle="0" />
|
||||||
|
</Path.RenderTransform>
|
||||||
|
</Path>
|
||||||
|
<ContentPresenter Grid.Column="1"
|
||||||
|
Name="HeaderContent"
|
||||||
|
ContentSource="Header" />
|
||||||
|
</Grid>
|
||||||
|
</ToggleButton.Content>
|
||||||
|
</ToggleButton>
|
||||||
|
<Border Name="Content">
|
||||||
|
<Border.LayoutTransform>
|
||||||
|
<ScaleTransform ScaleY="0" />
|
||||||
|
</Border.LayoutTransform>
|
||||||
|
<ContentPresenter Content="{TemplateBinding Content}" />
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="Expander.IsExpanded"
|
||||||
|
Value="True">
|
||||||
|
<Trigger.EnterActions>
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Content"
|
||||||
|
Storyboard.TargetProperty="LayoutTransform.ScaleY"
|
||||||
|
To="1"
|
||||||
|
Duration="0:0:0.3" />
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Content"
|
||||||
|
Storyboard.TargetProperty="Opacity"
|
||||||
|
To="1"
|
||||||
|
Duration="0:0:0.3" />
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Arrow"
|
||||||
|
Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
|
||||||
|
Duration="0:0:0.2"
|
||||||
|
To="90"
|
||||||
|
DecelerationRatio="1" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</Trigger.EnterActions>
|
||||||
|
<Trigger.ExitActions>
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Content"
|
||||||
|
Storyboard.TargetProperty="LayoutTransform.ScaleY"
|
||||||
|
To="0"
|
||||||
|
Duration="0:0:0.3" />
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Content"
|
||||||
|
Storyboard.TargetProperty="Opacity"
|
||||||
|
To="0"
|
||||||
|
Duration="0:0:0.3" />
|
||||||
|
<DoubleAnimation Storyboard.TargetName="Arrow"
|
||||||
|
Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
|
||||||
|
Duration="0:0:0.2"
|
||||||
|
AccelerationRatio="1" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</Trigger.ExitActions>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
</Style.Resources>
|
||||||
|
|
||||||
|
<Setter Property="SnapsToDevicePixels"
|
||||||
|
Value="true" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type s:ZoomBox}">
|
||||||
|
<Border CornerRadius="1"
|
||||||
|
BorderThickness="1"
|
||||||
|
Background="#EEE"
|
||||||
|
BorderBrush="DimGray">
|
||||||
|
<Expander IsExpanded="True"
|
||||||
|
Background="Transparent">
|
||||||
|
<Border BorderBrush="DimGray"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
Padding="0"
|
||||||
|
Height="180">
|
||||||
|
<Grid>
|
||||||
|
<Canvas Margin="5"
|
||||||
|
Name="PART_ZoomCanvas">
|
||||||
|
<Canvas.Background>
|
||||||
|
<VisualBrush Stretch="Uniform"
|
||||||
|
Visual="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ScrollViewer.Content}" />
|
||||||
|
</Canvas.Background>
|
||||||
|
<Thumb Name="PART_ZoomThumb"
|
||||||
|
Cursor="SizeAll">
|
||||||
|
<Thumb.Style>
|
||||||
|
<Style TargetType="Thumb">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Thumb">
|
||||||
|
<Rectangle StrokeThickness="1"
|
||||||
|
Stroke="Black"
|
||||||
|
Fill="Transparent" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Thumb.Style>
|
||||||
|
</Thumb>
|
||||||
|
</Canvas>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
<Expander.Header>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Slider Name="PART_ZoomSlider"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="0"
|
||||||
|
Ticks="25,50,75,100,125,150,200,300,400,500"
|
||||||
|
Minimum="25"
|
||||||
|
Maximum="500"
|
||||||
|
SmallChange="25"
|
||||||
|
LargeChange="25"
|
||||||
|
Value="100"
|
||||||
|
MinWidth="104"
|
||||||
|
MinHeight="21"
|
||||||
|
IsSnapToTickEnabled="True"
|
||||||
|
IsMoveToPointEnabled="False" />
|
||||||
|
|
||||||
|
<TextBlock Text="{Binding ElementName=PART_ZoomSlider, Path=Value}"
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,0,14,0" />
|
||||||
|
<TextBlock Text="%"
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="1,0,2,0" />
|
||||||
|
</Grid>
|
||||||
|
</Expander.Header>
|
||||||
|
</Expander>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
16
AIStudio.Wpf.DiagramHelper/Properties/AssemblyInfo.cs
Normal file
16
AIStudio.Wpf.DiagramHelper/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
|
|
||||||
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramHelper")]
|
||||||
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramHelper.Controls")]
|
||||||
|
|
||||||
|
[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
|
||||||
8
AIStudio.Wpf.DiagramHelper/Themes/Generic.xaml
Normal file
8
AIStudio.Wpf.DiagramHelper/Themes/Generic.xaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramHelper;component/Controls/ComboBox.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -12,4 +12,11 @@
|
|||||||
<ProjectReference Include="..\AIStudio.Wpf.DiagramHelper\AIStudio.Wpf.DiagramHelper.csproj" />
|
<ProjectReference Include="..\AIStudio.Wpf.DiagramHelper\AIStudio.Wpf.DiagramHelper.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="Controls\ToolBoxControl.xaml">
|
||||||
|
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
98
AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml
Normal file
98
AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:controls="clr-namespace:AIStudio.Wpf.Flowchart.Controls"
|
||||||
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram">
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Themes/FlowNode.xaml"/>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramHelper;component/Controls/ComboBox.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style x:Key="AIStudio.Styles.FlowchartEditor" TargetType="{x:Type controls:FlowchartEditor}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type controls:FlowchartEditor}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<!-- ToolBox Control -->
|
||||||
|
<ContentControl Template="{Binding ToolBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||||
|
|
||||||
|
<!-- Diagram Control -->
|
||||||
|
<dd:DiagramControl Grid.Column="1" x:Name="PART_DiagramControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||||
|
|
||||||
|
<ContentControl Grid.Column="2" x:Name="properity" Template="{Binding PropertiesBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="AIStudio.Styles.FlowchartEditor.Default" TargetType="{x:Type controls:FlowchartEditor}" BasedOn="{StaticResource AIStudio.Styles.FlowchartEditor}">
|
||||||
|
<Setter Property="ToolBox">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Control">
|
||||||
|
<controls:ToolBoxControl />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Setter Property="PropertiesBox">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Control">
|
||||||
|
<dd:PropertiesView CustomSetting="True"
|
||||||
|
SelectedObject="{Binding Path=SelectedObject,RelativeSource={RelativeSource AncestorType={x:Type controls:FlowchartEditor}}}"
|
||||||
|
Width="200">
|
||||||
|
<dd:PropertiesView.Resources>
|
||||||
|
|
||||||
|
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
|
||||||
|
<Setter Property="ContentTemplate">
|
||||||
|
<Setter.Value>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
|
<ComboBox BorderThickness="0" Text="{Binding ActType}" Style="{StaticResource ComboBoxStyle}">
|
||||||
|
<ComboBoxItem Content="or"/>
|
||||||
|
<ComboBoxItem Content="and"/>
|
||||||
|
</ComboBox>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="UserIdsStyle" TargetType="{x:Type ContentControl}">
|
||||||
|
<Setter Property="ContentTemplate">
|
||||||
|
<Setter.Value>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
|
<dd:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||||
|
SelectedValues="{Binding UserIds}"
|
||||||
|
ItemsSource="{Binding Path=Users,RelativeSource={RelativeSource AncestorType={x:Type controls:FlowchartEditor}}}" ></dd:MultiSelectComboBox>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="RoleIdsStyle" TargetType="{x:Type ContentControl}">
|
||||||
|
<Setter Property="ContentTemplate">
|
||||||
|
<Setter.Value>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||||
|
<dd:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||||
|
SelectedValues="{Binding RoleIds}"
|
||||||
|
ItemsSource="{Binding Path=Roles,RelativeSource={RelativeSource AncestorType={x:Type controls:FlowchartEditor}}}"></dd:MultiSelectComboBox>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</dd:PropertiesView.Resources>
|
||||||
|
</dd:PropertiesView>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type controls:FlowchartEditor}" BasedOn="{StaticResource AIStudio.Styles.FlowchartEditor.Default}" />
|
||||||
|
</ResourceDictionary>
|
||||||
211
AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
Normal file
211
AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.Flowchart.Controls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// FlowchartEditor.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
[TemplatePart(Name = PART_DiagramControl, Type = typeof(DiagramControl))]
|
||||||
|
public partial class FlowchartEditor : UserControl
|
||||||
|
{
|
||||||
|
public const string PART_DiagramControl = "PART_DiagramControl";
|
||||||
|
private DiagramControl _diagramControl;
|
||||||
|
private IDiagramServiceProvider _service
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DiagramServicesProvider.Instance.Provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DiagramViewModel _diagramViewModel = new DiagramViewModel()
|
||||||
|
{
|
||||||
|
ShowGrid = true,
|
||||||
|
GridCellSize = new Size(100, 60),
|
||||||
|
GridMargin = 0d,
|
||||||
|
CellHorizontalAlignment = CellHorizontalAlignment.Center,
|
||||||
|
CellVerticalAlignment = CellVerticalAlignment.Center,
|
||||||
|
PageSizeType = PageSizeType.Custom,
|
||||||
|
PageSize = new Size(double.NaN, double.NaN),
|
||||||
|
};
|
||||||
|
|
||||||
|
static FlowchartEditor()
|
||||||
|
{
|
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(FlowchartEditor), new FrameworkPropertyMetadata(typeof(FlowchartEditor)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlowchartEditor()
|
||||||
|
{
|
||||||
|
_diagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnApplyTemplate()
|
||||||
|
{
|
||||||
|
base.OnApplyTemplate();
|
||||||
|
|
||||||
|
_diagramControl = GetTemplateChild(PART_DiagramControl) as DiagramControl;
|
||||||
|
_diagramControl.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||||
|
_diagramControl.VerticalAlignment = VerticalAlignment.Stretch;
|
||||||
|
_diagramControl.DataContext = _diagramViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DiagramViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == "IsSelected")
|
||||||
|
{
|
||||||
|
SelectedObject = _diagramViewModel.SelectedItems?.FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//一点要绑定不为空的FlowchartModel才能用,即便为空的也要new一个再来绑定
|
||||||
|
public static readonly DependencyProperty FlowchartModelProperty =
|
||||||
|
DependencyProperty.Register(nameof(FlowchartModel),
|
||||||
|
typeof(FlowchartModel),
|
||||||
|
typeof(FlowchartEditor),
|
||||||
|
new FrameworkPropertyMetadata(null, OnFlowchartModelChanged));
|
||||||
|
|
||||||
|
public FlowchartModel FlowchartModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (FlowchartModel)GetValue(FlowchartModelProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(FlowchartModelProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void OnFlowchartModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var view = d as FlowchartEditor;
|
||||||
|
var model = e.NewValue as FlowchartModel;
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
view.CreateFlowchartModel(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateFlowchartModel(FlowchartModel model)
|
||||||
|
{
|
||||||
|
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
|
||||||
|
_diagramViewModel.Items.Clear();
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
foreach (var node in model.Nodes)
|
||||||
|
{
|
||||||
|
_diagramViewModel.DirectAddItemCommand.Execute(node);
|
||||||
|
}
|
||||||
|
foreach (var link in model.Links)
|
||||||
|
{
|
||||||
|
_diagramViewModel.DirectAddItemCommand.Execute(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ToolBox
|
||||||
|
/// <summary>
|
||||||
|
/// 附加组件模板
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty ToolBoxProperty = DependencyProperty.Register(
|
||||||
|
nameof(ToolBox), typeof(ControlTemplate), typeof(FlowchartEditor), new FrameworkPropertyMetadata(default(ControlTemplate)));
|
||||||
|
|
||||||
|
public ControlTemplate ToolBox
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ControlTemplate)GetValue(ToolBoxProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(ToolBoxProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ToolBox
|
||||||
|
/// <summary>
|
||||||
|
/// 附加组件模板
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty PropertiesBoxProperty = DependencyProperty.Register(
|
||||||
|
nameof(PropertiesBox), typeof(ControlTemplate), typeof(FlowchartEditor), new FrameworkPropertyMetadata(default(ControlTemplate)));
|
||||||
|
|
||||||
|
public ControlTemplate PropertiesBox
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (ControlTemplate)GetValue(PropertiesBoxProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(PropertiesBoxProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SelectedObject
|
||||||
|
|
||||||
|
public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty.Register(nameof(SelectedObject), typeof(object), typeof(FlowchartEditor), new UIPropertyMetadata(default(object)));
|
||||||
|
public object SelectedObject
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (object)GetValue(SelectedObjectProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(SelectedObjectProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Users
|
||||||
|
public static readonly DependencyProperty UsersProperty
|
||||||
|
= DependencyProperty.Register(nameof(Users), typeof(List<SelectOption>), typeof(FlowchartEditor), new UIPropertyMetadata(default(List<SelectOption>)));
|
||||||
|
public List<SelectOption> Users
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (List<SelectOption>)GetValue(UsersProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(UsersProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Roles
|
||||||
|
public static readonly DependencyProperty RolesProperty
|
||||||
|
= DependencyProperty.Register(nameof(Roles), typeof(List<SelectOption>), typeof(FlowchartEditor), new UIPropertyMetadata(default(List<SelectOption>)));
|
||||||
|
public List<SelectOption> Roles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (List<SelectOption>)GetValue(RolesProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(RolesProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Test.ToolBoxControl"
|
<UserControl x:Class="AIStudio.Wpf.Flowchart.Controls.ToolBoxControl"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
@@ -6,7 +6,13 @@
|
|||||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Themes/FlowNode.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</UserControl.Resources>
|
||||||
<Border BorderBrush="LightGray" BorderThickness="1">
|
<Border BorderBrush="LightGray" BorderThickness="1">
|
||||||
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
|
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
|
||||||
<ItemsControl.Template>
|
<ItemsControl.Template>
|
||||||
@@ -11,8 +11,9 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner.Test
|
namespace AIStudio.Wpf.Flowchart.Controls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ToolBoxControl.xaml
|
/// Interaction logic for ToolBoxControl.xaml
|
||||||
@@ -22,6 +23,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Test
|
|||||||
public ToolBoxControl()
|
public ToolBoxControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.DataContext = new ToolBoxViewModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
29
AIStudio.Wpf.Flowchart/Models/FlowchartModel.cs
Normal file
29
AIStudio.Wpf.Flowchart/Models/FlowchartModel.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.Flowchart.Models
|
||||||
|
{
|
||||||
|
public class FlowchartModel
|
||||||
|
{
|
||||||
|
private List<FlowNode> _nodes = new List<FlowNode>();
|
||||||
|
public List<FlowNode> Nodes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _nodes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ConnectorViewModel> _links = new List<ConnectorViewModel>();
|
||||||
|
public List<ConnectorViewModel> Links
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _links;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
AIStudio.Wpf.Flowchart/Properties/AssemblyInfo.cs
Normal file
17
AIStudio.Wpf.Flowchart/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
|
|
||||||
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart")]
|
||||||
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart.Controls")]
|
||||||
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart.Controls")]
|
||||||
|
|
||||||
|
[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
|
||||||
8
AIStudio.Wpf.Flowchart/Themes/Generic.xaml
Normal file
8
AIStudio.Wpf.Flowchart/Themes/Generic.xaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Controls/FlowchartEditor.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -7,7 +7,7 @@ using AIStudio.Wpf.Flowchart;
|
|||||||
using AIStudio.Wpf.Flowchart.Models;
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||||
{
|
{
|
||||||
public class ToolBoxViewModel
|
public class ToolBoxViewModel
|
||||||
{
|
{
|
||||||
Reference in New Issue
Block a user