mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-10 03:30:50 +08:00
整理一下项目文件
This commit is contained in:
@@ -0,0 +1,519 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
[Serializable]
|
||||
public class ColorViewModel : BindableBase, IColorViewModel
|
||||
{
|
||||
#region 界面使用
|
||||
public static Color[] FillColors { get; } = new Color[] { Colors.Red, Colors.Green, Colors.Blue, Colors.White, Colors.Black, Colors.Purple };
|
||||
public static Color[] LineColors { get; } = new Color[] { Colors.Red, Colors.Green, Colors.Blue, Colors.White, Colors.Black, Colors.Purple };
|
||||
#endregion
|
||||
|
||||
public ColorViewModel()
|
||||
{
|
||||
LineColor = new ColorObject() { Color = Colors.Gray };
|
||||
FillColor = new ColorObject() { Color = Colors.Transparent };
|
||||
}
|
||||
private IColorObject _lineColor;
|
||||
public IColorObject LineColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_lineColor != value)
|
||||
{
|
||||
if (_lineColor != null && _lineColor is ColorObject _lineColor1)
|
||||
{
|
||||
_lineColor1.PropertyChanged -= ColorViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _lineColor, value);
|
||||
if (_lineColor != null && _lineColor is ColorObject _lineColor2)
|
||||
{
|
||||
_lineColor2.PropertyChanged += ColorViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged(nameof(LineColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IColorObject _fillcolor;
|
||||
public IColorObject FillColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fillcolor;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_fillcolor != value)
|
||||
{
|
||||
if (_fillcolor != null && _fillcolor is ColorObject colorObject1)
|
||||
{
|
||||
colorObject1.PropertyChanged -= ColorViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _fillcolor, value);
|
||||
if (_fillcolor != null && _fillcolor is ColorObject colorObject2)
|
||||
{
|
||||
colorObject2.PropertyChanged += ColorViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged(nameof(FillColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender == LineColor)
|
||||
{
|
||||
RaisePropertyChanged(nameof(LineColor));
|
||||
}
|
||||
else if (sender == FillColor)
|
||||
{
|
||||
RaisePropertyChanged(nameof(FillColor));
|
||||
}
|
||||
}
|
||||
|
||||
private Color _shadowColor = Colors.Transparent;
|
||||
public Color ShadowColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _shadowColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _shadowColor, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(ShadowColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _lineWidth = 1;
|
||||
public double LineWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _lineWidth, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LineWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrowPathStyle _leftArrowPathStyle = ArrowPathStyle.None;
|
||||
public ArrowPathStyle LeftArrowPathStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _leftArrowPathStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _leftArrowPathStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LeftArrowPathStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrowPathStyle _rightArrowPathStyle = ArrowPathStyle.Arrow1;
|
||||
public ArrowPathStyle RightArrowPathStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rightArrowPathStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _rightArrowPathStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(RightArrowPathStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrowSizeStyle _leftArrowSizeStyle = ArrowSizeStyle.Middle;
|
||||
public ArrowSizeStyle LeftArrowSizeStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _leftArrowSizeStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _leftArrowSizeStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LeftArrowSizeStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrowSizeStyle _rightArrowSizeStyle = ArrowSizeStyle.Middle;
|
||||
public ArrowSizeStyle RightArrowSizeStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rightArrowSizeStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _rightArrowSizeStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(RightArrowSizeStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LineDashStyle _lineDashStyle = LineDashStyle.None;
|
||||
public LineDashStyle LineDashStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineDashStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _lineDashStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LineDashStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class ColorObject : BindableBase, IColorObject
|
||||
{
|
||||
public ColorObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void GradientStop_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (var old in e.OldItems.OfType<GradientStop>())
|
||||
{
|
||||
old.PropertyChanged -= GradientStop_PropertyChanged;
|
||||
}
|
||||
}
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
foreach (var old in e.NewItems.OfType<GradientStop>())
|
||||
{
|
||||
old.PropertyChanged += GradientStop_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GradientStop_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
RaisePropertyChanged(nameof(GradientStop));
|
||||
}
|
||||
|
||||
|
||||
public void BrushTypeChanged()
|
||||
{
|
||||
if (BrushType == BrushType.LinearGradientBrush || BrushType == BrushType.RadialGradientBrush)
|
||||
{
|
||||
if (GradientStop == null)
|
||||
{
|
||||
GradientStop = new ObservableCollection<GradientStop>();
|
||||
GradientStop.Add(new GradientStop(Color, 0));
|
||||
GradientStop.Add(new GradientStop(Colors.Gray, 1));
|
||||
SelectedGradientStop = GradientStop.FirstOrDefault();
|
||||
RaisePropertyChanged(nameof(GradientStop));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BrushType _brushType = BrushType.SolidColorBrush;
|
||||
public BrushType BrushType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _brushType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _brushType, value))
|
||||
{
|
||||
BrushTypeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _color = new Color();
|
||||
public Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _color, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<GradientStop> _gradientStop;
|
||||
public ObservableCollection<GradientStop> GradientStop
|
||||
{
|
||||
get
|
||||
{
|
||||
return _gradientStop;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_gradientStop != value)
|
||||
{
|
||||
if (_gradientStop != null)
|
||||
{
|
||||
_gradientStop.CollectionChanged -= GradientStop_CollectionChanged;
|
||||
}
|
||||
SetProperty(ref _gradientStop, value);
|
||||
if (_gradientStop != null)
|
||||
{
|
||||
_gradientStop.CollectionChanged += GradientStop_CollectionChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GradientStop _selectedGradientStop;
|
||||
public GradientStop SelectedGradientStop
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedGradientStop;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectedGradientStop, value);
|
||||
}
|
||||
}
|
||||
private Point _startPoint;
|
||||
public Point StartPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _startPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _startPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
private Point _endPoint;
|
||||
public Point EndPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _endPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _opacity = 1;
|
||||
public double Opacity
|
||||
{
|
||||
get
|
||||
{
|
||||
return _opacity;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _opacity, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _light;
|
||||
public double Light
|
||||
{
|
||||
get
|
||||
{
|
||||
return _light;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _light, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _image;
|
||||
public string Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return _image;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _image, value);
|
||||
}
|
||||
}
|
||||
|
||||
private LinearOrientation _linearOrientation;
|
||||
public LinearOrientation LinearOrientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return _linearOrientation;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _linearOrientation, value);
|
||||
}
|
||||
}
|
||||
|
||||
private RadialOrientation _radialOrientation;
|
||||
public RadialOrientation RadialOrientation
|
||||
{
|
||||
get
|
||||
{
|
||||
return _radialOrientation;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _radialOrientation, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int _angle;
|
||||
public int Angle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _angle;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _angle, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int _subType;
|
||||
|
||||
public int SubType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _subType;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _subType, value);
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand AddGradientStopCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
var offset = GradientStop.Skip(GradientStop.Count - 2).Select(p => p.Offset).Average();
|
||||
GradientStop.Add(new GradientStop(Colors.Gray, offset));
|
||||
});
|
||||
}
|
||||
}
|
||||
public ICommand DeleteGradientStopCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
if (SelectedGradientStop != null && GradientStop != null && GradientStop.Count > 2)
|
||||
{
|
||||
GradientStop.Remove(SelectedGradientStop);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IColorObject
|
||||
{
|
||||
BrushType BrushType { get; set; }
|
||||
Color Color { get; set; }
|
||||
ObservableCollection<GradientStop> GradientStop { get; set; }
|
||||
Point StartPoint { get; set; }
|
||||
Point EndPoint { get; set; }
|
||||
double Opacity { get; set; }
|
||||
LinearOrientation LinearOrientation { get; set; }
|
||||
RadialOrientation RadialOrientation { get; set; }
|
||||
int Angle { get; set; }
|
||||
string Image { get; set; }
|
||||
int SubType { get; set; }
|
||||
}
|
||||
|
||||
public class GradientStop : BindableBase
|
||||
{
|
||||
public GradientStop()
|
||||
{
|
||||
|
||||
}
|
||||
public GradientStop(Color color, double offset)
|
||||
{
|
||||
Color = color;
|
||||
Offset = offset;
|
||||
}
|
||||
private Color _color = new Color();
|
||||
public Color Color
|
||||
{
|
||||
get
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _color, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _offset;
|
||||
public double Offset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _offset, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple service interface
|
||||
/// </summary>
|
||||
public interface IDiagramServiceProvider : INotifyPropertyChanged
|
||||
{
|
||||
IColorViewModel ColorViewModel { get; }
|
||||
IFontViewModel FontViewModel { get; }
|
||||
IDrawModeViewModel DrawModeViewModel { get; }
|
||||
IQuickThemeViewModel QuickThemeViewModel { get; }
|
||||
ILockObjectViewModel LockObjectViewModel { get; }
|
||||
SelectableDesignerItemViewModelBase SelectedItem { get; set; }
|
||||
IColorViewModel CopyDefaultColorViewModel();
|
||||
IFontViewModel CopyDefaultFontViewModel();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Simple service locator
|
||||
/// </summary>
|
||||
public class DiagramServiceProvider : BindableBase, IDiagramServiceProvider
|
||||
{
|
||||
public DiagramServiceProvider()
|
||||
{
|
||||
ColorViewModel = new ColorViewModel();
|
||||
FontViewModel = new FontViewModel();
|
||||
LockObjectViewModel = new LockObjectViewModel();
|
||||
_drawModeViewModel = new DrawModeViewModel();
|
||||
_quickThemeViewModel = new QuickThemeViewModel();
|
||||
|
||||
_drawModeViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
_quickThemeViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
|
||||
SetOldValue<IColorViewModel>(ColorViewModel, nameof(ColorViewModel));
|
||||
SetOldValue<IFontViewModel>(FontViewModel, nameof(FontViewModel));
|
||||
SetOldValue<ILockObjectViewModel>(LockObjectViewModel, nameof(LockObjectViewModel));
|
||||
}
|
||||
|
||||
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
RaisePropertyChanged(sender, e.PropertyName);
|
||||
}
|
||||
|
||||
public IColorViewModel CopyDefaultColorViewModel()
|
||||
{
|
||||
var viewModel = GetOldValue<ColorViewModel>(nameof(ColorViewModel));
|
||||
return CopyHelper.Mapper(viewModel);
|
||||
}
|
||||
|
||||
public IFontViewModel CopyDefaultFontViewModel()
|
||||
{
|
||||
var viewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
||||
return CopyHelper.Mapper<FontViewModel, IFontViewModel>(viewModel);
|
||||
}
|
||||
|
||||
private IColorViewModel _colorViewModel;
|
||||
public IColorViewModel ColorViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _colorViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_colorViewModel != null)
|
||||
{
|
||||
_colorViewModel.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _colorViewModel, value);
|
||||
if (_colorViewModel != null)
|
||||
{
|
||||
_colorViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IFontViewModel _fontViewModel;
|
||||
public IFontViewModel FontViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_fontViewModel != null)
|
||||
{
|
||||
_fontViewModel.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _fontViewModel, value);
|
||||
if (_fontViewModel != null)
|
||||
{
|
||||
_fontViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DrawModeViewModel _drawModeViewModel;
|
||||
public IDrawModeViewModel DrawModeViewModel
|
||||
{
|
||||
get { return _drawModeViewModel; }
|
||||
}
|
||||
|
||||
private QuickThemeViewModel _quickThemeViewModel;
|
||||
public IQuickThemeViewModel QuickThemeViewModel
|
||||
{
|
||||
get { return _quickThemeViewModel; }
|
||||
}
|
||||
|
||||
private ILockObjectViewModel _lockObjectViewModel;
|
||||
public ILockObjectViewModel LockObjectViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lockObjectViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_lockObjectViewModel != null)
|
||||
{
|
||||
_lockObjectViewModel.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _lockObjectViewModel, value);
|
||||
if (_lockObjectViewModel != null)
|
||||
{
|
||||
_lockObjectViewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SelectableDesignerItemViewModelBase _selectedItem;
|
||||
public SelectableDesignerItemViewModelBase SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged -= ViewModel_PropertyChanged;
|
||||
}
|
||||
if (SetProperty(ref _selectedItem, value))
|
||||
{
|
||||
if (_selectedItem == null)
|
||||
{
|
||||
ColorViewModel = GetOldValue<ColorViewModel>(nameof(ColorViewModel));
|
||||
FontViewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
||||
LockObjectViewModel = GetOldValue<LockObjectViewModel>(nameof(LockObjectViewModel));
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorViewModel = _selectedItem.ColorViewModel;
|
||||
FontViewModel = _selectedItem.FontViewModel;
|
||||
LockObjectViewModel = _selectedItem.LockObjectViewModel;
|
||||
}
|
||||
}
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Simple service locator helper
|
||||
/// </summary>
|
||||
public class DiagramServicesProvider
|
||||
{
|
||||
private static Lazy<DiagramServicesProvider> instance = new Lazy<DiagramServicesProvider>(() => new DiagramServicesProvider());
|
||||
private IDiagramServiceProvider serviceProvider = new DiagramServiceProvider();
|
||||
|
||||
public void SetNewServiceProvider(IDiagramServiceProvider provider)
|
||||
{
|
||||
serviceProvider = provider;
|
||||
}
|
||||
|
||||
public IDiagramServiceProvider Provider
|
||||
{
|
||||
get { return serviceProvider; }
|
||||
}
|
||||
|
||||
public static DiagramServicesProvider Instance
|
||||
{
|
||||
get { return instance.Value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class DrawModeViewModel : BindableBase, IDrawModeViewModel
|
||||
{
|
||||
public DrawMode GetDrawMode()
|
||||
{
|
||||
if (CursorDrawModeSelected)
|
||||
{
|
||||
return CursorDrawMode;
|
||||
}
|
||||
else if (VectorLineDrawModeSelected)
|
||||
{
|
||||
return VectorLineDrawMode;
|
||||
}
|
||||
else if (ShapeDrawModeSelected)
|
||||
{
|
||||
return ShapeDrawMode;
|
||||
}
|
||||
else if (TextDrawModeSelected)
|
||||
{
|
||||
return TextDrawMode;
|
||||
}
|
||||
|
||||
return DrawMode.Normal;
|
||||
}
|
||||
|
||||
public void ResetDrawMode()
|
||||
{
|
||||
CursorDrawModeSelected = true;
|
||||
CursorDrawMode = DrawMode.Normal;
|
||||
}
|
||||
|
||||
public void SetDrawMode(DrawMode drawMode)
|
||||
{
|
||||
CursorDrawMode = drawMode;
|
||||
}
|
||||
|
||||
private bool _cursordrawModeSelected = true;
|
||||
public bool CursorDrawModeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cursordrawModeSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _cursordrawModeSelected, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _vectorLineDrawModeSelected;
|
||||
public bool VectorLineDrawModeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _vectorLineDrawModeSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _vectorLineDrawModeSelected, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _shapeDrawModeSelected;
|
||||
public bool ShapeDrawModeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _shapeDrawModeSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _shapeDrawModeSelected, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _textDrawModeSelected;
|
||||
public bool TextDrawModeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _textDrawModeSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _textDrawModeSelected, value);
|
||||
}
|
||||
}
|
||||
|
||||
private DrawMode _cursordrawMode = DrawMode.Normal;
|
||||
public DrawMode CursorDrawMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cursordrawMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _cursordrawMode, value);
|
||||
CursorDrawModeSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private DrawMode _vectorLineDrawMode = DrawMode.CornerConnectingLine;
|
||||
public DrawMode VectorLineDrawMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _vectorLineDrawMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _vectorLineDrawMode, value);
|
||||
VectorLineDrawModeSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private DrawMode _shapeDrawMode = DrawMode.Rectangle;
|
||||
public DrawMode ShapeDrawMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _shapeDrawMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _shapeDrawMode, value);
|
||||
ShapeDrawModeSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private DrawMode _textDrawMode = DrawMode.Text;
|
||||
public DrawMode TextDrawMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _textDrawMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _textDrawMode, value);
|
||||
TextDrawModeSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
private CursorMode _cursorMode;
|
||||
public CursorMode CursorMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cursorMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _cursorMode, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,478 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class FontViewModel : BindableBase, IFontViewModel
|
||||
{
|
||||
#region 界面使用
|
||||
static FontViewModel()
|
||||
{
|
||||
var systemFontFamilies = new List<FontFamily>();
|
||||
foreach (FontFamily _f in Fonts.SystemFontFamilies)
|
||||
{
|
||||
LanguageSpecificStringDictionary _fontDic = _f.FamilyNames;
|
||||
if (_fontDic.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
|
||||
{
|
||||
string _fontName = null;
|
||||
if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out _fontName))
|
||||
{
|
||||
systemFontFamilies.Add(new FontFamily(_fontName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string _fontName = null;
|
||||
if (_fontDic.TryGetValue(XmlLanguage.GetLanguage("en-us"), out _fontName))
|
||||
{
|
||||
systemFontFamilies.Add(new FontFamily(_fontName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontFamilys = systemFontFamilies.Select(fontFamily => fontFamily.ToString()).ToArray();
|
||||
}
|
||||
public static string[] FontFamilys { get; }
|
||||
public static double[] FontSizes { get; } = new double[] { 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 48, 72 };
|
||||
public static FontCase[] FontCases { get; } = new FontCase[] { FontCase.None, FontCase.Upper, FontCase.Lower };
|
||||
public static Color[] FontColors { get; } = new Color[] { Colors.Red, Colors.Green, Colors.Blue, Colors.White, Colors.Black, Colors.Purple };
|
||||
|
||||
public ICommand GrowFontCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
if (FontSize < 72)
|
||||
FontSize++;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ShrinkFontCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
if (FontSize > 1)
|
||||
FontSize--;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ClearFormattingCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
FontFamily = "Arial";
|
||||
FontSize = 12;
|
||||
FontColor = Colors.Black;
|
||||
FontWeight = FontWeights.Regular;
|
||||
FontStyle = FontStyles.Normal;
|
||||
FontStretch = FontStretches.Normal;
|
||||
Underline = false;
|
||||
Strikethrough = false;
|
||||
OverLine = false;
|
||||
TextEffectColor = Colors.Transparent;
|
||||
HighlightColor = Colors.Transparent;
|
||||
FontCase = FontCase.None;
|
||||
HorizontalAlignment = HorizontalAlignment.Center;
|
||||
VerticalAlignment = VerticalAlignment.Center;
|
||||
LineHeight = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand TextEffectColorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
TextEffectColor = (Color)para;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand HighlightColorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
HighlightColor = (Color)para;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand FontColorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SimpleCommand(para =>
|
||||
{
|
||||
FontColor = (Color)para;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private HorizontalVerticalAlignment _horizontalVerticalAlignment = HorizontalVerticalAlignment.CenterAlignCenter;
|
||||
public HorizontalVerticalAlignment HorizontalVerticalAlignment
|
||||
{
|
||||
get
|
||||
{
|
||||
return _horizontalVerticalAlignment;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _horizontalVerticalAlignment, value))
|
||||
{
|
||||
_horizontalVerticalAlignment = value;
|
||||
switch (value)
|
||||
{
|
||||
case HorizontalVerticalAlignment.TopAlignLeft:
|
||||
HorizontalAlignment = HorizontalAlignment.Left;
|
||||
VerticalAlignment = VerticalAlignment.Top;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.TopAlignCenter:
|
||||
HorizontalAlignment = HorizontalAlignment.Center;
|
||||
VerticalAlignment = VerticalAlignment.Top;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.TopAlignRight:
|
||||
HorizontalAlignment = HorizontalAlignment.Right;
|
||||
VerticalAlignment = VerticalAlignment.Top;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.TopAlignJustify:
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
VerticalAlignment = VerticalAlignment.Top;
|
||||
break;
|
||||
|
||||
case HorizontalVerticalAlignment.CenterAlignLeft:
|
||||
HorizontalAlignment = HorizontalAlignment.Left;
|
||||
VerticalAlignment = VerticalAlignment.Center;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.CenterAlignCenter:
|
||||
HorizontalAlignment = HorizontalAlignment.Center;
|
||||
VerticalAlignment = VerticalAlignment.Center;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.CenterAlignRight:
|
||||
HorizontalAlignment = HorizontalAlignment.Right;
|
||||
VerticalAlignment = VerticalAlignment.Center;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.CenterAlignJustify:
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
VerticalAlignment = VerticalAlignment.Center;
|
||||
break;
|
||||
|
||||
case HorizontalVerticalAlignment.BottomAlignLeft:
|
||||
HorizontalAlignment = HorizontalAlignment.Left;
|
||||
VerticalAlignment = VerticalAlignment.Bottom;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.BottomAlignCenter:
|
||||
HorizontalAlignment = HorizontalAlignment.Center;
|
||||
VerticalAlignment = VerticalAlignment.Bottom;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.BottomAlignRight:
|
||||
HorizontalAlignment = HorizontalAlignment.Right;
|
||||
VerticalAlignment = VerticalAlignment.Bottom;
|
||||
break;
|
||||
case HorizontalVerticalAlignment.BottomAlignJustify:
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
VerticalAlignment = VerticalAlignment.Bottom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private string _fontFamily = "Arial";
|
||||
public string FontFamily
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontFamily;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontFamily, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontFamily));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _fontSize = 12;
|
||||
public double FontSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontSize, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontSize));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Color _fontColor = Colors.Black;
|
||||
public Color FontColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontColor, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FontWeight _fontWeight = FontWeights.Regular;
|
||||
|
||||
public FontWeight FontWeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontWeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontWeight, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontWeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FontStyle _fontStyle = FontStyles.Normal;
|
||||
public FontStyle FontStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontStyle, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FontStretch _fontStretch = FontStretches.Normal;
|
||||
|
||||
public FontStretch FontStretch
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontStretch;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontStretch, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontStretch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _underline;
|
||||
public bool Underline
|
||||
{
|
||||
get
|
||||
{
|
||||
return _underline;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _underline, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(TextDecorations));
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged(nameof(Underline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _strikethrough;
|
||||
public bool Strikethrough
|
||||
{
|
||||
get
|
||||
{
|
||||
return _strikethrough;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _strikethrough, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(TextDecorations));
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged(nameof(Strikethrough));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _overLine;
|
||||
public bool OverLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return _overLine;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _overLine, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(TextDecorations));
|
||||
}
|
||||
else
|
||||
{
|
||||
RaisePropertyChanged(nameof(OverLine));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TextDecorationCollection _textDecorations;
|
||||
|
||||
public TextDecorationCollection TextDecorations
|
||||
{
|
||||
get
|
||||
{
|
||||
_textDecorations = new TextDecorationCollection();
|
||||
if (Underline)
|
||||
{
|
||||
_textDecorations.Add(System.Windows.TextDecorations.Underline);
|
||||
}
|
||||
if (Strikethrough)
|
||||
{
|
||||
_textDecorations.Add(System.Windows.TextDecorations.Strikethrough);
|
||||
}
|
||||
if (OverLine)
|
||||
{
|
||||
_textDecorations.Add(System.Windows.TextDecorations.OverLine);
|
||||
}
|
||||
return _textDecorations;
|
||||
}
|
||||
//set
|
||||
//{
|
||||
// NotifyChanged(nameof(TextDecorations));
|
||||
//}
|
||||
}
|
||||
|
||||
private Color _textEffectColor = Colors.Transparent;
|
||||
public Color TextEffectColor
|
||||
{
|
||||
get { return _textEffectColor; }
|
||||
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _textEffectColor, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(TextEffectColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _highlightColor = Colors.Transparent;
|
||||
public Color HighlightColor
|
||||
{
|
||||
get { return _highlightColor; }
|
||||
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _highlightColor, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(HighlightColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FontCase _fontCase = FontCase.None;
|
||||
public FontCase FontCase
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fontCase;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _fontCase, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(FontCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
|
||||
public HorizontalAlignment HorizontalAlignment
|
||||
{
|
||||
get
|
||||
{
|
||||
return _horizontalAlignment;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _horizontalAlignment, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(HorizontalAlignment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VerticalAlignment _verticalAlignment = VerticalAlignment.Center;
|
||||
public VerticalAlignment VerticalAlignment
|
||||
{
|
||||
get
|
||||
{
|
||||
return _verticalAlignment;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _verticalAlignment, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(VerticalAlignment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double _lineHeight;
|
||||
public double LineHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!SetProperty(ref _lineHeight, value))
|
||||
{
|
||||
RaisePropertyChanged(nameof(LineHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IColorViewModel
|
||||
{
|
||||
IColorObject LineColor { get; set; }
|
||||
IColorObject FillColor { get; set; }
|
||||
Color ShadowColor { get; set; }
|
||||
double LineWidth { get; set; }
|
||||
ArrowPathStyle LeftArrowPathStyle { get; set; }
|
||||
ArrowPathStyle RightArrowPathStyle { get; set; }
|
||||
ArrowSizeStyle LeftArrowSizeStyle { get; set; }
|
||||
ArrowSizeStyle RightArrowSizeStyle { get; set; }
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IDrawModeViewModel
|
||||
{
|
||||
DrawMode GetDrawMode();
|
||||
void SetDrawMode(DrawMode drawMode);
|
||||
|
||||
void ResetDrawMode();
|
||||
|
||||
CursorMode CursorMode { get; set; }
|
||||
DrawMode VectorLineDrawMode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IFontViewModel
|
||||
{
|
||||
string FontFamily { get; set; }
|
||||
Color FontColor { get; set; }
|
||||
double FontSize { get; set; }
|
||||
Color TextEffectColor { get; set; }
|
||||
Color HighlightColor { get; set; }
|
||||
FontCase FontCase { get; set; }
|
||||
FontWeight FontWeight { get; set; }
|
||||
FontStyle FontStyle { get; set; }
|
||||
FontStretch FontStretch { get; set; }
|
||||
bool Underline { get; set; }
|
||||
bool Strikethrough { get; set; }
|
||||
bool OverLine { get; set; }
|
||||
HorizontalAlignment HorizontalAlignment { get; set; }
|
||||
VerticalAlignment VerticalAlignment { get; set; }
|
||||
double LineHeight { get; set; }
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface ILockObjectViewModel
|
||||
{
|
||||
List<LockObject> LockObject { get; set; }
|
||||
void SetValue(LockObject obj);
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IQuickThemeViewModel
|
||||
{
|
||||
QuickTheme[] QuickThemes { get; }
|
||||
QuickTheme QuickTheme { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class LockObjectViewModel : ILockObjectViewModel
|
||||
{
|
||||
public List<LockObject> LockObject { get; set; }
|
||||
|
||||
public LockObjectViewModel()
|
||||
{
|
||||
LockObject = CopyHelper.DeepCopy<List<LockObject>>(LockObjectViewModelhelper.SourceLockObject);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public void SetValue(LockObject obj)
|
||||
{
|
||||
var item = LockObject.FirstOrDefault(p => p.LockFlag == obj.LockFlag);
|
||||
item.IsChecked = obj.IsChecked;
|
||||
}
|
||||
}
|
||||
|
||||
public class LockObjectViewModelhelper
|
||||
{
|
||||
public static List<LockObject> SourceLockObject { get; private set; }
|
||||
static LockObjectViewModelhelper()
|
||||
{
|
||||
SourceLockObject = new List<LockObject>();
|
||||
var enums = Enum.GetValues(typeof(LockFlag));
|
||||
foreach (var _enum in enums.OfType<LockFlag>())
|
||||
{
|
||||
if (_enum == LockFlag.None) continue;
|
||||
|
||||
var item = new LockObject() { Name = _enum.ToString(), LockFlag = _enum };
|
||||
SourceLockObject.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class LockObject : BindableBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public LockFlag LockFlag { get; set; }
|
||||
|
||||
private LockFlag _lockFlagValue = LockFlag.None;
|
||||
public LockFlag LockFlagValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lockFlagValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _lockFlagValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isChecked;
|
||||
public bool IsChecked
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isChecked;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isChecked, value))
|
||||
{
|
||||
if (_isChecked == true)
|
||||
{
|
||||
LockFlagValue = LockFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
LockFlagValue = LockFlag.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
|
||||
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 } },
|
||||
};
|
||||
|
||||
|
||||
private QuickTheme _quickTheme;
|
||||
public QuickTheme QuickTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return _quickTheme;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _quickTheme, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class QuickTheme
|
||||
{
|
||||
public IColorViewModel ColorViewModel { get; set; }
|
||||
public IFontViewModel FontViewModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets text
|
||||
/// </summary>
|
||||
public string Text { get; set; } = "Abc";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets group name
|
||||
/// </summary>
|
||||
public string Group { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user