mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-06 09:16:37 +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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -28,15 +28,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class ToolBoxViewModel : BindableBase
|
||||
{
|
||||
private IDiagramServiceProvider _service
|
||||
{
|
||||
get
|
||||
{
|
||||
return DiagramServicesProvider.Instance.Provider;
|
||||
}
|
||||
}
|
||||
public ToolBoxViewModel()
|
||||
private MainWindowViewModel _mainWindowViewModel;
|
||||
|
||||
public ToolBoxViewModel(MainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
_mainWindowViewModel = mainWindowViewModel;
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -298,14 +294,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
|
||||
private void AddMyItem()
|
||||
{
|
||||
if (_service.SelectedItems != null)
|
||||
if (_mainWindowViewModel?.PageViewModel?.DiagramViewModel != null)
|
||||
{
|
||||
DiagramDocument diagramDocument = new DiagramDocument();
|
||||
diagramDocument.DiagramItems = new List<DiagramItem>();
|
||||
DiagramItem diagramItem = new DiagramItem();
|
||||
|
||||
var selectedDesignerItems = _service.SelectedItems.OfType<DesignerItemViewModelBase>();
|
||||
var selectedConnections = _service.SelectedItems.OfType<ConnectionViewModel>();
|
||||
var selectedDesignerItems = _mainWindowViewModel?.PageViewModel?.DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>();
|
||||
var selectedConnections = _mainWindowViewModel?.PageViewModel?.DiagramViewModel.SelectedItems.OfType<ConnectionViewModel>();
|
||||
|
||||
diagramItem.DesignerItems = selectedDesignerItems.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();
|
||||
diagramItem.Connections = selectedConnections.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();
|
||||
|
||||
@@ -1020,21 +1020,21 @@
|
||||
<Fluent:Button Margin="5" Command="{Binding PageViewModel.DiagramViewModel.DistributeVerticalCommand}" Size="Small" Icon="/AIStudio.Wpf.DiagramApp;component/Images/DistributeObjectsVertical.png"/>
|
||||
</StackPanel>
|
||||
</Fluent:DropDownButton>
|
||||
<Fluent:SplitButton Header="翻转" Icon="{iconPacks:VaadinIcons Kind=FlipH}" Width="50" VerticalAlignment="Top" IsCheckable="True" IsChecked="{Binding SelectedItem.ShowRotate}">
|
||||
<Fluent:SplitButton Header="翻转" Icon="{iconPacks:VaadinIcons Kind=FlipH}" Width="50" VerticalAlignment="Top" IsCheckable="True" IsChecked="{Binding SelectedItemViewModel.ShowRotate}">
|
||||
<Fluent:SplitButton.LargeIcon>
|
||||
<iconPacks:PackIconVaadinIcons Kind="FlipH" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:SplitButton.LargeIcon>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5" Text="镜像" VerticalAlignment="Center"/>
|
||||
<Fluent:ToggleButton IsChecked="{Binding PageViewModel.DiagramViewModel.SelectedItem.ScaleX,Converter={dd:ConverterValueMapToBool Parameter='1'}, ConverterParameter='-1'}"
|
||||
<Fluent:ToggleButton IsChecked="{Binding SelectedItemViewModel.ScaleX,Converter={dd:ConverterValueMapToBool Parameter='1'}, ConverterParameter='-1'}"
|
||||
Margin="5" Size="Small" Icon="{iconPacks:Material Kind=FlipHorizontal}"/>
|
||||
<Fluent:ToggleButton IsChecked="{Binding PageViewModel.DiagramViewModel.SelectedItem.ScaleY,Converter={dd:ConverterValueMapToBool Parameter='1'}, ConverterParameter='-1'}"
|
||||
<Fluent:ToggleButton IsChecked="{Binding SelectedItemViewModel.ScaleY,Converter={dd:ConverterValueMapToBool Parameter='1'}, ConverterParameter='-1'}"
|
||||
Margin="5" Size="Small" Icon="{iconPacks:Material Kind=FlipVertical}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5" Text="旋转" VerticalAlignment="Center"/>
|
||||
<controls:SliderRotation Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.Angle,Mode=TwoWay}"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.Angle,Mode=TwoWay}" Maximum="359" Minimum="0"
|
||||
<controls:SliderRotation Value="{Binding SelectedItemViewModel.Angle,Mode=TwoWay}"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding SelectedItemViewModel.Angle,Mode=TwoWay}" Maximum="359" Minimum="0"
|
||||
Format="0 deg" />
|
||||
</StackPanel>
|
||||
</Fluent:SplitButton>
|
||||
@@ -1045,19 +1045,19 @@
|
||||
<TextBlock Margin="5" Text="大小" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5" Text="宽" Width="15" VerticalAlignment="Center"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.ItemWidth,Mode=TwoWay}" Minimum="0"
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding SelectedItemViewModel.ItemWidth,Mode=TwoWay}" Minimum="0"
|
||||
Format="0" />
|
||||
<TextBlock Margin="5" Text="高" Width="15" VerticalAlignment="Center"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.ItemHeight,Mode=TwoWay}" Minimum="0"
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding SelectedItemViewModel.ItemHeight,Mode=TwoWay}" Minimum="0"
|
||||
Format="0" />
|
||||
</StackPanel>
|
||||
<TextBlock Margin="5" Text="X/Y位置"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="5" Text="X" Width="15" VerticalAlignment="Center"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.Left,Mode=TwoWay}" Minimum="0"
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding SelectedItemViewModel.Left,Mode=TwoWay}" Minimum="0"
|
||||
Format="0" />
|
||||
<TextBlock Margin="5" Text="Y" Width="15" VerticalAlignment="Center"/>
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding PageViewModel.DiagramViewModel.SelectedItem.Top,Mode=TwoWay}" Minimum="0"
|
||||
<Fluent:Spinner Margin="5" Width="60" Size="Small" Value="{Binding SelectedItemViewModel.Top,Mode=TwoWay}" Minimum="0"
|
||||
Format="0" />
|
||||
</StackPanel>
|
||||
<Separator />
|
||||
@@ -1328,7 +1328,7 @@
|
||||
ItemWidth="45"
|
||||
ItemHeight="56"
|
||||
ItemsSource="{Binding QuickThemeViewModel.QuickThemes}"
|
||||
SelectedItem="{Binding QuickThemeViewModel.QuickTheme}"
|
||||
SelectedItem="{Binding QuickThemeViewModel.QuickTheme,Delay=100}"
|
||||
ResizeMode="Both"
|
||||
Selectable="False">
|
||||
<Fluent:InRibbonGallery.ItemTemplate>
|
||||
@@ -1349,12 +1349,12 @@
|
||||
<Fluent:RibbonTabItem Header="插入">
|
||||
<Fluent:RibbonGroupBox Header="插入"
|
||||
IsLauncherVisible="True">
|
||||
<Fluent:SplitButton Header="空白页" Width="50" VerticalAlignment="Top" Command="{Binding AddPageCommand}">
|
||||
<Fluent:SplitButton Header="空白页" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.AddPageCommand}">
|
||||
<Fluent:SplitButton.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="FileOutline" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:SplitButton.LargeIcon>
|
||||
<Fluent:MenuItem Header="空白页" Size="Middle" Command="{Binding AddPageCommand}" Icon="{iconPacks:Material Kind=FileOutline}"/>
|
||||
<Fluent:MenuItem Header="复制本页" Size="Middle" Command="{Binding AddCopyPageCommand}" Icon="{iconPacks:Material Kind=ContentCopy}"/>
|
||||
<Fluent:MenuItem Header="空白页" Size="Middle" Command="{Binding PageViewModel.AddPageCommand}" Icon="{iconPacks:Material Kind=FileOutline}"/>
|
||||
<Fluent:MenuItem Header="复制本页" Size="Middle" Command="{Binding PageViewModel.AddCopyPageCommand}" Icon="{iconPacks:Material Kind=ContentCopy}"/>
|
||||
<Fluent:SplitButton.ToolTip>
|
||||
<Fluent:ScreenTip Title="InsertPage"
|
||||
Text="插入页面"
|
||||
@@ -1372,7 +1372,7 @@
|
||||
Width="190" />
|
||||
</Fluent:SplitButton.ToolTip>
|
||||
</Fluent:SplitButton>
|
||||
<Fluent:Button Header="图片" Width="50" VerticalAlignment="Top" Command="{Binding AddImageCommand}">
|
||||
<Fluent:Button Header="图片" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.AddImageCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Image" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -1392,7 +1392,7 @@
|
||||
Width="190" />
|
||||
</Fluent:Button.ToolTip>
|
||||
</Fluent:Button>
|
||||
<Fluent:Button Header="矢量文本" Width="50" VerticalAlignment="Top" Command="{Binding AddOutLineTextCommand}">
|
||||
<Fluent:Button Header="矢量文本" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.AddOutLineTextCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="FormatTextVariantOutline" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -1412,7 +1412,7 @@
|
||||
Width="190" />
|
||||
</Fluent:SplitButton.ToolTip>
|
||||
</Fluent:SplitButton>
|
||||
<Fluent:Button Header="二维码" Width="50" VerticalAlignment="Top" Command="{Binding AddBarcodeCommand}" CommandParameter="QR_CODE">
|
||||
<Fluent:Button Header="二维码" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.AddBarcodeCommand}" CommandParameter="QR_CODE">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Qrcode" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -1468,7 +1468,7 @@
|
||||
</Fluent:RibbonGroupBox>
|
||||
<Fluent:RibbonGroupBox Header="其它"
|
||||
IsLauncherVisible="True" >
|
||||
<Fluent:Button Header="搜索" Width="50" VerticalAlignment="Top" Command="{Binding SearchDownCommand}">
|
||||
<Fluent:Button Header="搜索" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.DiagramViewModel.SearchDownCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconFontAwesome Kind="SearchSolid" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -2523,20 +2523,20 @@
|
||||
<Grid>
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="增加页" Command="{binding:ControlBinding AddPageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="复制页" Command="{binding:ControlBinding AddCopyPageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="重命名页" Command="{binding:ControlBinding RenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="删除页" Command="{binding:ControlBinding DeletePageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="增加页" Command="{binding:ControlBinding PageViewModel.AddPageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="复制页" Command="{binding:ControlBinding PageViewModel.AddCopyPageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="重命名页" Command="{binding:ControlBinding PageViewModel.RenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MenuItem Header="删除页" Command="{binding:ControlBinding PageViewModel.DeletePageCommand}" CommandParameter="{Binding .}"/>
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<TextBlock Text="{Binding Name}" Visibility="{Binding IsEditName,Converter={StaticResource Boolean2VisibilityReConverter}}">
|
||||
<TextBlock.InputBindings>
|
||||
<MouseBinding MouseAction="LeftDoubleClick" Command="{binding:ControlBinding RenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
<MouseBinding MouseAction="LeftDoubleClick" Command="{binding:ControlBinding PageViewModel.RenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
</TextBlock.InputBindings>
|
||||
</TextBlock>
|
||||
<TextBox x:Name="renametextbox" Text="{Binding Name,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsEditName,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<TextBox.InputBindings>
|
||||
<KeyBinding Key="Enter" Command="{binding:ControlBinding EndRenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
<KeyBinding Key="Enter" Command="{binding:ControlBinding PageViewModel.EndRenamePageCommand}" CommandParameter="{Binding .}"/>
|
||||
</TextBox.InputBindings>
|
||||
<TextBox.Style>
|
||||
<Style TargetType="TextBox">
|
||||
@@ -2549,7 +2549,7 @@
|
||||
</TextBox.Style>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="LostFocus">
|
||||
<i:InvokeCommandAction Command="{binding:ControlBinding EndRenamePageCommand}" CommandParameter="{Binding .}" />
|
||||
<i:InvokeCommandAction Command="{binding:ControlBinding PageViewModel.EndRenamePageCommand}" CommandParameter="{Binding .}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</TextBox>
|
||||
@@ -2558,18 +2558,18 @@
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Fluent:Button Size="Small" Icon="{iconPacks:Material Kind=Plus}"
|
||||
Command="{Binding AddPageCommand}"/>
|
||||
Command="{Binding PageViewModel.AddPageCommand}"/>
|
||||
</StackPanel>
|
||||
</Fluent:StatusBarItem>
|
||||
|
||||
<Separator HorizontalAlignment="Left" />
|
||||
|
||||
<Fluent:StatusBarItem Title="Color" Visibility="{Binding SelectedItem,Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
<Fluent:StatusBarItem Title="Color" Visibility="{Binding SelectedItemViewModel,Converter={StaticResource NullableToVisibilityConverter}}"
|
||||
HorizontalAlignment="Right" >
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<TextBlock>形状ID:</TextBlock>
|
||||
<TextBox BorderThickness="0" IsReadOnly="True" Background="Transparent" Foreground="White"
|
||||
Text="{Binding SelectedItem.Id}"/>
|
||||
Text="{Binding SelectedItemViewModel.Id}"/>
|
||||
</StackPanel>
|
||||
</Fluent:StatusBarItem>
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace AIStudio.Wpf.DiagramApp
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.HookEvents();
|
||||
|
||||
MainWindowViewModel = new MainWindowViewModel();
|
||||
this.DataContext = MainWindowViewModel;
|
||||
this.Closing += MainWindow_Closing;
|
||||
@@ -44,32 +42,12 @@ namespace AIStudio.Wpf.DiagramApp
|
||||
e.Handled = MainWindowViewModel.KeyExecuted(e);
|
||||
}
|
||||
|
||||
private void HookEvents()
|
||||
{
|
||||
//this.PreviewMouseWheel += this.OnPreviewMouseWheel;
|
||||
}
|
||||
|
||||
private void ZoomSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
var textFormattingMode = e.NewValue > 1.0 || Math.Abs(e.NewValue - 1.0) < double.Epsilon ? TextFormattingMode.Ideal : TextFormattingMode.Display;
|
||||
TextOptions.SetTextFormattingMode(this, textFormattingMode);
|
||||
}
|
||||
|
||||
//private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
//{
|
||||
// if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
|
||||
// && Keyboard.IsKeyDown(Key.RightCtrl) == false)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// var newZoomValue = this.zoomSlider.Value + (e.Delta > 0 ? 0.1 : -0.1);
|
||||
|
||||
// this.zoomSlider.Value = Math.Max(Math.Min(newZoomValue, this.zoomSlider.Maximum), this.zoomSlider.Minimum);
|
||||
|
||||
// e.Handled = true;
|
||||
//}
|
||||
|
||||
private void btnPrint_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PrintDialog printDialog = new PrintDialog();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<TabControl Style="{StaticResource UniformTabControlStyle}" >
|
||||
<TabItem Header="填充" Height="34">
|
||||
<StackPanel
|
||||
DataContext="{Binding SelectedItem.ColorViewModel.FillColor}"
|
||||
DataContext="{Binding PageViewModel.DiagramViewModel.SelectedItem.ColorViewModel.FillColor}"
|
||||
Visibility="{Binding .,Converter={StaticResource NullableToVisibilityConverter}}">
|
||||
<StackPanel>
|
||||
<RadioButton Margin="5" IsChecked="{Binding BrushType,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" Content="无填充" />
|
||||
@@ -104,7 +104,7 @@
|
||||
</TabItem>
|
||||
<TabItem Header="线条" Height="34">
|
||||
<StackPanel
|
||||
DataContext="{Binding SelectedItem.ColorViewModel.LineColor}"
|
||||
DataContext="{Binding PageViewModel.DiagramViewModel.SelectedItem.ColorViewModel.LineColor}"
|
||||
Visibility="{Binding .,Converter={StaticResource NullableToVisibilityConverter}}">
|
||||
<StackPanel>
|
||||
<RadioButton Margin="5" IsChecked="{Binding BrushType,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" Content="无线条" />
|
||||
@@ -198,21 +198,21 @@
|
||||
<TabControl Style="{StaticResource UniformTabControlStyle}">
|
||||
<TabItem Header="图片" Height="34">
|
||||
<UniformGrid Columns="2" VerticalAlignment="Top">
|
||||
<Fluent:Button Header="插入图片" VerticalAlignment="Top" Command="{Binding AddImageCommand}">
|
||||
<Fluent:Button Header="插入图片" VerticalAlignment="Top" Command="{Binding PageViewModel.AddImageCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Image" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
</Fluent:Button>
|
||||
<Fluent:Button Header="改变图片" VerticalAlignment="Top" Command="{Binding EditImageCommand}">
|
||||
<Fluent:Button Header="改变图片" VerticalAlignment="Top" Command="{Binding PageViewModel.EditImageCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="ImageEdit" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
</Fluent:Button>
|
||||
<Fluent:SplitButton Header="图片裁剪" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding ResizeImageCommand}">
|
||||
<Fluent:SplitButton Header="图片裁剪" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding PageViewModel.ResizeImageCommand}">
|
||||
<Fluent:SplitButton.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="ImagePlus" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:SplitButton.LargeIcon>
|
||||
<ListBox dd:EnumHelper.Enum="{x:Type dd:ClipMode}" SelectedItem="{Binding SelectedItem.ClipMode}" BorderThickness="0">
|
||||
<ListBox dd:EnumHelper.Enum="{x:Type dd:ClipMode}" SelectedItem="{Binding PageViewModel.DiagramViewModel.SelectedItem.ClipMode}" BorderThickness="0">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
|
||||
@@ -220,7 +220,7 @@
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Fluent:SplitButton>
|
||||
<Fluent:Button Header="原始图" VerticalAlignment="Top" Command="{Binding ResetImageCommand}">
|
||||
<Fluent:Button Header="原始图" VerticalAlignment="Top" Command="{Binding PageViewModel.ResetImageCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="ImageRemove" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -229,7 +229,7 @@
|
||||
</TabItem>
|
||||
<TabItem Header="视频" Height="34">
|
||||
<UniformGrid Columns="2" VerticalAlignment="Top">
|
||||
<Fluent:Button Header="插入视频" VerticalAlignment="Top" Command="{Binding AddVideoCommand}">
|
||||
<Fluent:Button Header="插入视频" VerticalAlignment="Top" Command="{Binding PageViewModel.AddVideoCommand}">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Video" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -238,12 +238,12 @@
|
||||
</TabItem>
|
||||
<TabItem Header="二维码" Height="34">
|
||||
<UniformGrid Columns="2" VerticalAlignment="Top">
|
||||
<Fluent:Button Header="插入二维码" VerticalAlignment="Top" Command="{Binding AddBarcodeCommand}" CommandParameter="QR_CODE">
|
||||
<Fluent:Button Header="插入二维码" VerticalAlignment="Top" Command="{Binding PageViewModel.AddBarcodeCommand}" CommandParameter="QR_CODE">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Qrcode" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
</Fluent:Button>
|
||||
<Fluent:Button Header="插入条形码" VerticalAlignment="Top" Command="{Binding AddBarcodeCommand}" CommandParameter="CODE_39">
|
||||
<Fluent:Button Header="插入条形码" VerticalAlignment="Top" Command="{Binding PageViewModel.AddBarcodeCommand}" CommandParameter="CODE_39">
|
||||
<Fluent:Button.LargeIcon>
|
||||
<iconPacks:PackIconMaterial Kind="Barcode" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Fluent:Button.LargeIcon>
|
||||
@@ -254,7 +254,7 @@
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate TargetType="Control" x:Key="PropertyTemplate">
|
||||
<dd:PropertiesView SelectedObject="{Binding SelectedItem}">
|
||||
<dd:PropertiesView SelectedObject="{Binding PageViewModel.DiagramViewModel.SelectedItem}">
|
||||
<dd:PropertiesView.Resources>
|
||||
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
{
|
||||
this.Title = "矢量文本";
|
||||
this.Text = item.Text;
|
||||
this.FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(item.FontViewModel);
|
||||
this.FontViewModel = CopyHelper.Mapper(item.FontViewModel);
|
||||
}
|
||||
|
||||
private IFontViewModel _fontViewModel;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
Text = data.Text;
|
||||
FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(data.FontViewModel);
|
||||
FontViewModel = CopyHelper.Mapper(data.FontViewModel);
|
||||
AutoSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class CopyHelper
|
||||
public static class CopyHelper
|
||||
{
|
||||
public static T DeepCopyByReflect<T>(T obj)
|
||||
{
|
||||
@@ -140,7 +137,32 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public static ColorViewModel Mapper(IColorViewModel s)
|
||||
public static T Mapper<T>(T s) where T : SelectableViewModelBase
|
||||
{
|
||||
if (s == null)
|
||||
return null;
|
||||
|
||||
T d = Activator.CreateInstance(s.GetType()) as T;
|
||||
var properties = s.GetType().GetProperties();
|
||||
foreach (var propertie in properties)
|
||||
{
|
||||
//循环遍历属性
|
||||
if (propertie.CanRead && propertie.CanWrite)
|
||||
{
|
||||
//进行属性拷贝
|
||||
propertie.SetValue(d, propertie.GetValue(s, null), null);
|
||||
}
|
||||
}
|
||||
|
||||
d.ColorViewModel = CopyHelper.Mapper(s.ColorViewModel);
|
||||
d.FontViewModel = CopyHelper.Mapper(s.FontViewModel);
|
||||
d.ShapeViewModel = CopyHelper.Mapper(s.ShapeViewModel);
|
||||
d.LockObjectViewModel = CopyHelper.Mapper<LockObjectViewModel, ILockObjectViewModel>(s.LockObjectViewModel);
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
public static IColorViewModel Mapper(IColorViewModel s)
|
||||
{
|
||||
var d = CopyHelper.Mapper<ColorViewModel, IColorViewModel>(s);
|
||||
d.LineColor = CopyHelper.Mapper<ColorObject, IColorObject>(s.LineColor);
|
||||
@@ -160,7 +182,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return d;
|
||||
}
|
||||
|
||||
public static ShapeViewModel Mapper(IShapeViewModel s)
|
||||
public static IShapeViewModel Mapper(IShapeViewModel s)
|
||||
{
|
||||
var d = CopyHelper.Mapper<ShapeViewModel, IShapeViewModel>(s);
|
||||
d.SourceMarker = CopyHelper.Mapper<LinkMarker, ILinkMarker>(s.SourceMarker);
|
||||
@@ -176,6 +198,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return d;
|
||||
}
|
||||
|
||||
public static IFontViewModel Mapper(IFontViewModel s)
|
||||
{
|
||||
var d = CopyHelper.Mapper<FontViewModel, IFontViewModel>(s);
|
||||
return d;
|
||||
}
|
||||
|
||||
public static T Mapper<T>(IFontViewModel s) where T : IFontViewModel
|
||||
{
|
||||
var d = CopyHelper.Mapper<T, IFontViewModel>(s);
|
||||
return d;
|
||||
}
|
||||
|
||||
public static void CopyPropertyValue(IColorViewModel s, IColorViewModel d, string propertyName = null)
|
||||
{
|
||||
if (propertyName == "LineColor")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -6,6 +7,7 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -555,7 +557,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string SerializeObject(object obj, string serializableType)
|
||||
public static string SerializeObject(object obj, string serializableType = null)
|
||||
{
|
||||
if (serializableType?.ToLower() == ".xml")
|
||||
{
|
||||
@@ -581,7 +583,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public static SelectableItemBase DeserializeObject(Type type, string serializableString, string serializableType)
|
||||
public static SelectableItemBase DeserializeObject(Type type, string serializableString, string serializableType = null)
|
||||
{
|
||||
if (serializableType?.ToLower() == ".xml")
|
||||
{
|
||||
@@ -597,7 +599,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public static SelectableItemBase DeserializeObject(string typename, string serializableString, string serializableType)
|
||||
public static SelectableItemBase DeserializeObject(string typename, string serializableString, string serializableType = null)
|
||||
{
|
||||
Type type = TypeHelper.GetType(typename);
|
||||
if (serializableType?.ToLower() == ".xml")
|
||||
@@ -613,6 +615,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return JsonConvert.DeserializeObject(serializableString, type) as SelectableItemBase;
|
||||
}
|
||||
}
|
||||
|
||||
public static SelectableItemBase DeserializeObject(SerializableItem serializableItem, string serializableType = null)
|
||||
{
|
||||
return DeserializeObject(serializableItem.SerializableTypeName, serializableItem.SerializableString, serializableType);
|
||||
}
|
||||
}
|
||||
|
||||
public struct XmlFont
|
||||
|
||||
@@ -7,51 +7,54 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class QuickThemeViewModel : BindableBase, IQuickThemeViewModel
|
||||
{
|
||||
public QuickTheme[] QuickThemes { get; } = new QuickTheme[] {
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Colors.Transparent }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x1B,0x5C,0x3B)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x1B,0x5C,0x3B)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x20,0x3D,0x68)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x20,0x3D,0x68)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x47,0x47,0x47)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x47,0x47,0x47)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x00,0x52,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x00,0x52,0x73)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7C,0x5B,0x0E)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7C,0x5B,0x0E)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x40,0x63,0x26)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x40,0x63,0x26)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7B,0x3F,0x23)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7B,0x3F,0x23)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x6E,0x1D,0x1E) }, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x6E,0x1D,0x1E) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
public QuickTheme[] QuickThemes
|
||||
{
|
||||
get;
|
||||
} = new QuickTheme[] {
|
||||
new QuickTheme(){ Name = "1", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "2", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "3", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "4", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "5", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "6", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "7", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Colors.Transparent}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "8", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Colors.Transparent }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ Name = "9", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "10", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "11", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "12", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "13", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "14", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "15", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "16", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ Name = "17", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "18", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "19", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "20", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "21", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "22", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "23", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "24", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ Name = "25", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x9D,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xF4,0xED)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "26", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x51,0x76,0xAD)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE9,0xED,0xF8)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "27", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x83,0x83,0x83)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xEF,0xEF,0xEF)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "28", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x50,0x91,0xBA)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xE7,0xF2,0xFC)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "29", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC5,0x9C,0x50)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xF4,0xE8)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "30", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7A,0xA6,0x59)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xED,0xF6,0xEA)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "31", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xC3,0x78,0x55)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFF,0xED,0xE9)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
new QuickTheme(){ Name = "32", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xF5,0xC4,0xC5)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0xFA,0xE9,0xE9)}, LineWidth = 2}, FontViewModel = new FontViewModel(){ FontColor = Colors.Black } },
|
||||
|
||||
new QuickTheme(){ Name = "33", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x1B,0x5C,0x3B)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x1B,0x5C,0x3B)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "34", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x20,0x3D,0x68)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x20,0x3D,0x68)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "35", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x47,0x47,0x47)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x47,0x47,0x47)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "36", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x00,0x52,0x73)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x00,0x52,0x73)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "37", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7C,0x5B,0x0E)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7C,0x5B,0x0E)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "38", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x40,0x63,0x26)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x40,0x63,0x26)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "39", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7B,0x3F,0x23)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x7B,0x3F,0x23)}, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
new QuickTheme(){ Name = "40", ColorViewModel= new ColorViewModel(){LineColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x6E,0x1D,0x1E)}, FillColor = new ColorObject() { Color = Color.FromArgb(0xFF,0x6E,0x1D,0x1E) }, LineWidth = 1}, FontViewModel = new FontViewModel(){ FontColor = Colors.White } },
|
||||
};
|
||||
|
||||
|
||||
@@ -70,8 +73,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
public class QuickTheme
|
||||
{
|
||||
public IColorViewModel ColorViewModel { get; set; }
|
||||
public IFontViewModel FontViewModel { get; set; }
|
||||
public IColorViewModel ColorViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public IFontViewModel FontViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets text
|
||||
@@ -81,6 +90,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
/// <summary>
|
||||
/// Gets or sets group name
|
||||
/// </summary>
|
||||
public string Group { get; set; }
|
||||
public string Group
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
||||
public IFontViewModel CopyDefaultFontViewModel()
|
||||
{
|
||||
var viewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
||||
return CopyHelper.Mapper<FontViewModel, IFontViewModel>(viewModel);
|
||||
return CopyHelper.Mapper(viewModel);
|
||||
}
|
||||
|
||||
public IShapeViewModel CopyDefaultShapeViewModel()
|
||||
@@ -160,7 +160,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
||||
}
|
||||
|
||||
private SelectableDesignerItemViewModelBase _selectedItem;
|
||||
public SelectableDesignerItemViewModelBase SelectedItem
|
||||
public SelectableDesignerItemViewModelBase SelectedItemViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -168,6 +168,10 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
if (SetProperty(ref _selectedItem, value))
|
||||
{
|
||||
if (_selectedItem == null)
|
||||
@@ -185,6 +189,10 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
||||
LockObjectViewModel = _selectedItem.LockObjectViewModel;
|
||||
}
|
||||
}
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2755,7 +2755,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
() => {
|
||||
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||
{
|
||||
Remove(groupRoot);
|
||||
Remove(groupRoot);
|
||||
}
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -2774,7 +2774,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
item.Key.ZIndex = item.Value.Item2;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
||||
@@ -2786,6 +2786,135 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
#endregion
|
||||
|
||||
#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())
|
||||
{
|
||||
Dictionary<SelectableDesignerItemViewModelBase, IFontViewModel> infos = items.ToDictionary(p => p, p => CopyHelper.Mapper(p.FontViewModel));
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
foreach (var item in items)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(fontViewModel, item.FontViewModel, propertyName);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
foreach (var item in infos)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(item.Value, item.Key.FontViewModel, propertyName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SetColor(IColorViewModel colorViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||
{
|
||||
if (items.Any())
|
||||
{
|
||||
Dictionary<SelectableDesignerItemViewModelBase, IColorViewModel> infos = items.ToDictionary(p => p, p => CopyHelper.Mapper(p.ColorViewModel));
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
foreach (var item in items)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(colorViewModel, item.ColorViewModel, propertyName);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
foreach (var item in infos)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(item.Value, item.Key.ColorViewModel, propertyName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSharp(IShapeViewModel shapeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||
{
|
||||
if (items.Any())
|
||||
{
|
||||
Dictionary<SelectableDesignerItemViewModelBase, IShapeViewModel> infos = items.ToDictionary(p => p, p => CopyHelper.Mapper(p.ShapeViewModel));
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
foreach (var item in items)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(shapeViewModel, item.ShapeViewModel, propertyName);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
foreach (var item in infos)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(item.Value, item.Key.ShapeViewModel, propertyName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||
{
|
||||
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
|
||||
{
|
||||
if (items.Any())
|
||||
{
|
||||
Dictionary<SelectableDesignerItemViewModelBase, Tuple<IFontViewModel, IColorViewModel>> infos = items.ToDictionary(p => p, p => new Tuple<IFontViewModel, IColorViewModel>(CopyHelper.Mapper(p.FontViewModel), CopyHelper.Mapper(p.ColorViewModel)));
|
||||
DoCommandManager.DoNewCommand(this.ToString(),
|
||||
() => {
|
||||
foreach (var item in items)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(quickThemeViewModel.QuickTheme.FontViewModel, item.FontViewModel, "FontColor");
|
||||
CopyHelper.CopyPropertyValue(quickThemeViewModel.QuickTheme.ColorViewModel, item.ColorViewModel, "FillColor");
|
||||
CopyHelper.CopyPropertyValue(quickThemeViewModel.QuickTheme.ColorViewModel, item.ColorViewModel, "LineColor");
|
||||
CopyHelper.CopyPropertyValue(quickThemeViewModel.QuickTheme.ColorViewModel, item.ColorViewModel, "LineWidth");
|
||||
}
|
||||
},
|
||||
() => {
|
||||
foreach (var item in infos)
|
||||
{
|
||||
CopyHelper.CopyPropertyValue(item.Value.Item1, item.Key.FontViewModel, "FontColor");
|
||||
CopyHelper.CopyPropertyValue(item.Value.Item2, item.Key.ColorViewModel, "FillColor");
|
||||
CopyHelper.CopyPropertyValue(item.Value.Item2, item.Key.ColorViewModel, "LineColor");
|
||||
CopyHelper.CopyPropertyValue(item.Value.Item2, item.Key.ColorViewModel, "LineWidth");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
quickThemeViewModel.QuickTheme = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void LockAction(LockObject lockObject, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.LockObjectViewModel.SetValue(lockObject);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 快捷键操作
|
||||
public bool ExecuteShortcut(KeyEventArgs e)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
IsLoaded = true;
|
||||
}
|
||||
|
||||
public SelectableViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType)
|
||||
public SelectableViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType = null)
|
||||
{
|
||||
IsLoaded = false;
|
||||
Init(root, false);
|
||||
@@ -51,7 +51,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
IsLoaded = true;
|
||||
}
|
||||
|
||||
public virtual SerializableItem ToSerializableItem(string serializableType)
|
||||
public virtual SerializableItem ToSerializableItem(string serializableType = null)
|
||||
{
|
||||
var obj = GetSerializableObject();
|
||||
if (obj != null)
|
||||
@@ -84,7 +84,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
if (Root?.FontViewModel != null)
|
||||
{
|
||||
this.FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(Root.FontViewModel);
|
||||
this.FontViewModel = CopyHelper.Mapper(Root.FontViewModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -34,12 +34,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels
|
||||
{
|
||||
get;
|
||||
}
|
||||
SelectableDesignerItemViewModelBase SelectedItem
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
List<SelectableDesignerItemViewModelBase> SelectedItems
|
||||
SelectableDesignerItemViewModelBase SelectedItemViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -333,6 +333,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
void Init(bool initNew);
|
||||
|
||||
void Add(object parameter, bool? isSelected = false);
|
||||
@@ -342,6 +343,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
void ClearSelectedItems();
|
||||
|
||||
bool ExecuteShortcut(KeyEventArgs e);
|
||||
#endregion
|
||||
|
||||
#region 设置属性
|
||||
void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
|
||||
void SetFont(IFontViewModel fontViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
|
||||
void SetColor(IColorViewModel colorViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
|
||||
void SetSharp(IShapeViewModel shapeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
|
||||
void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
|
||||
void LockAction(LockObject lockObject, string propertyName, List<SelectableDesignerItemViewModelBase> items);
|
||||
#endregion
|
||||
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user