mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-02 15:50:51 +08:00
mind
This commit is contained in:
@@ -106,6 +106,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
@@ -790,6 +790,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
flow = new SFCViewModel(filename, diagram);
|
||||
}
|
||||
else if (diagram.DiagramType == DiagramType.Mind)
|
||||
{
|
||||
flow = new MindViewModel(filename, diagram);
|
||||
}
|
||||
else
|
||||
{
|
||||
flow = new PageViewModel(filename, diagram);
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
using AIStudio.Wpf.Mind;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
@@ -22,8 +23,11 @@ namespace AIStudio.Wpf.Flowchart
|
||||
|
||||
}
|
||||
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
{
|
||||
|
||||
{
|
||||
foreach (var vm in DiagramViewModels)
|
||||
{
|
||||
vm.InitLayoutCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitDiagramViewModel()
|
||||
@@ -47,7 +51,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
|
||||
{
|
||||
new MindDiagramViewModel(){Name= "页-1", DiagramType = DiagramType},
|
||||
GetDiagramViewModel("页-1", DiagramType),
|
||||
};
|
||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||
|
||||
@@ -77,6 +81,10 @@ namespace AIStudio.Wpf.Flowchart
|
||||
level1node.LayoutUpdated();
|
||||
}
|
||||
|
||||
protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType)
|
||||
{
|
||||
return new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
|
||||
{
|
||||
new DiagramViewModel(){Name= "页-1", DiagramType = DiagramType},
|
||||
GetDiagramViewModel("页-1", DiagramType),
|
||||
};
|
||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||
|
||||
@@ -241,9 +241,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
|
||||
foreach (var diagramItem in diagramDocument.DiagramItems)
|
||||
{
|
||||
var viewModel = new DiagramViewModel();
|
||||
viewModel.Name = diagramItem.Name;
|
||||
viewModel.DiagramType = diagramItem.DiagramType;
|
||||
var viewModel = GetDiagramViewModel(diagramItem.Name, diagramItem.DiagramType);
|
||||
viewModel.ShowGrid = diagramItem.ShowGrid;
|
||||
viewModel.PhysicalGridCellSize = diagramItem.PhysicalGridCellSize;
|
||||
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
|
||||
@@ -429,12 +427,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
index = DiagramViewModels.Count;
|
||||
}
|
||||
var page = new DiagramViewModel() { Name = NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = DiagramType };
|
||||
var page = GetDiagramViewModel(null, DiagramType);
|
||||
DiagramViewModels.Insert(index, page);
|
||||
DiagramViewModel = page;
|
||||
InitDiagramViewModel();
|
||||
}
|
||||
|
||||
protected virtual DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType)
|
||||
{
|
||||
return new DiagramViewModel() { Name = name??NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
|
||||
}
|
||||
|
||||
public void AddCopyPageExecuted(object para)
|
||||
{
|
||||
if (DiagramViewModel != null)
|
||||
|
||||
@@ -935,6 +935,24 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return this._redoCommand ?? (this._redoCommand = new SimpleCommand(Redo_Enabled, this.ExecutedRedoCommand));
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleCommand _initLayoutCommand;
|
||||
public SimpleCommand InitLayoutCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._initLayoutCommand ?? (this._initLayoutCommand = new SimpleCommand(ExecuteEnable, this.ExecutedInitLayoutCommand));
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleCommand _resetLayoutCommand;
|
||||
public SimpleCommand ResetLayoutCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._resetLayoutCommand ?? (this._resetLayoutCommand = new SimpleCommand(ExecuteEnable, this.ExecutedResetLayoutCommand));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public DoCommandManager DoCommandManager = new DoCommandManager();
|
||||
@@ -1037,6 +1055,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
#endregion
|
||||
|
||||
protected virtual void ExecutedInitLayoutCommand(object obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected virtual void ExecutedResetLayoutCommand(object obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
|
||||
@@ -194,6 +194,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand InitLayoutCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
SimpleCommand ResetLayoutCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
event DiagramEventHandler Event;
|
||||
|
||||
|
||||
@@ -59,11 +59,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
get;
|
||||
}
|
||||
|
||||
SimpleCommand ResetLayoutCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
SimpleCommand Expand2Level1Command
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -106,15 +106,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleCommand _resetLayoutCommand;
|
||||
public SimpleCommand ResetLayoutCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._resetLayoutCommand ?? (this._resetLayoutCommand = new SimpleCommand(MindExecuteEnable, this.ExecutedResetLayoutCommand));
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleCommand _expand2Level1Command;
|
||||
public SimpleCommand Expand2Level1Command
|
||||
{
|
||||
@@ -443,10 +434,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
}
|
||||
|
||||
private void ExecutedResetLayoutCommand(object obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void ExecutedExpand2Level1Command(object obj)
|
||||
{
|
||||
@@ -478,6 +465,31 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
protected override void ExecutedInitLayoutCommand(object obj)
|
||||
{
|
||||
GetChildren(RootItem);
|
||||
RootItem?.LayoutUpdated();
|
||||
}
|
||||
protected override void ExecutedResetLayoutCommand(object obj)
|
||||
{
|
||||
foreach (var item in Items.OfType<MindNode>())
|
||||
{
|
||||
item.Offset = new DiagramDesigner.Geometrys.PointBase();
|
||||
}
|
||||
RootItem?.LayoutUpdated();
|
||||
}
|
||||
|
||||
private void GetChildren(MindNode parent)
|
||||
{
|
||||
if (parent == null)
|
||||
return;
|
||||
|
||||
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))
|
||||
{
|
||||
GetChildren(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user