Пример #1
0
        internal bool HasActions(ChangeType type)
        {
            if (currentState == null)
            {
                return(false);
            }

            ChangeRecord r = currentState.FindRecord(type);

            return(r != null && r.HasActions);
        }
Пример #2
0
            /// <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]);
            }
Пример #3
0
        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);
            }
        }
Пример #4
0
        /// <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;
        }
Пример #5
0
            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);
            }
Пример #6
0
        /// <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;
            }
        }
Пример #7
0
            internal bool HasAction(ChangeType type, ActionType action)
            {
                ChangeRecord state = FindRecord(type);

                return(state != null && state.HasAction(action));
            }
Пример #8
0
 internal bool Contains(ChangeRecord state)
 {
     return(changeRecord.Contains(state));
 }