9 Commits

Author SHA1 Message Date
akwkevin
b0c9855d05 保存SFC数据到xml,json完成, 2021-08-03 18:19:47 +08:00
艾竹
5a1f869141 Merge branch 'master' of https://gitee.com/akwkevin/aistudio.-wpf.-diagram 2021-08-02 22:05:25 +08:00
艾竹
d11a3ef2fd 阀门优化 2021-08-02 22:04:58 +08:00
艾竹
9063ca5950 update README.md. 2021-08-02 13:50:45 +00:00
akwkevin
831256336f sfc逻辑基本完成 2021-08-02 18:08:43 +08:00
艾竹
0b8258003f sfc界面处理完成,还差顺序逻辑控制过程 2021-08-01 22:30:12 +08:00
akwkevin
9a0e85e1a9 sfc实现中 2021-07-30 18:26:35 +08:00
akwkevin
336249f313 结构调整,便于后续扩展 2021-07-29 13:55:18 +08:00
艾竹
87be7a8021 update README.md. 2021-07-28 01:19:33 +00:00
164 changed files with 4181 additions and 2384 deletions

View File

@@ -13,16 +13,6 @@
<Page Remove="DesignItems\Custom\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Controls\AnimationHelper.cs" />
<Compile Remove="Controls\CancelRoutedEventArgs.cs" />
<Compile Remove="Controls\ContextMenuToggleButton.cs" />
<Compile Remove="Controls\ScrollViewer.xaml.cs" />
<Compile Remove="Controls\TabControl.xaml.cs" />
<Compile Remove="Controls\TabItem.cs" />
<Compile Remove="Controls\TabPanel.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Icons\App.ico" />
<None Remove="Images\AlignObjectsBottom.png" />
@@ -115,8 +105,6 @@
</ItemGroup>
<ItemGroup>
<Page Remove="Controls\ScrollViewer.xaml" />
<Page Remove="Controls\TabControl.xaml" />
<Page Remove="Images\VectorIcons.xaml" />
</ItemGroup>
@@ -128,13 +116,14 @@
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.8.0" />
<PackageReference Include="MahApps.Metro.IconPacks.VaadinIcons" Version="4.8.0" />
<PackageReference Include="MathParser.org-mXparser" Version="4.4.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Util.Svg2XamlTestExtension" Version="1.2.5" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AIStudio.Wpf.BaseDiagram\AIStudio.Wpf.BaseDiagram.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
<ProjectReference Include="..\Util.DiagramDesigner\Util.DiagramDesigner.csproj" />
</ItemGroup>
@@ -239,32 +228,6 @@
</ItemGroup>
<ItemGroup>
<Page Update="Controls\PopupWindow.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Demos\Logical\ViewModels\LogicalGateItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Demos\Others\ViewModels\BarcodeDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Demos\Others\ViewModels\PersistDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Demos\Others\ViewModels\SettingsDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Demos\Others\ViewModels\OutLineTextDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Demos\Others\ViewModels\PathItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Themes\Generic.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>

View File

@@ -9,6 +9,9 @@
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/Generic.xaml" />
<ResourceDictionary Source="/AIStudio.Wpf.ADiagram;component/Themes/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Logical;component/ViewModels/LogicalGateItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.SFC;component/ViewModels/SFCNode.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -1,10 +0,0 @@
using System.Windows;
[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)
)]

View File

@@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AIStudio.Wpf.ADiagram.Controls
{
public class CancelRoutedEventArgs : RoutedEventArgs
{
public CancelRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
{
}
public bool Cancel { get; set; }
}
}

View File

@@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace AIStudio.Wpf.ADiagram.Controls
{
/// <summary>
/// 带上下文菜单的切换按钮
/// </summary>
public class ContextMenuToggleButton : ToggleButton
{
public ContextMenu Menu { get; set; }
protected override void OnClick()
{
base.OnClick();
if (Menu != null)
{
if (IsChecked == true)
{
Menu.PlacementTarget = this;
Menu.IsOpen = true;
}
else
{
Menu.IsOpen = false;
}
}
}
}
}

View File

@@ -1,58 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Themes/ScrollViewer.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="ScrollViewerBaseControlTemplate" TargetType="controls:ScrollViewer">
<ControlTemplate.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_VerticalScrollBar">
<EasingDoubleKeyFrame KeyTime="0:0:.1" Value=".8"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_HorizontalScrollBar">
<EasingDoubleKeyFrame KeyTime="0:0:.1" Value=".8"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard2">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_VerticalScrollBar">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_HorizontalScrollBar">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.RowSpan="2" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
<ScrollBar x:Name="PART_VerticalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
<ScrollBar x:Name="PART_HorizontalScrollBar" Opacity="0" Style="{StaticResource ScrollBarBaseStyle}" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsMouseOver,RelativeSource={RelativeSource Self}}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
</DataTrigger.ExitActions>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ScrollViewerBaseStyle" TargetType="controls:ScrollViewer">
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template" Value="{StaticResource ScrollViewerBaseControlTemplate}"/>
</Style>
</ResourceDictionary>

View File

@@ -1,237 +0,0 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace AIStudio.Wpf.ADiagram.Controls
{
public class ScrollViewer : System.Windows.Controls.ScrollViewer
{
private double _totalVerticalOffset;
private double _totalHorizontalOffset;
private bool _isRunning;
/// <summary>
/// 滚动方向
/// </summary>
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
"Orientation", typeof(Orientation), typeof(ScrollViewer), new PropertyMetadata(Orientation.Vertical));
/// <summary>
/// 滚动方向
/// </summary>
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
/// <summary>
/// 是否响应鼠标滚轮操作
/// </summary>
public static readonly DependencyProperty CanMouseWheelProperty = DependencyProperty.Register(
"CanMouseWheel", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(true));
/// <summary>
/// 是否响应鼠标滚轮操作
/// </summary>
public bool CanMouseWheel
{
get => (bool)GetValue(CanMouseWheelProperty);
set => SetValue(CanMouseWheelProperty, value);
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
if (!CanMouseWheel) return;
if (!IsInertiaEnabled)
{
if (Orientation == Orientation.Vertical)
{
base.OnMouseWheel(e);
}
else
{
_totalHorizontalOffset = HorizontalOffset;
CurrentHorizontalOffset = HorizontalOffset;
_totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth);
CurrentHorizontalOffset = _totalHorizontalOffset;
}
return;
}
e.Handled = true;
if (Orientation == Orientation.Vertical)
{
if (!_isRunning)
{
_totalVerticalOffset = VerticalOffset;
CurrentVerticalOffset = VerticalOffset;
}
_totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight);
ScrollToVerticalOffsetInternal(_totalVerticalOffset);
}
else
{
if (!_isRunning)
{
_totalHorizontalOffset = HorizontalOffset;
CurrentHorizontalOffset = HorizontalOffset;
}
_totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth);
ScrollToHorizontalOffsetInternal(_totalHorizontalOffset);
}
}
internal void ScrollToTopInternal(double milliseconds = 500)
{
if (!_isRunning)
{
_totalVerticalOffset = VerticalOffset;
CurrentVerticalOffset = VerticalOffset;
}
ScrollToVerticalOffsetInternal(0, milliseconds);
}
internal void ScrollToVerticalOffsetInternal(double offset, double milliseconds = 500)
{
var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase
{
EasingMode = EasingMode.EaseOut
};
animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s, e1) =>
{
CurrentVerticalOffset = offset;
_isRunning = false;
};
_isRunning = true;
BeginAnimation(CurrentVerticalOffsetProperty, animation, HandoffBehavior.Compose);
}
internal void ScrollToHorizontalOffsetInternal(double offset, double milliseconds = 500)
{
var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase
{
EasingMode = EasingMode.EaseOut
};
animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s, e1) =>
{
CurrentHorizontalOffset = offset;
_isRunning = false;
};
_isRunning = true;
BeginAnimation(CurrentHorizontalOffsetProperty, animation, HandoffBehavior.Compose);
}
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) =>
IsPenetrating ? null : base.HitTestCore(hitTestParameters);
/// <summary>
/// 是否支持惯性
/// </summary>
public static readonly DependencyProperty IsInertiaEnabledProperty = DependencyProperty.RegisterAttached(
"IsInertiaEnabled", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(false));
public static void SetIsInertiaEnabled(DependencyObject element, bool value)
{
element.SetValue(IsInertiaEnabledProperty, value);
}
public static bool GetIsInertiaEnabled(DependencyObject element)
{
return (bool)element.GetValue(IsInertiaEnabledProperty);
}
/// <summary>
/// 是否支持惯性
/// </summary>
public bool IsInertiaEnabled
{
get => (bool)GetValue(IsInertiaEnabledProperty);
set => SetValue(IsInertiaEnabledProperty, value);
}
/// <summary>
/// 控件是否可以穿透点击
/// </summary>
public static readonly DependencyProperty IsPenetratingProperty = DependencyProperty.RegisterAttached(
"IsPenetrating", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(false));
/// <summary>
/// 控件是否可以穿透点击
/// </summary>
public bool IsPenetrating
{
get => (bool)GetValue(IsPenetratingProperty);
set => SetValue(IsPenetratingProperty, value);
}
public static void SetIsPenetrating(DependencyObject element, bool value)
{
element.SetValue(IsPenetratingProperty, value);
}
public static bool GetIsPenetrating(DependencyObject element)
{
return (bool)element.GetValue(IsPenetratingProperty);
}
/// <summary>
/// 当前垂直滚动偏移
/// </summary>
internal static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register(
"CurrentVerticalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(0d, OnCurrentVerticalOffsetChanged));
private static void OnCurrentVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ScrollViewer ctl && e.NewValue is double v)
{
ctl.ScrollToVerticalOffset(v);
}
}
/// <summary>
/// 当前垂直滚动偏移
/// </summary>
internal double CurrentVerticalOffset
{
// ReSharper disable once UnusedMember.Local
get => (double)GetValue(CurrentVerticalOffsetProperty);
set => SetValue(CurrentVerticalOffsetProperty, value);
}
/// <summary>
/// 当前水平滚动偏移
/// </summary>
internal static readonly DependencyProperty CurrentHorizontalOffsetProperty = DependencyProperty.Register(
"CurrentHorizontalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(0d, OnCurrentHorizontalOffsetChanged));
private static void OnCurrentHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ScrollViewer ctl && e.NewValue is double v)
{
ctl.ScrollToHorizontalOffset(v);
}
}
/// <summary>
/// 当前水平滚动偏移
/// </summary>
internal double CurrentHorizontalOffset
{
get => (double)GetValue(CurrentHorizontalOffsetProperty);
set => SetValue(CurrentHorizontalOffsetProperty, value);
}
}
}

View File

