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

@@ -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")