private void CBPolynomial_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Clear DifDiv
            difDiv.Clear();
            //Calculate f(x_i) <=> y_i and change values in DGVPoints and in Dictionary
            double result = 0.0;

            for (int i = 0; i < DGVPoints.RowCount; i++)
            {
                result = (double)((KeyValuePair <string, Func <double, double> >)CBPolynomial.SelectedItem).Value.DynamicInvoke(Convert.ToDouble(DGVPoints[1, i].Value));
                DGVPoints[2, i].Value = result;
                if (DGVPointsDict.Count == DGVPoints.RowCount)
                {
                    DGVPointsDict[i] = new KeyValuePair <double, double>(DGVPointsDict[i].Key, Convert.ToDouble(DGVPoints[2, i].Value));
                }
            }
            difDiv.Clear();
            GenerateDifDiv(0, DGVPoints.RowCount - 1);

            DGVPoints.InvalidateColumn(2);

            if (true)
            {
                plotView1.Model = null;
                plotView1.Model = new PlotModel();
            }
            //Plot
            for (int i = plotView1.Model.Series.Count - 1; i >= 0; i--)
            {
                plotView1.Model.Series.RemoveAt(i);
            }
            string title = ((KeyValuePair <string, Func <double, double> >)CBPolynomial.SelectedItem).Key;

            plotView1.Model.Series.Add(new OxyPlot.Series.FunctionSeries(((KeyValuePair <string, Func <double, double> >)CBPolynomial.SelectedItem).Value, -100, 100, 0.1, title));
            plotView1.Model.Axes.Add(new OxyPlot.Axes.LinearAxis {
                Position = OxyPlot.Axes.AxisPosition.Left, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.Black, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            });
            plotView1.Model.Axes.Add(new OxyPlot.Axes.LinearAxis {
                Position = OxyPlot.Axes.AxisPosition.Bottom, ExtraGridlines = new double[] { 0 }, ExtraGridlineThickness = 1, ExtraGridlineColor = OxyColors.Black, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot
            });
            plotView1.Model.Axes[1].AbsoluteMinimum = -100;
            plotView1.Model.Axes[1].AbsoluteMaximum = 100;
            if (scatterSeries.Points.Count != 0)
            {
                scatterSeries.Points.Clear();
                foreach (KeyValuePair <double, double> item in DGVPointsDict.Values)
                {
                    scatterSeries.Points.Add(new ScatterPoint(item.Key, item.Value, 5, 1));
                }
                plotView1.Model.Series.Remove(scatterSeries);
                plotView1.Model.Series.Add(scatterSeries);
            }
            plotView1.Model.InvalidatePlot(true);

            NMIN_MAX_ValueChanged(null, null);
            NMIN.Enabled = true;
            NMAX.Enabled = true;
            TBInterpolationPolynomial.Text = "? Interpolation polynomial ?";
        }
        //Edit cell
        private void DGVPoints_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex == 1)
            {
                double oldx_i     = Convert.ToDouble(DGVPoints[e.ColumnIndex, e.RowIndex].Value);
                double newx_i     = Convert.ToDouble(e.FormattedValue);
                bool   can_or_not = true;
                if (oldx_i != newx_i)
                {
                    for (int i = 0; i < DGVPoints.RowCount; i++)
                    {
                        if (Convert.ToDouble(DGVPoints[1, i].Value) == newx_i)
                        {
                            MessageBox.Show("You can't change node to existing argument: " + newx_i, "Error");
                            e.Cancel   = true;
                            can_or_not = false;
                            break;
                        }
                    }
                    if (can_or_not == true)
                    {
                        double y_iNew = (double)((KeyValuePair <string, Func <double, double> >)CBPolynomial.SelectedItem).Value.DynamicInvoke(newx_i);
                        this.DGVPoints[2, e.RowIndex].Value = y_iNew;
                        this.DGVPointsDict[e.RowIndex]      = new KeyValuePair <double, double>(newx_i, y_iNew);
                        //edit plot
                        plotView1.Model.Series.Remove(scatterSeries);
                        scatterSeries.Points.RemoveAt(e.RowIndex);
                        scatterSeries.Points.Insert(e.RowIndex, new ScatterPoint(newx_i, y_iNew, 5, 1));
                        plotView1.Model.Series.Add(scatterSeries);
                        plotView1.Model.InvalidatePlot(true);

                        for (int i = 0; i < DGVPoints.RowCount - e.RowIndex; i++)
                        {
                            difDiv.RemoveAt(difDiv.Count - 1);
                        }
                        if (DGVPoints.RowCount > 0)
                        {
                            GenerateDifDiv(0, DGVPoints.RowCount - 1);
                        }
                    }
                    DGVPoints.InvalidateRow(e.RowIndex);
                }
            }
        }