@@ -1,181 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:interactivity="clr-namespace:Util.Controls.Handy.Interactivity">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Basic/Paths.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Basic/Converters.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Themes/Button.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Themes/RepeatButton.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Util.Controls.Handy;component/Style/Themes/ToggleButton.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ContextMenu x:Key="TabItemMenu" x:Shared="False">
<MenuItem Command="interactivity:ControlCommands.Close" Header="Close"/>
<MenuItem Command="interactivity:ControlCommands.CloseAll" Header="CloseAll"/>
<MenuItem Command="interactivity:ControlCommands.CloseOther" Header="CloseOther"/>
</ContextMenu>
<Style TargetType="controls:TabItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Text}"/>
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.ThemeBackground}"/>
<Setter Property="BorderThickness" Value="1,0,1,1"/>
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.Control.Border}"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="10,0,0,0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Menu" Value="{StaticResource TabItemMenu}"/>
<Setter Property="controls:IconElement.Width" Value="16"/>
<Setter Property="controls:IconElement.Height" Value="16"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Background="Transparent" Text="{Binding Header,RelativeSource={RelativeSource AncestorType=controls:TabItem}}"/>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TabItem">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true" ContextMenu="{TemplateBinding Menu}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="3" BorderThickness="{TemplateBinding BorderThickness}" x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Margin="0">
<Border Margin="0,0,0,-1" x:Name="innerBorder" Background="{DynamicResource MahApps.Brushes.Gray8}" Visibility="Collapsed"/>
</Border>
<Path x:Name="PathMain" Margin="10,0,0,0" Grid.Column="0" Width="{TemplateBinding controls:IconElement.Width}" Height="{TemplateBinding controls:IconElement.Height}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconElement.Geometry}"/>
<ContentPresenter Grid.Column="1" x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="Stretch" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
<Border Name="BorderMask" Grid.Column="1" HorizontalAlignment="Right" Width="20" Background="{TemplateBinding Background}">
<Border.OpacityMask>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="White" Offset="1"/>
<GradientStop Offset="0"/>
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
<Button Grid.Column="2" Focusable="False" Command="interactivity:ControlCommands.Close" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Background="Transparent" Style="{StaticResource ButtonCustom}" Width="28">
<Path Fill="{DynamicResource MahApps.Brushes.Text}" Width="8" Height="8" Style="{StaticResource ClosePathStyle}"/>
</Button>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Visibility" TargetName="innerBorder" Value="Visible"/>
<Setter Property="Background" TargetName="BorderMask" Value="{DynamicResource MahApps.Brushes.Gray8}"/>
</Trigger>
<Trigger Property="controls:IconElement.Geometry" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="PathMain"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="TabControlPlusTemplate" TargetType="controls:TabControl">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Background="{TemplateBinding Background}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}">
<controls:TabPanel MinHeight="{TemplateBinding TabItemHeight}" TabItemHeight="{TemplateBinding TabItemHeight}" TabItemWidth="{TemplateBinding TabItemWidth}" IsTabFillEnabled="{TemplateBinding IsTabFillEnabled}" Margin="0,0,-1,-1" x:Name="PART_HeaderPanel" HorizontalAlignment="Left" Background="{DynamicResource SecondaryTextBrush}" IsItemsHost="true" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1">
<interactivity:Interaction.Behaviors>
<interactivity:FluidMoveBehavior AppliesTo="Children" Duration="{Binding FluidMoveDuration,ElementName=PART_HeaderPanel}">
<interactivity:FluidMoveBehavior.EaseX>
<CubicEase EasingMode="EaseOut"/>
</interactivity:FluidMoveBehavior.EaseX>
</interactivity:FluidMoveBehavior>
</interactivity:Interaction.Behaviors>
</controls:TabPanel>
</Border>
<Border x:Name="contentPanel" Background="{DynamicResource MahApps.Brushes.ThemeBackground}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<Border Visibility="{Binding Visibility,ElementName=PART_OverflowButton}" Margin="0,-1,0,0" Grid.Row="0" Grid.Column="0" BorderThickness="1,0,0,1" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" Background="{DynamicResource MahApps.Brushes.Gray8}" HorizontalAlignment="Right">
<controls:ContextMenuToggleButton x:Name="PART_OverflowButton" Visibility="Collapsed" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource DownGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"/>
</Border>
</Grid>
</Border>
</ControlTemplate>
<ControlTemplate x:Key="TabControlPlusScrollableTemplate" TargetType="controls:TabControl">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Visibility="{TemplateBinding ShowScrollButton,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="0,-1,0,0" Grid.Row="0" Grid.Column="0" BorderThickness="0,0,1,1" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" Background="{DynamicResource MahApps.Brushes.Gray8}" HorizontalAlignment="Left" Panel.ZIndex="2">
<Border.CacheMode>
<BitmapCache SnapsToDevicePixels="True"/>
</Border.CacheMode>
<RepeatButton Focusable="False" Style="{StaticResource RepeatButtonIcon}" Padding="8" controls:IconElement.Geometry="{StaticResource LeftGeometry}" Foreground="{DynamicResource MahApps.Brushes.Text}" Background="{DynamicResource MahApps.Brushes.ThemeBackground}" x:Name="PART_ScrollButtonLeft"/>
</Border>
<controls:ScrollViewer HorizontalScrollBarVisibility="Hidden" CanMouseWheel="True" Orientation="Horizontal" IsInertiaEnabled="True" Grid.Row="0" Grid.Column="1" IsDeferredScrollingEnabled="True" x:Name="PART_OverflowScrollviewer">
<Border Background="{TemplateBinding Background}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" Name="PART_HeaderBorder">
<controls:TabPanel MinHeight="{TemplateBinding TabItemHeight}" TabItemHeight="{TemplateBinding TabItemHeight}" TabItemWidth="{TemplateBinding TabItemWidth}" IsTabFillEnabled="{TemplateBinding IsTabFillEnabled}" Margin="0,0,-1,-1" x:Name="PART_HeaderPanel" HorizontalAlignment="Left" Background="{DynamicResource SecondaryTextBrush}" IsItemsHost="true" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1">
<interactivity:Interaction.Behaviors>
<interactivity:FluidMoveBehavior AppliesTo="Children" Duration="{Binding FluidMoveDuration,ElementName=PART_HeaderPanel}">
<interactivity:FluidMoveBehavior.EaseX>
<CubicEase EasingMode="EaseOut"/>
</interactivity:FluidMoveBehavior.EaseX>
</interactivity:FluidMoveBehavior>
</interactivity:Interaction.Behaviors>
</controls:TabPanel>
</Border>
</controls:ScrollViewer>
<Border Margin="0,-1,0,0" Grid.Row="0" Grid.Column="2" BorderThickness="1,0,0,1" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" Background="{DynamicResource MahApps.Brushes.Gray8}" HorizontalAlignment="Right">
<Border.CacheMode>
<BitmapCache SnapsToDevicePixels="True"/>
</Border.CacheMode>
<StackPanel Orientation="Horizontal">
<RepeatButton Focusable="False" Visibility="{TemplateBinding ShowScrollButton,Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource RepeatButtonIcon}" BorderBrush="{DynamicResource MahApps.Brushes.Control.Border}" Padding="8" controls:IconElement.Geometry="{StaticResource RightGeometry}" Foreground="{DynamicResource MahApps.Brushes.Text}" Background="{DynamicResource MahApps.Brushes.ThemeBackground}" x:Name="PART_ScrollButtonRight"/>
<Border Visibility="{Binding Visibility,ElementName=PART_OverflowButton}" Width="1" Background="{DynamicResource MahApps.Brushes.Control.Border}"/>
<controls:ContextMenuToggleButton x:Name="PART_OverflowButton" Visibility="Collapsed" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource DownGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"/>
</StackPanel>
</Border>
<Border x:Name="contentPanel" Background="{DynamicResource MahApps.Brushes.ThemeBackground}" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</Border>
</ControlTemplate>
<Style TargetType="controls:TabControl">
<Setter Property="Padding" Value="0"/>
<Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray8}"/>
<Setter Property="BorderBrush" Value="{DynamicResource MahApps.Brushes.Control.Border}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template" Value="{StaticResource TabControlPlusTemplate}"/>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsScrollable" Value="True"/>
<Condition Property="IsTabFillEnabled" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Template" Value="{StaticResource TabControlPlusScrollableTemplate}"/>
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -1,443 +0,0 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Controls
{
[TemplatePart(Name = OverflowButtonKey, Type = typeof(ContextMenuToggleButton))]
[TemplatePart(Name = HeaderPanelKey, Type = typeof(TabPanel))]
[TemplatePart(Name = OverflowScrollviewer, Type = typeof(ScrollViewer))]
[TemplatePart(Name = ScrollButtonLeft, Type = typeof(ButtonBase))]
[TemplatePart(Name = ScrollButtonRight, Type = typeof(ButtonBase))]
[TemplatePart(Name = HeaderBorder, Type = typeof(System.Windows.Controls.Border))]
public class TabControl : System.Windows.Controls.TabControl
{
private const string OverflowButtonKey = "PART_OverflowButton";
private const string HeaderPanelKey = "PART_HeaderPanel";
private const string OverflowScrollviewer = "PART_OverflowScrollviewer";
private const string ScrollButtonLeft = "PART_ScrollButtonLeft";
private const string ScrollButtonRight = "PART_ScrollButtonRight";
private const string HeaderBorder = "PART_HeaderBorder";
private ContextMenuToggleButton _buttonOverflow;
internal TabPanel HeaderPanel { get; private set; }
private ScrollViewer _scrollViewerOverflow;
private ButtonBase _buttonScrollLeft;
private ButtonBase _buttonScrollRight;
private System.Windows.Controls.Border _headerBorder;
/// <summary>
/// 是否为内部操作
/// </summary>
internal bool IsInternalAction;
/// <summary>
/// 是否启用动画
/// </summary>
public static readonly DependencyProperty IsAnimationEnabledProperty = DependencyProperty.Register(
"IsAnimationEnabled", typeof(bool), typeof(TabControl), new PropertyMetadata(false));
/// <summary>
/// 是否启用动画
/// </summary>
public bool IsAnimationEnabled
{
get => (bool)GetValue(IsAnimationEnabledProperty);
set => SetValue(IsAnimationEnabledProperty, value);
}
/// <summary>
/// 是否可以拖动
/// </summary>
public static readonly DependencyProperty IsDraggableProperty = DependencyProperty.Register(
"IsDraggable", typeof(bool), typeof(TabControl), new PropertyMetadata(false));
/// <summary>
/// 是否可以拖动
/// </summary>
public bool IsDraggable
{
get => (bool)GetValue(IsDraggableProperty);
set => SetValue(IsDraggableProperty, value);
}
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.RegisterAttached(
"ShowCloseButton", typeof(bool), typeof(TabControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits));
public static void SetShowCloseButton(DependencyObject element, bool value)
=> element.SetValue(ShowCloseButtonProperty, value);
public static bool GetShowCloseButton(DependencyObject element)
=> (bool) element.GetValue(ShowCloseButtonProperty);
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public bool ShowCloseButton
{
get => (bool)GetValue(ShowCloseButtonProperty);
set => SetValue(ShowCloseButtonProperty, value);
}
/// <summary>
/// 是否显示上下文菜单
/// </summary>
public static readonly DependencyProperty ShowContextMenuProperty = DependencyProperty.RegisterAttached(
"ShowContextMenu", typeof(bool), typeof(TabControl), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits));
public static void SetShowContextMenu(DependencyObject element, bool value)
=> element.SetValue(ShowContextMenuProperty, value);
public static bool GetShowContextMenu(DependencyObject element)
=> (bool) element.GetValue(ShowContextMenuProperty);
/// <summary>
/// 是否显示上下文菜单
/// </summary>
public bool ShowContextMenu
{
get => (bool)GetValue(ShowContextMenuProperty);
set => SetValue(ShowContextMenuProperty, value);
}
/// <summary>
/// 是否将标签填充
/// </summary>
public static readonly DependencyProperty IsTabFillEnabledProperty = DependencyProperty.Register(
"IsTabFillEnabled", typeof(bool), typeof(TabControl), new PropertyMetadata(false));
/// <summary>
/// 是否将标签填充
/// </summary>
public bool IsTabFillEnabled
{
get => (bool)GetValue(IsTabFillEnabledProperty);
set => SetValue(IsTabFillEnabledProperty, value);
}
/// <summary>
/// 标签宽度
/// </summary>
public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register(
"TabItemWidth", typeof(double), typeof(TabControl), new PropertyMetadata(200.0));
/// <summary>
/// 标签宽度
/// </summary>
public double TabItemWidth
{
get => (double)GetValue(TabItemWidthProperty);
set => SetValue(TabItemWidthProperty, value);
}
/// <summary>
/// 标签高度
/// </summary>
public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register(
"TabItemHeight", typeof(double), typeof(TabControl), new PropertyMetadata(30.0));
/// <summary>
/// 标签高度
/// </summary>
public double TabItemHeight
{
get => (double)GetValue(TabItemHeightProperty);
set => SetValue(TabItemHeightProperty, value);
}
/// <summary>
/// 是否可以滚动
/// </summary>
public static readonly DependencyProperty IsScrollableProperty = DependencyProperty.Register(
"IsScrollable", typeof(bool), typeof(TabControl), new PropertyMetadata(false));
/// <summary>
/// 是否可以滚动
/// </summary>
public bool IsScrollable
{
get => (bool) GetValue(IsScrollableProperty);
set => SetValue(IsScrollableProperty, value);
}
/// <summary>
/// 是否显示溢出按钮
/// </summary>
public static readonly DependencyProperty ShowOverflowButtonProperty = DependencyProperty.Register(
"ShowOverflowButton", typeof(bool), typeof(TabControl), new PropertyMetadata(true));
/// <summary>
/// 是否显示溢出按钮
/// </summary>
public bool ShowOverflowButton
{
get => (bool) GetValue(ShowOverflowButtonProperty);
set => SetValue(ShowOverflowButtonProperty, value);
}
/// <summary>
/// 是否显示滚动按钮
/// </summary>
public static readonly DependencyProperty ShowScrollButtonProperty = DependencyProperty.Register(
"ShowScrollButton", typeof(bool), typeof(TabControl), new PropertyMetadata(false));
/// <summary>
/// 是否显示滚动按钮
/// </summary>
public bool ShowScrollButton
{
get => (bool) GetValue(ShowScrollButtonProperty);
set => SetValue(ShowScrollButtonProperty, value);
}
/// <summary>
/// 可见的标签数量
/// </summary>
private int _itemShowCount;
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
if (HeaderPanel == null)
{
IsInternalAction = false;
return;
}
UpdateOverflowButton();
if (IsInternalAction)
{
IsInternalAction = false;
return;
}
if (IsAnimationEnabled)
{
HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200)));
}
else
{
HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
}
if (e.Action == NotifyCollectionChangedAction.Add)
{
for (var i = 0; i < Items.Count; i++)
{
if (!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) return;
item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
item.TabPanel = HeaderPanel;
}
}
_headerBorder?.InvalidateMeasure();
IsInternalAction = false;
}
public override void OnApplyTemplate()
{
if (_buttonOverflow != null)
{
if (_buttonOverflow.Menu != null)
{
_buttonOverflow.Menu.Closed -= Menu_Closed;
_buttonOverflow.Menu = null;
}
_buttonOverflow.Click -= ButtonOverflow_Click;
}
if (_buttonScrollLeft != null) _buttonScrollLeft.Click -= ButtonScrollLeft_Click;
if (_buttonScrollRight != null) _buttonScrollRight.Click -= ButtonScrollRight_Click;
base.OnApplyTemplate();
HeaderPanel = GetTemplateChild(HeaderPanelKey) as TabPanel;
if (IsTabFillEnabled) return;
_buttonOverflow = GetTemplateChild(OverflowButtonKey) as ContextMenuToggleButton;
_scrollViewerOverflow = GetTemplateChild(OverflowScrollviewer) as ScrollViewer;
_buttonScrollLeft = GetTemplateChild(ScrollButtonLeft) as ButtonBase;
_buttonScrollRight = GetTemplateChild(ScrollButtonRight) as ButtonBase;
_headerBorder = GetTemplateChild(HeaderBorder) as System.Windows.Controls.Border;
if (_buttonScrollLeft != null) _buttonScrollLeft.Click += ButtonScrollLeft_Click;
if (_buttonScrollRight != null) _buttonScrollRight.Click += ButtonScrollRight_Click;
if (_buttonOverflow != null)
{
var menu = new System.Windows.Controls.ContextMenu
{
Placement = PlacementMode.Bottom,
PlacementTarget = _buttonOverflow
};
menu.Closed += Menu_Closed;
_buttonOverflow.Menu = menu;
_buttonOverflow.Click += ButtonOverflow_Click;
}
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
UpdateOverflowButton();
}
private void UpdateOverflowButton()
{
if (!IsTabFillEnabled)
{
_itemShowCount = (int)(ActualWidth / TabItemWidth);
if (_buttonOverflow != null)
{
_buttonOverflow.Visibility = (ShowOverflowButton && Items.Count > 0 && Items.Count >= _itemShowCount) ? Visibility.Visible : Visibility.Collapsed;
}
}
}
private void Menu_Closed(object sender, RoutedEventArgs e) => _buttonOverflow.IsChecked = false;
private void ButtonScrollRight_Click(object sender, RoutedEventArgs e) =>
_scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Min(
_scrollViewerOverflow.CurrentHorizontalOffset + TabItemWidth, _scrollViewerOverflow.ScrollableWidth));
private void ButtonScrollLeft_Click(object sender, RoutedEventArgs e) =>
_scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Max(
_scrollViewerOverflow.CurrentHorizontalOffset - TabItemWidth, 0));
private void ButtonOverflow_Click(object sender, RoutedEventArgs e)
{
if (_buttonOverflow.IsChecked == true)
{
_buttonOverflow.Menu.Items.Clear();
for (var i = 0; i < Items.Count; i++)
{
if(!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) continue;
var menuItem = new System.Windows.Controls.MenuItem
{
HeaderStringFormat = ItemStringFormat,
HeaderTemplate = ItemTemplate,
HeaderTemplateSelector = ItemTemplateSelector,
Header = item.Header,
Width = TabItemWidth,
IsChecked = item.IsSelected,
IsCheckable = true
};
menuItem.Click += delegate
{
_buttonOverflow.IsChecked = false;
var list = GetActualList();
if (list == null) return;
var actualItem = ItemContainerGenerator.ItemFromContainer(item);
if (actualItem == null) return;
var index = list.IndexOf(actualItem);
if (index >= _itemShowCount)
{
list.Remove(actualItem);
list.Insert(0, actualItem);
if (IsAnimationEnabled)
{
HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200)));
}
else
{
HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
}
HeaderPanel.ForceUpdate = true;
HeaderPanel.Measure(new Size(HeaderPanel.DesiredSize.Width, ActualHeight));
HeaderPanel.ForceUpdate = false;
SetCurrentValue(SelectedIndexProperty, 0);
}
item.IsSelected = true;
};
_buttonOverflow.Menu.Items.Add(menuItem);
}
}
}
internal double GetHorizontalOffset() => _scrollViewerOverflow?.CurrentHorizontalOffset ?? 0;
internal void UpdateScroll() => _scrollViewerOverflow?.RaiseEvent(new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, 0)
{
RoutedEvent = MouseWheelEvent
});
internal void CloseAllItems() => CloseOtherItems(null);
internal void CloseOtherItems(TabItem currentItem)
{
var actualItem = currentItem != null ? ItemContainerGenerator.ItemFromContainer(currentItem) : null;
var list = GetActualList();
if (list == null) return;
IsInternalAction = true;
for (var i = 0; i < Items.Count; i++)
{
var item = list[i];
if (!Equals(item, actualItem) && item != null)
{
var argsClosing = new CancelRoutedEventArgs(TabItem.ClosingEvent, item);
if (!(ItemContainerGenerator.ContainerFromItem(item) is TabItem tabItem)) continue;
tabItem.RaiseEvent(argsClosing);
if (argsClosing.Cancel) return;
tabItem.RaiseEvent(new RoutedEventArgs(TabItem.ClosedEvent, item));
list.Remove(item);
i--;
}
}
SetCurrentValue(SelectedIndexProperty, Items.Count == 0 ? -1 : 0);
}
internal IList GetActualList()
{
IList list;
if (ItemsSource != null)
{
list = ItemsSource as IList;
}
else
{
list = Items;
}
return list;
}
protected override bool IsItemItsOwnContainerOverride(object item) => item is TabItem;
protected override DependencyObject GetContainerForItemOverride() => new TabItem();
}
}

