mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 04:59:26 +08:00
ReDo Undo Item ItemWidth 和 Angle 等工具栏设置完成
This commit is contained in:
@@ -37,7 +37,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
ToolBoxViewModel = new ToolBoxViewModel();
|
||||
ToolBoxViewModel = new ToolBoxViewModel(this);
|
||||
|
||||
DiagramsViewModels = new ObservableCollection<PageViewModel>();
|
||||
DiagramsViewModels.Add(new PageViewModel("新建-1", "*", DiagramType.Normal));
|
||||
@@ -178,11 +178,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase SelectedItem
|
||||
public SelectableDesignerItemViewModelBase SelectedItemViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _service.SelectedItem;
|
||||
return _service.SelectedItemViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,118 +367,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
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
|
||||
@@ -525,47 +414,42 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|| e.PropertyName == nameof(ShapeViewModel)
|
||||
|| e.PropertyName == nameof(QuickThemeViewModel)
|
||||
|| e.PropertyName == nameof(LockObjectViewModel)
|
||||
|| e.PropertyName == nameof(SelectedItem))
|
||||
|| e.PropertyName == nameof(SelectedItemViewModel))
|
||||
{
|
||||
RaisePropertyChanged(e.PropertyName);
|
||||
}
|
||||
|
||||
if (PageViewModel == null) return;
|
||||
if (PageViewModel == null || PageViewModel.DiagramViewModel == null) return;
|
||||
|
||||
if (sender is IFontViewModel)
|
||||
PageViewModel.SetFont(sender as IFontViewModel, e.PropertyName);
|
||||
|
||||
if (sender is IColorViewModel)
|
||||
PageViewModel.SetColor(sender as IColorViewModel, e.PropertyName);
|
||||
|
||||
if (sender is IShapeViewModel)
|
||||
PageViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName);
|
||||
|
||||
if (sender is IQuickThemeViewModel)
|
||||
PageViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName);
|
||||
|
||||
if (sender is LockObject)
|
||||
PageViewModel.LockAction(sender as LockObject, e.PropertyName);
|
||||
|
||||
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)))
|
||||
{
|
||||
PageViewModel.SetPropertyValue(designer, e.PropertyName);
|
||||
PageViewModel.DiagramViewModel.SetFont(sender as IFontViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
else if (sender is IColorViewModel)
|
||||
{
|
||||
PageViewModel.DiagramViewModel.SetColor(sender as IColorViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
else if (sender is IShapeViewModel)
|
||||
{
|
||||
PageViewModel.DiagramViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
else if (sender is IQuickThemeViewModel)
|
||||
{
|
||||
PageViewModel.DiagramViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
else if (sender is LockObject)
|
||||
{
|
||||
PageViewModel.DiagramViewModel.LockAction(sender as LockObject, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
else if (sender is SelectableDesignerItemViewModelBase designer)
|
||||
{
|
||||
PageViewModel.DiagramViewModel.SetPropertyValue(designer, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool KeyExecuted(KeyEventArgs e)
|
||||
{
|
||||
//if (PageViewModel?.DiagramViewModel?.ExecuteShortcut(e) == true)
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString();
|
||||
bool executed = true;
|
||||
switch (para)
|
||||
@@ -577,22 +461,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
}
|
||||
|
||||
return executed;
|
||||
}
|
||||
|
||||
private void UnDoExecuted()
|
||||
{
|
||||
PageViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void ReDoExecuted()
|
||||
{
|
||||
PageViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void SelectedAllExecuted()
|
||||
{
|
||||
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenExecuted(string para = null)
|
||||
{
|
||||
@@ -789,75 +658,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
LockObjectViewModel.LockObject.ForEach(p => p.IsChecked = false);
|
||||
}
|
||||
|
||||
private void AddPageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.AddPageExecuted(para);
|
||||
}
|
||||
|
||||
private void AddCopyPageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.AddCopyPageExecuted(para);
|
||||
}
|
||||
|
||||
private void RenamePageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.RenamePageExecuted(para);
|
||||
}
|
||||
|
||||
private void EndRenamePageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.EndRenamePageExecuted(para);
|
||||
}
|
||||
|
||||
private void DeletePageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.DeletePageExecuted(para);
|
||||
}
|
||||
|
||||
private void AddImageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.AddImageExecuted(para);
|
||||
}
|
||||
|
||||
private void EditImageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.EditImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||
}
|
||||
|
||||
private void ResizeImageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.ResizeImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||
}
|
||||
|
||||
private void ResetImageExecuted(object para)
|
||||
{
|
||||
PageViewModel?.ResetImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||
}
|
||||
|
||||
private void AddVideoExectued(object para)
|
||||
{
|
||||
PageViewModel?.AddVideoExecuted(para);
|
||||
}
|
||||
|
||||
private void AddOutLineTextExecuted(object para)
|
||||
{
|
||||
PageViewModel?.AddOutLineTextExecuted(para);
|
||||
}
|
||||
|
||||
private void AddBarcodeExecuted(object para)
|
||||
{
|
||||
PageViewModel?.AddBarcodeExecuted(para);
|
||||
}
|
||||
|
||||
private void SelectedColorExecuted(object para)
|
||||
{
|
||||
if (para == null) return;
|
||||
|
||||
switch (ColorType)
|
||||
{
|
||||
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;
|
||||
case Models.ColorType.Text: PageViewModel?.DiagramViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||
case Models.ColorType.Fill: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||
case Models.ColorType.Line: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user