diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs index 3b7c51f..6e598e9 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs @@ -19,12 +19,19 @@ using AIStudio.Wpf.DiagramDesigner.Additionals; using AIStudio.Wpf.DiagramDesigner.Additionals.Commands; using AIStudio.Wpf.DiagramDesigner.ViewModels; using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel; +using AIStudio.Wpf.Mind; namespace AIStudio.Wpf.DiagramApp.ViewModels { public class MainWindowViewModel : BindableBase { - private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } } + private IDiagramServiceProvider _service + { + get + { + return DiagramServicesProvider.Instance.Provider; + } + } private string _history = System.AppDomain.CurrentDomain.BaseDirectory + "history.json"; public MainWindowViewModel() @@ -50,7 +57,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels } #region 属性 - public ToolBoxViewModel ToolBoxViewModel { get; private set; } + public ToolBoxViewModel ToolBoxViewModel + { + get; private set; + } private ObservableCollection _diagramsViewModels; public ObservableCollection DiagramsViewModels @@ -118,7 +128,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels } } - public Color[] StandardColor { get; set; } + public Color[] StandardColor + { + get; set; + } public IDrawModeViewModel DrawModeViewModel { @@ -222,8 +235,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels get { return - () => - { + () => { return new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal); }; } @@ -239,6 +251,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels } } + private ICommand _newMindCommand; + public ICommand NewMindCommand + { + get + { + return this._newMindCommand ?? (this._newMindCommand = new DelegateCommand(para => this.NewMind_Executed(para))); + } + } + private ICommand _openCommand; public ICommand OpenCommand { @@ -650,7 +671,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels public ItemActionCallback ClosingTabItemHandler { - get { return ClosingTabItemHandlerImpl; } + get + { + return ClosingTabItemHandlerImpl; + } } /// @@ -723,11 +747,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString(); bool executed = true; - switch (para) + switch (para) { case "Control+O": OpenExecuted(); break; case "Control+N": New_Executed(); break; - case "Control+S": SaveExecuted(); break; + case "Control+S": SaveExecuted(); break; default: executed = false; break; } @@ -746,7 +770,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels private void SelectedAllExecuted() { - PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null); + PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null); } private void OpenExecuted(string para = null) @@ -911,10 +935,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels { 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 { PageViewModel = new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type)); @@ -923,6 +943,16 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels DiagramsViewModels.Add(PageViewModel); } + private void NewMind_Executed(string mindtype = "Mind") + { + IsOpenBackstage = false; + + PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Mind, (MindType)Enum.Parse(typeof(MindType), mindtype)); + + + DiagramsViewModels.Add(PageViewModel); + } + private void ExitExecuted() { throw new NotImplementedException(); @@ -948,11 +978,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels PageViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para); } private void AlignBottomExecuted(object para) - { + { PageViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para); } private void AlignLeftExecuted(object para) - { + { PageViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para); } private void AlignHorizontalCentersExecuted(object para) diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs index 51ddd40..d465066 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs @@ -18,9 +18,9 @@ namespace AIStudio.Wpf.Flowchart { public class MindViewModel : PageViewModel { - public MindViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType) + public MindViewModel(string title, string status, DiagramType diagramType, MindType mindType) : base(title, status, diagramType) { - + MindType = mindType; } public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument) { @@ -28,6 +28,11 @@ namespace AIStudio.Wpf.Flowchart { vm.Init(); } + + if (MindDiagramViewModel != null) + { + MindType = MindDiagramViewModel.MindType; + } } protected override void InitDiagramViewModel() @@ -35,7 +40,7 @@ namespace AIStudio.Wpf.Flowchart base.InitDiagramViewModel(); DiagramViewModel.GridCellSize = new Size(100, 100); - DiagramViewModel.ShowGrid= false; + DiagramViewModel.ShowGrid = false; DiagramViewModel.AllowDrop = false; } @@ -44,7 +49,26 @@ namespace AIStudio.Wpf.Flowchart get { return DiagramViewModel as IMindDiagramViewModel; - } + } + } + + private MindType _mindType = Mind.MindType.Mind; + public MindType MindType + { + get + { + return _mindType; + } + set + { + if (SetProperty(ref _mindType, value)) + { + foreach (var vm in DiagramViewModels.OfType()) + { + vm.MindType = MindType; ; + } + } + } } protected override void Init() @@ -65,7 +89,7 @@ namespace AIStudio.Wpf.Flowchart MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_1 }); MindNode level2node1_1_2 = new MindNode(DiagramViewModel) { Text = "分支主题1_2" }; - MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_2 });; + MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_2 }); ; MindNode level2node1_1_3 = new MindNode(DiagramViewModel) { Text = "分支主题1_3" }; MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level2node1_1, level2node1_1_3 }); @@ -82,7 +106,7 @@ namespace AIStudio.Wpf.Flowchart protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType) { - var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType }; + var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType, MindType = MindType }; viewmodel.Init(); return viewmodel; diff --git a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml index 1d19195..1c9cf65 100644 --- a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml +++ b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml @@ -95,7 +95,22 @@ - + + + + +