2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reactive.Linq;
|
2023-04-15 21:55:27 +08:00
|
|
|
|
using System.Text.RegularExpressions;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
2023-01-12 23:02:53 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2022-12-08 20:54:45 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
2023-12-21 22:20:38 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Layout;
|
2022-12-08 20:54:45 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2023-08-23 22:49:42 +08:00
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class DiagramViewModel : BindableBase, IDiagramViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
#region 属性
|
2023-01-24 23:10:57 +08:00
|
|
|
|
public ObservableCollection<SelectableDesignerItemViewModelBase> Items { get; set; } = new ObservableCollection<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
public List<SelectableDesignerItemViewModelBase> SelectedItems
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Items.Where(x => x.IsSelected).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-05 21:30:53 +08:00
|
|
|
|
public SelectableDesignerItemViewModelBase SelectedItem
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return SelectedItems.FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-28 22:11:24 +08:00
|
|
|
|
private DiagramSelectionService selectionService;
|
|
|
|
|
|
public DiagramSelectionService SelectionService
|
2023-01-24 23:10:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectionService == null)
|
2023-06-28 22:11:24 +08:00
|
|
|
|
selectionService = new DiagramSelectionService(this);
|
2023-01-24 23:10:57 +08:00
|
|
|
|
|
|
|
|
|
|
return selectionService;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-04 23:07:20 +08:00
|
|
|
|
private bool _isReadOnly;
|
|
|
|
|
|
public bool IsReadOnly
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isReadOnly;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _isReadOnly, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-05 22:48:00 +08:00
|
|
|
|
public bool IsLoading
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-12-06 21:28:42 +08:00
|
|
|
|
public IDrawModeViewModel DrawModeViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IColorViewModel ColorViewModel
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-26 18:27:17 +08:00
|
|
|
|
public IFontViewModel FontViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IShapeViewModel ShapeViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 15:29:22 +08:00
|
|
|
|
public IAnimationViewModel AnimationViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 19:14:39 +08:00
|
|
|
|
private DiagramType _diagramType;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
[Browsable(false)]
|
2023-05-11 19:14:39 +08:00
|
|
|
|
public DiagramType DiagramType
|
2023-02-11 23:51:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
return _diagramType;
|
2023-02-11 23:51:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
SetProperty(ref _diagramType, value);
|
2023-02-11 23:51:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private double _zoomValue = 1;
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public double ZoomValue
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _zoomValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _zoomValue, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
private double _maximumZoomValue = 100;
|
2023-02-14 22:15:19 +08:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public double MaximumZoomValue
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _maximumZoomValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _maximumZoomValue, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-09 21:48:26 +08:00
|
|
|
|
private double _minimumZoomValue = 0.1;
|
2023-02-14 22:15:19 +08:00
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public double MinimumZoomValue
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _minimumZoomValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _minimumZoomValue, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-14 22:54:55 +08:00
|
|
|
|
private bool _defaultZoomBox;
|
|
|
|
|
|
public bool DefaultZoomBox
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _defaultZoomBox;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _defaultZoomBox, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-13 22:50:50 +08:00
|
|
|
|
private double _delayZoomValue = 1;
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public double DelayZoomValue
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _delayZoomValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _delayZoomValue, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
private FitViewModel _fitViewModel;
|
|
|
|
|
|
public FitViewModel FitViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _fitViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _fitViewModel, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private string _name;
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _name;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _name, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
private bool _isEditName;
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public bool IsEditName
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isEditName;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _isEditName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-08 09:22:37 +08:00
|
|
|
|
private System.Windows.Point _currentPoint;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
[Browsable(false)]
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public System.Windows.Point CurrentPoint
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _currentPoint;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _currentPoint, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Color _currentColor;
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public Color CurrentColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _currentColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _currentColor, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
|
2023-04-15 21:55:27 +08:00
|
|
|
|
private bool _showSearch;
|
|
|
|
|
|
public bool ShowSearch
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _showSearch;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _showSearch, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-19 23:26:14 +08:00
|
|
|
|
private string _searchText;
|
|
|
|
|
|
public string SearchText
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _searchText;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _searchText, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 21:55:27 +08:00
|
|
|
|
private string _replaceText;
|
|
|
|
|
|
public string ReplaceText
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _replaceText;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _replaceText, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-19 23:26:14 +08:00
|
|
|
|
private string _searchInfo;
|
|
|
|
|
|
public string SearchInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-03-29 22:55:12 +08:00
|
|
|
|
return _searchInfo;
|
2023-03-19 23:26:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _searchInfo, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 21:55:27 +08:00
|
|
|
|
private bool _searchCaseMatch;
|
|
|
|
|
|
public bool SearchCaseMatch
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _searchCaseMatch;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _searchCaseMatch, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool _searchWholeWordMatch;
|
|
|
|
|
|
public bool SearchWholeWordMatch
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _searchWholeWordMatch;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _searchWholeWordMatch, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
protected ObservableCollection<CinchMenuItem> menuOptions;
|
|
|
|
|
|
public IEnumerable<CinchMenuItem> MenuOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return menuOptions;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-05-27 12:35:44 +08:00
|
|
|
|
|
|
|
|
|
|
private Brush _thumbnail;
|
|
|
|
|
|
public Brush Thumbnail
|
2023-05-11 10:57:08 +08:00
|
|
|
|
{
|
2023-05-27 12:35:44 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _thumbnail;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _thumbnail, value);
|
|
|
|
|
|
}
|
2023-05-11 10:57:08 +08:00
|
|
|
|
}
|
2023-03-12 22:47:45 +08:00
|
|
|
|
|
2024-02-08 23:00:50 +08:00
|
|
|
|
public bool GenerateThumbnail
|
|
|
|
|
|
{
|
|
|
|
|
|
get;set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
public bool ShowMenuOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MenuOptions == null || MenuOptions.Count() == 0)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
else
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-04 20:21:18 +08:00
|
|
|
|
public DiagramOption DiagramOption
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
} = new DiagramOption();
|
|
|
|
|
|
|
2023-03-26 23:23:34 +08:00
|
|
|
|
public DoCommandManager DoCommandManager { get; private set; } = new DoCommandManager();
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
|
|
|
|
|
public event DiagramEventHandler Event;
|
|
|
|
|
|
|
2023-03-25 22:10:49 +08:00
|
|
|
|
protected double OffsetX = 10;
|
|
|
|
|
|
protected double OffsetY = 10;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#region 命令
|
2023-04-05 23:40:22 +08:00
|
|
|
|
private ICommand _clearCommand;
|
|
|
|
|
|
public ICommand ClearCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
return this._clearCommand ?? (this._clearCommand = new SimpleCommand(ExecuteEnable, ExecuteClearCommand));
|
2023-03-06 11:54:41 +08:00
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _clearSelectedItemsCommand;
|
|
|
|
|
|
public ICommand ClearSelectedItemsCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._clearSelectedItemsCommand ?? (this._clearSelectedItemsCommand = new SimpleCommand(ExecuteEnable, ExecuteClearSelectedItemsCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignTopCommand;
|
|
|
|
|
|
public ICommand AlignTopCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignTopCommand ?? (this._alignTopCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignTopCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignVerticalCentersCommand;
|
|
|
|
|
|
public ICommand AlignVerticalCentersCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignVerticalCentersCommand ?? (this._alignVerticalCentersCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignVerticalCentersCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignBottomCommand;
|
|
|
|
|
|
public ICommand AlignBottomCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignBottomCommand ?? (this._alignBottomCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignBottomCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignLeftCommand;
|
|
|
|
|
|
public ICommand AlignLeftCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignLeftCommand ?? (this._alignLeftCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignLeftCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignHorizontalCentersCommand;
|
|
|
|
|
|
public ICommand AlignHorizontalCentersCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignHorizontalCentersCommand ?? (this._alignHorizontalCentersCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignHorizontalCentersCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _alignRightCommand;
|
|
|
|
|
|
public ICommand AlignRightCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignRightCommand ?? (this._alignRightCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignRightCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _bringForwardCommand;
|
|
|
|
|
|
public ICommand BringForwardCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._bringForwardCommand ?? (this._bringForwardCommand = new SimpleCommand(ExecuteEnable, ExecuteBringForwardCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _bringToFrontCommand;
|
|
|
|
|
|
public ICommand BringToFrontCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._bringToFrontCommand ?? (this._bringToFrontCommand = new SimpleCommand(ExecuteEnable, ExecuteBringToFrontCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sendBackwardCommand;
|
|
|
|
|
|
public ICommand SendBackwardCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sendBackwardCommand ?? (this._sendBackwardCommand = new SimpleCommand(ExecuteEnable, ExecuteSendBackwardCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sendToBackCommand;
|
|
|
|
|
|
public ICommand SendToBackCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sendToBackCommand ?? (this._sendToBackCommand = new SimpleCommand(ExecuteEnable, ExecuteSendToBackCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _distributeHorizontalCommand;
|
|
|
|
|
|
public ICommand DistributeHorizontalCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._distributeHorizontalCommand ?? (this._distributeHorizontalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeHorizontalCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _distributeVerticalCommand;
|
|
|
|
|
|
public ICommand DistributeVerticalCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._distributeVerticalCommand ?? (this._distributeVerticalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeVerticalCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _selectAllCommand;
|
|
|
|
|
|
public ICommand SelectAllCommand
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._selectAllCommand ?? (this._selectAllCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectAllCommand));
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _selectInverseCommand;
|
|
|
|
|
|
public ICommand SelectInverseCommand
|
2023-03-11 22:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._selectInverseCommand ?? (this._selectInverseCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectInverseCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _selectItemCommand;
|
|
|
|
|
|
public ICommand SelectItemCommand
|
2023-03-05 21:30:53 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._selectItemCommand ?? (this._selectItemCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectItemCommand));
|
|
|
|
|
|
}
|
2023-03-05 21:30:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
private ICommand _addCommand;
|
|
|
|
|
|
public ICommand AddCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addCommand ?? (this._addCommand = new SimpleCommand(ExecuteEnable, ExecuteAddCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _deleteCommand;
|
|
|
|
|
|
public virtual ICommand DeleteCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._deleteCommand ?? (this._deleteCommand = new SimpleCommand(ExecuteEnable, ExecuteDeleteCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _copyCommand;
|
|
|
|
|
|
public ICommand CopyCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._copyCommand ?? (this._copyCommand = new SimpleCommand(ExecuteEnable, ExecuteCopyCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _pasteCommand;
|
|
|
|
|
|
public ICommand PasteCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._pasteCommand ?? (this._pasteCommand = new SimpleCommand(ExecuteEnable, ExecutePasteCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _cutCommand;
|
|
|
|
|
|
public ICommand CutCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._cutCommand ?? (this._cutCommand = new SimpleCommand(ExecuteEnable, ExecuteCutCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _leftMoveCommand;
|
|
|
|
|
|
public ICommand LeftMoveCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._leftMoveCommand ?? (this._leftMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteLeftMoveCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _rightMoveCommand;
|
|
|
|
|
|
public ICommand RightMoveCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._rightMoveCommand ?? (this._rightMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteRightMoveCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _upMoveCommand;
|
|
|
|
|
|
public ICommand UpMoveCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._upMoveCommand ?? (this._upMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteUpMoveCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _downMoveCommand;
|
|
|
|
|
|
public ICommand DownMoveCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._downMoveCommand ?? (this._downMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteDownMoveCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _centerMoveCommand;
|
|
|
|
|
|
public ICommand CenterMoveCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._centerMoveCommand ?? (this._centerMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteCenterMoveCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sameSizeCommand;
|
|
|
|
|
|
public ICommand SameSizeCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameSizeCommand ?? (this._sameSizeCommand = new SimpleCommand(ExecuteEnable, ExecuteSameSizeCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sameWidthCommand;
|
|
|
|
|
|
public ICommand SameWidthCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameWidthCommand ?? (this._sameWidthCommand = new SimpleCommand(ExecuteEnable, ExecuteSameWidthCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sameHeightCommand;
|
|
|
|
|
|
public ICommand SameHeightCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameHeightCommand ?? (this._sameHeightCommand = new SimpleCommand(ExecuteEnable, ExecuteSameHeightCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _sameAngleCommand;
|
|
|
|
|
|
public ICommand SameAngleCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameAngleCommand ?? (this._sameAngleCommand = new SimpleCommand(ExecuteEnable, ExecuteSameAngleCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _fitAutoCommand;
|
|
|
|
|
|
public ICommand FitAutoCommand
|
2023-03-12 22:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._fitAutoCommand ?? (this._fitAutoCommand = new SimpleCommand(ExecuteEnable, ExecuteFitAutoCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _fitWidthCommand;
|
|
|
|
|
|
public ICommand FitWidthCommand
|
2023-03-12 22:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._fitWidthCommand ?? (this._fitWidthCommand = new SimpleCommand(ExecuteEnable, ExecuteFitWidthCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _fitHeightCommand;
|
|
|
|
|
|
public ICommand FitHeightCommand
|
2023-03-12 22:47:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._fitHeightCommand ?? (this._fitHeightCommand = new SimpleCommand(ExecuteEnable, ExecuteFitHeightCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-21 22:20:38 +08:00
|
|
|
|
private ICommand _autoLayoutCommand;
|
|
|
|
|
|
public ICommand AutoLayoutCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._autoLayoutCommand ?? (this._autoLayoutCommand = new SimpleCommand(ExecuteEnable, ExecuteAutoLayoutCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _groupCommand;
|
|
|
|
|
|
public ICommand GroupCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._groupCommand ?? (this._groupCommand = new SimpleCommand(ExecuteEnable, ExecuteGroupCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _ungroupCommand;
|
|
|
|
|
|
public ICommand UngroupCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._ungroupCommand ?? (this._ungroupCommand = new SimpleCommand(ExecuteEnable, ExecuteUngroupCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _lockCommand;
|
|
|
|
|
|
public ICommand LockCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._lockCommand ?? (this._lockCommand = new SimpleCommand(ExecuteEnable, ExecuteLockCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _unlockCommand;
|
|
|
|
|
|
public ICommand UnlockCommand
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._unlockCommand ?? (this._unlockCommand = new SimpleCommand(ExecuteEnable, ExecuteUnlockCommand));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _editCommand;
|
|
|
|
|
|
public ICommand EditCommand
|
2023-03-05 21:30:53 +08:00
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._editCommand ?? (this._editCommand = new SimpleCommand(ExecuteEnable, ExecuteEditCommand));
|
|
|
|
|
|
}
|
2023-03-05 21:30:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _undoCommand;
|
|
|
|
|
|
public ICommand UndoCommand
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
return this._undoCommand ?? (this._undoCommand = new SimpleCommand(Undo_Enabled, this.ExecutedUndoCommand));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _redoCommand;
|
|
|
|
|
|
public ICommand RedoCommand
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-03-06 11:54:41 +08:00
|
|
|
|
return this._redoCommand ?? (this._redoCommand = new SimpleCommand(Redo_Enabled, this.ExecutedRedoCommand));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-08 19:45:07 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _resetLayoutCommand;
|
|
|
|
|
|
public ICommand ResetLayoutCommand
|
2023-03-08 19:45:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._resetLayoutCommand ?? (this._resetLayoutCommand = new SimpleCommand(ExecuteEnable, this.ExecutedResetLayoutCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-19 23:26:14 +08:00
|
|
|
|
|
2023-04-15 21:55:27 +08:00
|
|
|
|
private ICommand _showSearchCommand;
|
|
|
|
|
|
public ICommand ShowSearchCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._showSearchCommand ?? (this._showSearchCommand = new SimpleCommand(ExecuteEnable, this.ExecutedShowSearchCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _closeSearchCommand;
|
|
|
|
|
|
public ICommand CloseSearchCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._closeSearchCommand ?? (this._closeSearchCommand = new SimpleCommand(ExecuteEnable, this.ExecutedCloseSearchCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _searchDownCommand;
|
|
|
|
|
|
public ICommand SearchDownCommand
|
2023-03-19 23:26:14 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._searchDownCommand ?? (this._searchDownCommand = new SimpleCommand(ExecuteEnable, this.ExecutedSearchDownCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private ICommand _searchUpCommand;
|
|
|
|
|
|
public ICommand SearchUpCommand
|
2023-03-19 23:26:14 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._searchUpCommand ?? (this._searchUpCommand = new SimpleCommand(ExecuteEnable, this.ExecutedSearchUpCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-15 21:55:27 +08:00
|
|
|
|
|
|
|
|
|
|
private ICommand _replaceCommand;
|
|
|
|
|
|
public ICommand ReplaceCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._replaceCommand ?? (this._replaceCommand = new SimpleCommand(ExecuteEnable, this.ExecutedSearchReplaceCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _replaceAllCommand;
|
|
|
|
|
|
public ICommand ReplaceAllCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._replaceAllCommand ?? (this._replaceAllCommand = new SimpleCommand(ExecuteEnable, this.ExecutedSearchReplaceAllCommand));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#endregion
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#region ctor和初始化
|
2023-01-24 23:10:57 +08:00
|
|
|
|
public DiagramViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
Mediator.Instance.Register(this);
|
|
|
|
|
|
Items.CollectionChanged += Items_CollectionChanged;
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
var zoomValueChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == nameof(ZoomValue)).Throttle(TimeSpan.FromMilliseconds(100)).Subscribe(OnZoomValueChanged);//Sample
|
2023-04-05 20:35:10 +08:00
|
|
|
|
this.PropertyChanged += DiagramViewModel_PropertyChanged;
|
2023-04-02 22:59:22 +08:00
|
|
|
|
BuildMenuOptions();
|
2023-02-13 22:50:50 +08:00
|
|
|
|
}
|
2023-04-05 20:35:10 +08:00
|
|
|
|
|
2023-08-26 15:02:43 +08:00
|
|
|
|
public DiagramViewModel(DiagramItem diagramItem, string ext =".json") : this()
|
2023-08-23 22:49:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
Init(diagramItem);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var diagramItemData in diagramItem.DesignerItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = TypeHelper.GetType(diagramItemData.ModelTypeName);
|
|
|
|
|
|
DesignerItemViewModelBase itemBase = Activator.CreateInstance(type, this, diagramItemData, ext) as DesignerItemViewModelBase;
|
|
|
|
|
|
Items.Add(itemBase);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var connection in diagramItem.Connections)
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = TypeHelper.GetType(connection.SerializableTypeName);
|
|
|
|
|
|
var connectionItem = SerializeHelper.DeserializeObject(type, connection.SerializableString, ext) as ConnectionItem;
|
|
|
|
|
|
|
|
|
|
|
|
connectionItem.SourceType = System.Type.GetType(connectionItem.SourceTypeName);
|
|
|
|
|
|
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
|
|
|
|
|
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(Items, connectionItem.SourceId, connectionItem.SourceType);
|
|
|
|
|
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
|
|
|
|
|
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceInnerPoint);
|
|
|
|
|
|
|
|
|
|
|
|
DesignerItemViewModelBase sinkItem = DiagramViewModelHelper.GetConnectorDataItem(Items, connectionItem.SinkId, connectionItem.SinkType);
|
|
|
|
|
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
|
|
|
|
|
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkInnerPoint);
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
|
|
|
|
|
connectionVM.Id = Guid.NewGuid();
|
|
|
|
|
|
Items.Add(connectionVM);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-22 10:06:22 +08:00
|
|
|
|
public void Init(DiagramItem diagramItem)
|
2023-02-11 23:51:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
DiagramType = diagramItem.DiagramType;
|
2023-08-26 15:02:43 +08:00
|
|
|
|
Name = diagramItem.Name;
|
2023-05-11 19:14:39 +08:00
|
|
|
|
DiagramOption.LayoutOption.ShowGrid = diagramItem.ShowGrid;
|
|
|
|
|
|
DiagramOption.LayoutOption.PhysicalGridCellSize = diagramItem.PhysicalGridCellSize;
|
|
|
|
|
|
DiagramOption.LayoutOption.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
|
|
|
|
|
|
DiagramOption.LayoutOption.CellVerticalAlignment = diagramItem.CellVerticalAlignment;
|
|
|
|
|
|
DiagramOption.LayoutOption.PageSizeOrientation = diagramItem.PageSizeOrientation;
|
|
|
|
|
|
DiagramOption.LayoutOption.PhysicalPageSize = diagramItem.PhysicalPageSize;
|
|
|
|
|
|
DiagramOption.LayoutOption.PageSizeType = diagramItem.PageSizeType;
|
|
|
|
|
|
DiagramOption.LayoutOption.PhysicalGridMarginSize = diagramItem.PhysicalGridMarginSize;
|
|
|
|
|
|
DiagramOption.LayoutOption.GridColor = diagramItem.GridColor;
|
2023-08-26 21:30:31 +08:00
|
|
|
|
DiagramOption.LayoutOption.PageBackground = diagramItem.PageBackground;
|
2024-02-08 23:16:30 +08:00
|
|
|
|
DiagramOption.LayoutOption.AllowDrop = diagramItem.AllowDrop;
|
2023-03-08 23:02:50 +08:00
|
|
|
|
|
2024-02-08 23:16:30 +08:00
|
|
|
|
GenerateThumbnail = diagramItem.GenerateThumbnail;
|
2024-02-08 23:00:50 +08:00
|
|
|
|
Thumbnail = diagramItem.Thumbnail?.ToBrush((int)DiagramOption.LayoutOption.PageSize.Width, (int)DiagramOption.LayoutOption.PageSize.Height);
|
2024-02-08 23:16:30 +08:00
|
|
|
|
|
2023-04-02 22:59:22 +08:00
|
|
|
|
Init(true);
|
2023-03-08 23:02:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-02 22:59:22 +08:00
|
|
|
|
public virtual void Init(bool initNew)
|
2023-03-08 23:02:50 +08:00
|
|
|
|
{
|
|
|
|
|
|
DoCommandManager.Init();
|
2023-02-11 23:51:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
protected virtual void ExecutedResetLayoutCommand(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 命令使能
|
2023-03-05 21:30:53 +08:00
|
|
|
|
public virtual bool ExecuteEnable(object para)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
return IsReadOnly == false;
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#endregion
|
2023-01-24 23:10:57 +08:00
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
#region 菜单
|
|
|
|
|
|
private void BuildMenuOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
menuOptions = new ObservableCollection<CinchMenuItem>();
|
|
|
|
|
|
CinchMenuItem menuItem = new CinchMenuItem();
|
|
|
|
|
|
menuItem.Text = "居中";
|
|
|
|
|
|
menuItem.Command = CenterMoveCommand;
|
|
|
|
|
|
menuItem.CommandParameter = this;
|
|
|
|
|
|
menuOptions.Add(menuItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#region UnDo ReDo
|
|
|
|
|
|
|
|
|
|
|
|
private void Do(object sender, string propertyName, object newvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
sender.SetPropertyValue(propertyName, newvalue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnDo(object sender, string propertyName, object oldvalue)
|
|
|
|
|
|
{
|
|
|
|
|
|
sender.SetPropertyValue(propertyName, oldvalue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
|
|
|
|
|
private void ExecutedUndoCommand(object para)
|
2023-01-24 23:10:57 +08:00
|
|
|
|
{
|
2023-02-27 20:18:58 +08:00
|
|
|
|
Undo(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Undo(object para)
|
|
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
DoCommandManager.UnDo();
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-02-27 20:18:58 +08:00
|
|
|
|
return true;
|
2023-01-24 23:10:57 +08:00
|
|
|
|
}
|
2023-02-27 20:18:58 +08:00
|
|
|
|
|
2023-03-06 11:54:41 +08:00
|
|
|
|
private void ExecutedRedoCommand(object para)
|
2023-01-24 23:10:57 +08:00
|
|
|
|
{
|
2023-02-27 20:18:58 +08:00
|
|
|
|
Redo(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Redo(object para)
|
|
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
DoCommandManager.ReDo();
|
2023-02-27 20:18:58 +08:00
|
|
|
|
|
|
|
|
|
|
return true;
|
2023-01-24 23:10:57 +08:00
|
|
|
|
}
|
2023-02-27 20:18:58 +08:00
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
private bool Undo_Enabled(object para)
|
|
|
|
|
|
{
|
|
|
|
|
|
return DoCommandManager.CanUnDo;
|
|
|
|
|
|
}
|
|
|
|
|
|
private bool Redo_Enabled(object para)
|
|
|
|
|
|
{
|
|
|
|
|
|
return DoCommandManager.CanReDo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2023-03-08 19:45:07 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#region 属性改变
|
2023-04-05 20:35:10 +08:00
|
|
|
|
protected virtual void DiagramViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
2023-04-05 20:35:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.OldItems != null)
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
foreach (var item in e.OldItems.OfType<SelectableDesignerItemViewModelBase>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.PropertyChanged -= Item_PropertyChanged;
|
|
|
|
|
|
item.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.NewItems != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in e.NewItems.OfType<SelectableDesignerItemViewModelBase>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.PropertyChanged += Item_PropertyChanged;
|
|
|
|
|
|
}
|
2022-12-04 23:07:20 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
RaisePropertyChanged("Items");
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-03-26 23:23:34 +08:00
|
|
|
|
protected virtual void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
RaisePropertyChanged(sender, e.PropertyName);
|
2023-03-11 22:27:23 +08:00
|
|
|
|
if (e.PropertyName == "IsSelected")
|
|
|
|
|
|
{
|
|
|
|
|
|
RaisePropertyChanged(nameof(SelectedItem));
|
|
|
|
|
|
}
|
2023-01-24 23:10:57 +08:00
|
|
|
|
|
2023-02-12 11:02:20 +08:00
|
|
|
|
var selectable = sender as SelectableViewModelBase;
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
var property = sender.GetType().GetProperty(e.PropertyName);
|
|
|
|
|
|
var attr = property.GetCustomAttributes(typeof(CanDoAttribute), true);
|
|
|
|
|
|
if (attr != null && attr.Length != 0)
|
|
|
|
|
|
{
|
2023-02-12 11:02:20 +08:00
|
|
|
|
//加入ReDo
|
2023-04-08 21:48:43 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(sender.ToString() + e.PropertyName,
|
|
|
|
|
|
() => {
|
|
|
|
|
|
Do(sender, e.PropertyName, valuePropertyChangedEventArgs.NewValue);
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
UnDo(sender, e.PropertyName, valuePropertyChangedEventArgs.OldValue);
|
|
|
|
|
|
},
|
|
|
|
|
|
null,
|
|
|
|
|
|
false);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
|
2023-02-12 11:02:20 +08:00
|
|
|
|
Event?.Invoke(sender, new DiagramEventArgs(valuePropertyChangedEventArgs.PropertyName, valuePropertyChangedEventArgs.NewValue, valuePropertyChangedEventArgs.OldValue, selectable?.Id));
|
2023-01-24 23:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
2023-03-26 23:23:34 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
//提供给标尺计算,延迟100ms,等布局改变再计算。
|
|
|
|
|
|
private void OnZoomValueChanged(string obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
DelayZoomValue = ZoomValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-05-27 12:35:44 +08:00
|
|
|
|
public void SaveThumbnail()
|
|
|
|
|
|
{
|
2024-02-08 23:00:50 +08:00
|
|
|
|
if (GenerateThumbnail)
|
2023-05-27 12:35:44 +08:00
|
|
|
|
{
|
2024-02-08 23:00:50 +08:00
|
|
|
|
if (Thumbnail is VisualBrush visualBrush)
|
|
|
|
|
|
{
|
|
|
|
|
|
var size = ((UIElement)visualBrush.Visual).DesiredSize;
|
|
|
|
|
|
var image = visualBrush.ToBitmap(new Rect(size)).ToBitmapSource((int)size.Width, (int)size.Height);
|
|
|
|
|
|
var brush = new ImageBrush(image) { Stretch = Stretch.Uniform };
|
|
|
|
|
|
//brush.SetCurrentValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.HighQuality);
|
|
|
|
|
|
Thumbnail = brush;
|
|
|
|
|
|
}
|
2023-05-27 12:35:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
[MediatorMessageSink("DoneDrawingMessage")]
|
|
|
|
|
|
public void OnDoneDrawingMessage(bool dummy)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in Items.OfType<DesignerItemViewModelBase>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ShowConnectors = false;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#region 新增,删除
|
2023-04-05 23:40:22 +08:00
|
|
|
|
protected virtual void ExecuteClearCommand(object parameter)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
var items = this.Items.ToList();
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Add(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
private void ExecuteClearSelectedItemsCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectedItems = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (selectedItems.Any())
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, bool> infos = selectedItems.ToDictionary(p => p, p => p.IsSelected);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.IsSelected = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-02-19 21:38:28 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public void ClearSelectedItems()
|
|
|
|
|
|
{
|
2023-03-26 23:23:34 +08:00
|
|
|
|
foreach (var item in this.SelectedItems.ToList())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-05-14 18:02:59 +08:00
|
|
|
|
item.RemoveFromSelection();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
2023-08-13 11:36:47 +08:00
|
|
|
|
public virtual bool Next()
|
2023-05-03 23:42:34 +08:00
|
|
|
|
{
|
2023-08-13 11:36:47 +08:00
|
|
|
|
return false;
|
2023-08-22 10:06:22 +08:00
|
|
|
|
}
|
2023-05-03 23:42:34 +08:00
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
private void ExecuteSelectAllCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectedItems = Items.ToList();
|
|
|
|
|
|
if (selectedItems.Any())
|
2023-01-24 23:10:57 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, bool> infos = selectedItems.ToDictionary(p => p, p => p.IsSelected);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.IsSelected = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-01-24 23:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-05 21:30:53 +08:00
|
|
|
|
|
2023-03-11 22:27:23 +08:00
|
|
|
|
private void ExecuteSelectInverseCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectedItems = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-03-11 22:27:23 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-03-11 22:27:23 +08:00
|
|
|
|
}
|
2023-04-05 23:40:22 +08:00
|
|
|
|
else
|
2023-03-11 22:27:23 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.AddRange(Items);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, bool> infos = selectedItems.ToDictionary(p => p, p => p.IsSelected);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = !item.IsSelected;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.IsSelected = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-03-11 22:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-05 21:30:53 +08:00
|
|
|
|
public void ExecuteSelectItemCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectedItems = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-03-05 21:30:53 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(Items);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, bool> infos = selectedItems.ToDictionary(p => p, p => p.IsSelected);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-15 21:55:27 +08:00
|
|
|
|
ClearSelectedItems();
|
2023-04-05 23:40:22 +08:00
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.IsSelected = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-03-06 11:54:41 +08:00
|
|
|
|
}
|
2023-03-05 21:30:53 +08:00
|
|
|
|
}
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#endregion
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
#region 新增,删除 复制,粘贴
|
|
|
|
|
|
private void ExecuteAddCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> newitems = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase ite)
|
|
|
|
|
|
{
|
|
|
|
|
|
newitems.Add(ite);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
newitems.AddRange(items);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
ClearSelectedItems();
|
|
|
|
|
|
Add(newitems, true);
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
Delete(newitems);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool AddVerify(SelectableDesignerItemViewModelBase item)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Verify() == false)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//使用程序添加对象,比如Demo初始化
|
|
|
|
|
|
public void Add(object parameter, bool? isSelected = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase ite)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (AddVerify(ite) != true) return;
|
|
|
|
|
|
|
|
|
|
|
|
Add(ite, isSelected);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
2023-08-22 10:06:22 +08:00
|
|
|
|
//如果有条件不满足的不允许添加
|
|
|
|
|
|
if (items.Select(p => AddVerify(p)).ToList().Any(p => !p)) return;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
Add(item, isSelected);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Add(SelectableDesignerItemViewModelBase item, bool? isSelected = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Root = this;
|
|
|
|
|
|
item.ZIndex = Items.Any() ? Items.Max(p => p.ZIndex) + 1 : 0;
|
|
|
|
|
|
if (item.Id == Guid.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Id = Guid.NewGuid();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-12 22:58:24 +08:00
|
|
|
|
if (item is LogicalGateItemViewModelBase logical)
|
2023-05-21 22:06:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
logical.OrderNumber = Items.OfType<LogicalGateItemViewModelBase>().Count() + 1;
|
|
|
|
|
|
}
|
2023-08-12 22:58:24 +08:00
|
|
|
|
//if (item is BlockDesignerItemViewModel block)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// block.Text = block.Text + item.ZIndex;
|
|
|
|
|
|
//}
|
2023-05-21 22:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
var designerItemViewModelBase = item as DesignerItemViewModelBase;
|
|
|
|
|
|
if (designerItemViewModelBase != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
designerItemViewModelBase.SetCellAlignment();
|
|
|
|
|
|
}
|
2024-02-18 16:40:33 +08:00
|
|
|
|
item.Init(this, false);
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Items.Add(item);
|
|
|
|
|
|
if (isSelected != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = isSelected.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
private void ExecuteCopyCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Copy(parameter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
private List<SelectableDesignerItemViewModelBase> Copy(object parameter)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectedItems = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.AddRange(para);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (selectedItems.Any())
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
var selectedDesignerItems = selectedItems.OfType<DesignerItemViewModelBase>().ToList();
|
|
|
|
|
|
var selectedConnections = selectedItems.OfType<ConnectionViewModel>().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ConnectionViewModel connection in Items.OfType<ConnectionViewModel>())
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (!selectedConnections.Contains(connection))
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-05-03 09:59:46 +08:00
|
|
|
|
DesignerItemViewModelBase sourceItem = selectedDesignerItems.FirstOrDefault(p => p.Id == connection.SourceConnectorInfoFully?.DataItem.Id);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
DesignerItemViewModelBase sinkItem = selectedDesignerItems.FirstOrDefault(p => p.Id == connection.SinkConnectorInfoFully?.DataItem?.Id);
|
|
|
|
|
|
if (sourceItem != null && sinkItem != null && BelongToSameGroup(sourceItem, sinkItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedConnections.Add(connection);
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
string json = new SerializableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
DesignerItems = selectedDesignerItems.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList(),
|
|
|
|
|
|
Connections = selectedConnections.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList(),
|
|
|
|
|
|
}.ToJson();
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
OffsetX = 0;
|
|
|
|
|
|
OffsetY = 0;
|
|
|
|
|
|
System.Windows.Clipboard.Clear();
|
|
|
|
|
|
System.Windows.Clipboard.SetData(System.Windows.DataFormats.Serializable, json);
|
|
|
|
|
|
}
|
|
|
|
|
|
return selectedItems;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecutePasteCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Paste(parameter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
protected virtual List<SelectableDesignerItemViewModelBase> Paste(object parameter, bool paste = true)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (System.Windows.Clipboard.ContainsData(System.Windows.DataFormats.Serializable))
|
|
|
|
|
|
{
|
|
|
|
|
|
string clipboardData = System.Windows.Clipboard.GetData(System.Windows.DataFormats.Serializable) as String;
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(clipboardData))
|
2023-04-05 23:40:22 +08:00
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> items = new List<SelectableDesignerItemViewModelBase>();
|
2023-03-24 22:32:42 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2023-03-25 22:10:49 +08:00
|
|
|
|
OffsetX += 10;
|
2023-04-06 23:01:18 +08:00
|
|
|
|
OffsetY += 10;
|
2023-03-25 22:10:49 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
SerializableObject copyitem = JsonConvert.DeserializeObject<SerializableObject>(clipboardData);
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<Guid, Guid> mappingOldToNewIDs = new Dictionary<Guid, Guid>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var diagramItemData in copyitem.DesignerItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
DesignerItemViewModelBase newItem = null;
|
|
|
|
|
|
|
|
|
|
|
|
Type type = TypeHelper.GetType(diagramItemData.ModelTypeName);
|
|
|
|
|
|
|
|
|
|
|
|
DesignerItemViewModelBase itemBase = Activator.CreateInstance(type, this, diagramItemData, ".json") as DesignerItemViewModelBase;
|
|
|
|
|
|
Guid newID = Guid.NewGuid();
|
|
|
|
|
|
mappingOldToNewIDs.Add(itemBase.Id, newID);
|
|
|
|
|
|
itemBase.Id = newID;
|
|
|
|
|
|
itemBase.Left += OffsetX;
|
|
|
|
|
|
itemBase.Top += OffsetY;
|
|
|
|
|
|
|
|
|
|
|
|
newItem = itemBase;
|
|
|
|
|
|
|
|
|
|
|
|
if (newItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
items.Add(newItem);
|
|
|
|
|
|
}
|
2023-04-05 23:40:22 +08:00
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> connectors = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
foreach (var connection in copyitem.Connections)
|
|
|
|
|
|
{
|
|
|
|
|
|
var connectionItem = JsonConvert.DeserializeObject<ConnectionItem>(connection.SerializableString);
|
|
|
|
|
|
Guid newID = Guid.NewGuid();
|
|
|
|
|
|
mappingOldToNewIDs.Add(connectionItem.Id, newID);
|
|
|
|
|
|
|
|
|
|
|
|
connectionItem.SourceId = mappingOldToNewIDs[connectionItem.SourceId];
|
|
|
|
|
|
connectionItem.SinkId = mappingOldToNewIDs[connectionItem.SinkId];
|
|
|
|
|
|
|
2023-03-25 22:10:49 +08:00
|
|
|
|
connectionItem.SourceType = TypeHelper.GetType(connectionItem.SourceTypeName);
|
|
|
|
|
|
connectionItem.SinkType = TypeHelper.GetType(connectionItem.SinkTypeName);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SourceId, connectionItem.SourceType);
|
|
|
|
|
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
|
|
|
|
|
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
|
|
|
|
|
|
|
|
|
|
|
DesignerItemViewModelBase sinkItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SinkId, connectionItem.SinkType);
|
|
|
|
|
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
|
|
|
|
|
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
|
|
|
|
|
|
|
|
|
|
|
|
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
2023-03-25 22:10:49 +08:00
|
|
|
|
connectionVM.Id = Guid.NewGuid();
|
2023-03-24 22:32:42 +08:00
|
|
|
|
connectors.Add(connectionVM);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//修复父级的引用
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.ParentId != Guid.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mappingOldToNewIDs.ContainsKey(item.ParentId))
|
|
|
|
|
|
item.ParentId = mappingOldToNewIDs[item.ParentId];
|
|
|
|
|
|
}
|
2023-04-05 23:40:22 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
items.AddRange(connectors);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Windows.MessageBox.Show(e.StackTrace, e.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
return null;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (paste)
|
|
|
|
|
|
{
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
ClearSelectedItems();
|
|
|
|
|
|
Add(items, true);
|
|
|
|
|
|
FixOtherInfo(items);
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return items;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
return null;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected virtual void FixOtherInfo(List<SelectableDesignerItemViewModelBase> items)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (connector is FullyCreatedConnectorInfo fully)
|
|
|
|
|
|
{
|
|
|
|
|
|
return itemsToRemove.Contains(fully.DataItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteCutCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Cut(parameter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
private List<SelectableDesignerItemViewModelBase> Cut(object parameter, bool cut = true)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (Copy(null) == null)
|
|
|
|
|
|
return null;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
var items = Delete(parameter, false);
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cut)
|
|
|
|
|
|
{
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Add(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return items;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-11 23:58:22 +08:00
|
|
|
|
protected virtual void ExecuteDeleteCommand(object parameter)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
var items = Delete(parameter, false);
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Add(items);
|
2023-04-05 23:40:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
public void Delete(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Delete(parameter, true, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual List<SelectableDesignerItemViewModelBase> Delete(object parameter, bool delete = true, bool direct = false)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> itemsToRemove = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
itemsToRemove.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
itemsToRemove.AddRange(para);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
itemsToRemove.AddRange(SelectedItems);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
if (direct == false)
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> connectionsToAlsoRemove = new List<SelectableDesignerItemViewModelBase>();
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
foreach (var connector in Items.OfType<ConnectionViewModel>())
|
2023-03-24 22:32:42 +08:00
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SourceConnectorInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
connectionsToAlsoRemove.Add(connector);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SinkConnectorInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
connectionsToAlsoRemove.Add(connector);
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
itemsToRemove.AddRange(connectionsToAlsoRemove);
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (itemsToRemove.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (delete)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in itemsToRemove)
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
item.Dispose();
|
2023-04-05 23:40:22 +08:00
|
|
|
|
Items.Remove(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return itemsToRemove;
|
2023-03-24 22:32:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
#region 布局
|
|
|
|
|
|
private void ExecuteAlignTopCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Top);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2021-07-23 09:42:22 +08:00
|
|
|
|
double top = selectedItems.OrderBy(p => p.Top).Select(p => p.Top).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Top = top;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Top = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteAlignVerticalCentersCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Top);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-06-11 23:58:22 +08:00
|
|
|
|
double mid = selectedItems.Select(p => p.Top + p.GetItemHeight() / 2).Average();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.Top = mid - item.GetItemHeight() / 2;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Top = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteAlignBottomCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Top);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-06-11 23:58:22 +08:00
|
|
|
|
double top = selectedItems.OrderBy(p => p.Top + p.GetItemHeight()).Select(p => p.Top + p.GetItemHeight()).LastOrDefault();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.Top = top - item.GetItemHeight();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Top = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteAlignLeftCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2021-07-23 09:42:22 +08:00
|
|
|
|
double left = selectedItems.OrderBy(p => p.Left).Select(p => p.Left).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Left = left;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Left = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteAlignHorizontalCentersCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-06-11 23:58:22 +08:00
|
|
|
|
double mid = selectedItems.Select(p => p.Left + p.GetItemWidth() / 2).Average();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.Left = mid - item.GetItemWidth() / 2;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Left = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteAlignRightCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-06-11 23:58:22 +08:00
|
|
|
|
double right = selectedItems.OrderBy(p => p.Left + p.GetItemWidth()).Select(p => p.Left + p.GetItemWidth()).LastOrDefault();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.Left = right - item.GetItemWidth();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Left = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-26 20:05:21 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
private void ExecuteBringForwardCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> ordered = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
|
|
|
|
|
{
|
|
|
|
|
|
ordered.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
ordered.AddRange(para.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
ordered.AddRange(SelectedItems.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (ordered.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, int> infos = ordered.ToDictionary(p => p, p => p.ZIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
int count = this.Items.Count;
|
|
|
|
|
|
for (int i = 0; i < ordered.Count; i++)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
var item = ordered[i];
|
|
|
|
|
|
int currentIndex = item.ZIndex;
|
|
|
|
|
|
int newIndex = Math.Min(count - 1 - i, currentIndex + 1);
|
|
|
|
|
|
if (currentIndex != newIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ZIndex = newIndex;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
IEnumerable<SelectableDesignerItemViewModelBase> it = this.Items.Where(p => p.ZIndex == newIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var elm in it)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (elm != item)
|
|
|
|
|
|
{
|
|
|
|
|
|
elm.ZIndex = currentIndex;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ZIndex = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void ExecuteBringToFrontCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectionSorted = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectionSorted.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectionSorted.AddRange(para.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectionSorted.AddRange(SelectedItems.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectionSorted.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> childrenSorted = Items.OrderByDescending(p => p.ZIndex).ToList();
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, int> infos = selectionSorted.ToDictionary(p => p, p => p.ZIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
int i = childrenSorted.Count - 1;
|
|
|
|
|
|
int j = childrenSorted.Count - selectionSorted.Count - 1;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (SelectableDesignerItemViewModelBase item in childrenSorted)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectionSorted.Contains(item))
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ZIndex = i--;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ZIndex = j--;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.ZIndex = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void ExecuteSendBackwardCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> ordered = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
|
|
|
|
|
{
|
|
|
|
|
|
ordered.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
ordered.AddRange(para.OrderBy(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
ordered.AddRange(SelectedItems.OrderBy(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (ordered.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, int> infos = ordered.ToDictionary(p => p, p => p.ZIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
for (int i = 0; i < ordered.Count; i++)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
var item = ordered[i];
|
|
|
|
|
|
int currentIndex = item.ZIndex;
|
|
|
|
|
|
int newIndex = Math.Max(i, currentIndex - 1);
|
|
|
|
|
|
if (currentIndex != newIndex)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.ZIndex = newIndex;
|
|
|
|
|
|
IEnumerable<SelectableDesignerItemViewModelBase> it = this.Items.Where(p => p.ZIndex == newIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var elm in it)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (elm != ordered[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
elm.ZIndex = currentIndex;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ZIndex = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-03-25 22:10:49 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void ExecuteSendToBackCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<SelectableDesignerItemViewModelBase> selectionSorted = new List<SelectableDesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectionSorted.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectionSorted.AddRange(para.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectionSorted.AddRange(SelectedItems.OrderByDescending(p => p.ZIndex));
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectionSorted.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> childrenSorted = Items.OrderByDescending(p => p.ZIndex).ToList();
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, int> infos = selectionSorted.ToDictionary(p => p, p => p.ZIndex);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
int i = childrenSorted.Count - 1;
|
|
|
|
|
|
int j = selectionSorted.Count - 1;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (SelectableDesignerItemViewModelBase item in childrenSorted)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectionSorted.Contains(item))
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ZIndex = j--;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
item.ZIndex = i--;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.ZIndex = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-03-25 22:10:49 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void ExecuteDistributeHorizontalCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Count > 1)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2021-07-23 09:42:22 +08:00
|
|
|
|
double left = Double.MaxValue;
|
|
|
|
|
|
double right = Double.MinValue;
|
|
|
|
|
|
double sumWidth = 0;
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
left = Math.Min(left, item.Left);
|
2023-06-11 23:58:22 +08:00
|
|
|
|
right = Math.Max(right, item.Left + item.GetItemWidth());
|
|
|
|
|
|
sumWidth += item.GetItemWidth();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double distance = Math.Max(0, (right - left - sumWidth) / (selectedItems.Count() - 1));
|
|
|
|
|
|
double offset = selectedItems.First().Left;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
double delta = offset - item.Left;
|
|
|
|
|
|
foreach (DesignerItemViewModelBase di in SelectionService.GetGroupMembers(item))
|
|
|
|
|
|
{
|
|
|
|
|
|
di.Left += delta;
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
offset = offset + item.GetItemWidth() + distance;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Left = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-25 22:10:49 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void ExecuteDistributeVerticalCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Count > 1)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Top);
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2021-07-23 09:42:22 +08:00
|
|
|
|
double top = Double.MaxValue;
|
|
|
|
|
|
double bottom = Double.MinValue;
|
|
|
|
|
|
double sumHeight = 0;
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
top = Math.Min(top, item.Top);
|
2023-06-11 23:58:22 +08:00
|
|
|
|
bottom = Math.Max(bottom, item.Top + item.GetItemHeight());
|
|
|
|
|
|
sumHeight += item.GetItemHeight();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double distance = Math.Max(0, (bottom - top - sumHeight) / (selectedItems.Count() - 1));
|
|
|
|
|
|
double offset = selectedItems.First().Top;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
double delta = offset - item.Top;
|
|
|
|
|
|
foreach (DesignerItemViewModelBase di in SelectionService.GetGroupMembers(item))
|
|
|
|
|
|
{
|
|
|
|
|
|
di.Top += +delta;
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
offset = offset + item.GetItemHeight() + distance;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-04 23:07:20 +08:00
|
|
|
|
() => {
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in infos)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
item.Key.Top = item.Value;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#endregion
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#region 移动
|
2022-12-08 20:54:45 +08:00
|
|
|
|
private void ExecuteLeftMoveCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Left -= 0.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Left = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteRightMoveCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Left);
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Left += 0.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Left = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteUpMoveCommand(object parameter)
|
|
|
|
|
|
{
|
2023-02-19 21:38:28 +08:00
|
|
|
|
IEnumerable<DesignerItemViewModelBase> selectedItems;
|
|
|
|
|
|
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems = para;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems = this.SelectedItems.OfType<DesignerItemViewModelBase>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in selectedItems.OfType<DesignerItemViewModelBase>())
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
item.Top -= 0.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteDownMoveCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Top);
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems.OfType<DesignerItemViewModelBase>())
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Top += 0.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Top = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
protected virtual void ExecuteCenterMoveCommand(object parameter)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2023-02-19 21:38:28 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
2023-02-19 21:38:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
if (selectedItems.Any())
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, PointBase> infos = selectedItems.ToDictionary(p => p, p => p.TopLeft);
|
2023-03-12 22:47:45 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-07 19:21:27 +08:00
|
|
|
|
|
|
|
|
|
|
var BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(selectedItems);
|
|
|
|
|
|
var oldcenter = BoundingRect.Center;
|
2023-04-06 23:01:18 +08:00
|
|
|
|
foreach (var item in selectedItems.OfType<DesignerItemViewModelBase>())
|
|
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
item.Left = item.Left - oldcenter.X + DiagramOption.LayoutOption.PageSize.Width / 2;
|
|
|
|
|
|
item.Top = item.Top - oldcenter.Y + DiagramOption.LayoutOption.PageSize.Height / 2;
|
2023-04-06 23:01:18 +08:00
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(selectedItems) };
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.TopLeft = item.Value;
|
|
|
|
|
|
}
|
2023-03-26 23:23:34 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(selectedItems) };
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-26 23:23:34 +08:00
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
protected void UpdateZIndex()
|
2023-01-24 23:10:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
List<SelectableDesignerItemViewModelBase> ordered = Items.OrderBy(p => p.ZIndex).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ordered.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
ordered[i].ZIndex = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 大小
|
2022-12-08 20:54:45 +08:00
|
|
|
|
private void ExecuteSameSizeCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Count > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<DesignerItemViewModelBase, SizeBase> infos = selectedItems.ToDictionary(p => p, p => p.Size);
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.ItemWidth = selectedItems.FirstOrDefault().GetItemWidth();
|
|
|
|
|
|
item.ItemHeight = selectedItems.FirstOrDefault().GetItemHeight();
|
2023-04-06 23:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Size = item.Value;
|
2023-04-08 21:48:43 +08:00
|
|
|
|
}
|
2023-04-06 23:01:18 +08:00
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteSameWidthCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Count > 1)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.GetItemWidth());
|
2023-04-06 23:01:18 +08:00
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.ItemWidth = selectedItems.FirstOrDefault().GetItemWidth();
|
2023-04-06 23:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ItemWidth = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteSameHeightCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Count > 1)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.GetItemHeight());
|
2023-04-06 23:01:18 +08:00
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
item.ItemHeight = selectedItems.FirstOrDefault().GetItemHeight();
|
2023-04-06 23:01:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ItemHeight = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteSameAngleCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> selectedItems = new List<DesignerItemViewModelBase>();
|
|
|
|
|
|
if (parameter is DesignerItemViewModelBase node)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-04-06 23:01:18 +08:00
|
|
|
|
selectedItems.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(para);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectedItems.AddRange(SelectedItems.OfType<DesignerItemViewModelBase>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedItems.Count > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<DesignerItemViewModelBase, double> infos = selectedItems.ToDictionary(p => p, p => p.Angle);
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in selectedItems)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Angle = selectedItems.FirstOrDefault().Angle;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Angle = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-03-12 22:47:45 +08:00
|
|
|
|
#region 适应大小
|
|
|
|
|
|
private void ExecuteFitAutoCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-09 21:48:26 +08:00
|
|
|
|
if (Items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitAuto };
|
|
|
|
|
|
}
|
2023-03-12 22:47:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteFitWidthCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-09 21:48:26 +08:00
|
|
|
|
if (Items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitWidth };
|
|
|
|
|
|
}
|
2023-03-12 22:47:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteFitHeightCommand(object parameter)
|
|
|
|
|
|
{
|
2023-04-09 21:48:26 +08:00
|
|
|
|
if (Items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitHeight };
|
|
|
|
|
|
}
|
2023-03-12 22:47:45 +08:00
|
|
|
|
}
|
2023-12-21 22:20:38 +08:00
|
|
|
|
|
|
|
|
|
|
private void ExecuteAutoLayoutCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
ForceDirectedLayouter layouter = new ForceDirectedLayouter();
|
|
|
|
|
|
layouter.Layout(new Configuration { Network = this }, 10000);
|
|
|
|
|
|
}
|
2023-03-12 22:47:45 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#region 分组
|
2022-12-08 20:54:45 +08:00
|
|
|
|
private void ExecuteGroupCommand(object parameter)
|
|
|
|
|
|
{
|
2023-01-26 22:25:48 +08:00
|
|
|
|
List<DesignerItemViewModelBase> items;
|
2023-02-02 23:00:36 +08:00
|
|
|
|
GroupDesignerItemViewModel groupItem = null;
|
2023-01-26 22:25:48 +08:00
|
|
|
|
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
2023-04-07 19:21:27 +08:00
|
|
|
|
if (para.FirstOrDefault() is GroupDesignerItemViewModel groupDesignerItemViewModel)
|
2023-02-02 23:00:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
groupItem = groupDesignerItemViewModel;
|
|
|
|
|
|
items = para.Skip(1).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
items = para.ToList();
|
|
|
|
|
|
}
|
2023-01-26 22:25:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-02-04 20:21:18 +08:00
|
|
|
|
items = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-10 18:49:02 +08:00
|
|
|
|
RectangleBase rect = DiagramViewModelHelper.GetBoundingRectangle(items);
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-02-02 23:00:36 +08:00
|
|
|
|
if (groupItem == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
groupItem = new GroupDesignerItemViewModel();
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-04-08 21:48:43 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
Add(groupItem);
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in items)
|
|
|
|
|
|
item.ParentId = groupItem.Id;
|
|
|
|
|
|
groupItem.Resize();
|
|
|
|
|
|
ClearSelectedItems();
|
2023-05-14 18:02:59 +08:00
|
|
|
|
groupItem.AddToSelection(true, true);
|
2023-04-08 21:48:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(groupItem);
|
2023-04-08 21:48:43 +08:00
|
|
|
|
foreach (DesignerItemViewModelBase item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.IsSelected = true;
|
|
|
|
|
|
item.ParentId = Guid.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-02-10 18:49:02 +08:00
|
|
|
|
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteUngroupCommand(object parameter)
|
|
|
|
|
|
{
|
2023-02-04 20:21:18 +08:00
|
|
|
|
List<DesignerItemViewModelBase> groups;
|
|
|
|
|
|
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
|
|
|
|
|
{
|
2023-04-08 21:48:43 +08:00
|
|
|
|
groups = para.Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
2023-02-04 20:21:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
groups = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-04-08 21:48:43 +08:00
|
|
|
|
Dictionary<DesignerItemViewModelBase, Tuple<Guid, int>> items = new Dictionary<DesignerItemViewModelBase, Tuple<Guid, int>>();
|
2022-12-08 20:54:45 +08:00
|
|
|
|
foreach (DesignerItemViewModelBase groupRoot in groups)
|
|
|
|
|
|
{
|
2023-03-25 11:59:31 +08:00
|
|
|
|
var children = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == groupRoot.Id);
|
2022-12-08 20:54:45 +08:00
|
|
|
|
foreach (DesignerItemViewModelBase child in children)
|
2023-04-08 21:48:43 +08:00
|
|
|
|
items.Add(child, new Tuple<Guid, int>(child.ParentId, child.ZIndex));
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-04-08 21:48:43 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Delete(groups);
|
2023-04-08 21:48:43 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ParentId = Guid.Empty;
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
UpdateZIndex();
|
2023-04-08 21:48:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
() => {
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Add(groups);
|
2023-04-08 21:48:43 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.ParentId = item.Value.Item1;
|
|
|
|
|
|
item.Key.ZIndex = item.Value.Item2;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2023-04-09 12:38:57 +08:00
|
|
|
|
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-06 23:01:18 +08:00
|
|
|
|
private bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-01-24 23:10:57 +08:00
|
|
|
|
IGroupable root1 = SelectionService.GetGroupRoot(item1);
|
|
|
|
|
|
IGroupable root2 = SelectionService.GetGroupRoot(item2);
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
return (root1.Id == root2.Id);
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-01-24 23:10:57 +08:00
|
|
|
|
#endregion
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-04-09 12:38:57 +08:00
|
|
|
|
#region 设置属性
|
|
|
|
|
|
public void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.GetPropertyValue(propertyName));
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
var value = selectable.GetPropertyValue(propertyName);
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.SetPropertyValue(propertyName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.SetPropertyValue(propertyName, item.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetFont(IFontViewModel fontViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.FontViewModel.GetPropertyValue(propertyName));
|
2023-04-09 12:38:57 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-09 18:58:13 +08:00
|
|
|
|
var value = fontViewModel.GetPropertyValue(propertyName);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.FontViewModel.SetPropertyValue(propertyName, value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.Key.FontViewModel.SetPropertyValue(propertyName, item.Value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetColor(IColorViewModel colorViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.ColorViewModel.GetPropertyValue(propertyName));
|
2023-04-09 12:38:57 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-09 18:58:13 +08:00
|
|
|
|
var value = colorViewModel.GetPropertyValue(propertyName);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.ColorViewModel.SetPropertyValue(propertyName, value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.Key.ColorViewModel.SetPropertyValue(propertyName, item.Value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetSharp(IShapeViewModel shapeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.ShapeViewModel.GetPropertyValue(propertyName));
|
2023-04-09 12:38:57 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-09 18:58:13 +08:00
|
|
|
|
var value = shapeViewModel.GetPropertyValue(propertyName);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.ShapeViewModel.SetPropertyValue(propertyName, value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.Key.ShapeViewModel.SetPropertyValue(propertyName, item.Value);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 15:29:22 +08:00
|
|
|
|
public void SetAnimation(IAnimationViewModel animationViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.AnimationViewModel.GetPropertyValue(propertyName));
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
var value = animationViewModel.GetPropertyValue(propertyName);
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.AnimationViewModel.SetPropertyValue(propertyName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.AnimationViewModel.SetPropertyValue(propertyName, item.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-09 12:38:57 +08:00
|
|
|
|
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (items.Any())
|
|
|
|
|
|
{
|
2023-04-09 18:58:13 +08:00
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, Tuple<object, object, object, object>> infos
|
|
|
|
|
|
= items.ToDictionary(p => p, p => new Tuple<object, object, object, object>(
|
2023-04-29 15:29:22 +08:00
|
|
|
|
p.FontViewModel.GetPropertyValue("Color"),
|
2023-04-09 21:48:26 +08:00
|
|
|
|
p.ColorViewModel.GetPropertyValue("FillColor"),
|
2023-04-09 18:58:13 +08:00
|
|
|
|
p.ColorViewModel.GetPropertyValue("LineColor"),
|
|
|
|
|
|
p.ColorViewModel.GetPropertyValue("LineWidth")));
|
2023-04-09 12:38:57 +08:00
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
2023-04-29 15:29:22 +08:00
|
|
|
|
var value1 = quickThemeViewModel.QuickTheme.FontViewModel.GetPropertyValue("Color");
|
2023-04-09 18:58:13 +08:00
|
|
|
|
var value2 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("FillColor");
|
|
|
|
|
|
var value3 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineColor");
|
|
|
|
|
|
var value4 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineWidth");
|
2023-04-09 12:38:57 +08:00
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
2023-04-29 15:29:22 +08:00
|
|
|
|
item.FontViewModel.SetPropertyValue("Color", value1);
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.ColorViewModel.SetPropertyValue("FillColor", value2);
|
|
|
|
|
|
item.ColorViewModel.SetPropertyValue("LineColor", value3);
|
|
|
|
|
|
item.ColorViewModel.SetPropertyValue("LineWidth", value4);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
2023-04-29 15:29:22 +08:00
|
|
|
|
item.Key.FontViewModel.SetPropertyValue("Color", item.Value.Item1);
|
2023-04-09 18:58:13 +08:00
|
|
|
|
item.Key.ColorViewModel.SetPropertyValue("FillColor", item.Value.Item2);
|
|
|
|
|
|
item.Key.ColorViewModel.SetPropertyValue("LineColor", item.Value.Item3);
|
|
|
|
|
|
item.Key.ColorViewModel.SetPropertyValue("LineWidth", item.Value.Item4);
|
2023-04-09 12:38:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
quickThemeViewModel.QuickTheme = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void LockAction(LockObject lockObject, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.LockObjectViewModel.SetValue(lockObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-02-04 20:59:01 +08:00
|
|
|
|
#region 快捷键操作
|
|
|
|
|
|
public bool ExecuteShortcut(KeyEventArgs e)
|
|
|
|
|
|
{
|
2023-04-05 23:40:22 +08:00
|
|
|
|
if (SelectedItem?.IsEditing == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-04 20:59:01 +08:00
|
|
|
|
if (DiagramOption.ShortcutOption.SelectAll(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
SelectAllCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Copy(e))
|
2023-04-06 23:01:18 +08:00
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
CopyCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Paste(e))
|
|
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
PasteCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Cut(e))
|
|
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
CutCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Undo(e))
|
|
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
UndoCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Redo(e))
|
|
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
RedoCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Delete(e))
|
|
|
|
|
|
{
|
2023-04-24 22:43:56 +08:00
|
|
|
|
DeleteCommand.Execute(null);
|
|
|
|
|
|
return true;
|
2023-02-04 20:59:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.LeftMove(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
LeftMoveCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.RightMove(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
RightMoveCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.UpMove(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
UpMoveCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.DownMove(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
DownMoveCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Group(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
GroupCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-04-08 21:48:43 +08:00
|
|
|
|
else if (DiagramOption.ShortcutOption.Ungroup(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
UngroupCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-04-15 21:55:27 +08:00
|
|
|
|
else if (DiagramOption.ShortcutOption.Search(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowSearchCommand.Execute(null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.SearchDown(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchDownCommand.Execute(SearchText);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.SearchUp(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchUpCommand.Execute(SearchText);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.Replace(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
ReplaceCommand.Execute(new object[] { SearchText, ReplaceText });
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (DiagramOption.ShortcutOption.ReplaceAll(e))
|
|
|
|
|
|
{
|
|
|
|
|
|
ReplaceAllCommand.Execute(new object[] { SearchText, ReplaceText });
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2023-05-03 23:42:34 +08:00
|
|
|
|
else if (DiagramOption.ShortcutOption.Next(e))
|
|
|
|
|
|
{
|
2023-08-13 11:36:47 +08:00
|
|
|
|
//NextCommand.Execute(null);
|
|
|
|
|
|
return Next();
|
2023-05-03 23:42:34 +08:00
|
|
|
|
}
|
2023-02-04 20:59:01 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#region 锁定与解锁,待完善
|
2023-01-24 23:10:57 +08:00
|
|
|
|
private void ExecuteLockCommand(object parameter)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
private void ExecuteUnlockCommand(object parameter)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#endregion
|
2023-03-05 21:30:53 +08:00
|
|
|
|
|
2023-03-24 22:32:42 +08:00
|
|
|
|
#region 搜索与编辑
|
2023-03-05 21:30:53 +08:00
|
|
|
|
protected virtual void ExecuteEditCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parameter is SelectableDesignerItemViewModelBase designerItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
designerItem.ShowText = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SelectedItem != null)
|
|
|
|
|
|
SelectedItem.ShowText = true;
|
|
|
|
|
|
}
|
2023-03-06 11:54:41 +08:00
|
|
|
|
|
2023-03-05 21:30:53 +08:00
|
|
|
|
}
|
2023-03-19 23:26:14 +08:00
|
|
|
|
|
2023-04-15 21:55:27 +08:00
|
|
|
|
private void ExecutedShowSearchCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowSearch = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecutedCloseSearchCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowSearch = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-19 23:26:14 +08:00
|
|
|
|
private void ExecutedSearchUpCommand(object obj)
|
2023-04-05 23:40:22 +08:00
|
|
|
|
{
|
2023-03-19 23:26:14 +08:00
|
|
|
|
if (obj != null)
|
|
|
|
|
|
{
|
2023-04-15 21:55:27 +08:00
|
|
|
|
var selecteddesign = SelectedItem as SelectableDesignerItemViewModelBase;
|
|
|
|
|
|
|
|
|
|
|
|
var searchitems = Items.OfType<SelectableDesignerItemViewModelBase>().Where(p => SearchMatch(p.Text, obj.ToString()) == true).ToList();
|
2023-03-19 23:26:14 +08:00
|
|
|
|
if (searchitems.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int selectindex = 0;
|
|
|
|
|
|
if (selecteddesign != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = searchitems.IndexOf(selecteddesign);
|
|
|
|
|
|
if (index == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (index - 1 >= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = index - 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = searchitems.Count - 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
SelectItemCommand.Execute(searchitems[selectindex]);
|
|
|
|
|
|
SearchInfo = $"第{selectindex + 1}条,共{searchitems.Count}条";
|
|
|
|
|
|
|
|
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(SelectedItem as DesignerItemViewModelBase) };
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchInfo = "第0条,共0条";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchInfo = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecutedSearchDownCommand(object obj)
|
|
|
|
|
|
{
|
2023-03-29 22:55:12 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(obj?.ToString()))
|
2023-03-19 23:26:14 +08:00
|
|
|
|
{
|
2023-04-15 21:55:27 +08:00
|
|
|
|
var selecteddesign = SelectedItem as SelectableDesignerItemViewModelBase;
|
|
|
|
|
|
var searchitems = Items.OfType<SelectableDesignerItemViewModelBase>().Where(p => SearchMatch(p.Text, obj.ToString()) == true).ToList();
|
2023-03-19 23:26:14 +08:00
|
|
|
|
if (searchitems.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int selectindex = 0;
|
|
|
|
|
|
if (selecteddesign != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = searchitems.IndexOf(selecteddesign);
|
|
|
|
|
|
if (index == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (index + 1 < searchitems.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = index + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
selectindex = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
SelectItemCommand.Execute(searchitems[selectindex]);
|
|
|
|
|
|
SearchInfo = $"第{selectindex + 1}条,共{searchitems.Count}条";
|
|
|
|
|
|
|
|
|
|
|
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(SelectedItem as DesignerItemViewModelBase) };
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchInfo = "第0条,共0条";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SearchInfo = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-15 21:55:27 +08:00
|
|
|
|
|
|
|
|
|
|
private bool SearchMatch(string input, string searchtext)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (input == null || searchtext == null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (SearchCaseMatch == true && SearchWholeWordMatch == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
return input == searchtext;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (SearchCaseMatch == true && SearchWholeWordMatch == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return input.Contains(searchtext);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (SearchCaseMatch == false && SearchWholeWordMatch == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
return input.ToLower() == searchtext.ToLower();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return input.ToLower().Contains(searchtext.ToLower());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string ReplaceSearch(string input, string searchtext, string replcetext)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SearchCaseMatch == true)
|
|
|
|
|
|
{
|
2023-05-03 18:35:01 +08:00
|
|
|
|
return input.Replace(searchtext, replcetext);
|
2023-04-15 21:55:27 +08:00
|
|
|
|
}
|
2023-05-03 18:35:01 +08:00
|
|
|
|
else
|
2023-04-15 21:55:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
return Regex.Replace(input, searchtext, replcetext, RegexOptions.IgnoreCase);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecutedSearchReplaceCommand(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj is object[] array && array.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
var items = SelectedItems.Where(p => SearchMatch(p.Text, array[0]?.ToString()) == true).ToList();
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, string> infos = items.ToDictionary(p => p, p => p.Text);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Text = ReplaceSearch(item.Text, array[0]?.ToString(), array[1]?.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Text = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecutedSearchReplaceAllCommand(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj is object[] array && array.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
var items = Items.Where(p => SearchMatch(p.Text, array[0]?.ToString()) == true).ToList();
|
|
|
|
|
|
Dictionary<SelectableDesignerItemViewModelBase, string> infos = items.ToDictionary(p => p, p => p.Text);
|
|
|
|
|
|
DoCommandManager.DoNewCommand(this.ToString(),
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Text = ReplaceSearch(item.Text, array[0]?.ToString(), array[1]?.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
() => {
|
|
|
|
|
|
foreach (var item in infos)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key.Text = item.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-28 12:06:58 +08:00
|
|
|
|
#endregion
|
2023-05-03 13:28:16 +08:00
|
|
|
|
|
2023-05-27 12:35:44 +08:00
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{Name}-{DiagramType}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|