This commit is contained in:
艾竹
2023-03-24 22:32:42 +08:00
parent 5ff4376674
commit 8a2c742ec4
19 changed files with 776 additions and 648 deletions

View File

@@ -100,7 +100,7 @@ namespace AIStudio.Wpf.Flowchart
DiagramViewModel = DiagramViewModels.FirstOrDefault();
InitDiagramViewModel();
var level1node = MindDiagramViewModel.RootItem;
var level1node = MindDiagramViewModel.RootItems.FirstOrDefault();
MindNode level2node1_1 = new MindNode(DiagramViewModel) { Text = "分支主题1" };
MindDiagramViewModel.AddChildCommand.Execute(new MindNode[] { level1node, level2node1_1 });

View File

@@ -144,13 +144,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
if (_diagramViewModel != null)
{
_diagramViewModel.PropertyChanged -= DiagramViewModel_PropertyChanged;
_diagramViewModel.OutAddVerify -= AddVerify;
}
SetProperty(ref _diagramViewModel, value);
if (_diagramViewModel != null)
{
_diagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
_diagramViewModel.OutAddVerify += AddVerify;
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -59,13 +60,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public class CinchMenuItem
{
#region Public Properties
public String Text { get; set; }
public String IconUrl { get; set; }
public string Text { get; set; }
public string IconUrl { get; set; }
public bool IsChecked { get; set; }
public bool IsCheckable { get; set; }
public List<CinchMenuItem> Children { get; private set; }
public Object CommandParameter { get; set; }
public SimpleCommand Command { get; set; }
public object CommandParameter { get; set; }
public ICommand Command { get; set; }
#endregion
#region Ctor

View File

@@ -27,14 +27,14 @@ namespace AIStudio.Wpf.DiagramDesigner
{
PathMode = drawMode.ToString();
RouterMode = routerMode.ToString();
Init(sourceConnectorInfo, sinkConnectorInfo);
Init(root, sourceConnectorInfo, sinkConnectorInfo);
}
public ConnectionViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, ConnectionItem designer) : base(root, designer)
{
PathMode = designer.PathMode;
RouterMode = designer.RouterMode;
Init(sourceConnectorInfo, sinkConnectorInfo);
Init(root, sourceConnectorInfo, sinkConnectorInfo);
}
public override SelectableItemBase GetSerializableObject()
@@ -51,9 +51,9 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
protected virtual void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
protected virtual void Init(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
{
this.Root = sourceConnectorInfo.DataItem.Root;
this.Root = root?? sourceConnectorInfo.Root;
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
{
@@ -427,17 +427,17 @@ namespace AIStudio.Wpf.DiagramDesigner
#endregion
#region
public SimpleCommand DeleteConnectionCommand
public ICommand DeleteConnectionCommand
{
get; set;
}
public SimpleCommand AddVertexCommand
public ICommand AddVertexCommand
{
get; set;
}
public SimpleCommand AddLabelCommand
public ICommand AddLabelCommand
{
get; set;
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.DiagramDesigner.Models;
using SvgPathProperties;
@@ -82,12 +83,12 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
public SimpleCommand DeleteLabelCommand
public ICommand DeleteLabelCommand
{
get; set;
}
public SimpleCommand EditCommand
public ICommand EditCommand
{
get; private set;
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.DiagramDesigner.Models;
@@ -68,7 +69,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public override PointBase MiddlePosition => new PointBase(Connector.Area.Left + Left + ConnectorWidth / 2, Connector.Area.Top + Top + ConnectorHeight / 2);
public SimpleCommand DeleteVertexCommand
public ICommand DeleteVertexCommand
{
get; set;
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.DiagramDesigner.Models;
@@ -185,11 +186,11 @@ namespace AIStudio.Wpf.DiagramDesigner
#endregion
#region
public SimpleCommand DeleteCommand
public ICommand DeleteCommand
{
get; private set;
}
public SimpleCommand MenuItemCommand
public ICommand MenuItemCommand
{
get; private set;
}

View File

@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public interface ISelectItems
{
SimpleCommand SelectItemCommand
ICommand SelectItemCommand
{
get;
}
@@ -64,7 +64,7 @@ namespace AIStudio.Wpf.DiagramDesigner
return true;
}
public SimpleCommand SelectItemCommand
public ICommand SelectItemCommand
{
get; private set;
}

View File

@@ -84,12 +84,12 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public SimpleCommand AddItemCommand
public ICommand AddItemCommand
{
get; private set;
}
public SimpleCommand ImageSwitchCommand
public ICommand ImageSwitchCommand
{
get; private set;
}

View File

@@ -141,8 +141,8 @@ namespace AIStudio.Wpf.DiagramDesigner
menuOptions.Add(menuItem);
}
private SimpleCommand _menuItemCommand;
public SimpleCommand MenuItemCommand
private ICommand _menuItemCommand;
public ICommand MenuItemCommand
{
get
{

View File

@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner.Models;
@@ -11,8 +12,8 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public abstract class LogicalGateItemViewModelBase : DesignerItemViewModelBase
{
public SimpleCommand AddInputCommand { get; private set; }
public SimpleCommand AddOutputCommand { get; private set; }
public ICommand AddInputCommand { get; private set; }
public ICommand AddOutputCommand { get; private set; }
public LogicalGateItemViewModelBase(LogicalType logicalType) : this(null, logicalType)

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner.Models;
namespace AIStudio.Wpf.DiagramDesigner
@@ -69,8 +70,8 @@ namespace AIStudio.Wpf.DiagramDesigner
menuOptions.Add(menuItem);
}
private SimpleCommand _menuItemCommand;
public SimpleCommand MenuItemCommand
private ICommand _menuItemCommand;
public ICommand MenuItemCommand
{
get
{

View File

@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
@@ -75,7 +76,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public SimpleCommand MenuItemCommand
public ICommand MenuItemCommand
{
get; private set;
}

View File

@@ -31,190 +31,198 @@ namespace AIStudio.Wpf.DiagramDesigner
get;
}
SimpleCommand CreateNewDiagramCommand
ICommand CreateNewDiagramCommand
{
get;
}
SimpleCommand DirectAddItemCommand
ICommand DirectAddItemCommand
{
get;
}
SimpleCommand AddItemCommand
ICommand AddItemCommand
{
get;
}
SimpleCommand RemoveItemCommand
ICommand RemoveItemCommand
{
get;
}
SimpleCommand DirectRemoveItemCommand
ICommand DirectRemoveItemCommand
{
get;
}
SimpleCommand ClearSelectedItemsCommand
ICommand ClearSelectedItemsCommand
{
get;
}
SimpleCommand AlignTopCommand
ICommand AlignTopCommand
{
get;
}
SimpleCommand AlignVerticalCentersCommand
ICommand AlignVerticalCentersCommand
{
get;
}
SimpleCommand AlignBottomCommand
ICommand AlignBottomCommand
{
get;
}
SimpleCommand AlignLeftCommand
ICommand AlignLeftCommand
{
get;
}
SimpleCommand AlignHorizontalCentersCommand
ICommand AlignHorizontalCentersCommand
{
get;
}
SimpleCommand AlignRightCommand
ICommand AlignRightCommand
{
get;
}
SimpleCommand BringForwardCommand
ICommand BringForwardCommand
{
get;
}
SimpleCommand BringToFrontCommand
ICommand BringToFrontCommand
{
get;
}
SimpleCommand SendBackwardCommand
ICommand SendBackwardCommand
{
get;
}
SimpleCommand SendToBackCommand
ICommand SendToBackCommand
{
get;
}
SimpleCommand DistributeHorizontalCommand
ICommand DistributeHorizontalCommand
{
get;
}
SimpleCommand DistributeVerticalCommand
ICommand DistributeVerticalCommand
{
get;
}
SimpleCommand SelectAllCommand
ICommand SelectAllCommand
{
get;
}
SimpleCommand SelectInverseCommand
ICommand SelectInverseCommand
{
get;
}
SimpleCommand SelectItemCommand
ICommand SelectItemCommand
{
get;
}
SimpleCommand CopyCommand
ICommand CopyCommand
{
get;
}
SimpleCommand PasteCommand
ICommand PasteCommand
{
get;
}
SimpleCommand CutCommand
ICommand CutCommand
{
get;
}
SimpleCommand DeleteCommand
ICommand DeleteCommand
{
get;
}
SimpleCommand LeftMoveCommand
ICommand LeftMoveCommand
{
get;
}
SimpleCommand RightMoveCommand
ICommand RightMoveCommand
{
get;
}
SimpleCommand UpMoveCommand
ICommand UpMoveCommand
{
get;
}
SimpleCommand DownMoveCommand
ICommand DownMoveCommand
{
get;
}
SimpleCommand CenterMoveCommand
ICommand CenterMoveCommand
{
get;
}
SimpleCommand SameSizeCommand
ICommand SameSizeCommand
{
get;
}
SimpleCommand SameWidthCommand
ICommand SameWidthCommand
{
get;
}
SimpleCommand SameHeightCommand
ICommand SameHeightCommand
{
get;
}
SimpleCommand SameAngleCommand
ICommand SameAngleCommand
{
get;
}
SimpleCommand GroupCommand
ICommand FitAutoCommand
{
get;
}
SimpleCommand UngroupCommand
ICommand FitWidthCommand
{
get;
}
SimpleCommand LockCommand
ICommand FitHeightCommand
{
get;
}
SimpleCommand UnlockCommand
ICommand GroupCommand
{
get;
}
SimpleCommand EditCommand
ICommand UngroupCommand
{
get;
}
SimpleCommand UndoCommand
ICommand LockCommand
{
get;
}
SimpleCommand RedoCommand
ICommand UnlockCommand
{
get;
}
SimpleCommand ResetLayoutCommand
ICommand EditCommand
{
get;
}
ICommand UndoCommand
{
get;
}
ICommand RedoCommand
{
get;
}
ICommand ResetLayoutCommand
{
get;
}
ICommand SearchDownCommand
{
get;
}
ICommand SearchUpCommand
{
get;
}
event DiagramEventHandler Event;
Func<SelectableDesignerItemViewModelBase, bool> OutAddVerify
{
get; set;
}
//void ClearSelectedItems();
//bool BelongToSameGroup(IGroupable item1, IGroupable item2);
//Rectangle GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items);
//void UpdateZIndex();
bool IsReadOnly
{
get; set;

View File

@@ -79,7 +79,12 @@
<TextBlock>插入同级主题</TextBlock>
</StackPanel>
</Button>
<Button Style="{StaticResource FlatButtonStyle}" Command="{Binding AddRootCommand}">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Stretch="Uniform" Fill="Black" Data="M696 334.2H326.6c-27.4 0-49.7-22.3-49.7-49.7V114c0-27.4 22.3-49.7 49.7-49.7H696c27.4 0 49.7 22.3 49.7 49.7v170.5c0.1 27.4-22.2 49.7-49.7 49.7zM326.6 106.8c-3.9 0-7.1 3.3-7.1 7.1v170.5c0 3.9 3.3 7.1 7.1 7.1H696c3.9 0 7.1-3.3 7.1-7.1V114c0-3.9-3.3-7.1-7.1-7.1H326.6zM895 960.8H127.7c-27.4 0-49.7-22.3-49.7-49.7V541.6c0-27.4 22.3-49.7 49.7-49.7H895c27.4 0 49.7 22.3 49.7 49.7V911c0 27.5-22.3 49.8-49.7 49.8zM127.7 534.5c-3.9 0-7.1 3.3-7.1 7.1V911c0 3.9 3.3 7.1 7.1 7.1H895c3.9 0 7.1-3.3 7.1-7.1V541.6c0-3.9-3.3-7.1-7.1-7.1H127.7zM511.4 533.1c-11.8 0-21.3-9.5-21.3-21.3l-0.1-198.9c0-11.8 9.5-21.3 21.3-21.3s21.3 9.5 21.3 21.3l0.1 198.9c0 11.8-9.5 21.3-21.3 21.3z"></Path>
<TextBlock>新建根主题</TextBlock>
</StackPanel>
</Button>
</UniformGrid>
<Line Grid.Column="3" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
<UniformGrid Rows="2" Grid.Row="0" Grid.Column="4" >
@@ -611,7 +616,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.Helpers;
@@ -20,67 +21,111 @@ namespace AIStudio.Wpf.Mind.ViewModels
get; set;
}
MindNode RootItem
List<MindNode> RootItems
{
get;
}
SimpleCommand AddParentCommand
ICommand AddRootCommand
{
get;
}
SimpleCommand AddChildCommand
ICommand AddParentCommand
{
get;
}
SimpleCommand AddPearCommand
ICommand AddChildCommand
{
get;
}
SimpleCommand MoveForwardCommand
ICommand AddPearCommand
{
get;
}
SimpleCommand MoveBackCommand
ICommand MoveForwardCommand
{
get;
}
SimpleCommand ChangeMindTypeCommand
ICommand MoveBackCommand
{
get;
}
SimpleCommand ChangeMindThemeCommand
ICommand SelectBrotherCommand
{
get;
}
SimpleCommand SelectBrotherCommand
ICommand SelectPearCommand
{
get;
}
SimpleCommand SelectPearCommand
ICommand SelectRouteCommand
{
get;
}
SimpleCommand SelectRouteCommand
ICommand SelectChildCommand
{
get;
}
SimpleCommand SelectChildCommand
ICommand AddLinkCommand
{
get;
}
SimpleCommand Expand2LevelCommand
ICommand RemoveLinkCommand
{
get;
}
ICommand AddImageCommand
{
get;
}
ICommand RemoveImageCommand
{
get;
}
ICommand AddRemarkCommand
{
get;
}
ICommand RemoveRemarkCommand
{
get;
}
ICommand AddPriorityCommand
{
get;
}
ICommand AddRatioCommand
{
get;
}
ICommand AddTagCommand
{
get;
}
ICommand RemoveTagCommand
{
get;
}
ICommand ChangeMindTypeCommand
{
get;
}
ICommand ChangeMindThemeCommand
{
get;
}
ICommand ClearThemeCommand
{
get;
}
ICommand CopyThemeCommand
{
get;
}
ICommand PasteThemeCommand
{
get;
}
ICommand Expand2LevelCommand
{
get;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.Helpers;
@@ -38,11 +39,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
SetProperty(ref _mindThemeModel, value);
}
}
public MindNode RootItem
public List<MindNode> RootItems
{
get
{
return Items.OfType<MindNode>().FirstOrDefault();
return Items.OfType<MindNode>().Where(p => p.NodeLevel == 0).ToList();
}
}
@@ -52,21 +53,30 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
return SelectedItem as MindNode;
}
}
}
#endregion
#region
private SimpleCommand _addParentCommand;
public SimpleCommand AddParentCommand
#region
private ICommand _addRootCommand;
public ICommand AddRootCommand
{
get
{
return this._addParentCommand ?? (this._addParentCommand = new SimpleCommand(MindLevelEnable, ExecuteAddParentCommand));
return this._addRootCommand ?? (this._addRootCommand = new SimpleCommand(ExecuteEnable, this.ExecuteAddRootCommand));
}
}
private SimpleCommand _addChildCommand;
public SimpleCommand AddChildCommand
private ICommand _addParentCommand;
public ICommand AddParentCommand
{
get
{
return this._addParentCommand ?? (this._addParentCommand = new SimpleCommand(MindLevelEnable, this.ExecuteAddParentCommand));
}
}
private ICommand _addChildCommand;
public ICommand AddChildCommand
{
get
{
@@ -74,8 +84,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _AddPearCommand;
public SimpleCommand AddPearCommand
private ICommand _AddPearCommand;
public ICommand AddPearCommand
{
get
{
@@ -83,8 +93,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _moveForwardCommand;
public SimpleCommand MoveForwardCommand
private ICommand _moveForwardCommand;
public ICommand MoveForwardCommand
{
get
{
@@ -92,8 +102,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _moveBackCommand;
public SimpleCommand MoveBackCommand
private ICommand _moveBackCommand;
public ICommand MoveBackCommand
{
get
{
@@ -101,8 +111,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _deleteCommand;
public override SimpleCommand DeleteCommand
private ICommand _deleteCommand;
public override ICommand DeleteCommand
{
get
{
@@ -110,8 +120,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _selectBrotherCommand;
public SimpleCommand SelectBrotherCommand
private ICommand _selectBrotherCommand;
public ICommand SelectBrotherCommand
{
get
{
@@ -119,8 +129,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _selectPearCommand;
public SimpleCommand SelectPearCommand
private ICommand _selectPearCommand;
public ICommand SelectPearCommand
{
get
{
@@ -128,8 +138,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _selectRouteCommand;
public SimpleCommand SelectRouteCommand
private ICommand _selectRouteCommand;
public ICommand SelectRouteCommand
{
get
{
@@ -137,8 +147,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _selectChildCommand;
public SimpleCommand SelectChildCommand
private ICommand _selectChildCommand;
public ICommand SelectChildCommand
{
get
{
@@ -146,8 +156,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addLinkCommand;
public SimpleCommand AddLinkCommand
private ICommand _addLinkCommand;
public ICommand AddLinkCommand
{
get
{
@@ -155,8 +165,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _removeLinkCommand;
public SimpleCommand RemoveLinkCommand
private ICommand _removeLinkCommand;
public ICommand RemoveLinkCommand
{
get
{
@@ -164,8 +174,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addImageCommand;
public SimpleCommand AddImageCommand
private ICommand _addImageCommand;
public ICommand AddImageCommand
{
get
{
@@ -173,8 +183,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _removeImageCommand;
public SimpleCommand RemoveImageCommand
private ICommand _removeImageCommand;
public ICommand RemoveImageCommand
{
get
{
@@ -182,8 +192,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addRemarkCommand;
public SimpleCommand AddRemarkCommand
private ICommand _addRemarkCommand;
public ICommand AddRemarkCommand
{
get
{
@@ -191,8 +201,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _removeRemarkCommand;
public SimpleCommand RemoveRemarkCommand
private ICommand _removeRemarkCommand;
public ICommand RemoveRemarkCommand
{
get
{
@@ -200,8 +210,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addPriorityCommand;
public SimpleCommand AddPriorityCommand
private ICommand _addPriorityCommand;
public ICommand AddPriorityCommand
{
get
{
@@ -209,8 +219,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addRatioCommand;
public SimpleCommand AddRatioCommand
private ICommand _addRatioCommand;
public ICommand AddRatioCommand
{
get
{
@@ -218,8 +228,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _addTagCommand;
public SimpleCommand AddTagCommand
private ICommand _addTagCommand;
public ICommand AddTagCommand
{
get
{
@@ -227,8 +237,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _removeTagCommand;
public SimpleCommand RemoveTagCommand
private ICommand _removeTagCommand;
public ICommand RemoveTagCommand
{
get
{
@@ -236,8 +246,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _changeMindTypeCommand;
public SimpleCommand ChangeMindTypeCommand
private ICommand _changeMindTypeCommand;
public ICommand ChangeMindTypeCommand
{
get
{
@@ -245,8 +255,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _changeMindThemeCommand;
public SimpleCommand ChangeMindThemeCommand
private ICommand _changeMindThemeCommand;
public ICommand ChangeMindThemeCommand
{
get
{
@@ -254,8 +264,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _clearThemeCommand;
public SimpleCommand ClearThemeCommand
private ICommand _clearThemeCommand;
public ICommand ClearThemeCommand
{
get
{
@@ -263,8 +273,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _copyThemeCommand;
public SimpleCommand CopyThemeCommand
private ICommand _copyThemeCommand;
public ICommand CopyThemeCommand
{
get
{
@@ -272,8 +282,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _pasteThemeCommand;
public SimpleCommand PasteThemeCommand
private ICommand _pasteThemeCommand;
public ICommand PasteThemeCommand
{
get
{
@@ -281,16 +291,17 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
private SimpleCommand _expand2LevelCommand;
public SimpleCommand Expand2LevelCommand
private ICommand _expand2LevelCommand;
public ICommand Expand2LevelCommand
{
get
{
return this._expand2LevelCommand ?? (this._expand2LevelCommand = new SimpleCommand(ExecuteEnable, this.ExecutedExpand2LevelCommand));
}
}
}
#endregion
#region ctor和初始化
public MindDiagramViewModel()
{
@@ -302,13 +313,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
InitRootItem();
}
ResetChildren(RootItem);
RootItem?.LayoutUpdated();
ResetChildren(RootItems);
RootItems?.ForEach(p => p.LayoutUpdated());
base.Init();
}
public void InitRootItem()
{
ClearSelectedItemsCommand.Execute(null);
MindNode level1node = new MindNode(this) { Root = this, Id = Guid.NewGuid(), Text = "思维导图" };
level1node.InitLayout(true);
Items.Add(level1node);
@@ -317,6 +329,61 @@ namespace AIStudio.Wpf.Mind.ViewModels
CenterMoveCommand.Execute(level1node);
}
protected override void ExecutedResetLayoutCommand(object obj)
{
foreach (var item in Items.OfType<MindNode>())
{
item.Offset = new DiagramDesigner.Geometrys.PointBase();
}
RootItems?.ForEach(p => p.LayoutUpdated());
}
private void ResetChildren(IEnumerable<MindNode> parents)
{
if (parents == null)
return;
foreach (var parent in parents)
{
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();
}
ResetChildren(parent.Children);
}
}
private List<MindNode> GetParent(MindNode node)
{
List<MindNode> mindnode = new List<MindNode>();
while (node.ParentNode != null)
{
mindnode.Add(node.ParentNode);
node = node.ParentNode;
}
return mindnode;
}
private List<MindNode> GetChildren(MindNode parent)
{
List<MindNode> mindnode = new List<MindNode>();
if (parent.Children != null)
{
foreach (var child in parent.Children)
{
mindnode.Add(child);
mindnode.AddRange(GetChildren(child));
}
}
return mindnode;
}
#endregion
#region 使
public bool MindExecuteEnable(object para)
{
if (ExecuteEnable(para) == false) return false;
@@ -332,8 +399,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
return (SelectedItem as MindNode).NodeLevel != 0;
}
#endregion
#region ,
public void ExecuteAddRootCommand(object parameter)
{
InitRootItem();
}
#region
public void ExecuteAddChildCommand(object parameter)
{
List<MindNode> items = new List<MindNode>();
@@ -561,25 +634,30 @@ namespace AIStudio.Wpf.Mind.ViewModels
return false;
}
nodes = nodes.Except(new List<MindNode> { RootItem }).ToList();
if (nodes.Any())
{
Dictionary<MindNode, int> indexs = nodes.ToDictionary(p => p, p => p.ParentNode.Children.IndexOf(p));
Dictionary<MindNode, int> indexs = nodes.ToDictionary(p => p, p => p.ParentNode != null ? p.ParentNode.Children.IndexOf(p) : 0);
DoCommandManager.DoNewCommand(this.ToString(),
() => {
foreach (var node in nodes)
{
node.ParentNode.RemoveChild(node, true);
if (node.NodeLevel == 0)
{
DirectRemoveItemCommand.Execute(node);
}
else
{
node.ParentNode?.RemoveChild(node, true);
}
}
RootItem.LayoutUpdated();
RootItems.ForEach(p => p.LayoutUpdated());
},
() => {
foreach (var node in nodes)
{
node.ParentNode.AddChild(node, indexs[node]);
}
RootItem.LayoutUpdated();
RootItems.ForEach(p => p.LayoutUpdated());
});
return true;
}
@@ -588,20 +666,39 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
#endregion
#region ,
protected override void FixConnection(List<SelectableDesignerItemViewModelBase> items)
{
List<MindNode> parents = new List<MindNode>();
foreach (var item in items.OfType<MindNode>())
{
var parent = Items.OfType<MindNode>().FirstOrDefault(p => p.Id == item.ParentId);
if (parent != null)
{
parents.Add(parent);
}
else
{
parents.Add(item);
}
}
ResetChildren(parents);
}
#endregion
#region
private void ExecuteAddLinkCommand(object obj)
{
if (obj is object[] array && array.Length == 2)
{
SelectedItems.OfType<MindNode>().ToList().ForEach(p =>
{
SelectedItems.OfType<MindNode>().ToList().ForEach(p => {
if (p.LinkInfo == null)
p.LinkInfo = new LinkInfo();
p.LinkInfo.Link = array[0]?.ToString();
p.LinkInfo.Text = array[1]?.ToString();
});
});
}
}
@@ -610,7 +707,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
SelectedItems.OfType<MindNode>().ToList().ForEach(p => {
if (p.LinkInfo != null)
{
p.LinkInfo.Link = null;
p.LinkInfo.Link = null;
p.LinkInfo.Text = null;
}
});
@@ -698,7 +795,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitLayout(true); });
Items.OfType<MindNode>().ToList().ForEach(item => { item.InitConnectLayout(); });
RootItem?.LayoutUpdated();
RootItems?.ForEach(p => p.LayoutUpdated());
}
}
@@ -716,7 +813,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
PageBackground = Colors.White;
}
Items.OfType<MindNode>().ToList().ForEach(item => { item.ThemeChange(); });
RootItem?.LayoutUpdated();
}
}
@@ -744,7 +840,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
node.ThemeChange();
}
RootItem.LayoutUpdated();
},
() => {
//ToDo
@@ -797,13 +892,12 @@ namespace AIStudio.Wpf.Mind.ViewModels
CopyHelper.CopyPropertyValue(_formatNode.ColorViewModel, node.ColorViewModel);
CopyHelper.CopyPropertyValue(_formatNode.FontViewModel, node.FontViewModel);
}
RootItem.LayoutUpdated();
},
() => {
//ToDo
});
}
}
}
@@ -812,10 +906,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
#region
protected override void ExecuteCenterMoveCommand(object parameter)
{
RootItem.Left = (PageSize.Width - RootItem.ItemWidth) / 2;
RootItem.Top = (PageSize.Height - RootItem.ItemHeight) / 2;
RootItem?.LayoutUpdated();
FitViewModel = new FitViewModel() { BoundingRect = RootItem.GetBounds() };
var rootitem = MindSelectedItem?.RootNode;
if (rootitem != null)
{
rootitem.Left = (PageSize.Width - rootitem.ItemWidth) / 2;
rootitem.Top = (PageSize.Height - rootitem.ItemHeight) / 2;
rootitem?.LayoutUpdated();
FitViewModel = new FitViewModel() { BoundingRect = rootitem.GetBounds() };
}
}
private void ExecutedExpand2LevelCommand(object obj)
@@ -914,55 +1012,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
#endregion
#region
protected override void ExecutedResetLayoutCommand(object obj)
{
foreach (var item in Items.OfType<MindNode>())
{
item.Offset = new DiagramDesigner.Geometrys.PointBase();
}
RootItem?.LayoutUpdated();
}
private void ResetChildren(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))
{
item.Parent = parent;
item.InitLayout(false);
item.InitConnectLayout();
ResetChildren(item);
}
}
private List<MindNode> GetParent(MindNode node)
{
List<MindNode> mindnode = new List<MindNode>();
while (node.ParentNode != null)
{
mindnode.Add(node.ParentNode);
node = node.ParentNode;
}
return mindnode;
}
private List<MindNode> GetChildren(MindNode parent)
{
List<MindNode> mindnode = new List<MindNode>();
if (parent.Children != null)
{
foreach (var child in parent.Children)
{
mindnode.Add(child);
mindnode.AddRange(GetChildren(child));
}
}
return mindnode;
}
#endregion
}
}

View File

@@ -8,6 +8,7 @@ using System.Security.Policy;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Linq;
using AIStudio.Wpf.DiagramDesigner;
@@ -75,7 +76,7 @@ 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();
IsInnerConnector = true;
IsInnerConnector = true;
MindLayout.Appearance(this, MindThemeModel, initAppearance);
this.PropertyChanged -= this.Item_PropertyChanged;
@@ -139,7 +140,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
return Parent as MindNode;
}
}
public MindNode RootNode
{
get
{
return GetLevel1Node();
}
}
public int NodeLevel
@@ -346,7 +354,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
if (_tags != null)
{
_tags.CollectionChanged += _tags_CollectionChanged;
}
}
}
}
@@ -373,32 +381,32 @@ namespace AIStudio.Wpf.Mind.ViewModels
#endregion
#region
public SimpleCommand AddParentCommand
public ICommand AddParentCommand
{
get; private set;
}
public SimpleCommand AddChildCommand
public ICommand AddChildCommand
{
get; private set;
}
public SimpleCommand AddPearCommand
public ICommand AddPearCommand
{
get; private set;
}
public SimpleCommand DeleteCommand
public ICommand DeleteCommand
{
get; private set;
}
public SimpleCommand MoveForwardCommand
public ICommand MoveForwardCommand
{
get; private set;
}
public SimpleCommand MoveBackCommand
public ICommand MoveBackCommand
{
get; private set;
}
@@ -490,9 +498,10 @@ namespace AIStudio.Wpf.Mind.ViewModels
public void InitConnectLayout()
{
var connector = Root?.Items.OfType<ConnectionViewModel>().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
if (connector != null)
var newconnecter = MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
if (connector == null)
{
MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
Root?.DirectAddItemCommand.Execute(new SelectableDesignerItemViewModelBase[] { newconnecter });
}
}
#endregion
@@ -541,7 +550,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
break;
}
case nameof(Rate):
case nameof(Priority):
case nameof(Priority):
case nameof(Remark):
case nameof(LinkInfo.Link):
{