mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 04:59:26 +08:00
动画demo完成
This commit is contained in:
@@ -7,7 +7,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class DefaultDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public DefaultDesignerItemViewModel() : base()
|
||||
public DefaultDesignerItemViewModel() : this(null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DefaultDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -17,23 +17,24 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
//private IDisposable propertyChangedSubscription;
|
||||
//private IDisposable connectorsChangedSubscription;
|
||||
|
||||
|
||||
public SimpleCommand AddItemCommand { get; private set; }
|
||||
public SimpleCommand ImageSwitchCommand { get; private set; }
|
||||
|
||||
public GifImageItemViewModel() : base()
|
||||
public GifImageItemViewModel() : this(null)
|
||||
{
|
||||
|
||||
}
|
||||
public GifImageItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GifImageItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
public GifImageItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public GifImageItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override SelectableItemBase GetSerializableObject()
|
||||
@@ -41,26 +42,26 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new MediaDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
AddItemCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
|
||||
ImageSwitchCommand = new SimpleCommand(Command_Enable, ExecuteImageSwitchCommand);
|
||||
|
||||
base.Init();
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init(root);
|
||||
|
||||
ClearConnectors();
|
||||
//propertyChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Left" || o.ToString() == "Top" || o.ToString() == "ItemWidth" || o.ToString() == "ItemHeight").Subscribe(ChangeImageElement);
|
||||
//connectorsChangedSubscription = WhenConnectorsChanged.Subscribe(OnConnectorsChanged);
|
||||
|
||||
BuildMenuOptions();
|
||||
|
||||
AddItemCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
|
||||
ImageSwitchCommand = new SimpleCommand(Command_Enable, ExecuteImageSwitchCommand);
|
||||
}
|
||||
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
base.LoadDesignerItemViewModel(designerbase);
|
||||
|
||||
if (designerbase is MediaDesignerItem designer)
|
||||
if (designerbase is MediaDesignerItem designer)
|
||||
{
|
||||
this.Icon = designer.Icon;
|
||||
foreach (var connector in designer.Connectors)
|
||||
@@ -74,12 +75,25 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
private bool _shouldInsertAnchor;
|
||||
public bool ShouldInsertAnchor
|
||||
{
|
||||
get { return _shouldInsertAnchor; }
|
||||
get
|
||||
{
|
||||
return _shouldInsertAnchor;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _shouldInsertAnchor, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleCommand AddItemCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public SimpleCommand ImageSwitchCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private string dir = System.AppDomain.CurrentDomain.BaseDirectory + "Images\\Gifs";
|
||||
private void BuildMenuOptions()
|
||||
|
||||
@@ -15,12 +15,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ImageItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
|
||||
private static readonly string filter = "图片|*.bmp;*.jpg;*.jpeg;*.gif;*.png";
|
||||
public ImageItemViewModel() : base()
|
||||
|
||||
public ImageItemViewModel() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public ImageItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ImageItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
@@ -36,9 +41,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new ImageDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
|
||||
this.PropertyChanged += ImageItemViewModel_PropertyChanged;
|
||||
|
||||
@@ -110,9 +115,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
base.LoadDesignerItemViewModel(designerbase);
|
||||
|
||||
if (designerbase is ImageDesignerItem designer)
|
||||
{
|
||||
|
||||
@@ -5,23 +5,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class LinkPointDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public Point CurrentLocation
|
||||
public LinkPointDesignerItemViewModel(Point location) : this(null, location)
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point() { X = Left + ItemWidth / 2, Y = Top + ItemHeight / 2 };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LinkPointDesignerItemViewModel(Point location) : base()
|
||||
public LinkPointDesignerItemViewModel(IDiagramViewModel root, Point location) : base(root)
|
||||
{
|
||||
Left = Math.Max(0, location.X - ItemWidth / 2);
|
||||
Top = Math.Max(0, location.Y - ItemHeight / 2);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
|
||||
this.ClearConnectors();
|
||||
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
|
||||
@@ -29,5 +26,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
ItemWidth = 5;
|
||||
ItemHeight = 5;
|
||||
}
|
||||
|
||||
public Point CurrentLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Point() { X = Left + ItemWidth / 2, Y = Top + ItemHeight / 2 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,18 @@ using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class LogicalGateItemViewModelBase : DesignerItemViewModelBase
|
||||
public abstract class LogicalGateItemViewModelBase : DesignerItemViewModelBase
|
||||
{
|
||||
public SimpleCommand AddInputCommand { get; private set; }
|
||||
public SimpleCommand AddOutputCommand { get; private set; }
|
||||
|
||||
|
||||
public LogicalGateItemViewModelBase(LogicalType logicalType) : base()
|
||||
public LogicalGateItemViewModelBase(LogicalType logicalType) : this(null, logicalType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public LogicalGateItemViewModelBase(IDiagramViewModel root, LogicalType logicalType) : base(root)
|
||||
{
|
||||
this.LogicalType = logicalType;
|
||||
|
||||
@@ -89,14 +94,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new LogicalGateDesignerItemBase(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
ShowRotate = false;
|
||||
ShowArrow = false;
|
||||
AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para));
|
||||
AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para));
|
||||
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
}
|
||||
|
||||
private void BuildMenuOptions()
|
||||
@@ -133,9 +138,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
base.LoadDesignerItemViewModel(designerbase);
|
||||
|
||||
if (designerbase is LogicalGateDesignerItemBase designer)
|
||||
{
|
||||
|
||||
@@ -10,11 +10,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
protected virtual string Filter { get; set; } = "媒体·|*.*";
|
||||
|
||||
public MediaItemViewModel() : base()
|
||||
public MediaItemViewModel() : this(null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MediaItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MediaItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
@@ -30,17 +35,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new MediaDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
|
||||
BuildMenuOptions();
|
||||
}
|
||||
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableItemBase designerbase)
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(parent, designerbase);
|
||||
base.LoadDesignerItemViewModel(designerbase);
|
||||
|
||||
if (designerbase is MediaDesignerItem designer)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class PointDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public PointDesignerItemViewModel(Point location) : this(null, location)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PointDesignerItemViewModel(IDiagramViewModel root, Point location) : base(root)
|
||||
{
|
||||
Left = Math.Max(0, location.X - ItemWidth / 2);
|
||||
Top = Math.Max(0, location.Y - ItemHeight / 2);
|
||||
}
|
||||
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init(root);
|
||||
|
||||
this.ClearConnectors();
|
||||
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
|
||||
|
||||
ItemWidth = 5;
|
||||
ItemHeight = 5;
|
||||
}
|
||||
|
||||
private bool _showConnectors = false;
|
||||
public new bool ShowConnectors
|
||||
{
|
||||
@@ -25,24 +47,5 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new Point() { X = Left + ItemWidth / 2, Y = Top + ItemHeight / 2 };
|
||||
}
|
||||
}
|
||||
|
||||
public PointDesignerItemViewModel(Point location) : base()
|
||||
{
|
||||
Left = Math.Max(0, location.X - ItemWidth / 2);
|
||||
Top = Math.Max(0, location.Y - ItemHeight / 2);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
this.ClearConnectors();
|
||||
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
|
||||
|
||||
ItemWidth = 5;
|
||||
ItemHeight = 5;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,33 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ShapeDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public List<PointDesignerItemViewModel> PointDesignerItemViewModels { get; set; }
|
||||
public ShapeDesignerItemViewModel(DrawMode drawMode, List<Point> points) : this(null, drawMode, points)
|
||||
{
|
||||
}
|
||||
|
||||
public ShapeDesignerItemViewModel(IDiagramViewModel root, DrawMode drawMode, List<Point> points) : base(root)
|
||||
{
|
||||
DrawMode = drawMode;
|
||||
ConnectionPoints = points;
|
||||
|
||||
ItemWidth = ConnectionPoints.Max(p => p.X) - ConnectionPoints.Min(p => p.X);
|
||||
ItemHeight = ConnectionPoints.Max(p => p.Y) - ConnectionPoints.Min(p => p.Y);
|
||||
Left = ConnectionPoints.Min(p => p.X);
|
||||
Top = ConnectionPoints.Min(p => p.Y);
|
||||
|
||||
PointDesignerItemViewModels = new List<PointDesignerItemViewModel>();
|
||||
ConnectionPoints.ForEach((Action<Point>)(p => {
|
||||
var item = new PointDesignerItemViewModel(p);
|
||||
PointDesignerItemViewModels.Add((PointDesignerItemViewModel)item);
|
||||
}));
|
||||
|
||||
PointDesignerItemViewModels.ForEach(p => p.PropertyChanged += PointDesignerItemViewModel_PropertyChanged);
|
||||
}
|
||||
|
||||
public List<PointDesignerItemViewModel> PointDesignerItemViewModels
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private List<Point> _connectionPoints;
|
||||
public List<Point> ConnectionPoints
|
||||
@@ -25,7 +51,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SetProperty(ref _connectionPoints, value);
|
||||
}
|
||||
}
|
||||
public DrawMode DrawMode { get; set; }
|
||||
public DrawMode DrawMode
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private bool _showConnectors = false;
|
||||
public new bool ShowConnectors
|
||||
@@ -46,26 +75,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleCommand MenuItemCommand { get; private set; }
|
||||
|
||||
public ShapeDesignerItemViewModel(DrawMode drawMode, List<Point> points) : base()
|
||||
public SimpleCommand MenuItemCommand
|
||||
{
|
||||
DrawMode = drawMode;
|
||||
ConnectionPoints = points;
|
||||
|
||||
ItemWidth = ConnectionPoints.Max(p => p.X) - ConnectionPoints.Min(p => p.X);
|
||||
ItemHeight = ConnectionPoints.Max(p => p.Y) - ConnectionPoints.Min(p => p.Y);
|
||||
Left = ConnectionPoints.Min(p => p.X);
|
||||
Top = ConnectionPoints.Min(p => p.Y);
|
||||
|
||||
PointDesignerItemViewModels = new List<PointDesignerItemViewModel>();
|
||||
ConnectionPoints.ForEach((Action<Point>)(p =>
|
||||
{
|
||||
var item = new PointDesignerItemViewModel(p);
|
||||
PointDesignerItemViewModels.Add((PointDesignerItemViewModel)item);
|
||||
}));
|
||||
|
||||
PointDesignerItemViewModels.ForEach(p => p.PropertyChanged += PointDesignerItemViewModel_PropertyChanged);
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private void PointDesignerItemViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
@@ -85,10 +97,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Top = ConnectionPoints.Min(p => p.Y);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
|
||||
this.ClearConnectors();
|
||||
|
||||
|
||||
@@ -7,7 +7,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class TextDesignerItemViewModel : DesignerItemViewModelBase
|
||||
{
|
||||
public TextDesignerItemViewModel()
|
||||
public TextDesignerItemViewModel() : this(null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TextDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -27,9 +32,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new TextDesignerItem(this);
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init();
|
||||
base.Init(root);
|
||||
|
||||
this.ItemWidth = 150;
|
||||
this.ClearConnectors();
|
||||
|
||||
@@ -10,16 +10,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
protected override string Filter { get; set; } = "视频|*.wmv;*.asf;*.asx;*.rm;*.rmvb;*.mp4;*.3gp;*.mov;*.m4v;*.avi;*.dat;*.mkv;*.flv;*.vob";
|
||||
|
||||
public VideoItemViewModel() : base()
|
||||
public VideoItemViewModel() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public VideoItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public VideoItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public VideoItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user