mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-20 16:36:36 +08:00
内部连接点示例
This commit is contained in:
@@ -30,18 +30,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private void LineControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is ConnectionViewModel connector)
|
||||
if (this.DataContext is ConnectionViewModel connector && connector.ColorViewModel != null)
|
||||
{
|
||||
connector.PropertyChanged -= Connector_PropertyChanged;
|
||||
connector.ColorViewModel.PropertyChanged -= Connector_PropertyChanged;
|
||||
}
|
||||
_story?.Stop();
|
||||
}
|
||||
|
||||
private async void PathAnimation_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is ConnectionViewModel connector)
|
||||
if (this.DataContext is ConnectionViewModel connector && connector.ColorViewModel != null)
|
||||
{
|
||||
connector.PropertyChanged -= Connector_PropertyChanged;
|
||||
connector.ColorViewModel.PropertyChanged -= Connector_PropertyChanged;
|
||||
connector.PropertyChanged += Connector_PropertyChanged;
|
||||
}
|
||||
this.ball.Visibility = Visibility.Collapsed;
|
||||
@@ -52,7 +52,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(ConnectionViewModel.PathGeneratorResult):
|
||||
case nameof(ColorViewModel.LineAnimation):
|
||||
case nameof(ColorViewModel.LineAnimationDuration):
|
||||
await DoAnimation();
|
||||
break;
|
||||
|
||||
@@ -71,10 +72,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
ball.Visibility = Visibility.Collapsed;
|
||||
break;
|
||||
case LineAnimation.PathAnimation:
|
||||
PathAnimation();
|
||||
PathAnimation(connector.ColorViewModel.LineAnimationDuration);
|
||||
break;
|
||||
case LineAnimation.DashAnimation:
|
||||
DashAnimation();
|
||||
DashAnimation(connector.ColorViewModel.LineAnimationDuration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -82,7 +83,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
Storyboard _story;
|
||||
|
||||
private void PathAnimation()
|
||||
private void PathAnimation(double second)
|
||||
{
|
||||
this.ball.Visibility = Visibility.Visible;
|
||||
|
||||
@@ -105,7 +106,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
DoubleAnimationUsingPath animationX = new DoubleAnimationUsingPath();
|
||||
animationX.PathGeometry = this.line.Data?.GetFlattenedPathGeometry();
|
||||
animationX.Source = PathAnimationSource.X;
|
||||
animationX.Duration = new Duration(TimeSpan.FromSeconds(2));
|
||||
animationX.Duration = new Duration(TimeSpan.FromSeconds(second));
|
||||
|
||||
DoubleAnimationUsingPath animationY = new DoubleAnimationUsingPath();
|
||||
animationY.PathGeometry = this.line.Data?.GetFlattenedPathGeometry();
|
||||
@@ -135,12 +136,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
private void DashAnimation()
|
||||
private void DashAnimation(double second)
|
||||
{
|
||||
this.ball.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
var animation = new DoubleAnimation(0, -10, new Duration(TimeSpan.FromSeconds(0.5)))
|
||||
var animation = new DoubleAnimation(0, -10, new Duration(TimeSpan.FromSeconds(second)))
|
||||
{
|
||||
RepeatBehavior = RepeatBehavior.Forever,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user