diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs index 08042db..323102b 100644 --- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs @@ -119,7 +119,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels private void GetDataExcute(object obj) { - OutputData = GetDataFunc(); + OutputData = GetDataFunc?.Invoke(); } private void SetDataExcute(object obj) diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs index 9bc8c86..7e8cb7d 100644 --- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs @@ -81,7 +81,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels private void GetDataExcute(object obj) { - OutputData = GetDataFunc(); + OutputData = GetDataFunc?.Invoke(); } private void SetDataExcute(object obj) diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs index 87858f3..eeda949 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs @@ -784,7 +784,7 @@ namespace AIStudio.Wpf.DiagramDesigner } private SimpleCommand _deleteCommand; - public SimpleCommand DeleteCommand + public virtual SimpleCommand DeleteCommand { get { @@ -955,7 +955,7 @@ namespace AIStudio.Wpf.DiagramDesigner } #endregion - public DoCommandManager DoCommandManager = new DoCommandManager(); + protected DoCommandManager DoCommandManager = new DoCommandManager(); public event DiagramEventHandler Event; @@ -989,6 +989,13 @@ namespace AIStudio.Wpf.DiagramDesigner PhysicalGridMarginSize = diagramItem.PhysicalGridMarginSize; GridColor = diagramItem.GridColor; AllowDrop = diagramItem.AllowDrop; + + Init(); + } + + public virtual void Init() + { + DoCommandManager.Init(); } public virtual bool ExecuteEnable(object para) @@ -2087,12 +2094,12 @@ namespace AIStudio.Wpf.DiagramDesigner return true; } - private void ExecuteDeleteCommand(object parameter) + protected void ExecuteDeleteCommand(object parameter) { Delete(parameter); } - private bool Delete(object parameter) + protected virtual bool Delete(object parameter) { List itemsToRemove; diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs index 5b7b21e..c23a1ac 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs @@ -329,6 +329,8 @@ namespace AIStudio.Wpf.DiagramDesigner } #endregion + void Init(); + bool ExecuteShortcut(KeyEventArgs e); event PropertyChangedEventHandler PropertyChanged; diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml index 803f5bd..9d71fc8 100644 --- a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml +++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml @@ -18,7 +18,7 @@ - + diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs index ce78b0e..9d1e9ad 100644 --- a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs +++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs @@ -11,6 +11,7 @@ using System.Xml.Linq; using AIStudio.Wpf.DiagramDesigner; using AIStudio.Wpf.DiagramDesigner.Geometrys; using AIStudio.Wpf.Mind.ViewModels; +using AIStudio.Wpf.DiagramModels; namespace AIStudio.Wpf.Mind.Controls { @@ -18,10 +19,13 @@ namespace AIStudio.Wpf.Mind.Controls /// MindEditor.xaml 的交互逻辑 /// [TemplatePart(Name = PART_DiagramControl, Type = typeof(DiagramControl))] + [TemplatePart(Name = PART_ContentControl, Type = typeof(ContentControl))] public partial class MindEditor : UserControl { public const string PART_DiagramControl = "PART_DiagramControl"; + public const string PART_ContentControl = "PART_ContentControl"; private DiagramControl _diagramControl; + private ContentControl _contentControl; private MindDiagramViewModel _diagramViewModel; @@ -47,7 +51,10 @@ namespace AIStudio.Wpf.Mind.Controls _diagramControl = GetTemplateChild(PART_DiagramControl) as DiagramControl; _diagramControl.HorizontalAlignment = HorizontalAlignment.Stretch; _diagramControl.VerticalAlignment = VerticalAlignment.Stretch; - this.DataContext = _diagramViewModel; + _diagramControl.DataContext = _diagramViewModel; + + _contentControl = GetTemplateChild(PART_ContentControl) as ContentControl; + _contentControl.DataContext = _diagramViewModel; GetDataFunc = GetData; } @@ -90,14 +97,13 @@ namespace AIStudio.Wpf.Mind.Controls private void CreateFlowchartModel(string json) { - //_diagramViewModel.IsLoading = true; - //_diagramViewModel.Items.Clear(); - //MindNode level1node = new MindNode(_diagramViewModel) { Text = "思维导图" }; - //_diagramViewModel.DirectAddItemCommand.Execute(level1node); - //level1node.Left = 200; - //level1node.Top = 200; - //_diagramViewModel.DoCommandManager.Init(); - //_diagramViewModel.IsLoading = false; + _diagramViewModel.IsLoading = true; + + _diagramViewModel.Items.Clear(); + _diagramViewModel.ToObject(json); + + _diagramViewModel.Init(); + _diagramViewModel.IsLoading = false; } public static readonly DependencyProperty GetDataFuncProperty = diff --git a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml index b56f1b9..3fe2b0b 100644 --- a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml +++ b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml @@ -85,7 +85,7 @@ 编辑 -