View File

@@ -1,467 +0,0 @@
using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace AIStudio.Wpf.ADiagram.Controls
{
public class TabItem : System.Windows.Controls.TabItem
{
/// <summary>
/// 动画速度
/// </summary>
private const int AnimationSpeed = 150;
/// <summary>
/// 选项卡是否处于拖动状态
/// </summary>
private static bool ItemIsDragging;
/// <summary>
/// 选项卡是否等待被拖动
/// </summary>
private bool _isWaiting;
/// <summary>
/// 拖动中的选项卡坐标
/// </summary>
private Point _dragPoint;
/// <summary>
/// 鼠标按下时选项卡位置
/// </summary>
private int _mouseDownIndex;
/// <summary>
/// 鼠标按下时选项卡横向偏移
/// </summary>
private double _mouseDownOffsetX;
/// <summary>
/// 鼠标按下时的坐标
/// </summary>
private Point _mouseDownPoint;
/// <summary>
/// 右侧可移动的最大值
/// </summary>
private double _maxMoveRight;
/// <summary>
/// 左侧可移动的最大值
/// </summary>
private double _maxMoveLeft;
/// <summary>
/// 选项卡宽度
/// </summary>
public double ItemWidth { get; internal set; }
/// <summary>
/// 选项卡拖动等待距离在鼠标移动了超过20个像素无关单位后选项卡才开始被拖动
/// </summary>
private const double WaitLength = 20;
/// <summary>
/// 选项卡是否处于拖动状态
/// </summary>
private bool _isDragging;
/// <summary>
/// 选项卡是否已经被拖动
/// </summary>
private bool _isDragged;
/// <summary>
/// 目标横向位移
/// </summary>
internal double TargetOffsetX { get; set; }
/// <summary>
/// 当前编号
/// </summary>
private int _currentIndex;
/// <summary>
/// 标签容器横向滚动距离
/// </summary>
private double _scrollHorizontalOffset;
private TabPanel _tabPanel;
/// <summary>
/// 标签容器
/// </summary>
internal TabPanel TabPanel
{
get
{
if (_tabPanel == null && TabControlParent != null)
{
_tabPanel = TabControlParent.HeaderPanel;
}
return _tabPanel;
}
set => _tabPanel = value;
}
/// <summary>
/// 当前编号
/// </summary>
internal int CurrentIndex
{
get => _currentIndex;
set
{
if (_currentIndex == value || value < 0) return;
var oldIndex = _currentIndex;
_currentIndex = value;
UpdateItemOffsetX(oldIndex);
}
}
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public static readonly DependencyProperty ShowCloseButtonProperty =
TabControl.ShowCloseButtonProperty.AddOwner(typeof(TabItem));
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public bool ShowCloseButton
{
get => (bool)GetValue(ShowCloseButtonProperty);
set => SetValue(ShowCloseButtonProperty, value);
}
public static void SetShowCloseButton(DependencyObject element, bool value)
=> element.SetValue(ShowCloseButtonProperty, value);
public static bool GetShowCloseButton(DependencyObject element)
=> (bool)element.GetValue(ShowCloseButtonProperty);
/// <summary>
/// 是否显示上下文菜单
/// </summary>
public static readonly DependencyProperty ShowContextMenuProperty =
TabControl.ShowContextMenuProperty.AddOwner(typeof(TabItem), new FrameworkPropertyMetadata(OnShowContextMenuChanged));
private static void OnShowContextMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (TabItem) d;
if (ctl.Menu != null)
{
var show = (bool)e.NewValue;
ctl.Menu.IsEnabled = show;
ctl.Menu.Show(show);
}
}
/// <summary>
/// 是否显示上下文菜单
/// </summary>
public bool ShowContextMenu
{
get => (bool) GetValue(ShowContextMenuProperty);
set => SetValue(ShowContextMenuProperty, value);
}
public static void SetShowContextMenu(DependencyObject element, bool value)
=> element.SetValue(ShowContextMenuProperty, value);
public static bool GetShowContextMenu(DependencyObject element)
=> (bool)element.GetValue(ShowContextMenuProperty);
public static readonly DependencyProperty MenuProperty = DependencyProperty.Register(
"Menu", typeof(System.Windows.Controls.ContextMenu), typeof(TabItem), new PropertyMetadata(default(System.Windows.Controls.ContextMenu), OnMenuChanged));
private static void OnMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (TabItem) d;
ctl.OnMenuChanged(e.NewValue as System.Windows.Controls.ContextMenu);
}
private void OnMenuChanged(System.Windows.Controls.ContextMenu menu)
{
if (IsLoaded && menu != null)
{
var parent = TabControlParent;
if (parent == null) return;
var item = parent.ItemContainerGenerator.ItemFromContainer(this);
menu.DataContext = item;
menu.SetBinding(IsEnabledProperty, new Binding(ShowContextMenuProperty.Name)
{
Source = this
});
menu.SetBinding(VisibilityProperty, new Binding(ShowContextMenuProperty.Name)
{
Source = this,
Converter = ResourceHelper.GetResource<IValueConverter>("Boolean2VisibilityConverter")
});
}
}
public System.Windows.Controls.ContextMenu Menu
{
get => (System.Windows.Controls.ContextMenu) GetValue(MenuProperty);
set => SetValue(MenuProperty, value);
}
/// <summary>
/// 更新选项卡横向偏移
/// </summary>
/// <param name="oldIndex"></param>
private void UpdateItemOffsetX(int oldIndex)
{
if (!_isDragging) return;
var moveItem = TabPanel.ItemDic[CurrentIndex];
moveItem.CurrentIndex -= CurrentIndex - oldIndex;
var offsetX = moveItem.TargetOffsetX;
var resultX = offsetX + (oldIndex - CurrentIndex) * ItemWidth;
TabPanel.ItemDic[CurrentIndex] = this;
TabPanel.ItemDic[moveItem.CurrentIndex] = moveItem;
moveItem.CreateAnimation(offsetX, resultX);
}
public TabItem()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
CommandBindings.Add(new CommandBinding(ControlCommands.CloseAll,
(s, e) => { TabControlParent.CloseAllItems(); }));
CommandBindings.Add(new CommandBinding(ControlCommands.CloseOther,
(s, e) => { TabControlParent.CloseOtherItems(this); }));
Loaded += (s, e) => OnMenuChanged(Menu);
}
private Util.Controls.Handy.TabControls.TabControl TabControlParent => System.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(this) as TabControl;
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
{
base.OnMouseRightButtonDown(e);
IsSelected = true;
Focus();
}
protected override void OnHeaderChanged(object oldHeader, object newHeader)
{
base.OnHeaderChanged(oldHeader, newHeader);
if (TabPanel != null)
{
TabPanel.ForceUpdate = true;
InvalidateMeasure();
TabPanel.ForceUpdate = true;
}
}
internal void Close()
{
var parent = TabControlParent;
if (parent == null) return;
var item = parent.ItemContainerGenerator.ItemFromContainer(this);
var argsClosing = new CancelRoutedEventArgs(ClosingEvent, item);
RaiseEvent(argsClosing);
if (argsClosing.Cancel) return;
TabPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, parent.IsAnimationEnabled
? new Duration(TimeSpan.FromMilliseconds(200))
: new Duration(TimeSpan.FromMilliseconds(1)));
parent.IsInternalAction = true;
RaiseEvent(new RoutedEventArgs(ClosedEvent, item));
var list = parent.GetActualList();
list?.Remove(item);
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
var parent = TabControlParent;
if (parent == null) return;
if (parent.IsDraggable && !ItemIsDragging && !_isDragging)
{
parent.UpdateScroll();
TabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
_mouseDownOffsetX = RenderTransform.Value.OffsetX;
_scrollHorizontalOffset = parent.GetHorizontalOffset();
var mx = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset;
_mouseDownIndex = CalLocationIndex(mx);
var subIndex = _mouseDownIndex - CalLocationIndex(_scrollHorizontalOffset);
_maxMoveLeft = -subIndex * ItemWidth;
_maxMoveRight = parent.ActualWidth - ActualWidth + _maxMoveLeft;
_isDragging = true;
ItemIsDragging = true;
_isWaiting = true;
_dragPoint = e.GetPosition(parent);
_dragPoint = new Point(_dragPoint.X + _scrollHorizontalOffset, _dragPoint.Y);
_mouseDownPoint = _dragPoint;
CaptureMouse();
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (ItemIsDragging && _isDragging)
{
var parent = TabControlParent;
if (parent == null) return;
var subX = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset;
CurrentIndex = CalLocationIndex(subX);
var p = e.GetPosition(parent);
p = new Point(p.X + _scrollHorizontalOffset, p.Y);
var subLeft = p.X - _dragPoint.X;
var totalLeft = p.X - _mouseDownPoint.X;
if (Math.Abs(subLeft) <= WaitLength && _isWaiting) return;
_isWaiting = false;
_isDragged = true;
var left = subLeft + RenderTransform.Value.OffsetX;
if (totalLeft < _maxMoveLeft)
{
left = _maxMoveLeft + _mouseDownOffsetX;
}
else if (totalLeft > _maxMoveRight)
{
left = _maxMoveRight + _mouseDownOffsetX;
}
var t = new TranslateTransform(left, 0);
RenderTransform = t;
_dragPoint = p;
}
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
ReleaseMouseCapture();
if (_isDragged)
{
var parent = TabControlParent;
if (parent == null) return;
var subX = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset;
var index = CalLocationIndex(subX);
var left = index * ItemWidth;
var offsetX = RenderTransform.Value.OffsetX;
CreateAnimation(offsetX, offsetX - subX + left, index);
}
_isDragging = false;
ItemIsDragging = false;
_isDragged = false;
}
/// <summary>
/// 创建动画
/// </summary>
internal void CreateAnimation(double offsetX, double resultX, int index = -1)
{
var parent = TabControlParent;
void AnimationCompleted()
{
RenderTransform = new TranslateTransform(resultX, 0);
if (index == -1) return;
var list = parent.GetActualList();
if (list == null) return;
var item = parent.ItemContainerGenerator.ItemFromContainer(this);
if (item == null) return;
TabPanel.CanUpdate = false;
parent.IsInternalAction = true;
list.Remove(item);
parent.IsInternalAction = true;
list.Insert(index, item);
TabPanel.CanUpdate = true;
TabPanel.ForceUpdate = true;
TabPanel.Measure(new Size(TabPanel.DesiredSize.Width, ActualHeight));
TabPanel.ForceUpdate = false;
Focus();
IsSelected = true;
if (!IsMouseCaptured)
{
parent.SetCurrentValue(Selector.SelectedIndexProperty, _currentIndex);
}
}
TargetOffsetX = resultX;
if (!parent.IsAnimationEnabled)
{
AnimationCompleted();
return;
}
var animation = AnimationHelper.CreateAnimation(resultX, AnimationSpeed);
animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s1, e1) => AnimationCompleted();
var f = new TranslateTransform(offsetX, 0);
RenderTransform = f;
f.BeginAnimation(TranslateTransform.XProperty, animation, HandoffBehavior.Compose);
}
/// <summary>
/// 计算选项卡当前合适的位置编号
/// </summary>
/// <param name="left"></param>
/// <returns></returns>
private int CalLocationIndex(double left)
{
if (_isWaiting)
{
return CurrentIndex;
}
var maxIndex = TabControlParent.Items.Count - 1;
var div = (int)(left / ItemWidth);
var rest = left % ItemWidth;
var result = rest / ItemWidth > .5 ? div + 1 : div;
return result > maxIndex ? maxIndex : result;
}
public static readonly RoutedEvent ClosingEvent = EventManager.RegisterRoutedEvent("Closing", RoutingStrategy.Bubble, typeof(EventHandler), typeof(TabItem));
public event EventHandler Closing
{
add => AddHandler(ClosingEvent, value);
remove => RemoveHandler(ClosingEvent, value);
}
public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent("Closed", RoutingStrategy.Bubble, typeof(EventHandler), typeof(TabItem));
public event EventHandler Closed
{
add => AddHandler(ClosedEvent, value);
remove => RemoveHandler(ClosedEvent, value);
}
}
}

View File

@@ -1,172 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Controls
{
public class TabPanel : System.Windows.Controls.Panel
{
private int _itemCount;
/// <summary>
/// 是否可以更新
/// </summary>
internal bool CanUpdate = true;
/// <summary>
/// 选项卡字典
/// </summary>
internal Dictionary<int, TabItem> ItemDic = new Dictionary<int, TabItem>();
/// <summary>
/// 流式行为持续时间
/// </summary>
public static readonly DependencyProperty FluidMoveDurationProperty = DependencyProperty.Register(
"FluidMoveDuration", typeof(Duration), typeof(TabPanel), new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(200))));
/// <summary>
/// 流式行为持续时间
/// </summary>
public Duration FluidMoveDuration
{
get => (Duration)GetValue(FluidMoveDurationProperty);
set => SetValue(FluidMoveDurationProperty, value);
}
/// <summary>
/// 是否将标签填充
/// </summary>
public static readonly DependencyProperty IsTabFillEnabledProperty = DependencyProperty.Register(
"IsTabFillEnabled", typeof(bool), typeof(TabPanel), new PropertyMetadata(ValueBoxes.FalseBox));
/// <summary>
/// 是否将标签填充
/// </summary>
public bool IsTabFillEnabled
{
get => (bool)GetValue(IsTabFillEnabledProperty);
set => SetValue(IsTabFillEnabledProperty, value);
}
/// <summary>
/// 标签宽度
/// </summary>
public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register(
"TabItemWidth", typeof(double), typeof(TabPanel), new PropertyMetadata(200.0));
/// <summary>
/// 标签宽度
/// </summary>
public double TabItemWidth
{
get => (double)GetValue(TabItemWidthProperty);
set => SetValue(TabItemWidthProperty, value);
}
/// <summary>
/// 标签高度
/// </summary>
public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register(
"TabItemHeight", typeof(double), typeof(TabPanel), new PropertyMetadata(30.0));
/// <summary>
/// 标签高度
/// </summary>
public double TabItemHeight
{
get => (double)GetValue(TabItemHeightProperty);
set => SetValue(TabItemHeightProperty, value);
}
/// <summary>
/// 是否可以强制更新
/// </summary>
internal bool ForceUpdate;
private Size _oldSize;
/// <summary>
/// 是否已经加载
/// </summary>
private bool _isLoaded;
protected override Size MeasureOverride(Size constraint)
{
if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate) return _oldSize;
constraint.Height = TabItemHeight;
_itemCount = InternalChildren.Count;
var size = new Size();
ItemDic.Clear();
var count = InternalChildren.Count;
if (count == 0)
{
_oldSize = new Size();
return _oldSize;
}
constraint.Width += InternalChildren.Count;
var itemWidth = .0;
var arr = new int[count];
if (!IsTabFillEnabled)
{
itemWidth = TabItemWidth;
}
else
{
if (TemplatedParent is TabControl tabControl)
{
arr = ArithmeticHelper.DivideInt2Arr((int)tabControl.ActualWidth + InternalChildren.Count, count);
}
}
for (var index = 0; index < count; index++)
{
if (IsTabFillEnabled)
{
itemWidth = arr[index];
}
if (InternalChildren[index] is TabItem tabItem)
{
tabItem.RenderTransform = new TranslateTransform();
tabItem.MaxWidth = itemWidth;
var rect = new Rect
{
X = size.Width - tabItem.BorderThickness.Left,
Width = itemWidth,
Height = TabItemHeight
};
tabItem.Arrange(rect);
tabItem.ItemWidth = itemWidth - tabItem.BorderThickness.Left;
tabItem.CurrentIndex = index;
tabItem.TargetOffsetX = 0;
ItemDic[index] = tabItem;
size.Width += tabItem.ItemWidth;
}
}
size.Height = constraint.Height;
_oldSize = size;
return _oldSize;
}
public TabPanel()
{
Loaded += (s, e) =>
{
if (_isLoaded) return;
ForceUpdate = true;
Measure(new Size(DesiredSize.Width, ActualHeight));
ForceUpdate = false;
foreach (var item in ItemDic.Values)
{
item.TabPanel = this;
}
_isLoaded = true;
};
}
}
}

