demo提交

This commit is contained in:
艾竹
2023-01-25 23:55:30 +08:00
parent b857151bdc
commit f11a4170d8
49 changed files with 1220 additions and 184 deletions

View File

@@ -4,12 +4,13 @@ using System;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Helpers;
using System.Windows;
namespace AIStudio.Wpf.DiagramApp.Models
{
public class PathToolBoxData : ToolBoxData
{
public PathToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(null, icon, type, width, height)
public PathToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -18,7 +19,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class TextToolBoxData : ToolBoxData
{
public TextToolBoxData(string text, Type type, double width = 32, double height = 32) : base(text, null, type, width, height)
public TextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(text, null, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -27,7 +28,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class EllipseTextToolBoxData : ToolBoxData
{
public EllipseTextToolBoxData(string text, Type type, double width = 32, double height = 32) : base(text, null, type, width, height)
public EllipseTextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(text, null, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -36,7 +37,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class ImageToolBoxData : ToolBoxData
{
public ImageToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(null, icon, type, width, height)
public ImageToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, description)
{
}
@@ -46,7 +47,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
{
public string FileName { get; set; }
public DesignerItemViewModelBase DesignerItemViewModel { get; set; }
public DesignerItemToolBoxData(DesignerItemBase designerItemBase, string filename, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
public DesignerItemToolBoxData(DesignerItemBase designerItemBase, string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, null, type, width, height, desiredSize, description)
{
Addition = designerItemBase;
DesignerItemViewModel = Activator.CreateInstance(type, null, designerItemBase) as DesignerItemViewModelBase;
@@ -57,7 +58,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class SvgToolBoxData : ToolBoxData
{
public SvgToolBoxData(string filename, Type type, double width = 32, double height = 32) : base(null, filename, type, width, height)
public SvgToolBoxData(string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, filename, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Blue;
}
@@ -65,7 +66,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class MediaToolBoxData : ToolBoxData
{
public MediaToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(icon, null, type, width, height)
public MediaToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(icon, null, type, width, height, desiredSize, description)
{
}

View File

@@ -3,13 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ScrollBar.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/Expander.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/GroupBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ToolTip.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ScrollViewer.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ZoomBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ComboBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Themes/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Styles/Fluent.xaml" />
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Styles/Expander.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Styles/ListBox.xaml"/>

View File

@@ -25,7 +25,13 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class ToolBoxViewModel : BindableBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
private IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
public ToolBoxViewModel()
{
Init();
@@ -44,11 +50,26 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public ObservableCollection<ToolBoxCategory> TotalToolBoxCategory { get; set; }
public ObservableCollection<ToolBoxCategory> TotalToolBoxCategory
{
get; set;
}
public ToolBoxCategory MyToolBoxCategory { get { return ToolBoxCategory[0]; } }
public ToolBoxCategory MyToolBoxCategory
{
get
{
return ToolBoxCategory?.FirstOrDefault();
}
}
public ToolBoxCategory SvgToolBoxCategory { get { return ToolBoxCategory[2]; } }
public ToolBoxCategory SvgToolBoxCategory
{
get
{
return ToolBoxCategory?.FirstOrDefault(p => p.Header == "Svg");
}
}
private ICommand _deleteCommand;
public ICommand DeleteCommand
@@ -91,11 +112,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
ToolBoxCategory.Add(new MineToolBoxCategory() { Header = "我的形状", ToolBoxItems = new ObservableCollection<ToolBoxData>(), IsExpanded = true });
List<ToolBoxData> toolBoxItems = new List<ToolBoxData>();
toolBoxItems.Add(new ImageToolBoxData("../Images/Setting.png", typeof(SettingsDesignerItemViewModel)));
toolBoxItems.Add(new ImageToolBoxData("../Images/Persist.png", typeof(PersistDesignerItemViewModel)));
toolBoxItems.Add(new ImageToolBoxData("../Images/Setting.png", typeof(SettingsDesignerItemViewModel), description: "致谢WPF-Diagram-Designer的开源作者保留开源作品中的两个设计"));
toolBoxItems.Add(new ImageToolBoxData("../Images/Persist.png", typeof(PersistDesignerItemViewModel), description: "致谢WPF-Diagram-Designer的开源作者保留开源作品中的两个设计"));
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "WPF-Diagram-Designer", ToolBoxItems = new ObservableCollection<ToolBoxData>(toolBoxItems), IsExpanded = true });
List<ToolBoxData> defaultToolBoxItems = new List<ToolBoxData>();
defaultToolBoxItems.Add(new TextToolBoxData("", typeof(DefaultDesignerItemViewModel)));
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "Default", ToolBoxItems = new ObservableCollection<ToolBoxData>(defaultToolBoxItems), IsExpanded = true });
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "Svg", ToolBoxItems = new ObservableCollection<ToolBoxData>() });
List<PathToolBoxData> pathToolBoxItems = new List<PathToolBoxData>();
@@ -240,7 +267,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
try
{
var xmlobject = JsonConvert.DeserializeObject<DiagramDocument>(File.ReadAllText(filename));
var xmlobject = JsonConvert.DeserializeObject<DiagramDocument>(File.ReadAllText(filename));
Type type = TypeHelper.GetType(xmlobject.DiagramItems[0].DesignerItems[0].SerializableTypeName);
@@ -294,7 +321,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public class ToolBoxCategory : BindableBase
{
public string Header { get; set; }
public string Header
{
get; set;
}
private bool _isExpanded;
public bool IsExpanded

View File

@@ -23,7 +23,7 @@
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -41,7 +41,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:MediaToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -59,7 +59,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:TextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -75,7 +75,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:EllipseTextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Ellipse Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -91,7 +91,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:PathToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -106,7 +106,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:SvgToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
@@ -121,7 +121,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:DesignerItemToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
@@ -162,7 +162,7 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type flowchartmodel:FlowchartToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"