Mind Editoe

This commit is contained in:
艾竹
2023-03-05 21:30:53 +08:00
parent 9061146139
commit 79f4896fbd
41 changed files with 2090 additions and 484 deletions

View File

@@ -26,6 +26,14 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public SelectableDesignerItemViewModelBase SelectedItem
{
get
{
return SelectedItems.FirstOrDefault();
}
}
private SelectionService selectionService;
public SelectionService SelectionService
{
@@ -646,6 +654,11 @@ namespace AIStudio.Wpf.DiagramDesigner
get; private set;
}
public SimpleCommand SelectItemCommand
{
get; private set;
}
public SimpleCommand CopyCommand
{
get; private set;
@@ -723,6 +736,11 @@ namespace AIStudio.Wpf.DiagramDesigner
get; private set;
}
public SimpleCommand EditCommand
{
get; private set;
}
private SimpleCommand _undoCommand;
public SimpleCommand UndoCommand
{
@@ -742,7 +760,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
#endregion
private DoCommandManager DoCommandManager = new DoCommandManager();
public DoCommandManager DoCommandManager = new DoCommandManager();
public event DiagramEventHandler Event;
@@ -770,6 +788,7 @@ namespace AIStudio.Wpf.DiagramDesigner
DistributeHorizontalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeHorizontalCommand);
DistributeVerticalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeVerticalCommand);
SelectAllCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectAllCommand);
SelectItemCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectItemCommand);
CopyCommand = new SimpleCommand(ExecuteEnable, ExecuteCopyCommand);
PasteCommand = new SimpleCommand(ExecuteEnable, ExecutePasteCommand);
CutCommand = new SimpleCommand(ExecuteEnable, ExecuteCutCommand);
@@ -787,6 +806,7 @@ namespace AIStudio.Wpf.DiagramDesigner
UngroupCommand = new SimpleCommand(ExecuteEnable, ExecuteUngroupCommand);
LockCommand = new SimpleCommand(ExecuteEnable, ExecuteLockCommand);
UnlockCommand = new SimpleCommand(ExecuteEnable, ExecuteUnlockCommand);
EditCommand = new SimpleCommand(ExecuteEnable, ExecuteEditCommand);
Mediator.Instance.Register(this);
Items.CollectionChanged += Items_CollectionChanged;
@@ -815,7 +835,7 @@ namespace AIStudio.Wpf.DiagramDesigner
AllowDrop = diagramItem.AllowDrop;
}
public bool ExecuteEnable(object para)
public virtual bool ExecuteEnable(object para)
{
return IsReadOnly == false;
}
@@ -832,7 +852,7 @@ namespace AIStudio.Wpf.DiagramDesigner
sender.SetPropertyValue(propertyName, oldvalue);
}
private bool _undoing;
private void UndoExecuted(object para)
{
Undo(para);
@@ -845,11 +865,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{
return false;
}
_undoing = true;
DoCommandManager.UnDo();
_undoing = false;
return true;
}
@@ -865,10 +883,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
return false;
}
_undoing = true;
DoCommandManager.ReDo();
_undoing = false;
return true;
}
@@ -909,8 +924,6 @@ namespace AIStudio.Wpf.DiagramDesigner
{
RaisePropertyChanged(sender, e.PropertyName);
if (_undoing == true) return;
//连续改变需要特殊处理不单独触发属性改变ReDo
if (sender is DesignerItemViewModelBase designer)
{
@@ -1121,6 +1134,14 @@ namespace AIStudio.Wpf.DiagramDesigner
item.IsSelected = true;
}
}
public void ExecuteSelectItemCommand(object parameter)
{
if (parameter is ISelectable selectable)
{
selectable.IsSelected = true;
}
}
#endregion
#region
@@ -2259,5 +2280,19 @@ namespace AIStudio.Wpf.DiagramDesigner
{
}
protected virtual void ExecuteEditCommand(object parameter)
{
if (parameter is SelectableDesignerItemViewModelBase designerItem)
{
designerItem.ShowText = true;
}
else
{
if (SelectedItem != null)
SelectedItem.ShowText = true;
}
}
}
}