Exemple #1
0
        private void CtrlDataPoints_ValueAddedHandler(double x, double y)
        {
            DataPointViewModel dataPoint = new DataPointViewModel()
            {
                XValue = x, YValue = y
            };
            var xList = from xValue in _DataPoints select xValue.XValue;

            if (xList.Contains(dataPoint.XValue))
            {
                MessageBox.Show("You already entered a value for this position");
                return;
            }



            _DataPoints.Add(dataPoint);
            _DataPoints.Sort();

            _interpol.AddValue(new TDataPoint(x, y));
            if (_interpol.Count > 1)
            {
                Interpolate();
            }
            else
            {
                LineSeries ser = new LineSeries();
                ser.Points.Add(new DataPoint(0, 0));
                ser.Points.Add(new DataPoint(x, y));
                ((PlotterViewModel)CtrlPlotterSpline.DataContext).MyModel.Series.Add(ser);
                ((PlotterViewModel)CtrlPlotterSpline.DataContext).MyModel.InvalidatePlot(true);
            }

            lvDataPoints.Items.Clear();
            foreach (DataPointViewModel data in _DataPoints)
            {
                lvDataPoints.Items.Add(data);
            }
        }