2016-05-01 95 views
0

我使用這個功能等待動畫恢復

public static void Line(Canvas Drawing_Area, Point p1, Point p2) 
    { 
     Line line = new Line(); 
     Drawing_Area.Children.Insert(0, line); 
     line.Stroke = Brushes.Black; 
     line.StrokeThickness = 3; 
     Storyboard sb = new Storyboard(); 
     Random r = new Random(); 
     line.X1 = p1.X; 
     line.Y1 = p1.Y - TopMargin; 
     line.X2 = p1.X; 
     line.Y2 = p1.Y - TopMargin; 
     DoubleAnimation animation1 = new DoubleAnimation(line.Y1, p1.Y - TopMargin, new Duration(new TimeSpan(0, 0, 1))); 
     DoubleAnimation animation2 = new DoubleAnimation(line.X1, p1.X, new Duration(new TimeSpan(0, 0, 1))); 
     DoubleAnimation animation3 = new DoubleAnimation(line.Y2, p2.Y - TopMargin, new Duration(new TimeSpan(0, 0, 1))); 
     DoubleAnimation animation4 = new DoubleAnimation(line.X2, p2.X, new Duration(new TimeSpan(0, 0, 1))); 
     Storyboard.SetTargetProperty(animation1, new PropertyPath("(Line.Y1)")); 
     Storyboard.SetTargetProperty(animation2, new PropertyPath("(Line.X1)")); 
     Storyboard.SetTargetProperty(animation3, new PropertyPath("(Line.Y2)")); 
     Storyboard.SetTargetProperty(animation4, new PropertyPath("(Line.X2)")); 
     sb.Children.Add(animation1); 
     sb.Children.Add(animation2); 
     sb.Children.Add(animation3); 
     sb.Children.Add(animation4); 
     sb.Begin(line); 
    } 

我怎麼能等待動畫繼續(現有功能)前完成

回答

0

故事板有Completed事件動畫線前完成你可以訂閱它,告訴你故事板何時完成運行。

您也可以使用Event Wait Handles阻止線程繼續執行,直到其他事件觸發爲止。