View File

@@ -21,7 +21,7 @@
"ItemWidth": 65.0,
"ItemHeight": 65.0,
"Icon": "M 0,0 H 60 V 40 C 30,30 30,50 0,40 Z",
"ItemTypeName": "AIStudio.Wpf.ADiagram.Demos.Others.PathItemViewModel",
"ItemTypeName": "AIStudio.Wpf.BaseDiagram.Extensions.ViewModels.PathItemViewModel",
"Id": "da395032-ad9e-4dab-a035-f59bed5cb4c4",
"ZIndex": 0,
"IsGroup": false,
@@ -93,76 +93,6 @@
],
"FlowNodeDesignerItems": [
],
"AllDesignerItems": [
{
"Left": 132.80000000000007,
"Top": 101.26000022888184,
"Margin": 0.0,
"ItemWidth": 65.0,
"ItemHeight": 65.0,
"Icon": "M 0,0 H 60 V 40 C 30,30 30,50 0,40 Z",
"ItemTypeName": "AIStudio.Wpf.ADiagram.Demos.Others.PathItemViewModel",
"Id": "da395032-ad9e-4dab-a035-f59bed5cb4c4",
"ZIndex": 0,
"IsGroup": false,
"ParentId": "00000000-0000-0000-0000-000000000000",
"Text": "欢迎来到AIStudio画板",
"ColorItem": {
"LineColor": {
"BrushType": 1,
"Color": "#FF808080",
"GradientStop": null,
"Offset": null,
"Image": null,
"SubType": 0,
"StartPoint": "0,0",
"EndPoint": "0,0",
"Opacity": 1.0,
"LinearOrientation": 0,
"RadialOrientation": 0,
"Angle": 0
},
"FillColor": {
"BrushType": 1,
"Color": "#FFFFA500",
"GradientStop": null,
"Offset": null,
"Image": null,
"SubType": 0,
"StartPoint": "0,0",
"EndPoint": "0,0",
"Opacity": 1.0,
"LinearOrientation": 0,
"RadialOrientation": 0,
"Angle": 0
},
"ShadowColor": "#00FFFFFF",
"LineWidth": 1.0,
"LeftArrowPathStyle": 0,
"RightArrowPathStyle": 1,
"LeftArrowSizeStyle": 10,
"RightArrowSizeStyle": 10
},
"FontItem": {
"FontWeight": "Normal",
"FontStyle": "Normal",
"FontStretch": "Normal",
"Underline": false,
"Strikethrough": false,
"OverLine": false,
"FontColor": "#FF000000",
"FontFamily": "Arial",
"FontSize": 11.0,
"FontObject": "Arial, 11pt",
"TextEffectColor": "#00FFFFFF",
"HighlightColor": "#00FFFFFF",
"FontCase": 0,
"HorizontalAlignment": 1,
"VerticalAlignment": 1,
"LineHeight": 0.0
}
}
],
"ConnectionIds": [
],
"Connections": [

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Enums
namespace AIStudio.Wpf.ADiagram.Models
{
public enum ColorType
{

View File

@@ -7,9 +7,16 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using AIStudio.Wpf.ADiagram.Demos.Flowchart;
using AIStudio.Wpf.ADiagram.Demos.Others;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels;
using AIStudio.Wpf.BaseDiagram.Extensions.Models;
using Newtonsoft.Json;
using AIStudio.Wpf.Flowchart.Models;
using AIStudio.Wpf.Flowchart.ViewModels;
using AIStudio.Wpf.SFC.Models;
using AIStudio.Wpf.SFC.ViewModels;
using System.Windows;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Models
{
@@ -17,7 +24,7 @@ namespace AIStudio.Wpf.ADiagram.Models
public class DiagramItem
{
public DiagramItem()
{
{
this.ConnectionIds = new List<Guid>();
this.Connections = new List<ConnectionItem>();
}
@@ -28,6 +35,75 @@ namespace AIStudio.Wpf.ADiagram.Models
[XmlAttribute]
public DiagramType DiagramType { get; set; }
[XmlAttribute]
public bool ShowGrid { get; set; }
[XmlIgnore]
public Size GridCellSize { get; set; }
[JsonIgnore]
[XmlAttribute("GridCellSize")]
public string XmlGridCellSize
{
get
{
return SerializeHelper.SerializeSize(GridCellSize);
}
set
{
GridCellSize = SerializeHelper.DeserializeSize(value);
}
}
[XmlAttribute]
public CellHorizontalAlignment CellHorizontalAlignment { get; set; }
[XmlAttribute]
public CellVerticalAlignment CellVerticalAlignment { get; set; }
[XmlAttribute]
public PageSizeOrientation PageSizeOrientation { get; set; }
[XmlIgnore]
public Size PageSize { get; set; }
[JsonIgnore]
[XmlAttribute("PageSize")]
public string XmlPageSize
{
get
{
return SerializeHelper.SerializeSize(PageSize);
}
set
{
PageSize = SerializeHelper.DeserializeSize(value);
}
}
[XmlAttribute]
public PageSizeType PageSizeType { get; set; }
[XmlAttribute]
public double GridMargin { get; set; }
[XmlIgnore]
public Color GridColor { get; set; }
[JsonIgnore]
[XmlAttribute("GridColor")]
public string XmlGridColor
{
get
{
return SerializeHelper.SerializeColor(GridColor);
}
set
{
GridColor = SerializeHelper.DeserializeColor(value);
}
}
[XmlArray]
public List<DesignerItemBase> DesignerItems { get; set; } = new List<DesignerItemBase>();
@@ -55,21 +131,31 @@ namespace AIStudio.Wpf.ADiagram.Models
[XmlArray]
public List<FlowNodeDesignerItem> FlowNodeDesignerItems { get; set; } = new List<FlowNodeDesignerItem>();
[XmlArray]
public List<SFCNodeDesignerItem> SFCNodeDesignerItems { get; set; } = new List<SFCNodeDesignerItem>();
[JsonIgnore]
[XmlIgnore]
public List<DesignerItemBase> AllDesignerItems { get { return
DesignerItems.OfType<DesignerItemBase>()
.Union(TextDesignerItems.OfType<DesignerItemBase>())
.Union(LogicalGateItems.OfType<DesignerItemBase>())
.Union(MediaDesignerItems.OfType<DesignerItemBase>())
.Union(ImageDesignerItems.OfType<DesignerItemBase>())
.Union(PathDesignerItems.OfType<DesignerItemBase>())
.Union(PersistDesignerItems.OfType<DesignerItemBase>())
.Union(SettingsDesignerItems.OfType<DesignerItemBase>())
.Union(FlowNodeDesignerItems.OfType<FlowNodeDesignerItem>())
.ToList(); } }
public List<DesignerItemBase> AllDesignerItems
{
get
{
return
DesignerItems.OfType<DesignerItemBase>()
.Union(TextDesignerItems.OfType<DesignerItemBase>())
.Union(LogicalGateItems.OfType<DesignerItemBase>())
.Union(MediaDesignerItems.OfType<DesignerItemBase>())
.Union(ImageDesignerItems.OfType<DesignerItemBase>())
.Union(PathDesignerItems.OfType<DesignerItemBase>())
.Union(PersistDesignerItems.OfType<DesignerItemBase>())
.Union(SettingsDesignerItems.OfType<DesignerItemBase>())
.Union(FlowNodeDesignerItems.OfType<DesignerItemBase>())
.Union(SFCNodeDesignerItems.OfType<DesignerItemBase>())
.ToList();
}
}
[XmlArray]
[XmlArray]
public List<Guid> ConnectionIds { get; set; }
[XmlArray]
@@ -110,11 +196,15 @@ namespace AIStudio.Wpf.ADiagram.Models
else if (item is LogicalGateItemViewModelBase)
{
LogicalGateItems.Add(new LogicalGateDesignerItemBase(item as LogicalGateItemViewModelBase));
}
}
else if (item is FlowNode)
{
FlowNodeDesignerItems.Add(new FlowNodeDesignerItem(item as FlowNode));
}
else if (item is SFCNode)
{
SFCNodeDesignerItems.Add(new SFCNodeDesignerItem(item as SFCNode));
}
else if (item is BarcodeDesignerItemViewModel)
{
DesignerItems.Add(new DesignerItemBase(item, (item as BarcodeDesignerItemViewModel).Format.ToString()));
@@ -130,7 +220,7 @@ namespace AIStudio.Wpf.ADiagram.Models
{
if (item is PersistDesignerItemViewModel)
{
return new PersistDesignerItem(item as PersistDesignerItemViewModel);
return new PersistDesignerItem(item as PersistDesignerItemViewModel);
}
else if (item is SettingsDesignerItemViewModel)
{
@@ -164,6 +254,10 @@ namespace AIStudio.Wpf.ADiagram.Models
{
return new FlowNodeDesignerItem(item as FlowNode);
}
else if (item is SFCNode)
{
return new SFCNodeDesignerItem(item as SFCNode);
}
else
{
return new DesignerItemBase(item as DesignerItemViewModelBase);
@@ -188,6 +282,8 @@ namespace AIStudio.Wpf.ADiagram.Models
return typeof(LogicalGateDesignerItemBase);
if (vmType is FlowNode)
return typeof(FlowNodeDesignerItem);
if (vmType is SFCNode)
return typeof(SFCNodeDesignerItem);
throw new InvalidOperationException(string.Format("Unknown diagram type. Currently only {0} and {1} are supported",
typeof(PersistDesignerItem).AssemblyQualifiedName,
typeof(SettingsDesignerItemViewModel).AssemblyQualifiedName

View File

@@ -1,14 +1,9 @@
using Util.DiagramDesigner.Helpers;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.SFC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Shapes;
using Util.DiagramDesigner;
using AIStudio.Wpf.ADiagram.Demos.Flowchart;
using AIStudio.Wpf.ADiagram.Helpers;
using Util.DiagramDesigner.Helpers;
namespace AIStudio.Wpf.ADiagram.Models
{
@@ -58,6 +53,18 @@ namespace AIStudio.Wpf.ADiagram.Models
}
public class SFCToolBoxData : ToolBoxData
{
public SFCNodeKinds Kind { get; set; }
public SFCToolBoxData(SFCNodeKinds kind, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
{
Kind = kind;
ColorViewModel.LineColor.Color = Colors.Black;
ColorViewModel.FillColor.Color = Colors.Blue;
}
}
public class DesignerItemToolBoxData : ToolBoxData
{
public string FileName { get; set; }

View File

@@ -16,14 +16,12 @@
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Themes/Styles/Slider.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Themes/Styles/TabControl.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Themes/Styles/ToggleButton.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Flowchart/ViewModels/FlowNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Logical/ViewModels/LogicalGateItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/BarcodeDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/OutLineTextDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/PathItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/PersistDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/SettingsDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Demos/Others/ViewModels/SvgDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/BarcodeDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/OutLineTextDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/PathItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/PersistDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/SettingsDesignerItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Extensions/ViewModels/SvgDesignerItemViewModel.xaml"/>
</ResourceDictionary.MergedDictionaries>

View File

@@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters">
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram">
<converter:ThicknessBindingConverter x:Key="ThicknessBindingConverter"/>
<Style x:Key="DefaultExpanderBaseHeaderStyle" TargetType="{x:Type ToggleButton}">

View File

@@ -1,7 +1,7 @@
using AIStudio.Wpf.ADiagram.Commands;
using AIStudio.Wpf.ADiagram.Demos.Flowchart;
using AIStudio.Wpf.ADiagram.Demos.Others;
using AIStudio.Wpf.ADiagram.Helpers;
using AIStudio.Wpf.BaseDiagram.Commands;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels;
using AIStudio.Wpf.BaseDiagram.Helpers;
using AIStudio.Wpf.ADiagram.Models;
using Newtonsoft.Json;
using System;
@@ -20,14 +20,12 @@ using ZXing;
namespace AIStudio.Wpf.ADiagram.ViewModels
{
public class DiagramsViewModel : BindableBase
public partial class DiagramsViewModel : BindableBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
public MainWindowViewModel MainWindowViewModel { get; set; }
public DiagramsViewModel(MainWindowViewModel mainWindowViewModel, string title, string status, DiagramType diagramType)
public DiagramsViewModel(string title, string status, DiagramType diagramType)
{
MainWindowViewModel = mainWindowViewModel;
Title = title;
Status = status;
DiagramType = diagramType;
@@ -40,11 +38,17 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
Init();
}
public DiagramsViewModel(MainWindowViewModel mainWindowViewModel, string filename)
public DiagramsViewModel(string filename)
{
MainWindowViewModel = mainWindowViewModel;
FileName = filename;
OpenFile(filename);
var diagramDocument = OpenFile(filename);
OpenFile(diagramDocument);
}
public DiagramsViewModel(string filename, DiagramDocument diagramDocument)
{
FileName = filename;
OpenFile(diagramDocument);
}
protected virtual void InitDiagramViewModel()
@@ -192,7 +196,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
DiagramViewModel.SelectAllCommand.Execute(null);
}
private void OpenFile(string filename)
public static DiagramDocument OpenFile(string filename)
{
try
{
@@ -213,44 +217,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
diagramDocument = JsonConvert.DeserializeObject<DiagramDocument>(File.ReadAllText(filename));
}
Title = diagramDocument.Title;
DiagramType = diagramDocument.DiagramType;
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
foreach (var diagramitem in diagramDocument.DiagramItems)
{
var viewModel = new DiagramViewModel();
viewModel.Name = diagramitem.Name;
viewModel.DiagramType = diagramitem.DiagramType;
foreach (DesignerItemBase diagramItemData in diagramitem.AllDesignerItems)
{
Type type = TypeHelper.GetType(diagramItemData.ItemTypeName);
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, viewModel, diagramItemData);
viewModel.Items.Add(itemBase);
}
foreach (var connection in diagramitem.Connections)
{
connection.SourceType = System.Type.GetType(connection.SourceTypeName);
connection.SinkType = System.Type.GetType(connection.SinkTypeName);
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connection.SourceId, connection.SourceType);
ConnectorOrientation sourceConnectorOrientation = connection.SourceOrientation;
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation, connection.SourceXRatio, connection.SourceYRatio, connection.SourceInnerPoint);
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connection.SinkId, connection.SinkType);
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection);
viewModel.Items.Add(connectionVM);
}
viewModels.Add(viewModel);
}
DiagramViewModels = new ObservableCollection<IDiagramViewModel>(viewModels);
DiagramViewModel = DiagramViewModels.FirstOrDefault();
return diagramDocument;
}
catch (System.IO.FileNotFoundException fnfe)
{
@@ -279,6 +246,57 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
}
private void OpenFile(DiagramDocument diagramDocument)
{
Title = diagramDocument.Title;
DiagramType = diagramDocument.DiagramType;
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
foreach (var diagramItem in diagramDocument.DiagramItems)
{
var viewModel = new DiagramViewModel();
viewModel.Name = diagramItem.Name;
viewModel.DiagramType = diagramItem.DiagramType;
viewModel.ShowGrid = diagramItem.ShowGrid;
viewModel.GridCellSize = diagramItem.GridCellSize;
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
viewModel.CellVerticalAlignment = diagramItem.CellVerticalAlignment;
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
viewModel.PageSize = diagramItem.PageSize;
viewModel.PageSizeType = diagramItem.PageSizeType;
viewModel.GridMargin = diagramItem.GridMargin;
viewModel.GridColor = diagramItem.GridColor;
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
{
Type type = TypeHelper.GetType(diagramItemData.ItemTypeName);
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, viewModel, diagramItemData);
viewModel.Items.Add(itemBase);
}
foreach (var connection in diagramItem.Connections)
{
connection.SourceType = System.Type.GetType(connection.SourceTypeName);
connection.SinkType = System.Type.GetType(connection.SinkTypeName);
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connection.SourceId, connection.SourceType);
ConnectorOrientation sourceConnectorOrientation = connection.SourceOrientation;
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation, connection.SourceXRatio, connection.SourceYRatio, connection.SourceInnerPoint);
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connection.SinkId, connection.SinkType);
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection);
viewModel.Items.Add(connectionVM);
}
viewModels.Add(viewModel);
}
DiagramViewModels = new ObservableCollection<IDiagramViewModel>(viewModels);
DiagramViewModel = DiagramViewModels.FirstOrDefault();
}
public bool SaveFile(bool isSaveAs = false)
{
string filter = "Files (*.xml)|*.xml|Files (*.json)|*.json|All Files (*.*)|*.*";
@@ -310,6 +328,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
DiagramItem diagramItem = new DiagramItem();
diagramItem.Name = viewModel.Name;
diagramItem.DiagramType = viewModel.DiagramType;
diagramItem.ShowGrid = viewModel.ShowGrid;
diagramItem.GridCellSize = viewModel.GridCellSize;
diagramItem.CellHorizontalAlignment = viewModel.CellHorizontalAlignment;
diagramItem.CellVerticalAlignment = viewModel.CellVerticalAlignment;
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
diagramItem.PageSize = viewModel.PageSize;
diagramItem.PageSizeType = viewModel.PageSizeType;
diagramItem.GridMargin = viewModel.GridMargin;
diagramItem.GridColor = viewModel.GridColor;
diagramItem.AddItems(DiagramViewModel.Items);
@@ -775,7 +802,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
}
public void CenterExecuted(object para)
public void CenterMoveExecuted(object para)
{
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
{
@@ -784,6 +811,38 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
}
public void LeftMoveExecuted(object para)
{
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
{
item.Left -= 0.5;
}
}
public void RightMoveExecuted(object para)
{
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
{
item.Left += 0.5;
}
}
public void UpMoveExecuted(object para)
{
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
{
item.Top -= 0.5;
}
}
public void DownMoveExecuted(object para)
{
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
{
item.Top += 0.5;
}
}
public void SameWidthExecuted(object para)
{
if (para is DesignerItemViewModelBase designerItem)
@@ -862,6 +921,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
DiagramItem diagramItem = new DiagramItem();
diagramItem.Name = viewModel.Name;
diagramItem.DiagramType = viewModel.DiagramType;
diagramItem.ShowGrid = viewModel.ShowGrid;
diagramItem.GridCellSize = viewModel.GridCellSize;
diagramItem.CellHorizontalAlignment = viewModel.CellHorizontalAlignment;
diagramItem.CellVerticalAlignment = viewModel.CellVerticalAlignment;
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
diagramItem.PageSize = viewModel.PageSize;
diagramItem.PageSizeType = viewModel.PageSizeType;
diagramItem.GridMargin = viewModel.GridMargin;
diagramItem.GridColor = viewModel.GridColor;
diagramItem.AddItems(DiagramViewModel.Items);
@@ -891,6 +959,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
viewModel = new DiagramViewModel();
viewModel.Name = NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-");
viewModel.DiagramType = diagramItem.DiagramType;
viewModel.ShowGrid = diagramItem.ShowGrid;
viewModel.GridCellSize = diagramItem.GridCellSize;
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
viewModel.CellVerticalAlignment = diagramItem.CellVerticalAlignment;
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
viewModel.PageSize = diagramItem.PageSize;
viewModel.PageSizeType = diagramItem.PageSizeType;
viewModel.GridMargin = diagramItem.GridMargin;
viewModel.GridColor = diagramItem.GridColor;
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
{
@@ -1038,5 +1115,9 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
return new Size(formattedText.Width, formattedText.Height);
}
public virtual void Dispose()
{
}
}
}

View File

@@ -1,4 +1,6 @@
using AIStudio.Wpf.ADiagram.ViewModels;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.ADiagram.ViewModels;
using AIStudio.Wpf.Flowchart.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -9,17 +11,20 @@ using System.Windows;
using System.Windows.Media;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Flowchart
namespace AIStudio.Wpf.Flowchart
{
public class FlowchartViewModel : DiagramsViewModel
{
public FlowchartViewModel(MainWindowViewModel mainWindowViewModel, string title, string status, DiagramType diagramType) : base(mainWindowViewModel, title, status, diagramType)
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
}
public FlowchartViewModel(MainWindowViewModel mainWindowViewModel, string filename) : base(mainWindowViewModel, filename)
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
{
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
}
}
protected override void InitDiagramViewModel()
@@ -97,9 +102,17 @@ namespace AIStudio.Wpf.ADiagram.Demos.Flowchart
DiagramViewModel.ClearSelectedItems();
FlowchartService.InitOAData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList());
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
}
public override void Dispose()
{
base.Dispose();
foreach (var viewModel in DiagramViewModels)
{
FlowchartService.DisposeData(viewModel);
}
}
}
}

