using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Media.Animation; namespace fast_slow { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void ChangeSpeed(object sender, SelectionChangedEventArgs e) { double skala = 1; ComboBox comboBox = sender as ComboBox; ComboBoxItem selectedItem = comboBox.SelectedValue as ComboBoxItem; string speed = selectedItem.Content.ToString(); if (speed == "Slow"){skala=8;} else if (speed == "Medium"){skala=4;} else if (speed == "Fast"){skala=1;} UstawPr(skala); } private void UstawPr(double skala) { Storyboard sb = this.FindResource("Ruch") as Storyboard; DoubleAnimationUsingKeyFrames animation = sb.Children[0] as DoubleAnimationUsingKeyFrames; DoubleKeyFrameCollection keyFrames = animation.KeyFrames; keyFrames[0].KeyTime = new TimeSpan(0, 0, (int)(skala * 0)); keyFrames[1].KeyTime = new TimeSpan(0, 0, (int)(skala * 1)); keyFrames[2].KeyTime = new TimeSpan(0, 0, (int)(skala * 2)); sb.Begin(this); } } }