This commit is contained in:
艾竹
2023-03-10 12:09:13 +08:00
parent e4f6335224
commit b3c7e1efec
20 changed files with 442 additions and 255 deletions

View File

@@ -411,31 +411,44 @@ namespace AIStudio.Wpf.Mind.ViewModels
protected override bool Delete(object parameter)
{
if (parameter is MindNode node)
List<MindNode> nodes = new List<MindNode>();
if (parameter is MindNode node1)
{
nodes.Add(node1);
}
else if (parameter is IEnumerable<MindNode> para)
{
nodes.AddRange(para);
}
else
{
node = SelectedItem as MindNode;
nodes.AddRange(SelectedItems.OfType<MindNode>());
}
if (node.IsEditing == true)
if (nodes.FirstOrDefault()?.IsEditing != false)
{
return false;
}
if (node.Parent is MindNode parent)
nodes = nodes.Except(new List<MindNode>{ RootItem }).ToList();
if (nodes.Any())
{
int index = parent.Children.IndexOf(node);
Dictionary<MindNode, int> indexs = nodes.ToDictionary(p => p, p => p.ParentNode.Children.IndexOf(p));
DoCommandManager.DoNewCommand(this.ToString(),
() => {
parent.RemoveChild(node, true);
parent.LayoutUpdated();
foreach (var node in nodes)
{
node.ParentNode.RemoveChild(node, true);
}
RootItem.LayoutUpdated();
},
() => {
parent.AddChild(node, index);
parent.LayoutUpdated();
foreach (var node in nodes)
{
node.ParentNode.AddChild(node, indexs[node]);
}
RootItem.LayoutUpdated();
});
return true;
}
@@ -512,6 +525,9 @@ namespace AIStudio.Wpf.Mind.ViewModels
parent.Children = new System.Collections.ObjectModel.ObservableCollection<MindNode>(Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id));
foreach (var item in Items.OfType<MindNode>().Where(p => p.ParentId == parent.Id))
{
item.Parent = parent;
item.InitLayout(false);
item.InitConnectLayout();
GetChildren(item);
}
}

View File

@@ -70,10 +70,9 @@ namespace AIStudio.Wpf.Mind.ViewModels
var layout = GlobalType.AllTypes.Where(p => typeof(IMindLayout).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == MindType.ToString() + "Layout");
MindLayout = layout != null ? (System.Activator.CreateInstance(layout) as IMindLayout) : new MindLayout();
if (initAppearance)
{
MindLayout.Appearance(this);
}
IsInnerConnector = true;
MindLayout.Appearance(this, initAppearance);
this.PropertyChanged -= this.Item_PropertyChanged;
this.PropertyChanged += this.Item_PropertyChanged;
}
@@ -412,7 +411,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
var connector = Root?.Items.OfType<ConnectionViewModel>().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
if (connector != null)
{
MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
}
}
#endregion
@@ -431,7 +430,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
break;
}
case nameof(NodeLevel):
MindLayout?.Appearance(this);
MindLayout?.Appearance(this, false);
break;
case nameof(Left):
{