internal bool HasActions(ChangeType type) { if (currentState == null) { return(false); } ChangeRecord r = currentState.FindRecord(type); return(r != null && r.HasActions); }
/// <summary> /// Registers a new change record. (Ensure that a valid type is sent to this) /// </summary> /// <param name="type">Type of record specified</param> internal ChangeRecord AddRecord(ChangeType type) { if (ActiveManager.ignoreChange[(byte)type]) { return(null); } #if DEBUG if (!LimitDebugReporting) { Debug.Print(type + @" Record added"); } #endif changeRecord.Add(ChangeRecord.CreateRecord(type, ActiveManager)); return(changeRecord[RecordCount - 1]); }
private void updateCurrentRecord(ChangeType type) { if (type == ChangeType.None || currentState == null) { return; } currentRecord = currentState.FindRecord(type); if (currentRecord == null) { currentRecord = currentState.AddRecord(type); } else { currentRecord.SetAction(currentRecord.LastActionType); } }
/// <summary> /// Modifies the ChangeRecord property that prevents actions and data from being submitted to that record. /// </summary> /// <param name="type">The ChangeRecord type requested.</param> /// <param name="flag">The state to set.</param> internal void SetAllowChange(ChangeType type, bool flag) { if (currentState == null) { return; } ChangeRecord r = currentRecord; if (r == null || r.StoreType != type) { r = currentState.FindRecord(type); } if (r == null) { Debug.Print(@"Attempted to set allow state for an unset ChangeType: " + type); return; } r.AllowChanges = flag; }
internal int RemoveUnchangedRecords() { int recordIndex = 0; int recordsPopped = 0; ChangeRecord currentRecord = GetRecord(recordIndex); while (currentRecord != null) { currentRecord.RemoveUnchangedActions(); if (!currentRecord.HasActions) { recordsPopped++; DeleteRecord(currentRecord.StoreType); } else { recordIndex++; } currentRecord = GetRecord(recordIndex); } return(recordsPopped); }
/// <summary> /// Removes current state /// </summary> private void popState() { if (currentState == null || HistoryRecord.Count == 0) { return; } StateDirty = false; if (!dirtySet) { Dirty = false; } currentRecordIndex = HistoryRecord.IndexOf(currentState); if (HistoryRecord.Remove(currentState)) { #if DEBUG Debug.Print($"Record State {currentRecordIndex} popped"); } else { NotificationManager.ShowMessage("Error: State not found"); #endif } currentState = null; currentRecord = null; if (HistoryRecord.Count > 0) { if (currentRecordIndex >= HistoryRecord.Count) { currentRecordIndex = HistoryRecord.Count - 1; } } else { currentRecordIndex = -1; } restoreBackup(); //At this point currentRecordIndex should be accurate. if (currentRecordIndex >= 0) { currentState = HistoryRecord[currentRecordIndex]; if (currentState.CanUndo) { UndoAllowed = true; RedoAllowed = currentRecordIndex < HistoryRecord.Count - 1; } else { UndoAllowed = currentRecordIndex > 0; RedoAllowed = true; } } else { UndoAllowed = false; RedoAllowed = false; } }
internal bool HasAction(ChangeType type, ActionType action) { ChangeRecord state = FindRecord(type); return(state != null && state.HasAction(action)); }
internal bool Contains(ChangeRecord state) { return(changeRecord.Contains(state)); }