public FormCurvePointEdit(FormMain main_window, long editing_id, CurveType curve)
        {
            InitializeComponent();
            mMainWindow = main_window;
            registerEventHandlers();
            setResources();
            applyLanguage();
            m_editing_id = editing_id;
            m_curve      = curve;

            VsqBPPairSearchContext context = AppManager.getVsqFile().Track[AppManager.getSelected()].getCurve(m_curve.getName()).findElement(m_editing_id);

            txtDataPointClock.Text = context.clock + "";
            txtDataPointValue.Text = context.point.value + "";
            txtDataPointValue.SelectAll();

            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
        }
        private void applyValue(bool mode_clock)
        {
            if (!m_changed)
            {
                return;
            }
            int value = m_curve.getDefault();

            try {
                value = int.Parse(txtDataPointValue.Text);
            } catch (Exception ex) {
                Logger.write(typeof(FormCurvePointEdit) + ".applyValue; ex=" + ex + "\n");
                return;
            }
            if (value < m_curve.getMinimum())
            {
                value = m_curve.getMinimum();
            }
            else if (m_curve.getMaximum() < value)
            {
                value = m_curve.getMaximum();
            }

            int clock = 0;

            try {
                clock = int.Parse(txtDataPointClock.Text);
            } catch (Exception ex) {
                Logger.write(typeof(FormCurvePointEdit) + ".applyValue; ex=" + ex + "\n");
                return;
            }

            int       selected  = AppManager.getSelected();
            VsqTrack  vsq_track = AppManager.getVsqFile().Track[selected];
            VsqBPList src       = vsq_track.getCurve(m_curve.getName());
            VsqBPList list      = (VsqBPList)src.clone();

            VsqBPPairSearchContext context = list.findElement(m_editing_id);

            list.move(context.clock, clock, value);
            CadenciiCommand run = new CadenciiCommand(VsqCommand.generateCommandTrackCurveReplace(selected,
                                                                                                  m_curve.getName(),
                                                                                                  list));
            EditedZone zone = new EditedZone();

            Utility.compareList(zone, new VsqBPListComparisonContext(list, src));
            List <EditedZoneUnit> zoneUnits = new List <EditedZoneUnit>();

            foreach (var item in zone.iterator())
            {
                zoneUnits.Add(item);
            }
            AppManager.editHistory.register(AppManager.getVsqFile().executeCommand(run));

            txtDataPointClock.Text = clock + "";
            txtDataPointValue.Text = value + "";

            if (mMainWindow != null)
            {
                mMainWindow.setEdited(true);
                mMainWindow.ensureVisible(clock);
                mMainWindow.refreshScreen();
            }

            if (mode_clock)
            {
                txtDataPointClock.SelectAll();
            }
            else
            {
                txtDataPointValue.SelectAll();
            }

            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
            m_changed       = false;
        }
        public void commonButton_Click(Object sender, EventArgs e)
        {
            VsqBPList list = AppManager.getVsqFile().Track[AppManager.getSelected()].getCurve(m_curve.getName());
            VsqBPPairSearchContext search = list.findElement(m_editing_id);
            int index = search.index;

            if (sender == btnForward)
            {
                index++;
            }
            else if (sender == btnBackward)
            {
                index--;
            }
            else if (sender == btnBackward2)
            {
                index -= 5;
            }
            else if (sender == btnForward2)
            {
                index += 5;
            }
            else if (sender == btnForward3)
            {
                index += 10;
            }
            else if (sender == btnBackward3)
            {
                index -= 10;
            }

            if (index < 0)
            {
                index = 0;
            }

            if (list.size() <= index)
            {
                index = list.size() - 1;
            }

            VsqBPPair bp = list.getElementB(index);

            m_editing_id = bp.id;
            int clock = list.getKeyClock(index);

            txtDataPointClock.TextChanged -= commonTextBox_TextChanged;
            txtDataPointValue.TextChanged -= commonTextBox_TextChanged;
            txtDataPointClock.Text         = clock + "";
            txtDataPointValue.Text         = bp.value + "";
            txtDataPointClock.TextChanged += commonTextBox_TextChanged;
            txtDataPointValue.TextChanged += commonTextBox_TextChanged;

            txtDataPointValue.Focus();
            txtDataPointValue.SelectAll();

            AppManager.itemSelection.clearPoint();
            AppManager.itemSelection.addPoint(m_curve, bp.id);
            if (mMainWindow != null)
            {
                mMainWindow.ensureVisible(clock);
                mMainWindow.refreshScreen();
            }
        }