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 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(); }