View File

@@ -1,23 +1,21 @@
using AIStudio.Wpf.ADiagram.ViewModels;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.ADiagram.ViewModels;
using AIStudio.Wpf.Logical.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Logical
namespace AIStudio.Wpf.Logical
{
public class LogicalViewModel : DiagramsViewModel
{
public LogicalViewModel(MainWindowViewModel mainWindowViewModel, string title, string status, DiagramType diagramType) : base(mainWindowViewModel, title, status, diagramType)
public LogicalViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
}
public LogicalViewModel(MainWindowViewModel mainWindowViewModel, string filename) : base(mainWindowViewModel, filename)
public LogicalViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
}
@@ -136,6 +134,14 @@ namespace AIStudio.Wpf.ADiagram.Demos.Logical
}
}
if (arg is TimerDesignerItemViewModel)
{
if (DiagramViewModel.Items.OfType<LogicalGateItemViewModelBase>().Any(p => p.LogicalType == LogicalType.Time))
{
return false;
}
}
return true;
}

View File

@@ -1,9 +1,6 @@
using AIStudio.Wpf.ADiagram.Commands;
using AIStudio.Wpf.ADiagram.Demos.Flowchart;
using AIStudio.Wpf.ADiagram.Demos.Logical;
using AIStudio.Wpf.ADiagram.Enums;
using AIStudio.Wpf.ADiagram.Helpers;
using AIStudio.Wpf.ADiagram.Views;
using AIStudio.Wpf.ADiagram.Views;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.Logical;
using ControlzEx.Theming;
using Dragablz;
using Fluent;
@@ -18,6 +15,8 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Util.DiagramDesigner;
using AIStudio.Wpf.BaseDiagram.Helpers;
using AIStudio.Wpf.BaseDiagram.Commands;
namespace AIStudio.Wpf.ADiagram.ViewModels
{
@@ -32,7 +31,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
ConnectorViewModel.PathFinder = new OrthogonalPathFinder();
DiagramsViewModels = new ObservableCollection<DiagramsViewModel>();
DiagramsViewModels.Add(new DiagramsViewModel(this, "新建-1", "*", DiagramType.Normal));
DiagramsViewModels.Add(new DiagramsViewModel("新建-1", "*", DiagramType.Normal));
DiagramsViewModel = DiagramsViewModels.FirstOrDefault();
StandardColor = GenerateStandardGradients();
@@ -78,8 +77,8 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
}
private ColorType _colorObject;
public ColorType ColorType
private Models.ColorType _colorObject;
public Models.ColorType ColorType
{
get
{
@@ -217,7 +216,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
return
() =>
{
return new DiagramsViewModel(this, NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
return new DiagramsViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
};
}
}
@@ -462,7 +461,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
{
get
{
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterExecuted(para)));
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterMoveExecuted(para)));
}
}
@@ -662,6 +661,11 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
{
//here's how you can cancel stuff:
//args.Cancel();
if (args.DragablzItem.DataContext is DiagramsViewModel viewModel)
{
viewModel.Dispose();
}
}
private void MainWindowViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -707,8 +711,9 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
private void KeyExecuted(string para)
public bool KeyExecuted(string para)
{
bool executed = true;
switch (para)
{
case "Control+A": SelectedAllExecuted(); break;
@@ -720,8 +725,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
case "Control+S": SaveExecuted(); break;
case "Control+Z": UnDoExecuted(); break;
case "Control+Y": ReDoExecuted(); break;
case "None+Delete": DeleteExecuted(); break;
case "Delete": DeleteExecuted(); break;
case "Left": LeftMoveExecuted(); break;
case "Right": RightMoveExecuted(); break;
case "Up": UpMoveExecuted(); break;
case "Down": DownMoveExecuted(); break;
default: executed = false; break;
}
return executed;
}
private void UnDoExecuted()
@@ -774,7 +786,24 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
return;
}
var flow = new DiagramsViewModel(this, filename);
var diagram = DiagramsViewModel.OpenFile(filename);
DiagramsViewModel flow;
if (diagram.DiagramType == DiagramType.FlowChart)
{
flow = new FlowchartViewModel(filename, diagram);
}
else if (diagram.DiagramType == DiagramType.Logical)
{
flow = new LogicalViewModel(filename, diagram);
}
else if (diagram.DiagramType == DiagramType.SFC)
{
flow = new SFCViewModel(filename, diagram);
}
else
{
flow = new DiagramsViewModel(filename, diagram);
}
DiagramsViewModels.Add(flow);
DiagramsViewModel = flow;
@@ -884,15 +913,19 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
IsOpenBackstage = false;
if (type == DiagramType.FlowChart.ToString())
{
DiagramsViewModel = new FlowchartViewModel(this, NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
DiagramsViewModel = new FlowchartViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.Logical.ToString())
{
DiagramsViewModel = new LogicalViewModel(this, NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
DiagramsViewModel = new LogicalViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.SFC.ToString())
{
DiagramsViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else
{
DiagramsViewModel = new DiagramsViewModel(this, NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
DiagramsViewModel = new DiagramsViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
DiagramsViewModels.Add(DiagramsViewModel);
@@ -994,11 +1027,39 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
#endregion
private void CenterExecuted(object para)
private void CenterMoveExecuted(object para)
{
if (DiagramsViewModel == null) return;
DiagramsViewModel.CenterExecuted(para);
DiagramsViewModel.CenterMoveExecuted(para);
}
private void LeftMoveExecuted(object para = null)
{
if (DiagramsViewModel == null) return;
DiagramsViewModel.LeftMoveExecuted(para);
}
private void RightMoveExecuted(object para = null)
{
if (DiagramsViewModel == null) return;
DiagramsViewModel.RightMoveExecuted(para);
}
private void UpMoveExecuted(object para = null)
{
if (DiagramsViewModel == null) return;
DiagramsViewModel.UpMoveExecuted(para);
}
private void DownMoveExecuted(object para = null)
{
if (DiagramsViewModel == null) return;
DiagramsViewModel.DownMoveExecuted(para);
}
private void SameWidthExecuted(object para)
@@ -1135,9 +1196,9 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
switch (ColorType)
{
case ColorType.Text: DiagramsViewModel.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
case ColorType.Fill: DiagramsViewModel.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
case ColorType.Line: DiagramsViewModel.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
case Models.ColorType.Text: DiagramsViewModel.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
case Models.ColorType.Fill: DiagramsViewModel.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
case Models.ColorType.Line: DiagramsViewModel.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
}
}

View File

@@ -0,0 +1,303 @@
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.ADiagram.ViewModels;
using AIStudio.Wpf.Flowchart.ViewModels;
using AIStudio.Wpf.SFC;
using AIStudio.Wpf.SFC.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Media;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.Flowchart
{
public class SFCViewModel : DiagramsViewModel
{
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
}
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
{
SFCService.InitData(DiagramViewModel.Items.OfType<SFCNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
}
readDataTimer.Elapsed += timeCycle;
readDataTimer.Interval = 1000;
readDataTimer.AutoReset = false;
readDataTimer.Start();
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();
DiagramViewModel.ShowGrid = true;
DiagramViewModel.GridCellSize = new Size(100, 60);
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
}
private System.Timers.Timer readDataTimer = new System.Timers.Timer();
protected override void Init()
{
base.Init();
SFCStartNode start = new SFCStartNode() { Left = 0, Top = 60, Text = "S0" };
DiagramViewModel.DirectAddItemCommand.Execute(start);
SFCConditionNode condition1_1 = new SFCConditionNode() { Left = 0, Top = 120, Text = "X01", Expression = "p0==1&p1<20", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition1_1);
SFCConditionNode condition1_2 = new SFCConditionNode() { Left = 100, Top = 120, Text = "X02", Expression = "p0==1&p1<30", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition1_2);
SFCNodeNode step1 = new SFCNodeNode() { Left = 0, Top = 180, Text = "S1" };
DiagramViewModel.DirectAddItemCommand.Execute(step1);
SFCActionNode action11 = new SFCActionNode() { Left = 100, Top = 180, Text = "SET_V1", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action11);
SFCActionNode action12 = new SFCActionNode() { Left = 200, Top = 180, Text = "SET_V2", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action12);
SFCActionNode action13 = new SFCActionNode() { Left = 300, Top = 180, Text = "SET_V3", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action13);
SFCActionNode action14 = new SFCActionNode() { Left = 400, Top = 180, Text = "RES_V4", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action14);
SFCConditionNode condition2 = new SFCConditionNode() { Left = 0, Top = 240, Text = "X1", Expression = "p0>50", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition2);
SFCNodeNode step2 = new SFCNodeNode() { Left = 0, Top = 300, Text = "S2" };
DiagramViewModel.DirectAddItemCommand.Execute(step2);
SFCActionNode action2 = new SFCActionNode() { Left = 100, Top = 300, Text = "SET_V4", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action2);
SFCConditionNode condition3 = new SFCConditionNode() { Left = 0, Top = 360, Text = "X2", Expression = "p0>70", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition3);
SFCNodeNode step3 = new SFCNodeNode() { Left = 0, Top = 420, Text = "S3" };
DiagramViewModel.DirectAddItemCommand.Execute(step3);
SFCActionNode action3 = new SFCActionNode() { Left = 100, Top = 420, Text = "RES_V1", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action3);
SFCConditionNode condition4 = new SFCConditionNode() { Left = 0, Top = 480, Text = "X3", Expression = "p0>80", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition4);
SFCCOBeginNode cobegin = new SFCCOBeginNode() { Left = 38, Top = 540, Text = "" };
DiagramViewModel.DirectAddItemCommand.Execute(cobegin);
SFCNodeNode step4 = new SFCNodeNode() { Left = 0, Top = 600, Text = "S4" };
DiagramViewModel.DirectAddItemCommand.Execute(step4);
SFCActionNode action4 = new SFCActionNode() { Left = 100, Top = 600, Text = "RES_V2", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action4);
SFCConditionNode condition5 = new SFCConditionNode() { Left = 0, Top = 660, Text = "X4", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition5);
SFCNodeNode step5 = new SFCNodeNode() { Left = 200, Top = 600, Text = "S5" };
DiagramViewModel.DirectAddItemCommand.Execute(step5);
SFCActionNode action5 = new SFCActionNode() { Left = 300, Top = 600, Text = "RES_V3", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action5);
SFCConditionNode condition6 = new SFCConditionNode() { Left = 200, Top = 660, Text = "X5", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition6);
SFCCOEndNode coend = new SFCCOEndNode() { Left = 38, Top = 720, Text = "" };
DiagramViewModel.DirectAddItemCommand.Execute(coend);
ConnectorViewModel connector1_1 = new ConnectorViewModel(start.Output[0], condition1_1.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector1_1);
ConnectorViewModel connector2_1 = new ConnectorViewModel(condition1_1.Output[0], step1.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector2_1);
ConnectorViewModel connector1_2 = new ConnectorViewModel(start.Output[0], condition1_2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector1_2);
ConnectorViewModel connector2_2 = new ConnectorViewModel(condition1_2.Output[0], step1.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector2_2);
ConnectorViewModel connector31 = new ConnectorViewModel(step1.Action[0], action11.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector31);
ConnectorViewModel connector32 = new ConnectorViewModel(step1.Action[0], action12.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector32);
ConnectorViewModel connector33 = new ConnectorViewModel(step1.Action[0], action13.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector33);
ConnectorViewModel connector34 = new ConnectorViewModel(step1.Action[0], action14.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector34);
ConnectorViewModel connector4 = new ConnectorViewModel(step1.Output[0], condition2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector4);
ConnectorViewModel connector5 = new ConnectorViewModel(condition2.Output[0], step2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector5);
ConnectorViewModel connector6 = new ConnectorViewModel(step2.Action[0], action2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector6);
ConnectorViewModel connector7 = new ConnectorViewModel(step2.Output[0], condition3.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector7);
ConnectorViewModel connector8 = new ConnectorViewModel(condition3.Output[0], step3.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector8);
ConnectorViewModel connector9 = new ConnectorViewModel(step3.Action[0], action3.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector9);
ConnectorViewModel connector10 = new ConnectorViewModel(step3.Output[0], condition4.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector10);
ConnectorViewModel connector11 = new ConnectorViewModel(condition4.Output[0], cobegin.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector11);
ConnectorViewModel connector12 = new ConnectorViewModel(cobegin.Output[0], step4.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector12);
ConnectorViewModel connector13 = new ConnectorViewModel(step4.Action[0], action4.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector13);
ConnectorViewModel connector14 = new ConnectorViewModel(step4.Output[0], condition5.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector14);
ConnectorViewModel connector15 = new ConnectorViewModel(cobegin.Output[1], step5.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector15);
ConnectorViewModel connector16 = new ConnectorViewModel(step5.Action[0], action5.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector16);
ConnectorViewModel connector17 = new ConnectorViewModel(step5.Output[0], condition6.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector17);
ConnectorViewModel connector18 = new ConnectorViewModel(condition5.Output[0], coend.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector18);
ConnectorViewModel connector19 = new ConnectorViewModel(condition6.Output[0], coend.Input[1]);
DiagramViewModel.DirectAddItemCommand.Execute(connector19);
ConnectorViewModel connector20 = new ConnectorViewModel(coend.Output[0], start.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(connector20);
#region
TextDesignerItemViewModel despcription = new TextDesignerItemViewModel()
{
Left = 230,
Top = 270,
ItemWidth = 300,
ItemHeight = 120,
Text = @"模拟一个容器的高低液位控制方法
1.按下启动按钮, 程序启动
2.当液位低于20%的时候, V1,V2,V3打开, V4关闭
3.当液位高于50%的时候, V4打开
4.当液位高于70%的时侯, V1关闭
5.当液位高于80%的时候, V2,V3并行关闭"
};
despcription.FontViewModel.HorizontalAlignment = HorizontalAlignment.Left;
despcription.FontViewModel.VerticalAlignment = VerticalAlignment.Top;
DiagramViewModel.DirectAddItemCommand.Execute(despcription);
Simulate_ListViewModel list = new Simulate_ListViewModel()
{
Left = 410,
Top = 390,
};
DiagramViewModel.DirectAddItemCommand.Execute(list);
Simulate_StartViewModel btnstart = new Simulate_StartViewModel() { Left = 0, Top = 0, LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), };
DiagramViewModel.DirectAddItemCommand.Execute(btnstart);
Simulate_TankViewModel tank1 = new Simulate_TankViewModel() { Left = 100, Top = 43, ItemWidth = 48, ItemHeight = 60, Text = "T1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T1") };
DiagramViewModel.DirectAddItemCommand.Execute(tank1);
Simulate_SolenoidViewModel k1 = new Simulate_SolenoidViewModel() { Left = 200, Top = 0, Text = "K1", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k1);
Simulate_SolenoidViewModel k2 = new Simulate_SolenoidViewModel() { Left = 200, Top = 60, Text = "K2", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k2);
Simulate_SolenoidViewModel k3 = new Simulate_SolenoidViewModel() { Left = 200, Top = 120, Text = "K3", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k3);
Simulate_TankViewModel tank2 = new Simulate_TankViewModel() { Left = 300, Top = 28, Text = "T2", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") };
DiagramViewModel.DirectAddItemCommand.Execute(tank2);
Simulate_SolenoidViewModel k4 = new Simulate_SolenoidViewModel() { Left = 400, Top = 60, Text = "K4", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k4);
Simulate_TankViewModel tank3 = new Simulate_TankViewModel() { Left = 500, Top = 103, ItemWidth = 48, ItemHeight = 60, Text = "T3", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T3") };
DiagramViewModel.DirectAddItemCommand.Execute(tank3);
ConnectorViewModel conn1 = new ConnectorViewModel(tank1.Output[0], k1.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn1);
ConnectorViewModel conn2 = new ConnectorViewModel(tank1.Output[0], k2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn2);
ConnectorViewModel conn3 = new ConnectorViewModel(tank1.Output[0], k3.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn3);
ConnectorViewModel conn4 = new ConnectorViewModel(k1.Output[0], tank2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn4);
ConnectorViewModel conn5 = new ConnectorViewModel(k2.Output[0], tank2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn5);
ConnectorViewModel conn6 = new ConnectorViewModel(k3.Output[0], tank2.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn6);
ConnectorViewModel conn7 = new ConnectorViewModel(tank2.Output[1], k4.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn7);
ConnectorViewModel conn8 = new ConnectorViewModel(k4.Output[0], tank3.Input[0]);
DiagramViewModel.DirectAddItemCommand.Execute(conn8);
#endregion
DiagramViewModel.ClearSelectedItems();
SFCService.InitData(DiagramViewModel.Items.OfType<SFCNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
readDataTimer.Elapsed += timeCycle;
readDataTimer.Interval = 1000;
readDataTimer.AutoReset = false;
readDataTimer.Start();
}
private void timeCycle(object sender, ElapsedEventArgs e)
{
if (DiagramViewModel != null)
{
SFCService.Execute(DiagramViewModel);
}
readDataTimer.Start();
}
public override void Dispose()
{
base.Dispose();
readDataTimer.Stop();
readDataTimer.Dispose();
foreach (var viewModel in DiagramViewModels)
{
SFCService.DisposeData(viewModel);
}
}
}
}

View File

@@ -1,21 +1,21 @@
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.BaseDiagram.Commands;
using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels;
using AIStudio.Wpf.BaseDiagram.Helpers;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.Flowchart.ViewModels;
using AIStudio.Wpf.Logical.ViewModels;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows.Input;
using Util.DiagramDesigner;
using Util.DiagramDesigner.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using AIStudio.Wpf.ADiagram.Demos.Flowchart;
using AIStudio.Wpf.ADiagram.Demos.Logical;
using AIStudio.Wpf.ADiagram.Demos.Others;
using System.Windows.Input;
using AIStudio.Wpf.ADiagram.Commands;
using System.IO;
using Newtonsoft.Json;
using AIStudio.Wpf.ADiagram.Helpers;
using static AIStudio.Wpf.ADiagram.Helpers.NewNameHelper;
using AIStudio.Wpf.SFC;
using AIStudio.Wpf.SFC.ViewModels;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.ViewModels
{
@@ -180,6 +180,18 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
mediaToolBoxItems.Add(new MediaToolBoxData("../Images/SVG.png", typeof(SvgDesignerItemViewModel)));
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "媒体", ToolBoxItems = new ObservableCollection<ToolBoxData>(mediaToolBoxItems) });
List<ToolBoxData> sfcToolBoxItems = new List<ToolBoxData>();
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Start, typeof(SFCStartNode), 32, 28));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Condition, typeof(SFCConditionNode), 32, 28));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Node, typeof(SFCNodeNode), 32, 28));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Action, typeof(SFCActionNode), 32, 28));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.COBegin, typeof(SFCCOBeginNode), 32, 10));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.COEnd, typeof(SFCCOEndNode), 32, 10));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Tank, typeof(Simulate_TankViewModel), 32, 32));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Solenoid, typeof(Simulate_SolenoidViewModel)));
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Start, typeof(Simulate_StartViewModel)));
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "SFC顺序控制图", ToolBoxItems = new ObservableCollection<ToolBoxData>(sfcToolBoxItems) });
LoadMyItems();
LoadSvgItems();
}
@@ -195,7 +207,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
if (Directory.Exists(_svg))
{
var files = Directory.GetFiles(_svg);
foreach (var filename in files.OrderBy(p => p, new NaturalStringComparer()).Where(p => p.ToLower().EndsWith(".svg")))
foreach (var filename in files.OrderBy(p => p, new NewNameHelper.NaturalStringComparer()).Where(p => p.ToLower().EndsWith(".svg")))
{
SvgToolBoxCategory.ToolBoxItems.Add(new SvgToolBoxData(filename, typeof(SvgDesignerItemViewModel)));
}
@@ -246,7 +258,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
DiagramItem diagramItem = new DiagramItem();
diagramItem.AddItems(new List<DesignerItemViewModelBase> { designer });
diagramDocument.DiagramItems.Add(diagramItem);
string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType<DesignerItemToolBoxData>().Select(p => Path.GetFileNameWithoutExtension(p.FileName)),"");
string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType<DesignerItemToolBoxData>().Select(p => Path.GetFileNameWithoutExtension(p.FileName)), "");
var filename = $"{_custom}\\{newname}.json";
File.WriteAllText(filename, JsonConvert.SerializeObject(diagramDocument));

