private void OnColorChanged(object sender, EventArgs eventArgs)
        {
            ParameterDisplaySettingsViewModel cbvm =
                sender as ParameterDisplaySettingsViewModel;

            if (cbvm == null)
            {
                throw new ArgumentException("Wrong sender!");
            }
            PsaParameterDataViewModel vm = cbvm.ParamData as PsaParameterDataViewModel;

            if (graph.IsDisplayed(vm))
            {
                LineSeries2D series = graph.FindSeries(vm) as LineSeries2D;
                vm.Color     = new SolidColorBrush(cbvm.StrokeColor);
                series.Brush = new SolidColorBrush(cbvm.StrokeColor);
                SecondaryAxisY2D secAxs = XYDiagram2D.GetSeriesAxisY(series);
                if (secAxs != null)
                {
                    XYDiagram2D.GetSeriesAxisY(series).Brush = new SolidColorBrush(cbvm.StrokeColor);
                }
            }
            UpdateScalesSetView();
            UpdateScalesComboboxesView();
        }
        public void RemoveGraph(IPsaParameterDataViewModel vm)
        {
            current.Remove(vm);
            Series toDelete = null;

            foreach (Series s in graphDiagram.Series)
            {
                IPsaParameterDataViewModel param =
                    s.DataContext as IPsaParameterDataViewModel;
                if (param != null)
                {
                    if (param.Type == vm.Type)
                    {
                        toDelete = s;
                        break;
                    }
                }
            }
            // determine axes to delete
            AxisY2D axsToDelete = XYDiagram2D.
                                  GetSeriesAxisY((XYSeries)toDelete);
            bool axsUsedSomewhereElse = false;

            foreach (XYSeries s in graphDiagram.Series)
            {
                if (s != null && s == toDelete)
                {
                    continue;
                }
                AxisY2D axs = XYDiagram2D.GetSeriesAxisY(s);
                if (axs != null && axs == axsToDelete)
                {
                    axsUsedSomewhereElse = true;
                }
            }
            graphDiagram.Series.Remove(toDelete);
            SecondaryAxisY2D axsToDeleteCast =
                axsToDelete as SecondaryAxisY2D;

            if (!axsUsedSomewhereElse && axsToDeleteCast != null)
            {
                graphDiagram.SecondaryAxesY.
                Remove(axsToDeleteCast);
            }
        }
        private void RemoveGraph(PsaParameterDataViewModel vm)
        {
            Series toDelete = null;

            foreach (Series s in graph.SeriesCollection)
            {
                PsaParameterDataViewModel param =
                    s.DataContext as PsaParameterDataViewModel;
                if (param != null)
                {
                    if (param == vm) // the same object
                    {
                        toDelete = s;
                        break;
                    }
                }
            }
            // determine axes to delete
            AxisY2D axsToDelete          = XYDiagram2D.GetSeriesAxisY((XYSeries)toDelete);
            bool    axsUsedSomewhereElse = false;

            foreach (XYSeries s in graph.SeriesCollection)
            {
                if (s != null && s == toDelete)
                {
                    continue;
                }
                AxisY2D axs = XYDiagram2D.GetSeriesAxisY(s);
                if (axs != null && axs == axsToDelete)
                {
                    axsUsedSomewhereElse = true;
                }
            }
            graph.RemoveSeries(toDelete);
            SecondaryAxisY2D axsToDeleteCast = axsToDelete as SecondaryAxisY2D;

            if (!axsUsedSomewhereElse && axsToDeleteCast != null)
            {
                graph.graphDiagram.SecondaryAxesY.Remove(axsToDeleteCast);
            }
        }