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