mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-09 10:46:37 +08:00
为线的动画做扩展准备
This commit is contained in:
@@ -6,8 +6,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ShapeViewModel : BindableBase, IShapeViewModel
|
||||
{
|
||||
private ILinkMarker _sourceMarker = LinkMarker.None;
|
||||
public ILinkMarker SourceMarker
|
||||
private ISharpPath _sourceMarker = SharpPath.None;
|
||||
public ISharpPath SourceMarker
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -17,12 +17,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (_sourceMarker != value)
|
||||
{
|
||||
if (_sourceMarker != null && _sourceMarker is LinkMarker _linkMarker1)
|
||||
if (_sourceMarker != null && _sourceMarker is SharpPath _linkMarker1)
|
||||
{
|
||||
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _sourceMarker, value);
|
||||
if (_sourceMarker != null && _sourceMarker is LinkMarker _linkMarker2)
|
||||
if (_sourceMarker != null && _sourceMarker is SharpPath _linkMarker2)
|
||||
{
|
||||
_linkMarker2.PropertyChanged += ShapeViewModel_PropertyChanged;
|
||||
}
|
||||
@@ -34,8 +34,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private ILinkMarker _sinkMarker = LinkMarker.Arrow;
|
||||
public ILinkMarker SinkMarker
|
||||
private ISharpPath _sinkMarker = SharpPath.Arrow;
|
||||
public ISharpPath SinkMarker
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -45,12 +45,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (_sinkMarker != value)
|
||||
{
|
||||
if (_sinkMarker != null && _sinkMarker is LinkMarker _linkMarker1)
|
||||
if (_sinkMarker != null && _sinkMarker is SharpPath _linkMarker1)
|
||||
{
|
||||
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
||||
}
|
||||
SetProperty(ref _sinkMarker, value);
|
||||
if (_sinkMarker != null && _sinkMarker is LinkMarker _linkMarker2)
|
||||
if (_sinkMarker != null && _sinkMarker is SharpPath _linkMarker2)
|
||||
{
|
||||
_linkMarker2.PropertyChanged += ShapeViewModel_PropertyChanged;
|
||||
}
|
||||
@@ -75,12 +75,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public class LinkMarker : BindableBase, ILinkMarker
|
||||
public class SharpPath : BindableBase, ISharpPath
|
||||
{
|
||||
public static LinkMarker None { get; } = new LinkMarker("", 10, 10, ArrowPathStyle.None, ArrowSizeStyle.Middle);
|
||||
public static LinkMarker Arrow { get; } = new LinkMarker("M 0 -5 10 0 0 5 z", 10, 10, ArrowPathStyle.Arrow, ArrowSizeStyle.Middle);
|
||||
public static LinkMarker Circle { get; } = new LinkMarker("M 0, 0 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0", 10, 10, ArrowPathStyle.Circle, ArrowSizeStyle.Middle);
|
||||
public static LinkMarker Square { get; } = new LinkMarker("M 0 -5 10 -5 10 5 0 5 z", 10, 10, ArrowPathStyle.Square, ArrowSizeStyle.Middle);
|
||||
public static SharpPath None { get; } = new SharpPath("", 10, 10, ArrowPathStyle.None, ArrowSizeStyle.Middle);
|
||||
public static SharpPath Arrow { get; } = new SharpPath("M 0 -5 10 0 0 5 z", 10, 10, ArrowPathStyle.Arrow, ArrowSizeStyle.Middle);
|
||||
public static SharpPath Circle { get; } = new SharpPath("M 0, 0 a 5,5 0 1,0 10,0 a 5,5 0 1,0 -10,0", 10, 10, ArrowPathStyle.Circle, ArrowSizeStyle.Middle);
|
||||
public static SharpPath Square { get; } = new SharpPath("M 0 -5 10 -5 10 5 0 5 z", 10, 10, ArrowPathStyle.Square, ArrowSizeStyle.Middle);
|
||||
|
||||
public static readonly Dictionary<ArrowPathStyle, string> ArrowDictionary = new Dictionary<ArrowPathStyle, string>()
|
||||
{
|
||||
@@ -90,12 +90,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{ ArrowPathStyle.Square, Square.Path },
|
||||
};
|
||||
|
||||
public LinkMarker()
|
||||
public SharpPath()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public LinkMarker(string path, double width, double height, ArrowPathStyle arrowPathStyle, ArrowSizeStyle arrowSizeStyle)
|
||||
public SharpPath(string path, double width, double height, ArrowPathStyle arrowPathStyle, ArrowSizeStyle arrowSizeStyle)
|
||||
{
|
||||
Path = path;
|
||||
Width = width;
|
||||
@@ -184,19 +184,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public static LinkMarker NewArrow(double width, double height)
|
||||
=> new LinkMarker(FormattableString.Invariant($"M 0 -{height / 2} {width} 0 0 {height / 2}"), width, height, ArrowPathStyle.Arrow, (ArrowSizeStyle)width);
|
||||
public static SharpPath NewArrow(double width, double height)
|
||||
=> new SharpPath(FormattableString.Invariant($"M 0 -{height / 2} {width} 0 0 {height / 2}"), width, height, ArrowPathStyle.Arrow, (ArrowSizeStyle)width);
|
||||
|
||||
public static LinkMarker NewCircle(double r)
|
||||
=> new LinkMarker(FormattableString.Invariant($"M 0, 0 a {r},{r} 0 1,0 {r * 2},0 a {r},{r} 0 1,0 -{r * 2},0"), r * 2, r * 2, ArrowPathStyle.Circle, (ArrowSizeStyle)(r * 2));
|
||||
public static SharpPath NewCircle(double r)
|
||||
=> new SharpPath(FormattableString.Invariant($"M 0, 0 a {r},{r} 0 1,0 {r * 2},0 a {r},{r} 0 1,0 -{r * 2},0"), r * 2, r * 2, ArrowPathStyle.Circle, (ArrowSizeStyle)(r * 2));
|
||||
|
||||
public static LinkMarker NewRectangle(double width, double height)
|
||||
=> new LinkMarker(FormattableString.Invariant($"M 0 -{height / 2} {width} -{height / 2} {width} {height / 2} 0 {height / 2} z"), width, height, ArrowPathStyle.Square, (ArrowSizeStyle)width);
|
||||
public static SharpPath NewRectangle(double width, double height)
|
||||
=> new SharpPath(FormattableString.Invariant($"M 0 -{height / 2} {width} -{height / 2} {width} {height / 2} 0 {height / 2} z"), width, height, ArrowPathStyle.Square, (ArrowSizeStyle)width);
|
||||
|
||||
public static LinkMarker NewSquare(double size) => NewRectangle(size, size);
|
||||
public static SharpPath NewSquare(double size) => NewRectangle(size, size);
|
||||
}
|
||||
|
||||
public interface ILinkMarker
|
||||
public interface ISharpPath
|
||||
{
|
||||
string Path
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user