mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
为线的动画做扩展准备
This commit is contained in:
@@ -165,6 +165,13 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
return _service.ShapeViewModel;
|
return _service.ShapeViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _service.AnimationViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
public IQuickThemeViewModel QuickThemeViewModel
|
public IQuickThemeViewModel QuickThemeViewModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -418,6 +425,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|| e.PropertyName == nameof(FontViewModel)
|
|| e.PropertyName == nameof(FontViewModel)
|
||||||
|| e.PropertyName == nameof(ColorViewModel)
|
|| e.PropertyName == nameof(ColorViewModel)
|
||||||
|| e.PropertyName == nameof(ShapeViewModel)
|
|| e.PropertyName == nameof(ShapeViewModel)
|
||||||
|
|| e.PropertyName == nameof(AnimationViewModel)
|
||||||
|| e.PropertyName == nameof(QuickThemeViewModel)
|
|| e.PropertyName == nameof(QuickThemeViewModel)
|
||||||
|| e.PropertyName == nameof(LockObjectViewModel)
|
|| e.PropertyName == nameof(LockObjectViewModel)
|
||||||
|| e.PropertyName == nameof(SelectedItemViewModel))
|
|| e.PropertyName == nameof(SelectedItemViewModel))
|
||||||
@@ -678,7 +686,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
switch (ColorType)
|
switch (ColorType)
|
||||||
{
|
{
|
||||||
case Models.ColorType.Text: PageViewModel?.DiagramViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
case Models.ColorType.Text: PageViewModel?.DiagramViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "Color", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||||
case Models.ColorType.Fill: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
case Models.ColorType.Fill: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||||
case Models.ColorType.Line: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
case Models.ColorType.Line: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor", PageViewModel.DiagramViewModel.SelectedItems); break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1268,7 +1268,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="线条动画" Margin="5"/>
|
<TextBlock Text="线条动画" Margin="5"/>
|
||||||
<Fluent:ComboBox Size="Small" Width="140" Margin="5" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:LineAnimation}" SelectedItem="{Binding ColorViewModel.LineAnimation}">
|
<Fluent:ComboBox Size="Small" Width="140" Margin="5" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:LineAnimation}" SelectedItem="{Binding AnimationViewModel.LineAnimation}">
|
||||||
<Fluent:ComboBox.ItemTemplate>
|
<Fluent:ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
|
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
|
||||||
|
|||||||
@@ -181,11 +181,11 @@ namespace AIStudio.Wpf.DiagramDesigner.Serializable
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(diagramLink.SourceMarkerPath))
|
if (!string.IsNullOrEmpty(diagramLink.SourceMarkerPath))
|
||||||
{
|
{
|
||||||
linkModel.ShapeViewModel.SourceMarker = new LinkMarker() { Path = diagramLink.SourceMarkerPath, Width = diagramLink.SourceMarkerWidth ?? 10, Height = diagramLink.SourceMarkerWidth ?? 10 };
|
linkModel.ShapeViewModel.SourceMarker = new SharpPath() { Path = diagramLink.SourceMarkerPath, Width = diagramLink.SourceMarkerWidth ?? 10, Height = diagramLink.SourceMarkerWidth ?? 10 };
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(diagramLink.TargetMarkerPath))
|
if (!string.IsNullOrEmpty(diagramLink.TargetMarkerPath))
|
||||||
{
|
{
|
||||||
linkModel.ShapeViewModel.SinkMarker = new LinkMarker() { Path = diagramLink.TargetMarkerPath, Width = diagramLink.TargetMarkerWidth ?? 10.0, Height = diagramLink.TargetMarkerWidth ?? 10 };
|
linkModel.ShapeViewModel.SinkMarker = new SharpPath() { Path = diagramLink.TargetMarkerPath, Width = diagramLink.TargetMarkerWidth ?? 10.0, Height = diagramLink.TargetMarkerWidth ?? 10 };
|
||||||
}
|
}
|
||||||
return linkModel;
|
return linkModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
CopyHelper.CopyPropertyValue(source.ColorViewModel, target.ColorViewModel);
|
CopyHelper.CopyPropertyValue(source.ColorViewModel, target.ColorViewModel);
|
||||||
CopyHelper.CopyPropertyValue(source.FontViewModel, target.FontViewModel);
|
CopyHelper.CopyPropertyValue(source.FontViewModel, target.FontViewModel);
|
||||||
CopyHelper.CopyPropertyValue(source.ShapeViewModel, target.ShapeViewModel);
|
CopyHelper.CopyPropertyValue(source.ShapeViewModel, target.ShapeViewModel);
|
||||||
|
CopyHelper.CopyPropertyValue(source.AnimationViewModel, target.AnimationViewModel);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
d.ColorViewModel = CopyHelper.Mapper(s.ColorViewModel);
|
d.ColorViewModel = CopyHelper.Mapper(s.ColorViewModel);
|
||||||
d.FontViewModel = CopyHelper.Mapper(s.FontViewModel);
|
d.FontViewModel = CopyHelper.Mapper(s.FontViewModel);
|
||||||
d.ShapeViewModel = CopyHelper.Mapper(s.ShapeViewModel);
|
d.ShapeViewModel = CopyHelper.Mapper(s.ShapeViewModel);
|
||||||
|
d.AnimationViewModel = CopyHelper.Mapper(s.AnimationViewModel);
|
||||||
d.LockObjectViewModel = CopyHelper.Mapper<LockObjectViewModel, ILockObjectViewModel>(s.LockObjectViewModel);
|
d.LockObjectViewModel = CopyHelper.Mapper<LockObjectViewModel, ILockObjectViewModel>(s.LockObjectViewModel);
|
||||||
d.IsLoaded = true;
|
d.IsLoaded = true;
|
||||||
return d;
|
return d;
|
||||||
@@ -194,16 +195,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public static IShapeViewModel Mapper(IShapeViewModel s)
|
public static IShapeViewModel Mapper(IShapeViewModel s)
|
||||||
{
|
{
|
||||||
var d = CopyHelper.Mapper<ShapeViewModel, IShapeViewModel>(s);
|
var d = CopyHelper.Mapper<ShapeViewModel, IShapeViewModel>(s);
|
||||||
d.SourceMarker = CopyHelper.Mapper<LinkMarker, ILinkMarker>(s.SourceMarker);
|
d.SourceMarker = CopyHelper.Mapper<SharpPath, ISharpPath>(s.SourceMarker);
|
||||||
d.SinkMarker = CopyHelper.Mapper<LinkMarker, ILinkMarker>(s.SinkMarker);
|
d.SinkMarker = CopyHelper.Mapper<SharpPath, ISharpPath>(s.SinkMarker);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Mapper<T>(IShapeViewModel s) where T : IShapeViewModel
|
public static T Mapper<T>(IShapeViewModel s) where T : IShapeViewModel
|
||||||
{
|
{
|
||||||
var d = CopyHelper.Mapper<T, IShapeViewModel>(s);
|
var d = CopyHelper.Mapper<T, IShapeViewModel>(s);
|
||||||
d.SourceMarker = CopyHelper.Mapper<LinkMarkerItem, ILinkMarker>(s.SourceMarker);
|
d.SourceMarker = CopyHelper.Mapper<SharpPathItem, ISharpPath>(s.SourceMarker);
|
||||||
d.SinkMarker = CopyHelper.Mapper<LinkMarkerItem, ILinkMarker>(s.SinkMarker);
|
d.SinkMarker = CopyHelper.Mapper<SharpPathItem, ISharpPath>(s.SinkMarker);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +220,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IAnimationViewModel Mapper(IAnimationViewModel s)
|
||||||
|
{
|
||||||
|
var d = CopyHelper.Mapper<AnimationViewModel, IAnimationViewModel>(s);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T Mapper<T>(IAnimationViewModel s) where T : IAnimationViewModel
|
||||||
|
{
|
||||||
|
var d = CopyHelper.Mapper<T, IAnimationViewModel>(s);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
public static void CopyPropertyValue(IColorViewModel s, IColorViewModel d, string propertyName = null)
|
public static void CopyPropertyValue(IColorViewModel s, IColorViewModel d, string propertyName = null)
|
||||||
{
|
{
|
||||||
if (propertyName == "LineColor")
|
if (propertyName == "LineColor")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
ColorItem = new ColorItem() { LineColor = new ColorObjectItem(), FillColor = new ColorObjectItem() };
|
ColorItem = new ColorItem() { LineColor = new ColorObjectItem(), FillColor = new ColorObjectItem() };
|
||||||
FontItem = new FontItem();
|
FontItem = new FontItem();
|
||||||
SharpItem = new SharpItem() { SourceMarker = new LinkMarkerItem(), SinkMarker = new LinkMarkerItem() };
|
SharpItem = new SharpItem() { SourceMarker = new SharpPathItem(), SinkMarker = new SharpPathItem() };
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectableItemBase(SelectableViewModelBase viewmodel)
|
public SelectableItemBase(SelectableViewModelBase viewmodel)
|
||||||
@@ -37,8 +37,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.Name = viewmodel.Name;
|
this.Name = viewmodel.Name;
|
||||||
|
|
||||||
ColorItem = CopyHelper.Mapper<ColorItem>(viewmodel.ColorViewModel);
|
ColorItem = CopyHelper.Mapper<ColorItem>(viewmodel.ColorViewModel);
|
||||||
FontItem = CopyHelper.Mapper<FontItem, IFontViewModel>(viewmodel.FontViewModel);
|
FontItem = CopyHelper.Mapper<FontItem>(viewmodel.FontViewModel);
|
||||||
SharpItem = CopyHelper.Mapper<SharpItem>(viewmodel.ShapeViewModel);
|
SharpItem = CopyHelper.Mapper<SharpItem>(viewmodel.ShapeViewModel);
|
||||||
|
AnimationItem = CopyHelper.Mapper<AnimationItem>(viewmodel.AnimationViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
@@ -94,6 +95,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[XmlElement]
|
||||||
|
public AnimationItem AnimationItem
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlInclude(typeof(ColorItem))]
|
[XmlInclude(typeof(ColorItem))]
|
||||||
@@ -171,18 +178,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
|
||||||
public LineAnimation LineAnimation
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[XmlAttribute]
|
|
||||||
public double LineAnimationDuration
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,18 +186,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public class SharpItem : IShapeViewModel
|
public class SharpItem : IShapeViewModel
|
||||||
{
|
{
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public ILinkMarker SourceMarker
|
public ISharpPath SourceMarker
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[XmlElement("SourceMarker")]
|
[XmlElement("SourceMarker")]
|
||||||
public LinkMarkerItem XmlSourceMarker
|
public SharpPathItem XmlSourceMarker
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return SourceMarker as LinkMarkerItem;
|
return SourceMarker as SharpPathItem;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -210,18 +206,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public ILinkMarker SinkMarker
|
public ISharpPath SinkMarker
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[XmlElement("SinkMarker")]
|
[XmlElement("SinkMarker")]
|
||||||
public LinkMarkerItem XmlSinkMarker
|
public SharpPathItem XmlSinkMarker
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return SinkMarker as LinkMarkerItem;
|
return SinkMarker as SharpPathItem;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -273,7 +269,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[XmlElement("FontColor")]
|
[XmlElement("Color")]
|
||||||
public string XmlFontColor
|
public string XmlFontColor
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -419,6 +415,62 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[XmlInclude(typeof(AnimationItem))]
|
||||||
|
public class AnimationItem : IAnimationViewModel
|
||||||
|
{
|
||||||
|
[XmlAttribute]
|
||||||
|
public LineAnimation LineAnimation
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public double Duration
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public Color Color
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[XmlElement("Color")]
|
||||||
|
public string XmlColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SerializeHelper.SerializeColor(Color);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Color = SerializeHelper.DeserializeColor(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public double Width
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public double Height
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
public class SerializeHelper
|
public class SerializeHelper
|
||||||
{
|
{
|
||||||
public static string SerializeColor(Color color)
|
public static string SerializeColor(Color color)
|
||||||
@@ -798,7 +850,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LinkMarkerItem : ILinkMarker
|
public class SharpPathItem : ISharpPath
|
||||||
{
|
{
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public string Path
|
public string Path
|
||||||
|
|||||||
@@ -104,7 +104,10 @@
|
|||||||
Height="{Binding SinkConnectorInfo.ConnectorHeight}"
|
Height="{Binding SinkConnectorInfo.ConnectorHeight}"
|
||||||
Visibility="{Binding IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}" />
|
Visibility="{Binding IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||||
|
|
||||||
<Ellipse x:Name="ball" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
<Path x:Name="ball"
|
||||||
|
Stretch="Fill"
|
||||||
|
Data="{Binding AnimationViewModel.Path}"
|
||||||
|
Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||||
Width="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
Width="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
||||||
Height="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
Height="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}"
|
||||||
Panel.ZIndex="1" />
|
Panel.ZIndex="1" />
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (this.DataContext is ConnectionViewModel connector && connector.ColorViewModel != null)
|
if (this.DataContext is ConnectionViewModel connector && connector.ColorViewModel != null)
|
||||||
{
|
{
|
||||||
connector.ColorViewModel.PropertyChanged -= Connector_PropertyChanged;
|
connector.AnimationViewModel.PropertyChanged -= Connector_PropertyChanged;
|
||||||
connector.ColorViewModel.PropertyChanged += Connector_PropertyChanged;
|
connector.AnimationViewModel.PropertyChanged += Connector_PropertyChanged;
|
||||||
}
|
}
|
||||||
this.ball.Visibility = Visibility.Collapsed;
|
this.ball.Visibility = Visibility.Collapsed;
|
||||||
await DoAnimation();
|
await DoAnimation();
|
||||||
@@ -52,8 +52,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
switch (e.PropertyName)
|
switch (e.PropertyName)
|
||||||
{
|
{
|
||||||
case nameof(ColorViewModel.LineAnimation):
|
case nameof(AnimationViewModel.LineAnimation):
|
||||||
case nameof(ColorViewModel.LineAnimationDuration):
|
case nameof(AnimationViewModel.Duration):
|
||||||
await DoAnimation();
|
await DoAnimation();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (this.DataContext is ConnectionViewModel connector && connector.IsFullConnection)
|
if (this.DataContext is ConnectionViewModel connector && connector.IsFullConnection)
|
||||||
{
|
{
|
||||||
await System.Threading.Tasks.Task.Delay(100);
|
await System.Threading.Tasks.Task.Delay(100);
|
||||||
switch (connector.ColorViewModel.LineAnimation)
|
switch (connector.AnimationViewModel.LineAnimation)
|
||||||
{
|
{
|
||||||
case LineAnimation.None:
|
case LineAnimation.None:
|
||||||
_story?.Stop(this);
|
_story?.Stop(this);
|
||||||
@@ -76,14 +76,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
connector.ColorViewModel.FillColor.Color = Colors.Red;
|
connector.ColorViewModel.FillColor.Color = Colors.Red;
|
||||||
}
|
}
|
||||||
PathAnimation(connector.ColorViewModel.LineAnimationDuration);
|
PathAnimation(connector.AnimationViewModel.Duration);
|
||||||
break;
|
break;
|
||||||
case LineAnimation.DashAnimation:
|
case LineAnimation.DashAnimation:
|
||||||
if (connector.ColorViewModel.LineDashStyle == LineDashStyle.None)
|
if (connector.ColorViewModel.LineDashStyle == LineDashStyle.None)
|
||||||
{
|
{
|
||||||
connector.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
connector.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
||||||
}
|
}
|
||||||
DashAnimation(connector.ColorViewModel.LineAnimationDuration);
|
DashAnimation(connector.AnimationViewModel.Duration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,11 +128,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
_story?.Stop(this);
|
_story?.Stop(this);
|
||||||
_story = new Storyboard();
|
_story = new Storyboard();
|
||||||
_story.RepeatBehavior = RepeatBehavior.Forever;
|
//_story.RepeatBehavior = RepeatBehavior.Forever;
|
||||||
//story.AutoReverse = true;
|
//story.AutoReverse = true;
|
||||||
_story.Children.Add(animationX);
|
_story.Children.Add(animationX);
|
||||||
_story.Children.Add(animationY);
|
_story.Children.Add(animationY);
|
||||||
_story.Children.Add(animationAngle);
|
_story.Children.Add(animationAngle);
|
||||||
|
_story.Completed += (s, d) => {
|
||||||
|
_story.Begin(this, true);
|
||||||
|
};
|
||||||
Storyboard.SetTargetName(animationX, "translate");
|
Storyboard.SetTargetName(animationX, "translate");
|
||||||
Storyboard.SetTargetName(animationY, "translate");
|
Storyboard.SetTargetName(animationY, "translate");
|
||||||
Storyboard.SetTargetName(animationAngle, "rotate");
|
Storyboard.SetTargetName(animationAngle, "rotate");
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AnimationViewModel : BindableBase, IAnimationViewModel
|
||||||
|
{
|
||||||
|
private LineAnimation _lineAnimation = LineAnimation.None;
|
||||||
|
[CanDo]
|
||||||
|
public LineAnimation LineAnimation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _lineAnimation;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _lineAnimation, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _duration = 1;
|
||||||
|
[CanDo]
|
||||||
|
public double Duration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _duration;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _duration, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color _color = Colors.Red;
|
||||||
|
[CanDo]
|
||||||
|
public Color Color
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _color;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (!SetProperty(ref _color, value))
|
||||||
|
{
|
||||||
|
RaisePropertyChanged(nameof(Color));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _path = "M 10,20 A 20,20 0 1 1 50,20 A 20,20 0 1 1 10,20";
|
||||||
|
[CanDo]
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _path;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _witdh;
|
||||||
|
[CanDo]
|
||||||
|
public double Width
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _witdh;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _witdh, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _height;
|
||||||
|
[CanDo]
|
||||||
|
public double Height
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _height, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -144,34 +144,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LineAnimation _lineAnimation = LineAnimation.None;
|
|
||||||
[CanDo]
|
|
||||||
public LineAnimation LineAnimation
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _lineAnimation;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _lineAnimation, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double _lineAnimationDuration = 1;
|
|
||||||
[CanDo]
|
|
||||||
public double LineAnimationDuration
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _lineAnimationDuration;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _lineAnimationDuration, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
|
{
|
||||||
|
public interface IAnimationViewModel
|
||||||
|
{
|
||||||
|
LineAnimation LineAnimation
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
double Duration
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
Color Color
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
string Path
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
double Width
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
double Height
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,15 +28,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
LineDashStyle LineDashStyle
|
LineDashStyle LineDashStyle
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
LineAnimation LineAnimation
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
double LineAnimationDuration
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
event PropertyChangedEventHandler PropertyChanged;
|
event PropertyChangedEventHandler PropertyChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public interface IShapeViewModel
|
public interface IShapeViewModel
|
||||||
{
|
{
|
||||||
ILinkMarker SourceMarker
|
ISharpPath SourceMarker
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
ILinkMarker SinkMarker
|
ISharpPath SinkMarker
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public class ShapeViewModel : BindableBase, IShapeViewModel
|
public class ShapeViewModel : BindableBase, IShapeViewModel
|
||||||
{
|
{
|
||||||
private ILinkMarker _sourceMarker = LinkMarker.None;
|
private ISharpPath _sourceMarker = SharpPath.None;
|
||||||
public ILinkMarker SourceMarker
|
public ISharpPath SourceMarker
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -17,12 +17,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (_sourceMarker != value)
|
if (_sourceMarker != value)
|
||||||
{
|
{
|
||||||
if (_sourceMarker != null && _sourceMarker is LinkMarker _linkMarker1)
|
if (_sourceMarker != null && _sourceMarker is SharpPath _linkMarker1)
|
||||||
{
|
{
|
||||||
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
||||||
}
|
}
|
||||||
SetProperty(ref _sourceMarker, value);
|
SetProperty(ref _sourceMarker, value);
|
||||||
if (_sourceMarker != null && _sourceMarker is LinkMarker _linkMarker2)
|
if (_sourceMarker != null && _sourceMarker is SharpPath _linkMarker2)
|
||||||
{
|
{
|
||||||
_linkMarker2.PropertyChanged += ShapeViewModel_PropertyChanged;
|
_linkMarker2.PropertyChanged += ShapeViewModel_PropertyChanged;
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ILinkMarker _sinkMarker = LinkMarker.Arrow;
|
private ISharpPath _sinkMarker = SharpPath.Arrow;
|
||||||
public ILinkMarker SinkMarker
|
public ISharpPath SinkMarker
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -45,12 +45,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (_sinkMarker != value)
|
if (_sinkMarker != value)
|
||||||
{
|
{
|
||||||
if (_sinkMarker != null && _sinkMarker is LinkMarker _linkMarker1)
|
if (_sinkMarker != null && _sinkMarker is SharpPath _linkMarker1)
|
||||||
{
|
{
|
||||||
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
_linkMarker1.PropertyChanged -= ShapeViewModel_PropertyChanged;
|
||||||
}
|
}
|
||||||
SetProperty(ref _sinkMarker, value);
|
SetProperty(ref _sinkMarker, value);
|
||||||
if (_sinkMarker != null && _sinkMarker is LinkMarker _linkMarker2)
|
if (_sinkMarker != null && _sinkMarker is SharpPath _linkMarker2)
|
||||||
{
|
{
|
||||||
_linkMarker2.PropertyChanged += ShapeViewModel_PropertyChanged;
|
_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 SharpPath None { get; } = new SharpPath("", 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 SharpPath Arrow { get; } = new SharpPath("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 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 LinkMarker Square { get; } = new LinkMarker("M 0 -5 10 -5 10 5 0 5 z", 10, 10, ArrowPathStyle.Square, 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>()
|
public static readonly Dictionary<ArrowPathStyle, string> ArrowDictionary = new Dictionary<ArrowPathStyle, string>()
|
||||||
{
|
{
|
||||||
@@ -90,12 +90,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{ ArrowPathStyle.Square, Square.Path },
|
{ 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;
|
Path = path;
|
||||||
Width = width;
|
Width = width;
|
||||||
@@ -184,19 +184,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkMarker NewArrow(double width, double height)
|
public static SharpPath NewArrow(double width, double height)
|
||||||
=> new LinkMarker(FormattableString.Invariant($"M 0 -{height / 2} {width} 0 0 {height / 2}"), width, height, ArrowPathStyle.Arrow, (ArrowSizeStyle)width);
|
=> 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)
|
public static SharpPath 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));
|
=> 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)
|
public static SharpPath 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);
|
=> 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
|
string Path
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.Root = root ?? sourceConnectorInfo.Root;
|
this.Root = root ?? sourceConnectorInfo.Root;
|
||||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||||
{
|
{
|
||||||
this.ShapeViewModel.SinkMarker = new LinkMarker("", 10, 10, ArrowPathStyle.None, ArrowSizeStyle.Middle);
|
this.ShapeViewModel.SinkMarker = new SharpPath("", 10, 10, ArrowPathStyle.None, ArrowSizeStyle.Middle);
|
||||||
}
|
}
|
||||||
var routetype = TypeHelper.GetType(RouterMode);
|
var routetype = TypeHelper.GetType(RouterMode);
|
||||||
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
ColorViewModel = new ColorViewModel();
|
ColorViewModel = new ColorViewModel();
|
||||||
FontViewModel = new FontViewModel();
|
FontViewModel = new FontViewModel();
|
||||||
ShapeViewModel = new ShapeViewModel();
|
ShapeViewModel = new ShapeViewModel();
|
||||||
|
AnimationViewModel= new AnimationViewModel();
|
||||||
LockObjectViewModel = new LockObjectViewModel();
|
LockObjectViewModel = new LockObjectViewModel();
|
||||||
|
|
||||||
_drawModeViewModel = new DrawModeViewModel();
|
_drawModeViewModel = new DrawModeViewModel();
|
||||||
@@ -25,6 +26,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
SetOldValue(ColorViewModel, nameof(ColorViewModel));
|
SetOldValue(ColorViewModel, nameof(ColorViewModel));
|
||||||
SetOldValue(FontViewModel, nameof(FontViewModel));
|
SetOldValue(FontViewModel, nameof(FontViewModel));
|
||||||
SetOldValue(ShapeViewModel, nameof(ShapeViewModel));
|
SetOldValue(ShapeViewModel, nameof(ShapeViewModel));
|
||||||
|
SetOldValue(AnimationViewModel, nameof(AnimationViewModel));
|
||||||
SetOldValue(LockObjectViewModel, nameof(LockObjectViewModel));
|
SetOldValue(LockObjectViewModel, nameof(LockObjectViewModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +53,12 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
return CopyHelper.Mapper(viewModel);
|
return CopyHelper.Mapper(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IAnimationViewModel CopyDefaultAnimationViewModel()
|
||||||
|
{
|
||||||
|
var viewModel = GetOldValue<AnimationViewModel>(nameof(AnimationViewModel));
|
||||||
|
return CopyHelper.Mapper(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
private IColorViewModel _colorViewModel;
|
private IColorViewModel _colorViewModel;
|
||||||
public IColorViewModel ColorViewModel
|
public IColorViewModel ColorViewModel
|
||||||
{
|
{
|
||||||
@@ -90,6 +98,19 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IAnimationViewModel _animationViewModel;
|
||||||
|
public IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _animationViewModel;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _animationViewModel, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IDrawModeViewModel _drawModeViewModel;
|
private IDrawModeViewModel _drawModeViewModel;
|
||||||
public IDrawModeViewModel DrawModeViewModel
|
public IDrawModeViewModel DrawModeViewModel
|
||||||
{
|
{
|
||||||
@@ -147,6 +168,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
ColorViewModel = GetOldValue<ColorViewModel>(nameof(ColorViewModel));
|
ColorViewModel = GetOldValue<ColorViewModel>(nameof(ColorViewModel));
|
||||||
FontViewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
FontViewModel = GetOldValue<FontViewModel>(nameof(FontViewModel));
|
||||||
ShapeViewModel = GetOldValue<ShapeViewModel>(nameof(ShapeViewModel));
|
ShapeViewModel = GetOldValue<ShapeViewModel>(nameof(ShapeViewModel));
|
||||||
|
AnimationViewModel = GetOldValue<AnimationViewModel>(nameof(AnimationViewModel));
|
||||||
LockObjectViewModel = GetOldValue<LockObjectViewModel>(nameof(LockObjectViewModel));
|
LockObjectViewModel = GetOldValue<LockObjectViewModel>(nameof(LockObjectViewModel));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -154,6 +176,7 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel
|
|||||||
ColorViewModel = _selectedItem.ColorViewModel;
|
ColorViewModel = _selectedItem.ColorViewModel;
|
||||||
FontViewModel = _selectedItem.FontViewModel;
|
FontViewModel = _selectedItem.FontViewModel;
|
||||||
ShapeViewModel = _selectedItem.ShapeViewModel;
|
ShapeViewModel = _selectedItem.ShapeViewModel;
|
||||||
|
AnimationViewModel = _selectedItem.AnimationViewModel;
|
||||||
LockObjectViewModel = _selectedItem.LockObjectViewModel;
|
LockObjectViewModel = _selectedItem.LockObjectViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
private PageSizeType _pageSizeType = PageSizeType.A4;
|
private PageSizeType _pageSizeType = PageSizeType.A4;
|
||||||
public PageSizeType PageSizeType
|
public PageSizeType PageSizeType
|
||||||
{
|
{
|
||||||
@@ -2971,6 +2976,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAnimation(IAnimationViewModel animationViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||||
|
{
|
||||||
|
if (items.Any())
|
||||||
|
{
|
||||||
|
Dictionary<SelectableDesignerItemViewModelBase, object> infos = items.ToDictionary(p => p, p => p.AnimationViewModel.GetPropertyValue(propertyName));
|
||||||
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
|
() => {
|
||||||
|
var value = animationViewModel.GetPropertyValue(propertyName);
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
item.AnimationViewModel.SetPropertyValue(propertyName, value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
foreach (var item in infos)
|
||||||
|
{
|
||||||
|
item.Key.AnimationViewModel.SetPropertyValue(propertyName, item.Value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName, List<SelectableDesignerItemViewModelBase> items)
|
||||||
{
|
{
|
||||||
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
|
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
|
||||||
@@ -2979,19 +3006,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
Dictionary<SelectableDesignerItemViewModelBase, Tuple<object, object, object, object>> infos
|
Dictionary<SelectableDesignerItemViewModelBase, Tuple<object, object, object, object>> infos
|
||||||
= items.ToDictionary(p => p, p => new Tuple<object, object, object, object>(
|
= items.ToDictionary(p => p, p => new Tuple<object, object, object, object>(
|
||||||
p.FontViewModel.GetPropertyValue("FontColor"),
|
p.FontViewModel.GetPropertyValue("Color"),
|
||||||
p.ColorViewModel.GetPropertyValue("FillColor"),
|
p.ColorViewModel.GetPropertyValue("FillColor"),
|
||||||
p.ColorViewModel.GetPropertyValue("LineColor"),
|
p.ColorViewModel.GetPropertyValue("LineColor"),
|
||||||
p.ColorViewModel.GetPropertyValue("LineWidth")));
|
p.ColorViewModel.GetPropertyValue("LineWidth")));
|
||||||
DoCommandManager.DoNewCommand(this.ToString(),
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
var value1 = quickThemeViewModel.QuickTheme.FontViewModel.GetPropertyValue("FontColor");
|
var value1 = quickThemeViewModel.QuickTheme.FontViewModel.GetPropertyValue("Color");
|
||||||
var value2 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("FillColor");
|
var value2 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("FillColor");
|
||||||
var value3 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineColor");
|
var value3 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineColor");
|
||||||
var value4 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineWidth");
|
var value4 = quickThemeViewModel.QuickTheme.ColorViewModel.GetPropertyValue("LineWidth");
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
item.FontViewModel.SetPropertyValue("FontColor", value1);
|
item.FontViewModel.SetPropertyValue("Color", value1);
|
||||||
item.ColorViewModel.SetPropertyValue("FillColor", value2);
|
item.ColorViewModel.SetPropertyValue("FillColor", value2);
|
||||||
item.ColorViewModel.SetPropertyValue("LineColor", value3);
|
item.ColorViewModel.SetPropertyValue("LineColor", value3);
|
||||||
item.ColorViewModel.SetPropertyValue("LineWidth", value4);
|
item.ColorViewModel.SetPropertyValue("LineWidth", value4);
|
||||||
@@ -3000,7 +3027,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
() => {
|
() => {
|
||||||
foreach (var item in infos)
|
foreach (var item in infos)
|
||||||
{
|
{
|
||||||
item.Key.FontViewModel.SetPropertyValue("FontColor", item.Value.Item1);
|
item.Key.FontViewModel.SetPropertyValue("Color", item.Value.Item1);
|
||||||
item.Key.ColorViewModel.SetPropertyValue("FillColor", item.Value.Item2);
|
item.Key.ColorViewModel.SetPropertyValue("FillColor", item.Value.Item2);
|
||||||
item.Key.ColorViewModel.SetPropertyValue("LineColor", item.Value.Item3);
|
item.Key.ColorViewModel.SetPropertyValue("LineColor", item.Value.Item3);
|
||||||
item.Key.ColorViewModel.SetPropertyValue("LineWidth", item.Value.Item4);
|
item.Key.ColorViewModel.SetPropertyValue("LineWidth", item.Value.Item4);
|
||||||
|
|||||||
@@ -102,6 +102,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.ShapeViewModel = _service.CopyDefaultShapeViewModel();
|
this.ShapeViewModel = _service.CopyDefaultShapeViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Root?.AnimationViewModel != null)
|
||||||
|
{
|
||||||
|
this.AnimationViewModel = CopyHelper.Mapper(Root.AnimationViewModel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.AnimationViewModel = _service.CopyDefaultAnimationViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
LockObjectViewModel = new LockObjectViewModel();
|
LockObjectViewModel = new LockObjectViewModel();
|
||||||
|
|
||||||
if (initNew)
|
if (initNew)
|
||||||
@@ -130,6 +139,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
ColorViewModel = CopyHelper.Mapper(designerbase.ColorItem);
|
ColorViewModel = CopyHelper.Mapper(designerbase.ColorItem);
|
||||||
FontViewModel = CopyHelper.Mapper<FontViewModel, FontItem>(designerbase.FontItem);
|
FontViewModel = CopyHelper.Mapper<FontViewModel, FontItem>(designerbase.FontItem);
|
||||||
ShapeViewModel = CopyHelper.Mapper(designerbase.SharpItem);
|
ShapeViewModel = CopyHelper.Mapper(designerbase.SharpItem);
|
||||||
|
AnimationViewModel = CopyHelper.Mapper(designerbase.AnimationItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLoaded
|
public bool IsLoaded
|
||||||
@@ -367,6 +377,27 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IAnimationViewModel _animationViewModel;
|
||||||
|
public IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _animationViewModel;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_animationViewModel != null)
|
||||||
|
{
|
||||||
|
_animationViewModel.PropertyChanged -= AnimationViewModel_PropertyChanged;
|
||||||
|
}
|
||||||
|
SetProperty(ref _animationViewModel, value);
|
||||||
|
if (_animationViewModel != null)
|
||||||
|
{
|
||||||
|
_animationViewModel.PropertyChanged += AnimationViewModel_PropertyChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ILockObjectViewModel LockObjectViewModel
|
public ILockObjectViewModel LockObjectViewModel
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -459,6 +490,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
RaisePropertyChanged(sender, e);
|
RaisePropertyChanged(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void AnimationViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (IsLoaded == false) { return; }
|
||||||
|
|
||||||
|
RaisePropertyChanged(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{Id}-{Name}-{Text}";
|
return $"{Id}-{Name}-{Text}";
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels
|
|||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
IDrawModeViewModel DrawModeViewModel
|
IDrawModeViewModel DrawModeViewModel
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -42,5 +46,6 @@ namespace AIStudio.Wpf.DiagramDesigner.ViewModels
|
|||||||
IColorViewModel CopyDefaultColorViewModel();
|
IColorViewModel CopyDefaultColorViewModel();
|
||||||
IFontViewModel CopyDefaultFontViewModel();
|
IFontViewModel CopyDefaultFontViewModel();
|
||||||
IShapeViewModel CopyDefaultShapeViewModel();
|
IShapeViewModel CopyDefaultShapeViewModel();
|
||||||
|
IAnimationViewModel CopyDefaultAnimationViewModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,6 +360,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
IAnimationViewModel AnimationViewModel
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
DoCommandManager DoCommandManager
|
DoCommandManager DoCommandManager
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
|
|
||||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||||
connector1.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
connector1.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
||||||
connector1.ColorViewModel.LineAnimation = LineAnimation.DashAnimation;
|
connector1.AnimationViewModel.LineAnimation = LineAnimation.DashAnimation;
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||||
connector2.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
connector2.ColorViewModel.LineDashStyle = LineDashStyle.Dash1;
|
||||||
connector2.ColorViewModel.LineAnimation = LineAnimation.DashAnimation;
|
connector2.AnimationViewModel.LineAnimation = LineAnimation.DashAnimation;
|
||||||
DiagramViewModel.Add(connector2);
|
DiagramViewModel.Add(connector2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
|
|
||||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||||
connector1.ColorViewModel.FillColor.Color = Colors.Red;
|
connector1.ColorViewModel.FillColor.Color = Colors.Red;
|
||||||
connector1.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
|
connector1.AnimationViewModel.LineAnimation = LineAnimation.PathAnimation;
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||||
connector2.ColorViewModel.FillColor.Color = Colors.Red;
|
connector2.ColorViewModel.FillColor.Color = Colors.Red;
|
||||||
connector2.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
|
connector2.AnimationViewModel.LineAnimation = LineAnimation.PathAnimation;
|
||||||
DiagramViewModel.Add(connector2);
|
DiagramViewModel.Add(connector2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
DiagramViewModel.Add(node2);
|
DiagramViewModel.Add(node2);
|
||||||
|
|
||||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||||
connector1.ShapeViewModel.SourceMarker = LinkMarker.Arrow;
|
connector1.ShapeViewModel.SourceMarker = SharpPath.Arrow;
|
||||||
connector1.ShapeViewModel.SinkMarker = LinkMarker.Arrow;
|
connector1.ShapeViewModel.SinkMarker = SharpPath.Arrow;
|
||||||
connector1.AddLabel("Arrow");
|
connector1.AddLabel("Arrow");
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
DiagramViewModel.Add(node2);
|
DiagramViewModel.Add(node2);
|
||||||
|
|
||||||
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||||
connector1.ShapeViewModel.SourceMarker = LinkMarker.Circle;
|
connector1.ShapeViewModel.SourceMarker = SharpPath.Circle;
|
||||||
connector1.ShapeViewModel.SinkMarker = LinkMarker.Circle;
|
connector1.ShapeViewModel.SinkMarker = SharpPath.Circle;
|
||||||
connector1.AddLabel("Circle");
|
connector1.AddLabel("Circle");
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
@@ -49,8 +49,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
DiagramViewModel.Add(node2);
|
DiagramViewModel.Add(node2);
|
||||||
|
|
||||||
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||||
connector1.ShapeViewModel.SourceMarker = LinkMarker.Square;
|
connector1.ShapeViewModel.SourceMarker = SharpPath.Square;
|
||||||
connector1.ShapeViewModel.SinkMarker = LinkMarker.Square;
|
connector1.ShapeViewModel.SinkMarker = SharpPath.Square;
|
||||||
connector1.AddLabel("Square");
|
connector1.AddLabel("Square");
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
@@ -61,8 +61,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
DiagramViewModel.Add(node2);
|
DiagramViewModel.Add(node2);
|
||||||
|
|
||||||
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||||
connector1.ShapeViewModel.SourceMarker = LinkMarker.NewRectangle(10, 20);
|
connector1.ShapeViewModel.SourceMarker = SharpPath.NewRectangle(10, 20);
|
||||||
connector1.ShapeViewModel.SinkMarker = LinkMarker.NewArrow(20, 10);
|
connector1.ShapeViewModel.SinkMarker = SharpPath.NewArrow(20, 10);
|
||||||
connector1.AddLabel("Factory");
|
connector1.AddLabel("Factory");
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
DiagramViewModel.Add(node2);
|
DiagramViewModel.Add(node2);
|
||||||
|
|
||||||
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||||
connector1.ShapeViewModel.SourceMarker = new LinkMarker("M 0 -8 L 3 -8 3 8 0 8 z M 4 -8 7 -8 7 8 4 8 z M 8 -8 16 0 8 8 z", 16, 16, ArrowPathStyle.Arrow, ArrowSizeStyle.ExtraLarge);
|
connector1.ShapeViewModel.SourceMarker = new SharpPath("M 0 -8 L 3 -8 3 8 0 8 z M 4 -8 7 -8 7 8 4 8 z M 8 -8 16 0 8 8 z", 16, 16, ArrowPathStyle.Arrow, ArrowSizeStyle.ExtraLarge);
|
||||||
connector1.ShapeViewModel.SinkMarker = new LinkMarker("M 0 -8 L 8 -8 4 0 8 8 0 8 4 0 z", 8, 8, ArrowPathStyle.Arrow, ArrowSizeStyle.Small);
|
connector1.ShapeViewModel.SinkMarker = new SharpPath("M 0 -8 L 8 -8 4 0 8 8 0 8 4 0 z", 8, 8, ArrowPathStyle.Arrow, ArrowSizeStyle.Small);
|
||||||
connector1.AddLabel("Custom");
|
connector1.AddLabel("Custom");
|
||||||
DiagramViewModel.Add(connector1);
|
DiagramViewModel.Add(connector1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user