View File

@@ -6,18 +6,18 @@
xmlns:local="clr-namespace:AIStudio.Wpf.ADiagram"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:utilhandy="https://astudio.github.io/utilcontrol.handy"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:views="clr-namespace:AIStudio.Wpf.ADiagram.Views"
xmlns:binding="clr-namespace:AIStudio.Wpf.ADiagram.Commands"
xmlns:binding="clr-namespace:AIStudio.Wpf.BaseDiagram.Commands;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:controlzEx="urn:controlzex"
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
xmlns:helper="clr-namespace:AIStudio.Wpf.ADiagram.Helpers"
xmlns:enum="clr-namespace:AIStudio.Wpf.ADiagram.Enums"
xmlns:helper="clr-namespace:AIStudio.Wpf.BaseDiagram.Helpers;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Models"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:drop="urn:gong-wpf-dragdrop"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.ADiagram.ViewModels"
Style="{StaticResource RibbonWindowStyle}"
Icon="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Icons/App.ico"
@@ -71,7 +71,7 @@
<Fluent:Ribbon.Menu>
<Grid>
<!--Backstage items can be keytipped-->
<Fluent:Backstage x:Name="Backstage" IsOpen="{Binding IsOpenBackstage,Mode=TwoWay}">
<Fluent:Backstage x:Name="Backstage" IsOpen="{Binding IsOpenBackstage,Mode=TwoWay}">
<Fluent:BackstageTabControl>
<Fluent:Button Header="打开"
Icon="{iconPacks:Material Kind=OpenInNew}"
@@ -91,6 +91,9 @@
<Button Margin="5" ToolTip="逻辑图" Command="{Binding NewCommand}" CommandParameter="Logical" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M 23.6584,49.0333L 23.5634,46.9483L 22.5134,47.9133C 22.1467,48.2067 21.7434,48.4608 21.3034,48.6758C 20.8634,48.8908 20.3851,49.0575 19.8684,49.1758C 19.3517,49.2942 18.7851,49.3533 18.1684,49.3533C 17.3517,49.3533 16.6351,49.2317 16.0184,48.9883C 15.4017,48.745 14.8842,48.4067 14.4659,47.9733C 14.0476,47.54 13.7309,47.0167 13.5159,46.4033C 13.3009,45.79 13.1934,45.115 13.1934,44.3783C 13.1934,43.615 13.3526,42.9108 13.6709,42.2658C 13.9892,41.6208 14.4759,41.0667 15.1309,40.6033C 15.7859,40.14 16.6026,39.7758 17.5809,39.5108C 18.5592,39.2458 19.7067,39.1133 21.0234,39.1133L 23.1134,39.1133L 23.1134,38.1833C 23.1134,37.7867 23.0559,37.4283 22.9409,37.1083C 22.8259,36.7883 22.6409,36.5167 22.3859,36.2933C 22.1309,36.07 21.8001,35.8975 21.3934,35.7758C 20.9867,35.6542 20.4867,35.5933 19.8934,35.5933C 18.9567,35.5933 18.0326,35.7058 17.1209,35.9308C 16.2092,36.1558 15.3267,36.47 14.4734,36.8733L 14.4734,33.6733C 15.2367,33.3967 16.1167,33.1675 17.1134,32.9858C 18.1101,32.8042 19.1451,32.7133 20.2184,32.7133C 21.3984,32.7133 22.4117,32.8258 23.2584,33.0508C 24.1051,33.2758 24.8017,33.6142 25.3484,34.0658C 25.8951,34.5175 26.2992,35.0808 26.5609,35.7558C 26.8226,36.4308 26.9534,37.22 26.9534,38.1233L 26.9534,49.0333L 23.6584,49.0333 Z M 23.1134,41.9934L 20.8284,41.9934C 20.1984,41.9934 19.6634,42.0575 19.2234,42.1859C 18.7834,42.3142 18.4259,42.4909 18.1509,42.7159C 17.8759,42.9409 17.6742,43.2009 17.5459,43.4959C 17.4176,43.7909 17.3534,44.1033 17.3534,44.4333C 17.3534,45.0967 17.5576,45.6025 17.9659,45.9509C 18.3742,46.2992 18.9317,46.4734 19.6384,46.4734C 20.1584,46.4734 20.6992,46.275 21.2609,45.8783C 21.8226,45.4817 22.4401,44.915 23.1134,44.1784L 23.1134,41.9934 Z M 40.0334,49.0333L 40.0334,38.5584C 40.0334,36.795 39.3751,35.9134 38.0584,35.9134C 37.4017,35.9134 36.7734,36.1775 36.1734,36.7059C 35.5734,37.2342 34.9401,37.9517 34.2734,38.8583L 34.2734,49.0333L 30.4334,49.0334L 30.4334,33.0334L 33.7584,33.0334L 33.8534,35.3934L 34.8734,34.2859C 35.2267,33.9542 35.6092,33.6717 36.0209,33.4384C 36.4326,33.205 36.8759,33.0259 37.3509,32.9009C 37.8259,32.7759 38.3584,32.7134 38.9484,32.7134C 39.7717,32.7134 40.4901,32.8467 41.1034,33.1134C 41.7167,33.38 42.2292,33.7575 42.6409,34.2459C 43.0526,34.7342 43.3609,35.3217 43.5659,36.0084C 43.7709,36.695 43.8734,37.4617 43.8734,38.3084L 43.8734,49.0333L 40.0334,49.0333 Z M 57.6534,49.0333L 57.5584,46.6883L 56.5159,47.7808C 56.1576,48.1092 55.7734,48.3892 55.3634,48.6208C 54.9534,48.8525 54.5142,49.0325 54.0459,49.1609C 53.5776,49.2892 53.0601,49.3533 52.4934,49.3533C 51.5467,49.3533 50.7051,49.1642 49.9684,48.7859C 49.2317,48.4075 48.6134,47.87 48.1134,47.1733C 47.6134,46.4767 47.2317,45.6292 46.9684,44.6309C 46.7051,43.6325 46.5734,42.52 46.5734,41.2933C 46.5734,39.8233 46.7809,38.5508 47.1959,37.4758C 47.6109,36.4008 48.1867,35.5092 48.9234,34.8008C 49.6601,34.0925 50.5342,33.5675 51.5459,33.2259C 52.5576,32.8842 53.6567,32.7134 54.8434,32.7134L 56.0509,32.7909L 57.1334,32.9934L 57.1334,26.9534L 60.9734,26.9534L 60.9734,49.0333L 57.6534,49.0333 Z M 50.7334,41.0983C 50.7334,42.0017 50.7926,42.7725 50.9109,43.4108C 51.0292,44.0492 51.2051,44.5717 51.4384,44.9783C 51.6717,45.385 51.9584,45.6825 52.2984,45.8708C 52.6384,46.0592 53.0251,46.1534 53.4584,46.1534C 54.1017,46.1534 54.7126,45.885 55.2909,45.3484C 55.8692,44.8117 56.4834,44.0767 57.1334,43.1433L 57.1334,35.9933L 56.0259,35.7059L 54.6984,35.5933C 54.0917,35.5933 53.5451,35.7225 53.0584,35.9809C 52.5717,36.2392 52.1559,36.6042 51.8109,37.0758C 51.4659,37.5475 51.2001,38.1242 51.0134,38.8059C 50.8267,39.4875 50.7334,40.2517 50.7334,41.0983 Z M 36,60L 36,63L 33,63L 33,67L 36,67L 36,70L 40,70L 40,67L 43,67L 43,63L 40,63L 40,60L 36,60 Z M 38,73C 25.6744,73 14.8369,66.6288 8.60116,57L 67.3988,57C 61.1631,66.6288 50.3256,73 38,73 Z " ></Path>
</Button>
<Button Margin="5" ToolTip="顺序控制图" Command="{Binding NewCommand}" CommandParameter="SFC" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M10.984 13.836a.5.5 0 0 1-.353-.146l-.745-.743a.5.5 0 1 1 .706-.708l.392.391 1.181-1.18a.5.5 0 0 1 .708.707l-1.535 1.533a.504.504 0 0 1-.354.146zm9.353-.147l1.534-1.532a.5.5 0 0 0-.707-.707l-1.181 1.18-.392-.391a.5.5 0 1 0-.706.708l.746.743a.497.497 0 0 0 .706-.001zM4.527 7.452l2.557-1.585A1 1 0 0 0 7.09 4.17L4.533 2.56A1 1 0 0 0 3 3.406v3.196a1.001 1.001 0 0 0 1.527.85zm2.03-2.436L4 6.602V3.406l2.557 1.61zM24 12.5c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3h-2.08a3.503 3.503 0 0 1-3.46 3 3.502 3.502 0 0 1-3.46-3h-.558c-.972 0-1.85-.399-2.482-1.042V17c0 1.654 1.346 3 3 3h.04c.244-1.693 1.7-3 3.46-3 1.93 0 3.5 1.57 3.5 3.5S13.43 24 11.5 24a3.502 3.502 0 0 1-3.46-3H8c-2.206 0-4-1.794-4-4V9.899A5.008 5.008 0 0 1 0 5c0-2.757 2.243-5 5-5s5 2.243 5 5a5.005 5.005 0 0 1-4.952 4.998A2.482 2.482 0 0 0 7.482 12h.558c.244-1.693 1.7-3 3.46-3a3.502 3.502 0 0 1 3.46 3h2.08a3.503 3.503 0 0 1 3.46-3c1.93 0 3.5 1.57 3.5 3.5zm-15 8c0 1.378 1.122 2.5 2.5 2.5s2.5-1.122 2.5-2.5-1.122-2.5-2.5-2.5S9 19.122 9 20.5zM5 9c2.206 0 4-1.794 4-4S7.206 1 5 1 1 2.794 1 5s1.794 4 4 4zm9 3.5c0-1.378-1.122-2.5-2.5-2.5S9 11.122 9 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm9 0c0-1.378-1.122-2.5-2.5-2.5S18 11.122 18 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm-13 8a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm2 0a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm12 0c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3.002c-.007.001-.013.005-.021.005l-.506.017h-.017a.5.5 0 0 1-.016-.999l.506-.017c.018-.002.035.006.052.007A3.503 3.503 0 0 1 20.5 17c1.93 0 3.5 1.57 3.5 3.5zm-1 0c0-1.378-1.122-2.5-2.5-2.5S18 19.122 18 20.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5z" ></Path>
</Button>
</WrapPanel>
</TabItem>
<TabItem Header="待续" />
@@ -319,7 +322,7 @@
SizeDefinition="Middle,Small"
Command="{Binding DiagramsViewModel.DiagramViewModel.RedoCommand}">
<Fluent:Button.ToolTip>
<Fluent:ScreenTip Title="Redo"
<Fluent:ScreenTip Title="Redo"
Text="重做操作"
Width="190" />
</Fluent:Button.ToolTip>
@@ -1617,7 +1620,7 @@
<Binding Path="PageUnit"/>
<Binding ElementName="designerScrollViewer" Path="ActualWidth"/>
<Binding ElementName="panel" Path="ActualWidth"/>
<Binding ElementName="diagram" Path="ActualWidth"/>
<Binding ElementName="diagram" Path="ActualWidth"/>
</MultiBinding>
</controls:Ruler.CountShift>
</controls:Ruler>
@@ -1643,7 +1646,7 @@
<Binding Path="PageUnit"/>
<Binding ElementName="designerScrollViewer" Path="ActualHeight"/>
<Binding ElementName="panel" Path="ActualHeight"/>
<Binding ElementName="diagram" Path="ActualHeight"/>
<Binding ElementName="diagram" Path="ActualHeight"/>
</MultiBinding>
</controls:Ruler.CountShift>
</controls:Ruler>
@@ -1658,7 +1661,7 @@
</dragablz:TabablzControl>
<DockPanel Grid.Row="1" >
<Fluent:ComboBox Size="Small" IsEditable="False" helper:EnumHelper.Enum="{x:Type enum:ColorType}" SelectedItem="{Binding ColorType}" BorderThickness="0" BorderBrush="Transparent" Background="Transparent" Template="{StaticResource ComboboxControlTemplate1}" >
<Fluent:ComboBox Size="Small" IsEditable="False" helper:EnumHelper.Enum="{x:Type model:ColorType}" SelectedItem="{Binding ColorType}" BorderThickness="0" BorderBrush="Transparent" Background="Transparent" Template="{StaticResource ComboboxControlTemplate1}" >
<Fluent:ComboBox.ItemTemplate>
<DataTemplate>
<iconPacks:PackIconMaterial x:Name="icon" Kind="FormatColorText" Width="12" Height="12" Margin="2"/>

