mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-13 04:36:37 +08:00
内部连接点示例
This commit is contained in:
@@ -169,6 +169,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double LineAnimationDuration
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -150,6 +150,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SetProperty(ref _lineAnimation, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _lineAnimationDuration = 1;
|
||||
public double LineAnimationDuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return _lineAnimationDuration;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _lineAnimationDuration, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
double LineAnimationDuration
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,11 +476,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
case nameof(DesignerItemViewModelBase.ItemWidth):
|
||||
case nameof(DesignerItemViewModelBase.Left):
|
||||
case nameof(DesignerItemViewModelBase.Top):
|
||||
SourceA = PointHelper.GetPointForConnector(this.SourceConnectorInfo);
|
||||
if (IsFullConnection)
|
||||
{
|
||||
//减少触发一次画线
|
||||
SourceA = PointHelper.GetPointForConnector(this.SourceConnectorInfo);
|
||||
SourceB = PointHelper.GetPointForConnector(this.SinkConnectorInfoFully);
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceA = PointHelper.GetPointForConnector(this.SourceConnectorInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -519,12 +524,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else if (sender is ColorViewModel)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(ColorViewModel.LineAnimation):
|
||||
RaisePropertyChanged(nameof(PathGeneratorResult));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user