Mind 出发

This commit is contained in:
艾竹
2023-02-12 21:30:16 +08:00
parent 934357c87c
commit 4d36eac218
27 changed files with 491 additions and 133 deletions

View File

@@ -124,6 +124,7 @@
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Mind\AIStudio.Wpf.Mind.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
</ItemGroup>

View File

@@ -12,6 +12,7 @@
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Themes/FlowNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Logical;component/Themes/LogicalGateItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.SFC;component/Themes/SFCNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Themes/MindNode.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -13,7 +13,7 @@ using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.Flowchart
{
public class FlowchartViewModel : DiagramsViewModel
public class FlowchartViewModel : PageViewModel
{
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{

View File

@@ -9,7 +9,7 @@ using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.Logical
{
public class LogicalViewModel : DiagramsViewModel
public class LogicalViewModel : PageViewModel
{
public LogicalViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{

View File

@@ -29,9 +29,9 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
ToolBoxViewModel = new ToolBoxViewModel();
DiagramsViewModels = new ObservableCollection<DiagramsViewModel>();
DiagramsViewModels.Add(new DiagramsViewModel("新建-1", "*", DiagramType.Normal));
DiagramsViewModel = DiagramsViewModels.FirstOrDefault();
DiagramsViewModels = new ObservableCollection<PageViewModel>();
DiagramsViewModels.Add(new PageViewModel("新建-1", "*", DiagramType.Normal));
PageViewModel = DiagramsViewModels.FirstOrDefault();
StandardColor = GenerateStandardGradients();
@@ -50,8 +50,8 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
#region
public ToolBoxViewModel ToolBoxViewModel { get; private set; }
private ObservableCollection<DiagramsViewModel> _diagramsViewModels;
public ObservableCollection<DiagramsViewModel> DiagramsViewModels
private ObservableCollection<PageViewModel> _diagramsViewModels;
public ObservableCollection<PageViewModel> DiagramsViewModels
{
get
{
@@ -63,8 +63,8 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
private DiagramsViewModel _diagramsViewModel;
public DiagramsViewModel DiagramsViewModel
private PageViewModel _diagramsViewModel;
public PageViewModel PageViewModel
{
get
{
@@ -215,14 +215,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
#endregion
public Func<DiagramsViewModel> NewItemFactory
public Func<PageViewModel> NewItemFactory
{
get
{
return
() =>
{
return new DiagramsViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
return new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
};
}
}
@@ -659,7 +659,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
//here's how you can cancel stuff:
//args.Cancel();
if (args.DragablzItem.DataContext is DiagramsViewModel viewModel)
if (args.DragablzItem.DataContext is PageViewModel viewModel)
{
viewModel.Dispose();
}
@@ -683,22 +683,22 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
RaisePropertyChanged(e.PropertyName);
}
if (DiagramsViewModel == null) return;
if (PageViewModel == null) return;
if (sender is IFontViewModel)
DiagramsViewModel.SetFont(sender as IFontViewModel, e.PropertyName);
PageViewModel.SetFont(sender as IFontViewModel, e.PropertyName);
if (sender is IColorViewModel)
DiagramsViewModel.SetColor(sender as IColorViewModel, e.PropertyName);
PageViewModel.SetColor(sender as IColorViewModel, e.PropertyName);
if (sender is IShapeViewModel)
DiagramsViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName);
PageViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName);
if (sender is IQuickThemeViewModel)
DiagramsViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName);
PageViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName);
if (sender is LockObject)
DiagramsViewModel.LockAction(sender as LockObject, e.PropertyName);
PageViewModel.LockAction(sender as LockObject, e.PropertyName);
if (sender is DesignerItemViewModelBase designer
&& (e.PropertyName == nameof(designer.Angle)
@@ -707,14 +707,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|| e.PropertyName == nameof(designer.ScaleX)
|| e.PropertyName == nameof(designer.ScaleY)))
{
DiagramsViewModel.SetPropertyValue(designer, e.PropertyName);
PageViewModel.SetPropertyValue(designer, e.PropertyName);
}
}
public bool KeyExecuted(KeyEventArgs e)
{
if (DiagramsViewModel?.DiagramViewModel?.ExecuteShortcut(e) == true)
if (PageViewModel?.DiagramViewModel?.ExecuteShortcut(e) == true)
{
return true;
}
@@ -734,17 +734,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void UnDoExecuted()
{
DiagramsViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
PageViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
}
private void ReDoExecuted()
{
DiagramsViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
PageViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
}
private void SelectedAllExecuted()
{
DiagramsViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
}
private void OpenExecuted(string para = null)
@@ -771,13 +771,13 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
var viewmodel = DiagramsViewModels.FirstOrDefault(p => p.FileName == filename);
if (viewmodel != null)
{
DiagramsViewModel = viewmodel;
PageViewModel = viewmodel;
MessageBox.Show("文档已经打开");
return;
}
var diagram = DiagramsViewModel.OpenFile(filename, Path.GetExtension(filename));
DiagramsViewModel flow;
var diagram = PageViewModel.OpenFile(filename, Path.GetExtension(filename));
PageViewModel flow;
if (diagram.DiagramType == DiagramType.FlowChart)
{
flow = new FlowchartViewModel(filename, diagram);
@@ -792,14 +792,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
else
{
flow = new DiagramsViewModel(filename, diagram);
flow = new PageViewModel(filename, diagram);
}
DiagramsViewModels.Add(flow);
DiagramsViewModel = flow;
PageViewModel = flow;
if (string.IsNullOrEmpty(para))
{
SaveHistory(DiagramsViewModel);
SaveHistory(PageViewModel);
}
else
{
@@ -810,39 +810,39 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void SaveExecuted()
{
if (DiagramsViewModel == null) return;
if (PageViewModel == null) return;
if (DiagramsViewModel.SaveFile())
if (PageViewModel.SaveFile())
{
SaveHistory(DiagramsViewModel);
SaveHistory(PageViewModel);
}
}
private void SaveAsExecuted()
{
if (DiagramsViewModel == null) return;
if (PageViewModel == null) return;
if (DiagramsViewModel.SaveFile(true))
if (PageViewModel.SaveFile(true))
{
SaveHistory(DiagramsViewModel);
SaveHistory(PageViewModel);
}
}
private void SaveHistory(DiagramsViewModel diagramsViewModel)
private void SaveHistory(PageViewModel diagramsViewModel)
{
HistoryList.Remove(DiagramsViewModel.FileName);
HistoryList.Insert(0, DiagramsViewModel.FileName);
HistoryList.Remove(PageViewModel.FileName);
HistoryList.Insert(0, PageViewModel.FileName);
File.WriteAllText(_history, JsonConvert.SerializeObject(HistoryList));
}
private bool Save_Enable()
{
return DiagramsViewModel != null;
return PageViewModel != null;
}
private void PasteExecuted()
{
DiagramsViewModel?.DiagramViewModel?.PasteCommand.Execute(null);
PageViewModel?.DiagramViewModel?.PasteCommand.Execute(null);
}
private bool Paste_Enabled()
@@ -852,32 +852,32 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void CopyExecuted()
{
DiagramsViewModel?.DiagramViewModel?.CopyCommand.Execute(null);
PageViewModel?.DiagramViewModel?.CopyCommand.Execute(null);
}
private bool Copy_Enabled()
{
return DiagramsViewModel != null && DiagramsViewModel.DiagramViewModel != null && DiagramsViewModel.DiagramViewModel.SelectedItems.Count() > 0;
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
}
private void DeleteExecuted()
{
DiagramsViewModel?.DiagramViewModel?.DeleteCommand.Execute(null);
PageViewModel?.DiagramViewModel?.DeleteCommand.Execute(null);
}
private bool Delete_Enabled()
{
return DiagramsViewModel != null && DiagramsViewModel.DiagramViewModel != null && DiagramsViewModel.DiagramViewModel.SelectedItems.Count() > 0;
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
}
private void CutExecuted()
{
DiagramsViewModel?.DiagramViewModel?.CutCommand.Execute(null);
PageViewModel?.DiagramViewModel?.CutCommand.Execute(null);
}
private bool Cut_Enabled()
{
return DiagramsViewModel != null && DiagramsViewModel.DiagramViewModel != null && DiagramsViewModel.DiagramViewModel.SelectedItems.Count() > 0;
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
}
private void FormatExecuted()
@@ -887,7 +887,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private bool Format_Enabled()
{
return DiagramsViewModel != null && DiagramsViewModel.DiagramViewModel != null && DiagramsViewModel.DiagramViewModel.SelectedItems.Count() == 1;
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() == 1;
}
private void New_Executed(string type = "Normal")
@@ -895,22 +895,26 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
IsOpenBackstage = false;
if (type == DiagramType.FlowChart.ToString())
{
DiagramsViewModel = new FlowchartViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
PageViewModel = new FlowchartViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.Logical.ToString())
{
DiagramsViewModel = new LogicalViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
PageViewModel = 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));
PageViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.Mind.ToString())
{
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else
{
DiagramsViewModel = new DiagramsViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
PageViewModel = new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
DiagramsViewModels.Add(DiagramsViewModel);
DiagramsViewModels.Add(PageViewModel);
}
private void ExitExecuted()
@@ -920,112 +924,112 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void GroupExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.GroupCommand.Execute(para);
PageViewModel?.DiagramViewModel?.GroupCommand.Execute(para);
}
private void UngroupExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.UngroupCommand.Execute(para);
PageViewModel?.DiagramViewModel?.UngroupCommand.Execute(para);
}
#region
private void AlignTopExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignTopCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignTopCommand.Execute(para);
}
private void AlignVerticalCentersExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
}
private void AlignBottomExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
}
private void AlignLeftExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
}
private void AlignHorizontalCentersExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignHorizontalCentersCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignHorizontalCentersCommand.Execute(para);
}
private void AlignRightExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.AlignRightCommand.Execute(para);
PageViewModel?.DiagramViewModel?.AlignRightCommand.Execute(para);
}
private void BringForwardExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.BringForwardCommand.Execute(para);
PageViewModel?.DiagramViewModel?.BringForwardCommand.Execute(para);
}
private void BringToFrontExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.BringToFrontCommand.Execute(para);
PageViewModel?.DiagramViewModel?.BringToFrontCommand.Execute(para);
}
private void SendBackwardExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
}
private void SendToBackExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
}
private void DistributeHorizontalExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.DistributeHorizontalCommand.Execute(para);
PageViewModel?.DiagramViewModel?.DistributeHorizontalCommand.Execute(para);
}
private void DistributeVerticalExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.DistributeVerticalCommand.Execute(para);
PageViewModel?.DiagramViewModel?.DistributeVerticalCommand.Execute(para);
}
private void SelectAllExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SelectAllCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(para);
}
#endregion
private void CenterMoveExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.CenterMoveCommand.Execute(para);
PageViewModel?.DiagramViewModel?.CenterMoveCommand.Execute(para);
}
private void LeftMoveExecuted(object para = null)
{
DiagramsViewModel?.DiagramViewModel?.LeftMoveCommand.Execute(para);
PageViewModel?.DiagramViewModel?.LeftMoveCommand.Execute(para);
}
private void RightMoveExecuted(object para = null)
{
DiagramsViewModel?.DiagramViewModel?.RightMoveCommand.Execute(para);
PageViewModel?.DiagramViewModel?.RightMoveCommand.Execute(para);
}
private void UpMoveExecuted(object para = null)
{
DiagramsViewModel?.DiagramViewModel?.UpMoveCommand.Execute(para);
PageViewModel?.DiagramViewModel?.UpMoveCommand.Execute(para);
}
private void DownMoveExecuted(object para = null)
{
DiagramsViewModel?.DiagramViewModel?.DownMoveCommand.Execute(para);
PageViewModel?.DiagramViewModel?.DownMoveCommand.Execute(para);
}
private void SameWidthExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SameWidthCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SameWidthCommand.Execute(para);
}
private void SameHeightExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SameHeightCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SameHeightCommand.Execute(para);
}
private void SameSizeExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SameSizeCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SameSizeCommand.Execute(para);
}
private void SameAngleExecuted(object para)
{
DiagramsViewModel?.DiagramViewModel?.SameAngleCommand.Execute(para);
PageViewModel?.DiagramViewModel?.SameAngleCommand.Execute(para);
}
private void LockExecuted(object para)
@@ -1040,62 +1044,62 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void AddPageExecuted(object para)
{
DiagramsViewModel?.AddPageExecuted(para);
PageViewModel?.AddPageExecuted(para);
}
private void AddCopyPageExecuted(object para)
{
DiagramsViewModel?.AddCopyPageExecuted(para);
PageViewModel?.AddCopyPageExecuted(para);
}
private void RenamePageExecuted(object para)
{
DiagramsViewModel?.RenamePageExecuted(para);
PageViewModel?.RenamePageExecuted(para);
}
private void EndRenamePageExecuted(object para)
{
DiagramsViewModel?.EndRenamePageExecuted(para);
PageViewModel?.EndRenamePageExecuted(para);
}
private void DeletePageExecuted(object para)
{
DiagramsViewModel?.DeletePageExecuted(para);
PageViewModel?.DeletePageExecuted(para);
}
private void AddImageExecuted(object para)
{
DiagramsViewModel?.AddImageExecuted(para);
PageViewModel?.AddImageExecuted(para);
}
private void EditImageExecuted(object para)
{
DiagramsViewModel?.EditImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
PageViewModel?.EditImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void ResizeImageExecuted(object para)
{
DiagramsViewModel?.ResizeImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
PageViewModel?.ResizeImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void ResetImageExecuted(object para)
{
DiagramsViewModel?.ResetImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
PageViewModel?.ResetImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void AddVideoExectued(object para)
{
DiagramsViewModel?.AddVideoExecuted(para);
PageViewModel?.AddVideoExecuted(para);
}
private void AddOutLineTextExecuted(object para)
{
DiagramsViewModel?.AddOutLineTextExecuted(para);
PageViewModel?.AddOutLineTextExecuted(para);
}
private void AddBarcodeExecuted(object para)
{
DiagramsViewModel?.AddBarcodeExecuted(para);
PageViewModel?.AddBarcodeExecuted(para);
}
private void SelectedColorExecuted(object para)
@@ -1104,9 +1108,9 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
switch (ColorType)
{
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;
case Models.ColorType.Text: PageViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
case Models.ColorType.Fill: PageViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
case Models.ColorType.Line: PageViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
}
}

View File

@@ -0,0 +1,59 @@
using AIStudio.Wpf.DiagramApp.Models;
using AIStudio.Wpf.DiagramApp.ViewModels;
using AIStudio.Wpf.Flowchart.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 AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.ViewModels;
namespace AIStudio.Wpf.Flowchart
{
public class MindViewModel : PageViewModel
{
public MindViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
}
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();
DiagramViewModel.GridCellSize = new Size(100, 100);
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
DiagramViewModel.AllowDrop = false;
}
protected override void Init()
{
base.Init();
DesignerItemViewModelBase start = new MindLevel1Node() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, Text = "思维导图" };
DiagramViewModel.DirectAddItemCommand.Execute(start);
DiagramViewModel?.CenterMoveCommand.Execute(start);
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
}
public override void Dispose()
{
base.Dispose();
foreach (var viewModel in DiagramViewModels)
{
FlowchartService.DisposeData(viewModel);
}
}
}
}