View File

@@ -40,10 +40,8 @@ namespace AIStudio.Wpf.ADiagram
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
MainWindowViewModel.KeyCommand.Execute(e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
}
e.Handled = MainWindowViewModel.KeyExecuted(e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
}
private void HookEvents()
{

View File

@@ -4,13 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:views="clr-namespace:AIStudio.Wpf.ADiagram.Views"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:helper="clr-namespace:AIStudio.Wpf.ADiagram.Helpers"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:helper="clr-namespace:AIStudio.Wpf.BaseDiagram.Helpers;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:flowchart="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Flowchart"
xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>

View File

@@ -3,13 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:views="clr-namespace:AIStudio.Wpf.ADiagram.Views"
xmlns:viewmodels="clr-namespace:AIStudio.Wpf.ADiagram.ViewModels"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Models"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:conventer="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:command="clr-namespace:AIStudio.Wpf.ADiagram.Commands"
xmlns:conventer="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:command="clr-namespace:AIStudio.Wpf.BaseDiagram.Commands;assembly=AIStudio.Wpf.BaseDiagram"
xmlns:svg="clr-namespace:Svg2XamlTestExtension;assembly=Svg2XamlTestExtension"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
@@ -17,7 +16,9 @@
<ResourceDictionary>
<conventer:StringPathConverter x:Key="stringPathConverter"/>
<conventer:IntVisibilityConverter x:Key="IntVisibilityConverter"/>
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding DeleteItemCommand}"/>
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
@@ -147,7 +148,7 @@
TextDecorations="{Binding FontViewModel.TextDecorations}"
HorizontalContentAlignment="{Binding FontViewModel.HorizontalAlignment}"
VerticalContentAlignment="{Binding FontViewModel.VerticalAlignment}"
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"/>
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"/>
</Grid>
</Viewbox>
@@ -158,7 +159,43 @@
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:FlowchartToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Viewbox Stretch="Fill">
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
<TextBlock Text="{Binding Text}" Margin="5" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Left" />
</Grid>
</Viewbox>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:SFCToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
</Grid>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:ToolBoxCategory}">
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<Expander Header="{Binding Header}"

View File

