public void SetSpectralPoint(int idx, double lambda_, double intensity_)
        {
            if (Helper.InRange(idx, 0, points.Count - 1))
            {
                SpectralPoint sp_new = new SpectralPoint(lambda_, intensity_);

                if (idx == lastModifiedIdx)
                {
                    undo.SetAfter(sp_new);
                }
                else
                {
                    undo = new SpectrumUndo(EAction.Moved, points[idx], sp_new);
                }

                //reuse it as a flag....
                lastModifiedIdx = -1;
                //if it's still fits in the same point interval - exchange it
                if ((idx > 0) && (idx < points.Count - 1))
                {
                    int check = CheckInBetween(points[idx - 1], sp_new, points[idx + 1]);
                    if (check == 0)
                    {
                        lastModifiedIdx = idx;
                        points[idx] = sp_new;
                    }
                }
                //if not - remove + binary search
                if (lastModifiedIdx == -1)
                {
                    points.RemoveAt(idx);
                    lastModifiedIdx = AddHelperSpectralPoint(sp_new, true);
                }
                CallSpectrumChanged();
            }
        }
        public int AddSpectralPoint(SpectralPoint sp)
        {
            int idx = AddHelperSpectralPoint(sp, false);

            CallSpectrumChanged();

            undo = new SpectrumUndo(EAction.Added, null, sp);
            lastModifiedIdx = -1;

            return idx;
        }
        public void DeleteSpectralPoint(int idx)
        {
            if ((idx != -1) && (idx < points.Count))
            {
                undo = new SpectrumUndo(EAction.Deleted, points[idx], null);
                points.RemoveAt(idx);
                if (OnSpectrumChanged != null)
                    OnSpectrumChanged();

                lastModifiedIdx = -1;
            }
        }
        private void AddRedo(SpectrumUndo op)
        {
            redoList.Insert(0, op);
            SetBtnRedoEntry(op.ToString(), EFrontRear.Front);

            if (tsBtnRedo.DropDown.Items.Count > 10)
                tsBtnRedo.DropDown.Items.RemoveAt(10);

            tsBtnRedo.Enabled = redoList.Count > 0;
        }