View File

@@ -21,11 +21,11 @@ using AIStudio.Wpf.DiagramDesigner.Helpers;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public partial class DiagramsViewModel : BindableBase
public partial class PageViewModel : BindableBase
{
protected IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
public DiagramsViewModel(string title, string status, DiagramType diagramType)
public PageViewModel(string title, string status, DiagramType diagramType)
{
Title = title;
Status = status;
@@ -39,7 +39,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
Init();
}
public DiagramsViewModel(string filename)
public PageViewModel(string filename)
{
FileName = filename;
string ext = Path.GetExtension(filename);
@@ -47,7 +47,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
OpenFile(diagramDocument, ext);
}
public DiagramsViewModel(string filename, DiagramDocument diagramDocument)
public PageViewModel(string filename, DiagramDocument diagramDocument)
{
FileName = filename;
string ext = Path.GetExtension(filename);
@@ -253,6 +253,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
viewModel.PageSizeType = diagramItem.PageSizeType;
viewModel.PhysicalGridMarginSize = diagramItem.PhysicalGridMarginSize;
viewModel.GridColor = diagramItem.GridColor;
viewModel.AllowDrop = diagramItem.AllowDrop;
foreach (var diagramItemData in diagramItem.DesignerItems)
{

View File

@@ -16,7 +16,7 @@ using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.Flowchart
{
public class SFCViewModel : DiagramsViewModel
public class SFCViewModel : PageViewModel
{
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{

View File

@@ -94,6 +94,9 @@
<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>
<Button Margin="5" ToolTip="思维导图" Command="{Binding NewCommand}" CommandParameter="Mind" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M768 128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v7.296a128 128 0 0 1 0 241.408V640c0 46.933333 38.4 85.333333 85.333333 85.333333h49.92A128.128 128.128 0 0 1 640 640h128a128 128 0 1 1 0 256h-128a128 128 0 0 1-120.704-85.333333H469.333333c-94.293333 0-170.666667-76.373333-170.666666-170.666667H213.333333a128 128 0 1 1 0-256h85.333334c0-94.293333 76.373333-170.666667 170.666666-170.666667h49.92A128.128 128.128 0 0 1 640 128h128z m0 597.333333h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334zM341.333333 469.333333H213.333333a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z m426.666667-256h-128a42.666667 42.666667 0 0 0 0 85.333334h128a42.666667 42.666667 0 0 0 0-85.333334z" ></Path>
</Button>
</WrapPanel>
</TabItem>
<TabItem Header="待续" />
@@ -309,7 +312,7 @@
Header="撤销"
Icon="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Images/undo.png"
SizeDefinition="Middle,Small"
Command="{Binding DiagramsViewModel.DiagramViewModel.UndoCommand}">
Command="{Binding PageViewModel.DiagramViewModel.UndoCommand}">
<Fluent:Button.ToolTip>
<Fluent:ScreenTip Title="Undo"
Text="撤销操作"
@@ -320,7 +323,7 @@
Header="重做"
Icon="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Images/redo.png"
SizeDefinition="Middle,Small"
Command="{Binding DiagramsViewModel.DiagramViewModel.RedoCommand}">
Command="{Binding PageViewModel.DiagramViewModel.RedoCommand}">
<Fluent:Button.ToolTip>
<Fluent:ScreenTip Title="Redo"
Text="重做操作"
@@ -1461,7 +1464,7 @@
<TextBlock Text="S" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="9"/>
</Grid>
</Fluent:SplitButton.LargeIcon>
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageSizeType}" SelectedItem="{Binding DiagramsViewModel.DiagramViewModel.PageSizeType}">
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageSizeType}" SelectedItem="{Binding PageViewModel.DiagramViewModel.PageSizeType}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" Margin="5"/>
@@ -1478,7 +1481,7 @@
<Fluent:SplitButton.LargeIcon>
<iconPacks:PackIconMaterial Kind="PhoneRotateLandscape" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:SplitButton.LargeIcon>
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageSizeOrientation}" SelectedItem="{Binding DiagramsViewModel.DiagramViewModel.PageSizeOrientation}">
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageSizeOrientation}" SelectedItem="{Binding PageViewModel.DiagramViewModel.PageSizeOrientation}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" Margin="5"/>
@@ -1495,7 +1498,7 @@
<Fluent:SplitButton.LargeIcon>
<iconPacks:PackIconMaterial Kind="RulerSquare" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:SplitButton.LargeIcon>
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageUnit}" SelectedItem="{Binding DiagramsViewModel.DiagramViewModel.PageUnit}">
<ListBox BorderThickness="0" helper:EnumHelper.Enum="{x:Type dd:PageUnit}" SelectedItem="{Binding PageViewModel.DiagramViewModel.PageUnit}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" Margin="5"/>
@@ -1518,21 +1521,21 @@
Width="190" />
</Fluent:SplitButton.ToolTip>
</Fluent:SplitButton>
<Fluent:SplitButton Header="网格" Width="50" VerticalAlignment="Top" IsCheckable="True" IsChecked="{Binding DiagramsViewModel.ShowGrid}" >
<Fluent:SplitButton Header="网格" Width="50" VerticalAlignment="Top" IsCheckable="True" IsChecked="{Binding PageViewModel.ShowGrid}" >
<Fluent:SplitButton.LargeIcon>
<iconPacks:PackIconMaterial Kind="Grid" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:SplitButton.LargeIcon>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5" Text="宽度(mm)" VerticalAlignment="Center"/>
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding DiagramsViewModel.DiagramViewModel.PhysicalGridCellWidth,Mode=TwoWay}" Minimum="0" Format="0" />
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.PhysicalGridCellWidth,Mode=TwoWay}" Minimum="0" Format="0" />
<TextBlock Margin="5" Text="高度(mm)" VerticalAlignment="Center"/>
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding DiagramsViewModel.DiagramViewModel.PhysicalGridCellHeight,Mode=TwoWay}" Minimum="0" Format="0" />
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.PhysicalGridCellHeight,Mode=TwoWay}" Minimum="0" Format="0" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5" Text="左右边距(mm)" VerticalAlignment="Center"/>
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding DiagramsViewModel.DiagramViewModel.PhysicalGridMarginWidth,Mode=TwoWay}" Minimum="0" Format="0" />
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.PhysicalGridMarginWidth,Mode=TwoWay}" Minimum="0" Format="0" />
<TextBlock Margin="5" Text="上下边距(mm)" VerticalAlignment="Center"/>
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding DiagramsViewModel.DiagramViewModel.PhysicalGridMarginHeight,Mode=TwoWay}" Minimum="0" Format="0" />
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.PhysicalGridMarginHeight,Mode=TwoWay}" Minimum="0" Format="0" />
</StackPanel>
<Fluent:SplitButton.ToolTip>
@@ -1543,28 +1546,28 @@
</Fluent:SplitButton>
<Fluent:SplitButton Header="横对齐" Width="50" VerticalAlignment="Top">
<UniformGrid Rows="4">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Left'}, ConverterParameter='Left'}" ToolTip="左对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Left'}, ConverterParameter='Left'}" ToolTip="左对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignLeft" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Center'}, ConverterParameter='Center'}" ToolTip="居中对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Center'}, ConverterParameter='Center'}" ToolTip="居中对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignCenter" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Right'}, ConverterParameter='Right'}" ToolTip="右对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Right'}, ConverterParameter='Right'}" ToolTip="右对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignRight" VerticalAlignment="Center" HorizontalAlignment="Right"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" ToolTip="无对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" ToolTip="无对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<TextBlock Text="无" HorizontalAlignment="Center" VerticalAlignment="Center"/>
@@ -1587,7 +1590,7 @@
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Left">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Left">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1596,7 +1599,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Center">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Center">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1605,7 +1608,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Right">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="Right">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1614,7 +1617,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="None">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellHorizontalAlignment}" Value="None">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1629,28 +1632,28 @@
</Fluent:SplitButton>
<Fluent:SplitButton Header="竖对齐" Width="50" VerticalAlignment="Top">
<UniformGrid Columns="4">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Top'}, ConverterParameter='Top'}" ToolTip="上对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Top'}, ConverterParameter='Top'}" ToolTip="上对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignLeft" RotationAngle="90" VerticalAlignment="Top" HorizontalAlignment="Center"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Center'}, ConverterParameter='Center'}" ToolTip="居中对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Center'}, ConverterParameter='Center'}" ToolTip="居中对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignCenter" RotationAngle="90" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Bottom'}, ConverterParameter='Bottom'}" ToolTip="下对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='Bottom'}, ConverterParameter='Bottom'}" ToolTip="下对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<iconPacks:PackIconMaterial Foreground="Gray" Kind="FormatAlignRight" RotationAngle="90" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
</Border>
</Fluent:ToggleButton.LargeIcon>
</Fluent:ToggleButton>
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" ToolTip="无对齐">
<Fluent:ToggleButton Height="48" Width="48" SizeDefinition="Large" IsChecked="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" ToolTip="无对齐">
<Fluent:ToggleButton.LargeIcon>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
<TextBlock Text="无" HorizontalAlignment="Center" VerticalAlignment="Center"/>
@@ -1668,7 +1671,7 @@
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Top">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Top">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1677,7 +1680,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Center">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Center">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1686,7 +1689,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Bottom">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment}" Value="Bottom">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1695,7 +1698,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding DiagramsViewModel.DiagramViewModel.CellVerticalAlignment}" Value="None">
<DataTrigger Binding="{Binding PageViewModel.DiagramViewModel.CellVerticalAlignment}" Value="None">
<Setter Property="LargeIcon">
<Setter.Value>
<Border BorderThickness="1" BorderBrush="Gray" Margin="6,6,6,6">
@@ -1734,7 +1737,7 @@
<Fluent:SplitButton.LargeIcon>
<iconPacks:PackIconMaterial Kind="File" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:SplitButton.LargeIcon>
<Fluent:ColorGallery SelectedColor="{Binding DiagramsViewModel.DiagramViewModel.PageBackground, Mode=TwoWay}"
<Fluent:ColorGallery SelectedColor="{Binding PageViewModel.DiagramViewModel.PageBackground, Mode=TwoWay}"
Mode="StandardColors"
StandardColorGridRows="3"
Columns="10"
@@ -1806,7 +1809,7 @@
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48" Text="欢迎访问AIStudio画板" Foreground="{DynamicResource GrayBrush2}"/>
<dragablz:TabablzControl x:Name="table"
ItemsSource="{Binding DiagramsViewModels}"
SelectedItem="{Binding DiagramsViewModel}"
SelectedItem="{Binding PageViewModel}"
Background="Transparent"
ItemContainerStyle="{StaticResource TrapezoidDragableTabItemStyle}"
ShowDefaultCloseButton="True"
@@ -1945,8 +1948,8 @@
Grid.Row="2">
<Fluent:StatusBarItem Title="Page" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<ListBox ItemsSource="{Binding DiagramsViewModel.DiagramViewModels}"
SelectedItem="{Binding DiagramsViewModel.DiagramViewModel}"
<ListBox ItemsSource="{Binding PageViewModel.DiagramViewModels}"
SelectedItem="{Binding PageViewModel.DiagramViewModel}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
HorizontalAlignment="Center"
BorderBrush="Transparent"
@@ -2023,16 +2026,16 @@
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Width="150">
<Run>鼠标位置(mm)</Run>
<Run Text="{Binding DiagramsViewModel.DiagramViewModel.CurrentPoint.X,StringFormat=f1}"/>
<Run Text="{Binding PageViewModel.DiagramViewModel.CurrentPoint.X,StringFormat=f1}"/>
<Run>,</Run>
<Run Text="{Binding DiagramsViewModel.DiagramViewModel.CurrentPoint.Y,StringFormat=f1}"/>
<Run Text="{Binding PageViewModel.DiagramViewModel.CurrentPoint.Y,StringFormat=f1}"/>
</TextBlock>
<Rectangle Width="12" Height="12" Margin="5" VerticalAlignment="Center">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding DiagramsViewModel.DiagramViewModel.CurrentColor}" />
<SolidColorBrush Color="{Binding PageViewModel.DiagramViewModel.CurrentColor}" />
</Rectangle.Fill>
</Rectangle>
<TextBlock Width="66" VerticalAlignment="Center" Text="{Binding DiagramsViewModel.DiagramViewModel.CurrentColor}" />
<TextBlock Width="66" VerticalAlignment="Center" Text="{Binding PageViewModel.DiagramViewModel.CurrentColor}" />
</StackPanel>
</Fluent:StatusBarItem>
@@ -2051,7 +2054,7 @@
HorizontalAlignment="Right">
<Slider x:Name="zoomSlider"
Minimum="0.5"
Value="{Binding DiagramsViewModel.DiagramViewModel.ZoomValue}"
Value="{Binding PageViewModel.DiagramViewModel.ZoomValue}"
Maximum="2.0"
IsDirectionReversed="False"
Style="{DynamicResource ZoomSliderStyle}"