@@ -0,0 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Fluent.Ribbon" Version="8.0.3" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Util.Svg2XamlTestExtension" Version="1.2.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Util.DiagramDesigner\Util.DiagramDesigner.csproj" />
</ItemGroup>
<ItemGroup>
<Page Update="Controls\Barcode.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Controls\GradientStopControl.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Controls\MultiSelectComboBox.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Controls\PopupWindow.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Controls\PropertiesView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Controls\SliderRotation.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Extensions\ViewModels\BarcodeDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Extensions\ViewModels\OutLineTextDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Extensions\ViewModels\PathItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Extensions\ViewModels\PersistDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Extensions\ViewModels\SettingsDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Extensions\ViewModels\SvgDesignerItemViewModel.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="zxing.core">
<HintPath>..\AIStudio.Wpf.ADiagram\zxing.core.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -1,11 +1,11 @@
using AIStudio.Wpf.ADiagram.Services;
using AIStudio.Wpf.BaseDiagram.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram
namespace AIStudio.Wpf.BaseDiagram
{
/// <summary>
/// Simple service interface

View File

@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// This class allows delegating the commanding logic to methods passed as parameters,

View File

@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
public class CommandReference : Freezable, ICommand
{

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// The CompositeCommand composes one or more ICommands.

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
@@ -9,7 +8,7 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
[MarkupExtensionReturnType(typeof(object))]
public class ControlBinding : MarkupExtension

View File

@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
#region ConbrolCommand

View File

@@ -3,7 +3,7 @@ using System.Linq.Expressions;
using System.Reflection;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// An <see cref="ICommand"/> whose delegates can be attached for <see cref="Execute(T)"/> and <see cref="CanExecute(T)"/>.

View File

@@ -5,7 +5,7 @@ using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// An <see cref="ICommand"/> whose delegates do not take any parameters for <see cref="Execute()"/> and <see cref="CanExecute()"/>.

View File

@@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// An <see cref="ICommand"/> whose delegates can be attached for <see cref="Execute"/> and <see cref="CanExecute"/>.

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// Interface that defines if the object instance is active

View File

@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// Provide a way to observe property changes of INotifyPropertyChanged objects and invokes a

View File

@@ -6,7 +6,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Commands
namespace AIStudio.Wpf.BaseDiagram.Commands
{
/// <summary>
/// Represents each node of nested properties expression and takes care of

View File

@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// 包含一些常用的动画辅助方法

View File

@@ -1,9 +1,9 @@
<UserControl x:Class="AIStudio.Wpf.ADiagram.Controls.Barcode"
<UserControl x:Class="AIStudio.Wpf.BaseDiagram.Controls.Barcode"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:local="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>

View File

@@ -16,7 +16,7 @@ using WpfAnimatedGif;
using ZXing;
using ZXing.Presentation;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// Barcode.xaml 的交互逻辑

View File

@@ -1,12 +1,12 @@
<UserControl x:Class="AIStudio.Wpf.ADiagram.Controls.GradientStopControl"
<UserControl x:Class="AIStudio.Wpf.BaseDiagram.Controls.GradientStopControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:local="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:helper="clr-namespace:AIStudio.Wpf.ADiagram.Helpers"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters"
xmlns:helper="clr-namespace:AIStudio.Wpf.BaseDiagram.Helpers"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"

View File

@@ -14,7 +14,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// GradientStopControl.xaml 的交互逻辑

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="AIStudio.Wpf.ADiagram.Controls.MultiSelectComboBox"
<UserControl x:Class="AIStudio.Wpf.BaseDiagram.Controls.MultiSelectComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ComboBox Background="Transparent" BorderBrush="Transparent"

View File

@@ -14,10 +14,10 @@ using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Collections;
using AIStudio.Wpf.ADiagram.Helpers;
using AIStudio.Wpf.BaseDiagram.Helpers;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// Interaction logic for MultiSelectComboBox.xaml

View File

@@ -2,11 +2,10 @@
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
public class OutlineText : FrameworkElement
{

View File

@@ -1,4 +1,4 @@
<Window x:Class="AIStudio.Wpf.ADiagram.Controls.PopupWindow"
<Window x:Class="AIStudio.Wpf.BaseDiagram.Controls.PopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Binding Title}"

View File

@@ -12,7 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// PopupWindow.xaml 的交互逻辑

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="AIStudio.Wpf.ADiagram.Controls.PropertiesView"
<UserControl x:Class="AIStudio.Wpf.BaseDiagram.Controls.PropertiesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
@@ -7,7 +7,7 @@
<ControlTemplate x:Key="validationErrorTemplate">
<DockPanel>
<Image Source="/AIStudio.Wpf.ADiagram;component/Images/error.png" Height="16" Width="16"
<Image Source="/AIStudio.Wpf.BaseDiagram;component/Images/error.png" Height="16" Width="16"
DockPanel.Dock="Right" Margin="-18,0,0,0"
ToolTip="{Binding ElementName=adorner,
Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">

View File

@@ -14,7 +14,7 @@ using System.Windows.Shapes;
using System.ComponentModel;
using System.Reflection;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// Interaction logic for PropertiesView.xaml

View File

@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
public class RectangleGridEventArgs
{

View File

@@ -1,9 +1,9 @@
<UserControl x:Class="AIStudio.Wpf.ADiagram.Controls.SliderRotation"
<UserControl x:Class="AIStudio.Wpf.BaseDiagram.Controls.SliderRotation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:local="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Name="sliderRotation"

View File

@@ -12,7 +12,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// SliderRotation.xaml 的交互逻辑

View File

@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Controls
namespace AIStudio.Wpf.BaseDiagram.Controls
{
/// <summary>
/// A ruler control which supports both centimeters and inches. In order to use it vertically, change the <see cref="Marks">Marks</see> property to <c>Up</c> and rotate it ninety degrees.

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class BoolVisibilityConverter : IValueConverter
{

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class Boolean2VisibilityReConverter : IValueConverter
{

View File

@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ConverterBoolToValueMap : MarkupExtension, IValueConverter
{

View File

@@ -7,7 +7,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ConverterValueMapSetToVisibility : MarkupExtension, IValueConverter
{

View File

@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ConverterValueMapToBool : MarkupExtension, IValueConverter
{

View File

@@ -7,7 +7,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ConverterValueMapToVisibility : MarkupExtension, IValueConverter
{

View File

@@ -7,7 +7,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ConverterValueSetToOppositeVisibility : MarkupExtension, IValueConverter
{

View File

@@ -0,0 +1,176 @@
using System;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.BaseDiagram.Converters
{
#region Half
public class HalfConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var doubleValue = (value as double?).GetValueOrDefault();
return doubleValue / 2;
}
public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region String IsNullOrEmpty
public class IsNullOrEmptyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty((string)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region True -> False
public class BoolInverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region True -> Visible Or Collpased
public class BoolToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
public class BoolToInvisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region object try to convert to image (if is uri)
public class IconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || !(value.GetType() == typeof(string)))
return value;
var iconString = value as string;
if (!string.IsNullOrEmpty(iconString) && Uri.IsWellFormedUriString(iconString, UriKind.RelativeOrAbsolute))
{
var image = new System.Windows.Controls.Image()
{
Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(iconString, UriKind.RelativeOrAbsolute)),
};
System.Windows.Media.RenderOptions.SetBitmapScalingMode(image, System.Windows.Media.BitmapScalingMode.HighQuality);
return image;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region Double -> GridLength
public class GridLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var length = value?.ToString();
try
{
return (GridLength)TypeDescriptor.GetConverter(typeof(GridLength)).ConvertFromString(length);
}
catch
{
return new GridLength(1, GridUnitType.Auto);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
#region Combiner
public class MultiCombinerConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values.Clone();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return new object[] { DependencyProperty.UnsetValue, DependencyProperty.UnsetValue };
}
}
#endregion
#region NotAlignmentCenter
public class NotAlignmentCenterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is HorizontalAlignment)
{
var alignment = (HorizontalAlignment)value;
return alignment != HorizontalAlignment.Center;
}
else if (value is VerticalAlignment)
{
var alignment = (VerticalAlignment)value;
return alignment != VerticalAlignment.Center;
}
else
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
#endregion
}

View File

@@ -2,10 +2,10 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using AIStudio.Wpf.ADiagram.Controls;
using AIStudio.Wpf.BaseDiagram.Controls;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class CountShiftConverter : IMultiValueConverter
{

View File

@@ -2,7 +2,7 @@
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class DoubleToThickness : IValueConverter
{

View File

@@ -21,7 +21,7 @@ using System.Text;
using System.Windows.Data;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
class HtmlColorConverter : IValueConverter
{

View File

@@ -9,7 +9,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class IndentConverter : IValueConverter
{

View File

@@ -0,0 +1,24 @@
using System;
using System.Windows.Data;
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class IntToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, 0d))
return false;
else
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, false))
return 0d;
else
return 1d;
}
}
}

View File

@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
//选中项索引转换成可见项
public class IntVisibilityConverter : MarkupExtension, IValueConverter

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class NullableToBooleanConverter : IValueConverter
{

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class NullableToVisibilityConverter : IValueConverter
{

View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class NumberConverter : IValueConverter
{

View File

@@ -1,4 +1,4 @@
using AIStudio.Wpf.ADiagram.Controls;
using AIStudio.Wpf.BaseDiagram.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
using System.Windows.Data;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class RulerUnitConverter : IValueConverter
{

View File

@@ -7,7 +7,7 @@ using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class StringPathConverter : IValueConverter
{

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
/// <summary>
/// Converts a Thickness to a new Thickness. It's possible to ignore a side With the IgnoreThicknessSide property.

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.ADiagram.Converters
namespace AIStudio.Wpf.BaseDiagram.Converters
{
public class ThicknessToDoubleConverter : IValueConverter
{

View File

@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Util.DiagramDesigner;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.Models
{
public class PathDesignerItem : DesignerItemBase
{

View File

@@ -1,12 +1,8 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.Xml.Serialization;
using Util.DiagramDesigner;
using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.Models
{
public class PersistDesignerItem : DesignerItemBase
{

View File

@@ -1,13 +1,9 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.Models
{
public class SettingsDesignerItem : DesignerItemBase
public class SettingsDesignerItem : DesignerItemBase
{
public SettingsDesignerItem()
{

View File

@@ -1,16 +1,9 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using AIStudio.Wpf.ADiagram.Commands;
using AIStudio.Wpf.BaseDiagram.Commands;
using AIStudio.Wpf.BaseDiagram.Models;
using System.Windows.Input;
using AIStudio.Wpf.ADiagram.Models;
using ZXing;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class BarcodeDesignerItemData : TitleBindableBase
{

View File

@@ -1,17 +1,9 @@
using AIStudio.Wpf.ADiagram.Services;
using Util.DiagramDesigner;
using AIStudio.Wpf.BaseDiagram.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
using System.Globalization;
using Util.DiagramDesigner;
using ZXing;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class BarcodeDesignerItemViewModel : DesignerItemViewModelBase
{
@@ -39,7 +31,6 @@ namespace AIStudio.Wpf.ADiagram.Demos.Others
base.LoadDesignerItemViewModel(parent, designerbase);
Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), (designerbase as DesignerItemBase).Reserve.ToString());
ShowText = false;
}
public void AutoSize()
@@ -62,6 +53,19 @@ namespace AIStudio.Wpf.ADiagram.Demos.Others
public BarcodeFormat Format { get; set; } = BarcodeFormat.QR_CODE;
private bool _showText;
public override bool ShowText
{
get
{
return false;
}
set
{
SetProperty(ref _showText, value);
}
}
public override bool EditData()
{
if (IsReadOnly == true) return false;
@@ -71,7 +75,6 @@ namespace AIStudio.Wpf.ADiagram.Demos.Others
{
bool needauto = Text == null;
Text = data.Text;
ShowText = false;
Icon = data.Icon;
Margin = data.Margin;
if (needauto)

View File

@@ -1,9 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
@@ -14,14 +14,14 @@
<s:ColorBrushConverter x:Key="ColorBrushConverter"/>
<DataTemplate DataType="{x:Type model:BarcodeDesignerItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:BarcodeDesignerItemViewModel}">
<Viewbox Stretch="Fill" IsHitTestVisible="False">
<controls:Barcode Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" Padding="{Binding Margin,Converter={StaticResource DoubleToThickness}}" Text="{Binding Text}" Icon="{Binding Icon}" Format="{Binding Format}"/>
</Viewbox>
</DataTemplate>
<!-- DataTemplate for Popup look and feel -->
<DataTemplate DataType="{x:Type model:BarcodeDesignerItemData}">
<DataTemplate DataType="{x:Type viewmodel:BarcodeDesignerItemData}">
<Grid Width="550">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View File

@@ -1,13 +1,7 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.BaseDiagram.Models;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class OutLineTextDesignerItemData : TitleBindableBase
{

View File

@@ -1,16 +1,10 @@
using AIStudio.Wpf.ADiagram.Services;
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
using AIStudio.Wpf.BaseDiagram.Services;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class OutLineTextDesignerItemViewModel : TextDesignerItemViewModel
{

View File

@@ -1,9 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
@@ -13,7 +13,7 @@
<converter:DoubleToThickness x:Key="DoubleToThickness"/>
<s:ColorBrushConverter x:Key="ColorBrushConverter"/>
<DataTemplate DataType="{x:Type model:OutLineTextDesignerItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:OutLineTextDesignerItemViewModel}">
<Viewbox Stretch="Fill" IsHitTestVisible="False">
<controls:OutlineText StrokePosition="Outside"
Text="{Binding Text}"
@@ -30,7 +30,7 @@
</DataTemplate>
<!-- DataTemplate for Popup look and feel -->
<DataTemplate DataType="{x:Type model:OutLineTextDesignerItemData}">
<DataTemplate DataType="{x:Type viewmodel:OutLineTextDesignerItemData}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -91,19 +91,19 @@
</Fluent:ComboBox>
<Fluent:ToggleButton KeyTip="B"
x:Name="buttonBold"
Icon="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Images/Bold.png"
Icon="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Images/Bold.png"
HorizontalAlignment="Left"
SizeDefinition="Small"
IsChecked="{Binding FontViewModel.FontWeight,Converter={converter:ConverterValueMapToBool Parameter='Regular'}, ConverterParameter='Bold'}"/>
<Fluent:ToggleButton x:Name="buttonItalic"
KeyTip="I"
Icon="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Images/Italic.png"
Icon="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Images/Italic.png"
HorizontalAlignment="Left"
SizeDefinition="Small"
IsChecked="{Binding FontViewModel.FontStyle,Converter={converter:ConverterValueMapToBool Parameter='Normal'}, ConverterParameter='Italic'}"/>
<Fluent:ToggleButton x:Name="buttonUnderline"
KeyTip="U"
Icon="pack://application:,,,/AIStudio.Wpf.ADiagram;component/Images/Underline.png"
Icon="pack://application:,,,/AIStudio.Wpf.BaseDiagram;component/Images/Underline.png"
HorizontalAlignment="Left"
SizeDefinition="Small"
IsChecked="{Binding FontViewModel.Underline}"/>

View File

@@ -1,12 +1,6 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class PathItemViewModel : DesignerItemViewModelBase
{

View File

@@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:convent="clr-namespace:AIStudio.Wpf.ADiagram.Converters">
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:convent="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters">
<convent:StringPathConverter x:Key="stringPathConverter"/>
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
<Brush x:Key="ItemStroke">#FFD69436</Brush>
@@ -25,7 +25,7 @@
<Setter Property="Data" Value="{Binding Icon,Converter={StaticResource stringPathConverter}}"/>
</Style>
<DataTemplate DataType="{x:Type model:PathItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:PathItemViewModel}">
<Grid>
<Path Tag="Process" IsHitTestVisible="False" Style="{StaticResource PathItemStyle}"/>
</Grid>

View File

@@ -1,12 +1,6 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.BaseDiagram.Models;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
/// <summary>
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the

View File

@@ -1,14 +1,8 @@
using AIStudio.Wpf.ADiagram.Services;
using AIStudio.Wpf.BaseDiagram.Services;
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using AIStudio.Wpf.BaseDiagram.Extensions.Models;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class PersistDesignerItemViewModel : DesignerItemViewModelBase
{

View File

@@ -1,9 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
@@ -44,7 +44,7 @@
</ControlTemplate>
<!-- DataTemplate for DesignerCanvas look and feel -->
<DataTemplate DataType="{x:Type model:PersistDesignerItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:PersistDesignerItemViewModel}">
<Grid>
<Image IsHitTestVisible="False"
Stretch="Fill"
@@ -59,7 +59,7 @@
</DataTemplate>
<!-- DataTemplate for Popup look and feel -->
<DataTemplate DataType="{x:Type model:PersistDesignerItemData}">
<DataTemplate DataType="{x:Type viewmodel:PersistDesignerItemData}">
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View File

@@ -1,12 +1,6 @@
using Util.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.ADiagram.Models;
using AIStudio.Wpf.BaseDiagram.Models;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
/// <summary>
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the

View File

@@ -1,14 +1,9 @@
using AIStudio.Wpf.ADiagram.Services;
using Util.DiagramDesigner;
using AIStudio.Wpf.BaseDiagram.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using Util.DiagramDesigner;
using AIStudio.Wpf.BaseDiagram.Extensions.Models;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class SettingsDesignerItemViewModel : DesignerItemViewModelBase
{

View File

@@ -1,9 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:converter="clr-namespace:AIStudio.Wpf.ADiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.ADiagram.Controls"
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters"
xmlns:controls="clr-namespace:AIStudio.Wpf.BaseDiagram.Controls"
xmlns:dd="https://astudio.github.io/diagram"
xmlns:Fluent="urn:fluent-ribbon"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
@@ -44,7 +44,7 @@
</ControlTemplate>
<!-- DataTemplate for DesignerCanvas look and feel -->
<DataTemplate DataType="{x:Type model:SettingsDesignerItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:SettingsDesignerItemViewModel}">
<Grid>
<Image IsHitTestVisible="False"
Stretch="Fill"
@@ -59,7 +59,7 @@
</DataTemplate>
<!-- DataTemplate for Popup look and feel -->
<DataTemplate DataType="{x:Type model:SettingsDesignerItemData}">
<DataTemplate DataType="{x:Type viewmodel:SettingsDesignerItemData}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View File

@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Util.DiagramDesigner;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.ADiagram.Demos.Others
namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels
{
public class SvgDesignerItemViewModel: MediaItemViewModel
{

View File

@@ -1,11 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
xmlns:model="clr-namespace:AIStudio.Wpf.ADiagram.Demos.Others"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.BaseDiagram.Extensions.ViewModels"
xmlns:svg="clr-namespace:Svg2XamlTestExtension;assembly=Svg2XamlTestExtension">
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
<DataTemplate DataType="{x:Type model:SvgDesignerItemViewModel}">
<DataTemplate DataType="{x:Type viewmodel:SvgDesignerItemViewModel}">
<Grid IsHitTestVisible="False">
<svg:PackSvg Width="Auto" Height="Auto" Path="{Binding Icon}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
</Grid>

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace AIStudio.Wpf.ADiagram.Helpers
namespace AIStudio.Wpf.BaseDiagram.Helpers
{
public class EnumHelper : DependencyObject
{

View File

@@ -7,7 +7,7 @@ using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Helpers
namespace AIStudio.Wpf.BaseDiagram.Helpers
{
public class NewNameHelper
{

View File

@@ -5,7 +5,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.ADiagram.Helpers
namespace AIStudio.Wpf.BaseDiagram.Helpers
{
public class TypeHelper
{

View File

@@ -6,7 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace AIStudio.Wpf.ADiagram.Helpers
namespace AIStudio.Wpf.BaseDiagram.Helpers
{
public class XmlSerializeHelper
{

Some files were not shown because too many files have changed in this diff Show More