mind序列化完善中

This commit is contained in:
艾竹
2023-03-08 23:02:50 +08:00
parent c80923d19c
commit e4f6335224
11 changed files with 74 additions and 40 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Documents;
using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.Mind.ViewModels
@@ -61,15 +62,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _deleteSelfCommand;
public SimpleCommand DeleteSelfCommand
{
get
{
return this._deleteSelfCommand ?? (this._deleteSelfCommand = new SimpleCommand(MindLevelEnable, ExecuteDeleteSelfCommand));
}
}
private SimpleCommand _moveForwardCommand;
public SimpleCommand MoveForwardCommand
{
@@ -88,6 +80,15 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _deleteCommand;
public override SimpleCommand DeleteCommand
{
get
{
return this._deleteCommand ?? (this._deleteCommand = new SimpleCommand(MindLevelEnable, ExecuteDeleteCommand));
}
}
private SimpleCommand _changeMindTypeCommand;
public SimpleCommand ChangeMindTypeCommand
{
@@ -162,6 +163,22 @@ namespace AIStudio.Wpf.Mind.ViewModels
#endregion
public MindDiagramViewModel()
{
}
public override void Init()
{
if (Items.Count == 0)
{
InitRootItem();
}
GetChildren(RootItem);
RootItem?.LayoutUpdated();
base.Init();
}
public void InitRootItem()
{
MindNode level1node = new MindNode(this) { Root = this, Id = Guid.NewGuid(), Left = 200, Top = 200, Text = "思维导图" };
level1node.InitLayout(true);
@@ -392,7 +409,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
private void ExecuteDeleteSelfCommand(object parameter)
protected override bool Delete(object parameter)
{
if (parameter is MindNode node)
{
@@ -403,6 +420,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
node = SelectedItem as MindNode;
}
if (node.IsEditing == true)
{
return false;
}
if (node.Parent is MindNode parent)
{
int index = parent.Children.IndexOf(node);
@@ -415,7 +437,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
parent.AddChild(node, index);
parent.LayoutUpdated();
});
return true;
}
else
return false;
}
@@ -467,8 +493,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
#endregion
protected override void ExecutedInitLayoutCommand(object obj)
{
GetChildren(RootItem);
RootItem?.LayoutUpdated();
}
protected override void ExecutedResetLayoutCommand(object obj)
{