View File

@@ -0,0 +1,68 @@
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner
{
public class DoubleToCornerRadius : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
if (parameter != null)
{
switch (parameter.ToString())
{
case "TopLeft":
return new CornerRadius(System.Convert.ToDouble(value), 0, 0, 0);
case "TopRight":
return new CornerRadius(0, System.Convert.ToDouble(value), 0, 0);
case "BottomRight":
return new CornerRadius(0, 0, System.Convert.ToDouble(value), 0);
case "ButtomLeft":
return new CornerRadius(0, 0, 0, System.Convert.ToDouble(value));
default:
return new CornerRadius(System.Convert.ToDouble(value));
}
}
return new CornerRadius(System.Convert.ToDouble(value));
}
return new CornerRadius(0);
}
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
if (parameter != null)
{
switch (parameter.ToString())
{
case "TopLeft":
return ((CornerRadius)value).TopLeft;
case "TopRight":
return ((CornerRadius)value).TopRight;
case "BottomRight":
return ((CornerRadius)value).BottomRight;
case "BottomLeft":
return ((CornerRadius)value).BottomLeft;
default:
return ((CornerRadius)value).TopLeft;
}
}
return ((CornerRadius)value).TopLeft;
}
return 0.0;
}
}
}

View File

@@ -10,5 +10,6 @@ namespace AIStudio.Wpf.DiagramDesigner
FlowChart,
Logical,
SFC,
Mind
}
}

