private void SaveExperimentButton_Click(object sender, RoutedEventArgs e)
 {
     HeightSeries.Insert(HeightSeries.Count - 1, HeightSeries.Last());
     SpeedSeries.Insert(SpeedSeries.Count - 1, SpeedSeries.Last());
     AccelerationSeries.Insert(AccelerationSeries.Count - 1, AccelerationSeries.Last());
     Parameters.Insert(Parameters.Count - 1, Parameters.Last());
     AddEllipse = true;
     ++colorIndex;
     Update();
 }
 private void TRTB_TextChanged(object sender, TextChangedEventArgs e)
 {
     HeightSeries.Clear();
     SpeedSeries.Clear();
     AccelerationSeries.Clear();
     for (int i = 0; i < Ellipsies.Count(); ++i)
     {
         Canvas.Children.RemoveAt(Canvas.Children.Count - 1);
     }
     Ellipsies.Clear();
     Animations.Clear();
     AddEllipse = true;
     colorIndex = 0;
     TB_TextChanged(sender, e);
 }
        private void ListBox_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            var item = ItemsControl.ContainerFromElement((ItemsControl)sender, (DependencyObject)e.OriginalSource) as ListBoxItem;

            if (item == null)
            {
                return;
            }
            var series = (LineSeries)item.Content;

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                series.Visibility = series.Visibility == Visibility.Visible
                    ? Visibility.Hidden
                    : Visibility.Visible;
            }
            else if (e.RightButton == MouseButtonState.Pressed)
            {
                int index = -1;
                if (HeightRadioButton.IsChecked.Value)
                {
                    index = HeightSeries.IndexOf(series);
                }
                else if (SpeedRadioButton.IsChecked.Value)
                {
                    index = SpeedSeries.IndexOf(series);
                }
                else
                {
                    index = AccelerationSeries.IndexOf(series);
                }
                if (index == HeightSeries.Count - 1)
                {
                    return;
                }
                HeightSeries.RemoveAt(index);
                SpeedSeries.RemoveAt(index);
                AccelerationSeries.RemoveAt(index);
                Canvas.Children.Remove(Ellipsies[index]);
                Ellipsies.RemoveAt(index);
                Animations.RemoveAt(index);
                Parameters.RemoveAt(index);
                UpdateAnimation = true;
                DataChanged     = true;
            }
        }