mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-19 16:06:35 +08:00
XX
This commit is contained in:
@@ -46,14 +46,34 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
InitLayout(false);
|
||||
}
|
||||
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
{
|
||||
return new MindNodeDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
public override DiagramNode ToDiagram()
|
||||
{
|
||||
base.Init(root);
|
||||
var mindNodeModel = new MindNodeModel();
|
||||
|
||||
mindNodeModel.Spacing = Spacing;
|
||||
mindNodeModel.Offset = Offset;
|
||||
mindNodeModel.IsExpanded = IsExpanded;
|
||||
mindNodeModel.LinkInfoModel = new LinkInfoModel(LinkInfo);
|
||||
mindNodeModel.ImageInfoModel = new ImageInfoModel(ImageInfo);
|
||||
mindNodeModel.Remark = Remark;
|
||||
mindNodeModel.Priority = Priority;
|
||||
mindNodeModel.Rate = Rate;
|
||||
if (Tags != null)
|
||||
{
|
||||
mindNodeModel.Tags = new List<string>(Tags);
|
||||
}
|
||||
return mindNodeModel;
|
||||
}
|
||||
|
||||
protected override void Init(IDiagramViewModel root, bool initNew)
|
||||
{
|
||||
base.Init(root, initNew);
|
||||
|
||||
EnabledForConnection = false;
|
||||
AlwayForResized = true;
|
||||
@@ -71,6 +91,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
ImageInfo = new ImageInfo();
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
this.ClearConnectors();
|
||||
}
|
||||
|
||||
public void InitLayout(bool initAppearance)
|
||||
{
|
||||
var layout = GlobalType.AllTypes.Where(p => typeof(IMindLayout).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == MindType.ToString() + "Layout");
|
||||
@@ -108,26 +133,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override DiagramNode ToDiagram()
|
||||
{
|
||||
var mindNodeModel = new MindNodeModel();
|
||||
|
||||
mindNodeModel.Spacing = Spacing;
|
||||
mindNodeModel.Offset = Offset;
|
||||
mindNodeModel.IsExpanded = IsExpanded;
|
||||
mindNodeModel.LinkInfoModel = new LinkInfoModel(LinkInfo);
|
||||
mindNodeModel.ImageInfoModel = new ImageInfoModel(ImageInfo);
|
||||
mindNodeModel.Remark = Remark;
|
||||
mindNodeModel.Priority = Priority;
|
||||
mindNodeModel.Rate = Rate;
|
||||
if (Tags != null)
|
||||
{
|
||||
mindNodeModel.Tags = new List<string>(Tags);
|
||||
}
|
||||
return mindNodeModel;
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public IMindLayout MindLayout
|
||||
{
|
||||
@@ -462,7 +467,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
item.Parent = this;
|
||||
item.ParentId = this.Id;
|
||||
item.InitLayout(true);
|
||||
item.InitLayout(true);//因为节点的层级不同的样式,所以需要Parent确定后才能初始化
|
||||
|
||||
ConnectionViewModel connector = MindLayout?.GetOrSetConnectionViewModel(this, item);
|
||||
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { item, connector });
|
||||
@@ -498,10 +503,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
public void InitConnectLayout()
|
||||
{
|
||||
var connector = Root?.Items.OfType<ConnectionViewModel>().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
|
||||
var newconnecter = MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
|
||||
if (connector == null)
|
||||
if (connector != null)
|
||||
{
|
||||
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { newconnecter });
|
||||
MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
|
||||
}
|
||||
else if (ParentNode != null)
|
||||
{
|
||||
connector = MindLayout?.GetOrSetConnectionViewModel(ParentNode, this, null);
|
||||
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { connector });
|
||||
connector.ZIndex = -1;
|
||||
connector.IsSelected = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -510,6 +521,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
if (GetLevel1Node()?.LayoutUpdating == true) return;
|
||||
|
||||
if (Root == null) return;
|
||||
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(IsExpanded):
|
||||
|
||||
Reference in New Issue
Block a user