颜色,字体,支持redo undo

This commit is contained in:
艾竹
2023-04-08 23:38:01 +08:00
parent 8ad42aec49
commit 2ef5b7a1ed
6 changed files with 110 additions and 14 deletions

View File

@@ -88,9 +88,12 @@ namespace AIStudio.Wpf.DiagramDesigner
{
RaisePropertyChanged(nameof(FillColor));
}
RaisePropertyChanged(sender, e);
}
private Color _shadowColor = Colors.Transparent;
[CanDo]
public Color ShadowColor
{
get
@@ -107,6 +110,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _lineWidth = 1d;
[CanDo]
public double LineWidth
{
get
@@ -123,6 +127,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private LineDashStyle _lineDashStyle = LineDashStyle.None;
[CanDo]
public LineDashStyle LineDashStyle
{
get
@@ -139,6 +144,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private LineAnimation _lineAnimation = LineAnimation.None;
[CanDo]
public LineAnimation LineAnimation
{
get
@@ -152,6 +158,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _lineAnimationDuration = 1;
[CanDo]
public double LineAnimationDuration
{
get
@@ -214,6 +221,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private BrushType _brushType = BrushType.SolidColorBrush;
[CanDo]
public BrushType BrushType
{
get
@@ -230,6 +238,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private Color _color = new Color();
[CanDo]
public Color Color
{
get
@@ -279,6 +288,7 @@ namespace AIStudio.Wpf.DiagramDesigner
SetProperty(ref _selectedGradientStop, value);
}
}
private Point _startPoint;
public Point StartPoint
{
@@ -306,6 +316,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _opacity = 1;
[CanDo]
public double Opacity
{
get
@@ -332,6 +343,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private string _image;
[CanDo]
public string Image
{
get
@@ -345,6 +357,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private LinearOrientation _linearOrientation;
[CanDo]
public LinearOrientation LinearOrientation
{
get
@@ -358,6 +371,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private RadialOrientation _radialOrientation;
[CanDo]
public RadialOrientation RadialOrientation
{
get
@@ -371,6 +385,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private int _angle;
[CanDo]
public int Angle
{
get

View File

@@ -197,6 +197,7 @@ namespace AIStudio.Wpf.DiagramDesigner
#endregion
private string _fontFamily = "Arial";
[CanDo]
public string FontFamily
{
get
@@ -213,6 +214,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _fontSize = 12;
[CanDo]
public double FontSize
{
get
@@ -230,6 +232,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private Color _fontColor = Colors.Black;
[CanDo]
public Color FontColor
{
get
@@ -246,7 +249,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private FontWeight _fontWeight = FontWeights.Regular;
[CanDo]
public FontWeight FontWeight
{
get
@@ -263,6 +266,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private FontStyle _fontStyle = FontStyles.Normal;
[CanDo]
public FontStyle FontStyle
{
get
@@ -279,7 +283,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private FontStretch _fontStretch = FontStretches.Normal;
[CanDo]
public FontStretch FontStretch
{
get
@@ -296,6 +300,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private bool _underline;
[CanDo]
public bool Underline
{
get
@@ -316,6 +321,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private bool _strikethrough;
[CanDo]
public bool Strikethrough
{
get
@@ -336,6 +342,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private bool _overLine;
[CanDo]
public bool OverLine
{
get
@@ -356,7 +363,6 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private TextDecorationCollection _textDecorations;
public TextDecorationCollection TextDecorations
{
get
@@ -383,6 +389,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private Color _textEffectColor = Colors.Transparent;
[CanDo]
public Color TextEffectColor
{
get { return _textEffectColor; }
@@ -397,6 +404,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private Color _highlightColor = Colors.Transparent;
[CanDo]
public Color HighlightColor
{
get { return _highlightColor; }
@@ -411,6 +419,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private FontCase _fontCase = FontCase.None;
[CanDo]
public FontCase FontCase
{
get
@@ -427,6 +436,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
[CanDo]
public HorizontalAlignment HorizontalAlignment
{
get
@@ -443,6 +453,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private VerticalAlignment _verticalAlignment = VerticalAlignment.Center;
[CanDo]
public VerticalAlignment VerticalAlignment
{
get
@@ -459,6 +470,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _lineHeight = Double.NaN;
[CanDo]
public double LineHeight
{
get

View File

@@ -105,6 +105,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private string _path;
[CanDo]
public string Path
{
get
@@ -118,6 +119,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _witdh;
[CanDo]
public double Width
{
get
@@ -131,6 +133,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private double _height;
[CanDo]
public double Height
{
get
@@ -144,6 +147,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private ArrowPathStyle _pathStyle = ArrowPathStyle.None;
[CanDo]
public ArrowPathStyle PathStyle
{
get
@@ -163,6 +167,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
private ArrowSizeStyle _sizeStyle = ArrowSizeStyle.Middle;
[CanDo]
public ArrowSizeStyle SizeStyle
{
get

View File

@@ -93,23 +93,23 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
}
}
private IShapeViewModel _linkMarkerViewModel;
private IShapeViewModel _shapeViewModel;
public IShapeViewModel ShapeViewModel
{
get
{
return _linkMarkerViewModel;
return _shapeViewModel;
}
set
{
if (_linkMarkerViewModel != null)
if (_shapeViewModel != null)
{
_linkMarkerViewModel.PropertyChanged -= ViewModel_PropertyChanged;
_shapeViewModel.PropertyChanged -= ViewModel_PropertyChanged;
}
SetProperty(ref _linkMarkerViewModel, value);
if (_linkMarkerViewModel != null)
SetProperty(ref _shapeViewModel, value);
if (_shapeViewModel != null)
{
_linkMarkerViewModel.PropertyChanged += ViewModel_PropertyChanged;
_shapeViewModel.PropertyChanged += ViewModel_PropertyChanged;
}
}
}

View File

@@ -29,23 +29,26 @@ namespace AIStudio.Wpf.DiagramDesigner
public SelectableViewModelBase(IDiagramViewModel root)
{
IsLoaded = false;
Init(root, true);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
IsLoaded = true;
}
public SelectableViewModelBase(IDiagramViewModel root, SelectableItemBase designer)
{
IsLoaded = false;
Init(root, false);
LoadDesignerItemViewModel(designer);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
IsLoaded = true;
}
public SelectableViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType)
{
IsLoaded = false;
Init(root, false);
SelectableItemBase obj = SerializeHelper.DeserializeObject(serializableItem.SerializableTypeName, serializableItem.SerializableString, serializableType);
LoadDesignerItemViewModel(obj);
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
IsLoaded = true;
}
public virtual SerializableItem ToSerializableItem(string serializableType)
@@ -67,7 +70,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
protected virtual void Init(IDiagramViewModel root, bool initNew)
{
{
Root = root;
if (Root?.ColorViewModel != null)
@@ -103,6 +106,9 @@ namespace AIStudio.Wpf.DiagramDesigner
{
InitNew();
}
this.PropertyChanged -= Item_PropertyChanged;
this.PropertyChanged += Item_PropertyChanged;
}
protected virtual void InitNew()
@@ -123,6 +129,11 @@ namespace AIStudio.Wpf.DiagramDesigner
ShapeViewModel = CopyHelper.Mapper(designerbase.SharpItem);
}
protected bool IsLoaded
{
get;set;
}
public IDiagramViewModel Root
{
get; set;
@@ -299,7 +310,15 @@ namespace AIStudio.Wpf.DiagramDesigner
}
set
{
if (_colorViewModel != null)
{
_colorViewModel.PropertyChanged -= ColorViewModel_PropertyChanged;
}
SetProperty(ref _colorViewModel, value);
if (_colorViewModel != null)
{
_colorViewModel.PropertyChanged += ColorViewModel_PropertyChanged;
}
}
}
@@ -312,7 +331,15 @@ namespace AIStudio.Wpf.DiagramDesigner
}
set
{
if (_fontViewModel != null)
{
_fontViewModel.PropertyChanged -= FontViewModel_PropertyChanged;
}
SetProperty(ref _fontViewModel, value);
if (_fontViewModel != null)
{
_fontViewModel.PropertyChanged += FontViewModel_PropertyChanged;
}
}
}
@@ -325,7 +352,15 @@ namespace AIStudio.Wpf.DiagramDesigner
}
set
{
if (_shapeViewModel != null)
{
_shapeViewModel.PropertyChanged -= ShapeViewModel_PropertyChanged;
}
SetProperty(ref _shapeViewModel, value);
if (_shapeViewModel != null)
{
_shapeViewModel.PropertyChanged += ShapeViewModel_PropertyChanged;
}
}
}
@@ -384,14 +419,38 @@ namespace AIStudio.Wpf.DiagramDesigner
return IsReadOnly == false;
}
protected virtual void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (IsLoaded == false) { return; }
}
protected virtual void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (IsLoaded == false) { return; }
if (e.PropertyName == nameof(FontViewModel.FontCase))
{
RaisePropertyChanged("Text");
}
RaisePropertyChanged(sender, e);
}
protected virtual void ColorViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (IsLoaded == false) { return; }
RaisePropertyChanged(sender, e);
}
protected virtual void ShapeViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (IsLoaded == false) { return; }
RaisePropertyChanged(sender, e);
}
public override string ToString()
{
return $"{Id}-{Text}";

View File

@@ -134,6 +134,11 @@ namespace AIStudio.Wpf.DiagramDesigner
PropertyChanged?.Invoke(sender, new ValuePropertyChangedEventArgs(propertyName, oldvalue, newvalue));
}
protected void RaisePropertyChanged(object sender, PropertyChangedEventArgs args)
{
PropertyChanged?.Invoke(sender, args);
}
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>