void resetActionRecording() { inputFieldModify = null; lastKnownDirection = ValueDirection.NONE; prevValue = string.Empty; prevSongObject = null; prevSongObjectRef = null; }
void ResetActionRecording() { lastKnownDirection = ValueDirection.NONE; prevValue = string.Empty; prevSongObject = null; prevSongObjectRef = null; commandRecordingInProcess = false; }
public DelegateColumnSetup(int ordinal, string columnName, Type columnType, Func <object, object> getValue, Action <object, object> setValue, ValueDirection direction = ValueDirection.Write) { Ordinal = ordinal; ValueDirection = direction; ColumnType = columnType; ColumnName = columnName; _getValue = getValue; _setValue = setValue; }
protected void UpdateInputFieldRecord() { if (currentSongObject == null || prevSongObject == null || prevSongObject != currentSongObject) { if (! ( (currentSongObject.GetType() == typeof(ChartEvent) || currentSongObject.GetType() == typeof(Event)) && currentSongObject.GetType() == prevSongObject.GetType() ) ) { return; } } string value = GetValue(currentSongObject); if (value == prevValue || value == GetValue(prevSongObject)) { return; } // Check if there's a record already in if (inputFieldModify == null || lastKnownDirection == ValueDirection.NONE) { // Add a new record inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); if (GetValue(currentSongObject).Length < GetValue(prevSongObject).Length) { lastKnownDirection = ValueDirection.DOWN; } else if (GetValue(currentSongObject).Length > GetValue(prevSongObject).Length) { lastKnownDirection = ValueDirection.UP; } else { lastKnownDirection = ValueDirection.NONE; } } // Else check if a new record needs to overwrite this current one or if this one needs to be edited else if (inputFieldModify != null) { if (value.Length < prevValue.Length) { if (lastKnownDirection == ValueDirection.DOWN) { // Edit action inputFieldModify.after = currentSongObject.Clone(); } else { // New action inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } lastKnownDirection = ValueDirection.DOWN; } else if (value.Length > prevValue.Length) { if (lastKnownDirection == ValueDirection.UP) { // Edit action inputFieldModify.after = currentSongObject.Clone(); } else { // New action inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } lastKnownDirection = ValueDirection.UP; } else { // Add a new record inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } } prevValue = value; }
protected void ShouldRecordInputField(string newLabel, string oldLabel, out bool tentativeRecord, out bool lockedRecord, bool ignoreEmptyLabels = false) { tentativeRecord = false; lockedRecord = false; if (ignoreEmptyLabels && string.IsNullOrEmpty(newLabel)) { return; } if (currentSongObject == null || prevSongObject == null || prevSongObject != currentSongObject) { bool sameType = prevSongObject != null && currentSongObject.GetType() == prevSongObject.GetType(); if (!sameType) { return; } } string value = newLabel; if (value.Equals(oldLabel)) { return; } // Check if there's a record already in if (!commandRecordingInProcess || lastKnownDirection == ValueDirection.NONE) { if (value.Length < oldLabel.Length) { lastKnownDirection = ValueDirection.DOWN; } else if (value.Length > oldLabel.Length) { lastKnownDirection = ValueDirection.UP; } else { lastKnownDirection = ValueDirection.NONE; } lockedRecord = !commandRecordingInProcess; tentativeRecord = true; commandRecordingInProcess = true; } // Else check if a new record needs to overwrite this current one or if this one needs to be edited else if (commandRecordingInProcess) { if (value.Length < oldLabel.Length) { if (lastKnownDirection == ValueDirection.DOWN) { tentativeRecord = true; } else { lockedRecord = true; } lastKnownDirection = ValueDirection.DOWN; } else if (value.Length > oldLabel.Length) { if (lastKnownDirection == ValueDirection.UP) { tentativeRecord = true; } else { lockedRecord = true; } lastKnownDirection = ValueDirection.UP; } else { lockedRecord = true; } } }