2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramApp.Views;
|
2021-07-29 13:55:18 +08:00
|
|
|
|
using AIStudio.Wpf.Flowchart;
|
|
|
|
|
|
using AIStudio.Wpf.Logical;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using ControlzEx.Theming;
|
|
|
|
|
|
using Dragablz;
|
|
|
|
|
|
using Fluent;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reactive.Linq;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using System.Windows.Media;
|
2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
2023-01-25 15:58:05 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Additionals;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Additionals.Commands;
|
2023-03-18 21:44:58 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.ViewModels;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
|
2023-03-20 20:23:20 +08:00
|
|
|
|
using AIStudio.Wpf.Mind;
|
2023-04-02 12:01:46 +08:00
|
|
|
|
using AIStudio.Wpf.Mind.Models;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class MainWindowViewModel : BindableBase
|
|
|
|
|
|
{
|
2023-03-20 20:23:20 +08:00
|
|
|
|
private IDiagramServiceProvider _service
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return DiagramServicesProvider.Instance.Provider;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private string _history = System.AppDomain.CurrentDomain.BaseDirectory + "history.json";
|
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolBoxViewModel = new ToolBoxViewModel();
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
DiagramsViewModels = new ObservableCollection<PageViewModel>();
|
|
|
|
|
|
DiagramsViewModels.Add(new PageViewModel("新建-1", "*", DiagramType.Normal));
|
|
|
|
|
|
PageViewModel = DiagramsViewModels.FirstOrDefault();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
StandardColor = GenerateStandardGradients();
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(_history))
|
|
|
|
|
|
{
|
|
|
|
|
|
HistoryList = JsonConvert.DeserializeObject<ObservableCollection<string>>(File.ReadAllText(_history));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
HistoryList = new ObservableCollection<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PropertyChanged += MainWindowViewModel_PropertyChanged;
|
|
|
|
|
|
_service.PropertyChanged += Provider_PropertyChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
2023-03-20 20:23:20 +08:00
|
|
|
|
public ToolBoxViewModel ToolBoxViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; private set;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
private ObservableCollection<PageViewModel> _diagramsViewModels;
|
|
|
|
|
|
public ObservableCollection<PageViewModel> DiagramsViewModels
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _diagramsViewModels;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _diagramsViewModels, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-11 22:27:23 +08:00
|
|
|
|
private PageViewModel _pageViewModel;
|
2023-02-12 21:30:16 +08:00
|
|
|
|
public PageViewModel PageViewModel
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-03-11 22:27:23 +08:00
|
|
|
|
return _pageViewModel;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-03-11 22:27:23 +08:00
|
|
|
|
SetProperty(ref _pageViewModel, value);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-29 13:55:18 +08:00
|
|
|
|
private Models.ColorType _colorObject;
|
|
|
|
|
|
public Models.ColorType ColorType
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _colorObject;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _colorObject, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool _isOpenBackstage;
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsOpenBackstage
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _isOpenBackstage;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _isOpenBackstage, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<string> _historyList;
|
|
|
|
|
|
public ObservableCollection<string> HistoryList
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _historyList;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _historyList, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-20 20:23:20 +08:00
|
|
|
|
public Color[] StandardColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
public IDrawModeViewModel DrawModeViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.DrawModeViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IFontViewModel FontViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.FontViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public IColorViewModel ColorViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.ColorViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-01-26 18:27:17 +08:00
|
|
|
|
public IShapeViewModel ShapeViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.ShapeViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public IQuickThemeViewModel QuickThemeViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.QuickThemeViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public ILockObjectViewModel LockObjectViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.LockObjectViewModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 09:02:40 +08:00
|
|
|
|
public SelectableDesignerItemViewModelBase SelectedItem
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _service.SelectedItem;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Color ThemeColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get => ((SolidColorBrush)Application.Current.Resources["Fluent.Ribbon.Brushes.AccentBaseColorBrush"])?.Color ?? Colors.Pink;
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
var solidColorBrush = new SolidColorBrush(value);
|
|
|
|
|
|
solidColorBrush.Freeze();
|
|
|
|
|
|
Application.Current.Resources["Fluent.Ribbon.Brushes.AccentBaseColorBrush"] = solidColorBrush;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string CurrentBaseColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get => this.CurrentTheme.BaseColorScheme;
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThemeManager.Current.ChangeThemeBaseColor(Application.Current, value);
|
|
|
|
|
|
RaisePropertyChanged(nameof(this.CurrentTheme));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Theme CurrentTheme
|
|
|
|
|
|
{
|
|
|
|
|
|
get => ThemeManager.Current.DetectTheme(Application.Current);
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThemeManager.Current.ChangeTheme(Application.Current, value);
|
|
|
|
|
|
RaisePropertyChanged(nameof(this.CurrentBaseColor));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
public Func<PageViewModel> NewItemFactory
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return
|
2023-03-20 20:23:20 +08:00
|
|
|
|
() => {
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 命令
|
|
|
|
|
|
private ICommand _newCommand;
|
|
|
|
|
|
public ICommand NewCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._newCommand ?? (this._newCommand = new DelegateCommand<string>(para => this.New_Executed(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-20 20:23:20 +08:00
|
|
|
|
private ICommand _newMindCommand;
|
|
|
|
|
|
public ICommand NewMindCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._newMindCommand ?? (this._newMindCommand = new DelegateCommand<string>(para => this.NewMind_Executed(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private ICommand _openCommand;
|
|
|
|
|
|
public ICommand OpenCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._openCommand ?? (this._openCommand = new DelegateCommand<string>(para => this.OpenExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _saveCommand;
|
|
|
|
|
|
public ICommand SaveCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._saveCommand ?? (this._saveCommand = new CanExecuteDelegateCommand(() => this.SaveExecuted(), () => this.Save_Enable()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _saveAsCommand;
|
|
|
|
|
|
public ICommand SaveAsCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._saveAsCommand ?? (this._saveAsCommand = new CanExecuteDelegateCommand(() => this.SaveAsExecuted(), () => this.Save_Enable()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _pasteCommand;
|
|
|
|
|
|
public ICommand PasteCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._pasteCommand ?? (this._pasteCommand = new CanExecuteDelegateCommand(() => this.PasteExecuted(), () => this.Paste_Enabled()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _cutCommand;
|
|
|
|
|
|
public ICommand CutCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._cutCommand ?? (this._cutCommand = new CanExecuteDelegateCommand(() => this.CutExecuted(), () => this.Cut_Enabled()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _copyCommand;
|
|
|
|
|
|
public ICommand CopyCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._copyCommand ?? (this._copyCommand = new CanExecuteDelegateCommand(() => this.CopyExecuted(), () => Copy_Enabled()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _exitCommand;
|
|
|
|
|
|
public ICommand ExitCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._exitCommand ?? (this._exitCommand = new CanExecuteDelegateCommand(() => this.ExitExecuted()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _formatCommand;
|
|
|
|
|
|
public ICommand FormatCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._formatCommand ?? (this._formatCommand = new CanExecuteDelegateCommand(() => this.FormatExecuted(), () => Format_Enabled()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _deleteCommand;
|
|
|
|
|
|
public ICommand DeleteCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._deleteCommand ?? (this._deleteCommand = new CanExecuteDelegateCommand(() => this.DeleteExecuted(), () => Delete_Enabled()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignTopCommand;
|
|
|
|
|
|
public ICommand AlignTopCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignTopCommand ?? (this._alignTopCommand = new DelegateCommand<object>(para => this.AlignTopExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignVerticalCentersCommand;
|
|
|
|
|
|
public ICommand AlignVerticalCentersCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignVerticalCentersCommand ?? (this._alignVerticalCentersCommand = new DelegateCommand<object>(para => this.AlignVerticalCentersExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignBottomCommand;
|
|
|
|
|
|
public ICommand AlignBottomCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignBottomCommand ?? (this._alignBottomCommand = new DelegateCommand<object>(para => this.AlignBottomExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignLeftCommand;
|
|
|
|
|
|
public ICommand AlignLeftCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignLeftCommand ?? (this._alignLeftCommand = new DelegateCommand<object>(para => this.AlignLeftExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignHorizontalCentersCommand;
|
|
|
|
|
|
public ICommand AlignHorizontalCentersCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignHorizontalCentersCommand ?? (this._alignHorizontalCentersCommand = new DelegateCommand<object>(para => this.AlignHorizontalCentersExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _alignRightCommand;
|
|
|
|
|
|
public ICommand AlignRightCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._alignRightCommand ?? (this._alignRightCommand = new DelegateCommand<object>(para => this.AlignRightExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _groupCommand;
|
|
|
|
|
|
public ICommand GroupCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._groupCommand ?? (this._groupCommand = new DelegateCommand<object>(para => this.GroupExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _ungroupCommand;
|
|
|
|
|
|
public ICommand UngroupCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._ungroupCommand ?? (this._ungroupCommand = new DelegateCommand<object>(para => this.UngroupExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _bringForwardCommand;
|
|
|
|
|
|
public ICommand BringForwardCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._bringForwardCommand ?? (this._bringForwardCommand = new DelegateCommand<object>(para => this.BringForwardExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _bringToFrontCommand;
|
|
|
|
|
|
public ICommand BringToFrontCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._bringToFrontCommand ?? (this._bringToFrontCommand = new DelegateCommand<object>(para => this.BringToFrontExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sendBackwardCommand;
|
|
|
|
|
|
public ICommand SendBackwardCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sendBackwardCommand ?? (this._sendBackwardCommand = new DelegateCommand<object>(para => this.SendBackwardExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sendToBackCommand;
|
|
|
|
|
|
public ICommand SendToBackCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sendToBackCommand ?? (this._sendToBackCommand = new DelegateCommand<object>(para => this.SendToBackExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _distributeHorizontalCommand;
|
|
|
|
|
|
public ICommand DistributeHorizontalCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._distributeHorizontalCommand ?? (this._distributeHorizontalCommand = new DelegateCommand<object>(para => this.DistributeHorizontalExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _distributeVerticalCommand;
|
|
|
|
|
|
public ICommand DistributeVerticalCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._distributeVerticalCommand ?? (this._distributeVerticalCommand = new DelegateCommand<object>(para => this.DistributeVerticalExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _selectAllCommand;
|
|
|
|
|
|
public ICommand SelectAllCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._selectAllCommand ?? (this._selectAllCommand = new DelegateCommand<object>(para => this.SelectAllExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _centerCommand;
|
|
|
|
|
|
public ICommand CenterCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-08-01 22:30:12 +08:00
|
|
|
|
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterMoveExecuted(para)));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sameWidthCommand;
|
|
|
|
|
|
public ICommand SameWidthCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameWidthCommand ?? (this._sameWidthCommand = new DelegateCommand<object>(para => this.SameWidthExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sameHeightCommand;
|
|
|
|
|
|
public ICommand SameHeightCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameHeightCommand ?? (this._sameHeightCommand = new DelegateCommand<object>(para => this.SameHeightExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sameSizeCommand;
|
|
|
|
|
|
public ICommand SameSizeCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameSizeCommand ?? (this._sameSizeCommand = new DelegateCommand<object>(para => this.SameSizeExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sameAngleCommand;
|
|
|
|
|
|
public ICommand SameAngleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._sameAngleCommand ?? (this._sameAngleCommand = new DelegateCommand<object>(para => this.SameAngleExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _lockCommand;
|
|
|
|
|
|
public ICommand LockCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._lockCommand ?? (this._lockCommand = new DelegateCommand<object>(para => this.LockExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _unlockCommand;
|
|
|
|
|
|
public ICommand UnlockCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._unlockCommand ?? (this._unlockCommand = new DelegateCommand<object>(para => this.UnlockExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _selectedColorCommand;
|
|
|
|
|
|
public ICommand SelectedColorCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._selectedColorCommand ?? (this._selectedColorCommand = new DelegateCommand<object>(para => this.SelectedColorExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addPageCommand;
|
|
|
|
|
|
public ICommand AddPageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addPageCommand ?? (this._addPageCommand = new DelegateCommand<object>(para => this.AddPageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addCopyPageCommand;
|
|
|
|
|
|
public ICommand AddCopyPageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addCopyPageCommand ?? (this._addCopyPageCommand = new DelegateCommand<object>(para => this.AddCopyPageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _renamePageCommand;
|
|
|
|
|
|
public ICommand RenamePageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._renamePageCommand ?? (this._renamePageCommand = new DelegateCommand<object>(para => this.RenamePageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _endRenamePageCommand;
|
|
|
|
|
|
public ICommand EndRenamePageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._endRenamePageCommand ?? (this._endRenamePageCommand = new DelegateCommand<object>(para => this.EndRenamePageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _deletePageCommand;
|
|
|
|
|
|
public ICommand DeletePageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._deletePageCommand ?? (this._deletePageCommand = new DelegateCommand<object>(para => this.DeletePageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addImageCommand;
|
|
|
|
|
|
public ICommand AddImageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addImageCommand ?? (this._addImageCommand = new DelegateCommand<object>(para => this.AddImageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _editImageCommand;
|
|
|
|
|
|
public ICommand EditImageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._editImageCommand ?? (this._editImageCommand = new DelegateCommand<object>(para => this.EditImageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _resizeImageCommand;
|
|
|
|
|
|
public ICommand ResizeImageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._resizeImageCommand ?? (this._resizeImageCommand = new DelegateCommand<object>(para => this.ResizeImageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _resetImageCommand;
|
|
|
|
|
|
public ICommand ResetImageCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._resetImageCommand ?? (this._resetImageCommand = new DelegateCommand<object>(para => this.ResetImageExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addVideoCommand;
|
|
|
|
|
|
public ICommand AddVideoCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addVideoCommand ?? (this._addVideoCommand = new DelegateCommand<object>(para => this.AddVideoExectued(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addOutLineTextCommand;
|
|
|
|
|
|
public ICommand AddOutLineTextCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addOutLineTextCommand ?? (this._addOutLineTextCommand = new DelegateCommand<object>(para => this.AddOutLineTextExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _addBarcodeCommand;
|
|
|
|
|
|
public ICommand AddBarcodeCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._addBarcodeCommand ?? (this._addBarcodeCommand = new DelegateCommand<object>(para => this.AddBarcodeExecuted(para)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _aboutCommand;
|
|
|
|
|
|
public ICommand AboutCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return this._aboutCommand ?? (this._aboutCommand = new DelegateCommand(() => this.AboutExecuted()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public ItemActionCallback ClosingTabItemHandler
|
|
|
|
|
|
{
|
2023-03-20 20:23:20 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return ClosingTabItemHandlerImpl;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Callback to handle tab closing.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs<TabablzControl> args)
|
|
|
|
|
|
{
|
|
|
|
|
|
//here's how you can cancel stuff:
|
|
|
|
|
|
//args.Cancel();
|
2021-08-02 18:08:43 +08:00
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (args.DragablzItem.DataContext is PageViewModel viewModel)
|
2021-08-02 18:08:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
viewModel.Dispose();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MainWindowViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Provider_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.PropertyName == nameof(DrawModeViewModel)
|
|
|
|
|
|
|| e.PropertyName == nameof(FontViewModel)
|
|
|
|
|
|
|| e.PropertyName == nameof(ColorViewModel)
|
2023-01-26 18:27:17 +08:00
|
|
|
|
|| e.PropertyName == nameof(ShapeViewModel)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|| e.PropertyName == nameof(QuickThemeViewModel)
|
|
|
|
|
|
|| e.PropertyName == nameof(LockObjectViewModel)
|
|
|
|
|
|
|| e.PropertyName == nameof(SelectedItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
RaisePropertyChanged(e.PropertyName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (PageViewModel == null) return;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (sender is IFontViewModel)
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.SetFont(sender as IFontViewModel, e.PropertyName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (sender is IColorViewModel)
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.SetColor(sender as IColorViewModel, e.PropertyName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-26 18:27:17 +08:00
|
|
|
|
if (sender is IShapeViewModel)
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName);
|
2023-01-26 18:27:17 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
if (sender is IQuickThemeViewModel)
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (sender is LockObject)
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.LockAction(sender as LockObject, e.PropertyName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (sender is DesignerItemViewModelBase designer
|
|
|
|
|
|
&& (e.PropertyName == nameof(designer.Angle)
|
|
|
|
|
|
|| e.PropertyName == nameof(designer.ItemWidth)
|
|
|
|
|
|
|| e.PropertyName == nameof(designer.ItemHeight)
|
|
|
|
|
|
|| e.PropertyName == nameof(designer.ScaleX)
|
|
|
|
|
|
|| e.PropertyName == nameof(designer.ScaleY)))
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel.SetPropertyValue(designer, e.PropertyName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-04 20:59:01 +08:00
|
|
|
|
public bool KeyExecuted(KeyEventArgs e)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-04 22:42:09 +08:00
|
|
|
|
//if (PageViewModel?.DiagramViewModel?.ExecuteShortcut(e) == true)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
//}
|
2023-02-04 20:59:01 +08:00
|
|
|
|
|
|
|
|
|
|
var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString();
|
2021-08-01 22:30:12 +08:00
|
|
|
|
bool executed = true;
|
2023-03-20 20:23:20 +08:00
|
|
|
|
switch (para)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
case "Control+O": OpenExecuted(); break;
|
|
|
|
|
|
case "Control+N": New_Executed(); break;
|
2023-03-20 20:23:20 +08:00
|
|
|
|
case "Control+S": SaveExecuted(); break;
|
2021-08-01 22:30:12 +08:00
|
|
|
|
default: executed = false; break;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2021-08-01 22:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
return executed;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnDoExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ReDoExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SelectedAllExecuted()
|
|
|
|
|
|
{
|
2023-03-20 20:23:20 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OpenExecuted(string para = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string filename = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(para))
|
|
|
|
|
|
{
|
|
|
|
|
|
Microsoft.Win32.OpenFileDialog openFile = new Microsoft.Win32.OpenFileDialog();
|
|
|
|
|
|
openFile.Filter = "Designer Files (*.xml;*.json)|*.xml;*.json|All Files (*.*)|*.*";
|
|
|
|
|
|
|
|
|
|
|
|
if (openFile.ShowDialog() == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filename = openFile.FileName;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
filename = para;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var viewmodel = DiagramsViewModels.FirstOrDefault(p => p.FileName == filename);
|
|
|
|
|
|
if (viewmodel != null)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = viewmodel;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
MessageBox.Show("文档已经打开");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
var diagram = PageViewModel.OpenFile(filename, Path.GetExtension(filename));
|
|
|
|
|
|
PageViewModel flow;
|
2021-08-03 18:19:47 +08:00
|
|
|
|
if (diagram.DiagramType == DiagramType.FlowChart)
|
|
|
|
|
|
{
|
|
|
|
|
|
flow = new FlowchartViewModel(filename, diagram);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (diagram.DiagramType == DiagramType.Logical)
|
|
|
|
|
|
{
|
|
|
|
|
|
flow = new LogicalViewModel(filename, diagram);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (diagram.DiagramType == DiagramType.SFC)
|
|
|
|
|
|
{
|
|
|
|
|
|
flow = new SFCViewModel(filename, diagram);
|
|
|
|
|
|
}
|
2023-03-08 19:45:07 +08:00
|
|
|
|
else if (diagram.DiagramType == DiagramType.Mind)
|
|
|
|
|
|
{
|
|
|
|
|
|
flow = new MindViewModel(filename, diagram);
|
|
|
|
|
|
}
|
2021-08-03 18:19:47 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
flow = new PageViewModel(filename, diagram);
|
2021-08-03 18:19:47 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
DiagramsViewModels.Add(flow);
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = flow;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(para))
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
SaveHistory(PageViewModel);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
IsOpenBackstage = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (PageViewModel == null) return;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (PageViewModel.SaveFile())
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
SaveHistory(PageViewModel);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveAsExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (PageViewModel == null) return;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
if (PageViewModel.SaveFile(true))
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
SaveHistory(PageViewModel);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
private void SaveHistory(PageViewModel diagramsViewModel)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
HistoryList.Remove(PageViewModel.FileName);
|
|
|
|
|
|
HistoryList.Insert(0, PageViewModel.FileName);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
File.WriteAllText(_history, JsonConvert.SerializeObject(HistoryList));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Save_Enable()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return PageViewModel != null;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void PasteExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.PasteCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Paste_Enabled()
|
|
|
|
|
|
{
|
2022-12-08 20:54:45 +08:00
|
|
|
|
return Clipboard.ContainsData(DataFormats.Serializable);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CopyExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.CopyCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Copy_Enabled()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void DeleteExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.DeleteCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Delete_Enabled()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CutExecuted()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.CutCommand.Execute(null);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Cut_Enabled()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() > 0;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FormatExecuted()
|
|
|
|
|
|
{
|
|
|
|
|
|
_service.DrawModeViewModel.CursorMode = CursorMode.Format;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool Format_Enabled()
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
return PageViewModel != null && PageViewModel.DiagramViewModel != null && PageViewModel.DiagramViewModel.SelectedItems.Count() == 1;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void New_Executed(string type = "Normal")
|
|
|
|
|
|
{
|
|
|
|
|
|
IsOpenBackstage = false;
|
|
|
|
|
|
if (type == DiagramType.FlowChart.ToString())
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = new FlowchartViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (type == DiagramType.Logical.ToString())
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = new LogicalViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2021-08-01 22:30:12 +08:00
|
|
|
|
else if (type == DiagramType.SFC.ToString())
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel = new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 21:30:16 +08:00
|
|
|
|
DiagramsViewModels.Add(PageViewModel);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-20 20:23:20 +08:00
|
|
|
|
private void NewMind_Executed(string mindtype = "Mind")
|
|
|
|
|
|
{
|
|
|
|
|
|
IsOpenBackstage = false;
|
|
|
|
|
|
|
2023-04-02 12:01:46 +08:00
|
|
|
|
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Mind, mindtype.ToEnum<MindType>());
|
2023-03-20 20:23:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DiagramsViewModels.Add(PageViewModel);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void ExitExecuted()
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void GroupExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.GroupCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UngroupExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.UngroupCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 布局
|
|
|
|
|
|
private void AlignTopExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignTopCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void AlignVerticalCentersExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void AlignBottomExecuted(object para)
|
2023-03-20 20:23:20 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void AlignLeftExecuted(object para)
|
2023-03-20 20:23:20 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void AlignHorizontalCentersExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignHorizontalCentersCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void AlignRightExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.AlignRightCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void BringForwardExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.BringForwardCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void BringToFrontExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.BringToFrontCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void SendBackwardExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void SendToBackExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void DistributeHorizontalExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.DistributeHorizontalCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void DistributeVerticalExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.DistributeVerticalCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void SelectAllExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2021-08-01 22:30:12 +08:00
|
|
|
|
private void CenterMoveExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.CenterMoveCommand.Execute(para);
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LeftMoveExecuted(object para = null)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.LeftMoveCommand.Execute(para);
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RightMoveExecuted(object para = null)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.RightMoveCommand.Execute(para);
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpMoveExecuted(object para = null)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.UpMoveCommand.Execute(para);
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void DownMoveExecuted(object para = null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.DownMoveCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SameWidthExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SameWidthCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SameHeightExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SameHeightCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SameSizeExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SameSizeCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SameAngleExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DiagramViewModel?.SameAngleCommand.Execute(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LockExecuted(object para)
|
|
|
|
|
|
{
|
|
|
|
|
|
LockObjectViewModel.LockObject[0].IsChecked = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UnlockExecuted(object para)
|
|
|
|
|
|
{
|
|
|
|
|
|
LockObjectViewModel.LockObject.ForEach(p => p.IsChecked = false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddPageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddPageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddCopyPageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddCopyPageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RenamePageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.RenamePageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EndRenamePageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.EndRenamePageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void DeletePageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.DeletePageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddImageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddImageExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EditImageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.EditImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ResizeImageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.ResizeImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ResetImageExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.ResetImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddVideoExectued(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddVideoExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddOutLineTextExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddOutLineTextExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddBarcodeExecuted(object para)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
PageViewModel?.AddBarcodeExecuted(para);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SelectedColorExecuted(object para)
|
|
|
|
|
|
{
|
2023-01-22 21:46:59 +08:00
|
|
|
|
if (para == null) return;
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
switch (ColorType)
|
|
|
|
|
|
{
|
2023-02-12 21:30:16 +08:00
|
|
|
|
case Models.ColorType.Text: PageViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
|
|
|
|
|
|
case Models.ColorType.Fill: PageViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
|
|
|
|
|
|
case Models.ColorType.Line: PageViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AboutExecuted()
|
|
|
|
|
|
{
|
|
|
|
|
|
AboutWindow aboutWindow = new AboutWindow();
|
|
|
|
|
|
aboutWindow.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 方法
|
|
|
|
|
|
private Color[] GenerateStandardGradients()
|
|
|
|
|
|
{
|
|
|
|
|
|
var count = ColorGallery.StandardThemeColors.Length;
|
|
|
|
|
|
List<Color> result = new List<Color>();
|
|
|
|
|
|
for (var i = 0; i < count; i++)
|
|
|
|
|
|
{
|
2021-07-23 16:42:51 +08:00
|
|
|
|
//var colors = ColorGallery.GetGradient(ColorGallery.StandardThemeColors[i], 10);
|
|
|
|
|
|
//for (var j = 9; j >= 0; j--)
|
|
|
|
|
|
//{
|
2023-03-26 23:23:34 +08:00
|
|
|
|
// result.AddTo(colors[j]);
|
2021-07-23 16:42:51 +08:00
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
//var colors = ColorGallery.GetGradient(Colors.Black, 10);
|
|
|
|
|
|
//for (var j = 9; j >= 0; j--)
|
|
|
|
|
|
//{
|
2023-03-26 23:23:34 +08:00
|
|
|
|
// result.AddTo(colors[j]);
|
2021-07-23 16:42:51 +08:00
|
|
|
|
//}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
return result.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|