private void Ellipse_MouseEnter(object sender, MouseEventArgs e) { var color = ColorCombo.SelectedValue; var ef = EasingCombo.SelectedValue; if (ef == null) { return; } if (color == null) { return; } EasingFunctionBase easing = null; if ((string)ef != "None") { easing = (EasingFunctionBase)GetInstance($"System.Windows.Media.Animation.{(string) ef}"); easing.EasingMode = EasingMode.EaseOut; } DoubleAnimation doubleAnimation = new DoubleAnimation(); doubleAnimation.To = 330; doubleAnimation.EasingFunction = easing; doubleAnimation.Duration = TimeSpan.FromSeconds(6); doubleAnimation.FillBehavior = FillBehavior.Stop; MainEllipse.BeginAnimation(Canvas.TopProperty, doubleAnimation); Dispatcher.BeginInvoke( new ThreadStart((async() => { for (int t = 0; t < 50; t++) { try { var x = Canvas.GetLeft(MainEllipse); var y = Canvas.GetTop(MainEllipse); Color cc = (Color)ColorConverter.ConvertFromString((string)color); Ellipse freezeFrameControl = new Ellipse { Height = 2, Width = 2, Fill = new SolidColorBrush(cc) }; freezeFrameControl.ToolTip = new ToolTip().Content = (string)ef; Canvas.SetLeft(freezeFrameControl, x); Canvas.SetTop(freezeFrameControl, y); Canvas.Children.Add(freezeFrameControl); } catch (Exception exception) { Console.WriteLine(exception); throw; } await Task.Delay(100); } }))); }
private void StopSignal() { MainEllipse.BeginStoryboard(null, HandoffBehavior.SnapshotAndReplace); }
private void StartSignal() { MainEllipse.BeginStoryboard(story, HandoffBehavior.SnapshotAndReplace, false); }