private EditedZoneCommand generateCommandAdd(EditedZoneUnit[] areas) { EditedZone work = (EditedZone)clone(); for (int i = 0; i < areas.Length; i++) { EditedZoneUnit item = areas[i]; if (item == null) { continue; } work.mSeries.Add(new EditedZoneUnit(item.mStart, item.mEnd)); } work.normalize(); // thisに存在していて、workに存在しないものをremoveに登録 List <EditedZoneUnit> remove = new List <EditedZoneUnit>(); foreach (var itemThis in this.iterator()) { bool found = false; foreach (var itemWork in work.iterator()) { if (itemThis.mStart == itemWork.mStart && itemThis.mEnd == itemWork.mEnd) { found = true; break; } } if (!found) { remove.Add(new EditedZoneUnit(itemThis.mStart, itemThis.mEnd)); } } // workに存在していて、thisに存在しないものをaddに登録 List <EditedZoneUnit> add = new List <EditedZoneUnit>(); foreach (var itemWork in work.iterator()) { bool found = false; foreach (var itemThis in this.iterator()) { if (itemThis.mStart == itemWork.mStart && itemThis.mEnd == itemWork.mEnd) { found = true; break; } } if (!found) { add.Add(new EditedZoneUnit(itemWork.mStart, itemWork.mEnd)); } } work = null; return(new EditedZoneCommand(add, remove)); }
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; }