ReDo Undo Item ItemWidth 和 Angle 等工具栏设置完成

This commit is contained in:
艾竹
2023-04-09 12:38:57 +08:00
parent 2ef5b7a1ed
commit fae7826577
16 changed files with 487 additions and 464 deletions

View File

@@ -25,6 +25,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public partial class PageViewModel : BindableBase
{
#region
protected IDiagramServiceProvider _service
{
get
@@ -71,14 +72,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
InitDiagramViewModel();
}
#endregion
#region
public string FileName
{
get; set;
}
#region
private string _title;
public string Title
{
@@ -172,15 +173,124 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
#endregion
#region
#region
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)));
}
}
#endregion
#region
private void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsSelected")
{
_service.SelectedItems = DiagramViewModel?.SelectedItems;
_service.SelectedItem = DiagramViewModel?.SelectedItem;
_service.SelectedItemViewModel = CopyHelper.Mapper(DiagramViewModel?.SelectedItem);
}
var property = sender.GetType().GetProperty(e.PropertyName);
@@ -195,6 +305,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
#endregion
#region
protected virtual bool AddVerify(SelectableDesignerItemViewModelBase arg)
{
return true;
@@ -356,84 +467,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
return true;
}
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
{
if (connector is FullyCreatedConnectorInfo fully)
{
return itemsToRemove.Contains(fully.DataItem);
}
return false;
}
#region
public void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item != selectable)
{
CopyHelper.CopyPropertyValue(selectable, item, propertyName);
}
}
}
public void SetFont(IFontViewModel fontViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.FontViewModel != fontViewModel)
{
CopyHelper.CopyPropertyValue(fontViewModel, item.FontViewModel, propertyName);
}
}
}
public void SetColor(IColorViewModel colorViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.ColorViewModel != colorViewModel)
{
CopyHelper.CopyPropertyValue(colorViewModel, item.ColorViewModel, propertyName);
}
}
}
public void SetSharp(IShapeViewModel shapeViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.ShapeViewModel != shapeViewModel)
{
CopyHelper.CopyPropertyValue(shapeViewModel, item.ShapeViewModel, propertyName);
}
}
}
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName)
{
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
SetFont(quickThemeViewModel.QuickTheme.FontViewModel, "FontColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "FillColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "LineColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "LineWidth");
}
quickThemeViewModel.QuickTheme = null;
}
}
public void LockAction(LockObject lockObject, string propertyName)
{
foreach (var item in DiagramViewModel?.SelectedItems)
{
item.LockObjectViewModel.SetValue(lockObject);
}
}
public virtual void AddPageExecuted(object para)
{
int index = 0;
@@ -550,6 +583,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void EditImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -559,6 +597,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void ResizeImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -568,6 +611,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void ResetImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -575,7 +622,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public void AddVideoExecuted(object para)
public void AddVideoExectued(object para)
{
VideoItemViewModel itemBase = new VideoItemViewModel();
DiagramViewModel?.AddItemCommand.Execute(itemBase);
@@ -604,20 +651,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
_service.DrawModeViewModel.CursorMode = CursorMode.Move;
}
}
#endregion
private Size MeasureString(OutLineTextDesignerItemViewModel itemBase)
{
var formattedText = new FormattedText(
itemBase.Text,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(new FontFamily(itemBase.FontViewModel.FontFamily), itemBase.FontViewModel.FontStyle, itemBase.FontViewModel.FontWeight, itemBase.FontViewModel.FontStretch),
itemBase.FontViewModel.FontSize,
Brushes.Black);
return new Size(formattedText.Width, formattedText.Height);
}
#endregion
public virtual void Dispose()
{