mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-11 20:19:26 +08:00
ReDo Undo Item ItemWidth 和 Angle 等工具栏设置完成
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user