View File

@@ -30,6 +30,7 @@ namespace AIStudio.Wpf.DiagramDesigner
PageSizeType = diagramView.PageSizeType;
PhysicalGridMarginSize = diagramView.PhysicalGridMarginSize;
GridColor = diagramView.GridColor;
AllowDrop = diagramView.AllowDrop;
}
[XmlAttribute]
@@ -154,6 +155,12 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
[XmlAttribute]
public bool AllowDrop
{
get; set;
}
[XmlArray]
public List<SerializableItem> DesignerItems { get; set; } = new List<SerializableItem>();

View File

@@ -836,7 +836,7 @@
GridMarginSize="{Binding GridMarginSize}"
GridColor="{Binding GridColor}"
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
AllowDrop="True">
AllowDrop="{Binding AllowDrop}">
</s:DesignerCanvas>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

View File

@@ -13,6 +13,9 @@ using SvgPathProperties;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// DefaultLink
/// </summary>
public class ConnectionViewModel : SelectableDesignerItemViewModelBase
{
public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode = DrawMode.ConnectingLineSmooth, RouterMode routerMode = AIStudio.Wpf.DiagramDesigner.RouterMode.RouterNormal) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)

View File

@@ -199,6 +199,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{
menuOptions.Clear();
var orientation = new CinchMenuItem("方向");
var none = new CinchMenuItem("无");
none.Command = MenuItemCommand;
none.CommandParameter = ConnectorOrientation.None;
var top = new CinchMenuItem("上");
top.Command = MenuItemCommand;
top.CommandParameter = ConnectorOrientation.Top;
@@ -211,6 +214,7 @@ namespace AIStudio.Wpf.DiagramDesigner
var right = new CinchMenuItem("右");
right.Command = MenuItemCommand;
right.CommandParameter = ConnectorOrientation.Right;
orientation.Children.Add(none);
orientation.Children.Add(top);
orientation.Children.Add(bottom);
orientation.Children.Add(left);

View File

@@ -8,12 +8,22 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public class DiagramOption
{
public LayoutOption LayoutOption
{
get; set;
} = new LayoutOption();
public ShortcutOption ShortcutOption
{
get; set;
} = new ShortcutOption();
}
public class LayoutOption
{
}
public class ShortcutOption
{
[Description("Select All shortcut (CTRL+A by default)")]

View File

@@ -503,6 +503,11 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
} = new DiagramOption();
public bool AllowDrop
{
get; set;
} = true;
private double OffsetX = 10;
private double OffsetY = 10;
#endregion
@@ -742,6 +747,7 @@ namespace AIStudio.Wpf.DiagramDesigner
PageSizeType = diagramItem.PageSizeType;
PhysicalGridMarginSize = diagramItem.PhysicalGridMarginSize;
GridColor = diagramItem.GridColor;
AllowDrop = diagramItem.AllowDrop;
}
public bool ExecuteEnable(object para)

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,6 +11,9 @@ using AIStudio.Wpf.DiagramDesigner.Models;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// DefaultGroup
/// </summary>
public class GroupDesignerItemViewModel : DesignerItemViewModelBase
{
public GroupDesignerItemViewModel() : this(null)

View File

@@ -257,6 +257,10 @@ namespace AIStudio.Wpf.DiagramDesigner
{
get; set;
}
bool AllowDrop
{
get; set;
}
System.Windows.Point CurrentPoint
{
get; set;

View File

@@ -1,10 +1,14 @@
using System;
using System.ComponentModel;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Models;
using AIStudio.Wpf.DiagramDesigner.Services;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// DefaultNode
/// </summary>
public class DefaultDesignerItemViewModel : DesignerItemViewModelBase
{
public DefaultDesignerItemViewModel() : this(null)

View File

@@ -114,7 +114,7 @@ namespace AIStudio.Wpf.DiagramDesigner
private void ExecuteAddItemCommand(object parameter)
{
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true);
MouseButtonEventArgs mosueArg = ((EventToCommandArgs)parameter).EventArgs as MouseButtonEventArgs;
var position = mosueArg.GetPosition(((EventToCommandArgs)parameter).Sender as IInputElement);
connector.XRatio = (position.X - connector.ConnectorWidth / 2) / connector.DataItem.ItemWidth;

View File

@@ -5,6 +5,9 @@ using System.Windows.Media;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// DefaultTextNode
/// </summary>
public class TextDesignerItemViewModel : DesignerItemViewModelBase
{
public TextDesignerItemViewModel() : this(null)

View File

@@ -19,4 +19,17 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
</ItemGroup>
<ItemGroup>
<Page Update="Themes\MindNode.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Themes\Generic.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace AIStudio.Wpf.Mind
{
public enum NodeLevel
{
Level1,
Level2,
Level3
}
}

View File

@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Controls/FlowchartEditor.xaml"/>-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

View File

@@ -0,0 +1,23 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.Mind.ViewModels">
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
<dd:DoubleToCornerRadius x:Key="DoubleToCornerRadius"/>
<DataTemplate DataType="{x:Type viewmodel:MindLevel1Node}">
<Grid IsHitTestVisible="False">
<Grid>
<Border BorderThickness="1"
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
CornerRadius="{Binding CornerRadius,Converter={StaticResource DoubleToCornerRadius}}">
</Border>
</Grid>
</Grid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Models;
namespace AIStudio.Wpf.Mind.ViewModels
{
public class MindNode : DesignerItemViewModelBase
{
public MindNode(NodeLevel nodeLevel) : this(null, nodeLevel)
{
}
public MindNode(IDiagramViewModel root, NodeLevel nodeLevel) : base(root)
{
NodeLevel = nodeLevel;
}
public MindNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
}
public MindNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
}
[Browsable(false)]
public NodeLevel NodeLevel
{
get; set;
}
private double _cornerRadius = 3;
public double CornerRadius
{
get
{
return _cornerRadius;
}
set
{
SetProperty(ref _cornerRadius, value);
}
}
}
public class MindLevel1Node : MindNode
{
public MindLevel1Node() : this(null)
{
}
public MindLevel1Node(IDiagramViewModel root) : base(root, NodeLevel.Level1)
{
}
public MindLevel1Node(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
}
public MindLevel1Node(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
}
}
public class MindLevel2Node : MindNode
{
public MindLevel2Node() : this(null)
{
}
public MindLevel2Node(IDiagramViewModel root) : base(root, NodeLevel.Level2)
{
}
public MindLevel2Node(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
}
public MindLevel2Node(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
}
}
public class MindLevel3Node : MindNode
{
public MindLevel3Node() : this(null)
{
}
public MindLevel3Node(IDiagramViewModel root) : base(root, NodeLevel.Level2)
{
}
public MindLevel3Node(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
}
public MindLevel3Node(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
}
}
}