Пример #1
0
    public void UpdateCmp()
    {
        //Stack the simulator current state so it can be undone
        UndoState undoState = new UndoState();

        undoState.Snapshot();
        Simulator.sim.undoStack.Push(undoState);

        if (!string.IsNullOrEmpty(cmpInput.text))
        {
            if (int.Parse(cmpInput.text) >= 1)
            {
                cmp           = true;
                cmpInput.text = "1";
            }
            else
            {
                cmp           = false;
                cmpInput.text = "0";
            }
        }
        else
        {
            cmp           = false;
            cmpInput.text = "0";
        }
    }
Пример #2
0
        /// <summary>
        /// Roll forward to the next state.
        ///
        /// Page definition properties are not in scope of undo/redo
        /// </summary>
        /// <param name="parentOfShapes">Is necessary to create shapes with references to their parent.</param>
        public void Redo(IShapeParent parentOfShapes)
        {
            this.VerifyAccess();

            this.VerifyState(ModelState.Ready, ModelState.Invalid);

            if (this.HasRedoData)
            {
                UndoState undoState = this.mRedoList.First.Value;

                string fragment = string.Empty;

                if (this.mDocRoot.Count > 0)
                {
                    fragment = this.GetShapesAsXmlString(this.mDocRoot);
                }

                this.mUndoList.AddFirst(new UndoState(fragment, this.mHasUnsavedData));
                this.mRedoList.RemoveFirst();

                // Reload shape collection from this Xml formated (persistence) undo state
                this.RecreateShapeCollectionFromXml(parentOfShapes, undoState.DocRoot);

                this.mHasUnsavedData = undoState.HasUnsavedData;

                this.State = ModelState.Ready;

                this.SendPropertyChanged("HasUndoData", "HasRedoData", "HasUnsavedData");
            }
        }
Пример #3
0
    public void UpdatePC()
    {
        TextBox.textBox.Clear();

        //Stack the simulator current state so it can be undone
        UndoState undoState = new UndoState();

        undoState.Snapshot();
        Simulator.sim.undoStack.Push(undoState);

        if (state >= 0 && state <= 14 && Simulator.sim.currentProcess == currentProcess)
        {
            if (state >= 6 && state <= 8)
            {
                Simulator.sim.codeLine[state].color = new Color(0.625f, 0.125f, 0.125f);
            }
            else
            {
                Simulator.sim.codeLine[state].color = Color.white;
            }
        }

        if (!string.IsNullOrEmpty(pcInput.text))
        {
            if (int.Parse(pcInput.text) >= 0 && int.Parse(pcInput.text) <= 15)
            {
                state = int.Parse(pcInput.text);

                if (state < 0)
                {
                    state        = 0;
                    pcInput.text = "0";
                }
                if (state > 15)
                {
                    state        = 15;
                    pcInput.text = "15";
                }
            }
        }
        else
        {
            state        = 0;
            pcInput.text = "0";
        }

        if (state >= 0 && state <= 14 && Simulator.sim.currentProcess == currentProcess)
        {
            if (state >= 6 && state <= 8)
            {
                Simulator.sim.codeLine[state].color = new Color(1f, 0.5f, 0.5f);
            }
            else
            {
                Simulator.sim.codeLine[state].color = new Color(1f, 1f, 0f);
            }
        }

        Animate(state - 1);
    }
Пример #4
0
        /// <summary>
        /// Roll forward to the next state.
        ///
        /// Page definition properties are not in scope of undo/redo
        /// </summary>
        /// <param name="parentOfShapes">Is necessary to create shapes with references to their parent.</param>
        public void Redo(IShapeParent parentOfShapes)
        {
            VerifyAccess();

            VerifyState(ModelState.Ready, ModelState.Invalid);

            if (HasRedoData)
            {
                UndoState undoState = _RedoList.First.Value;

                string fragment = string.Empty;

                if (_DocRoot.Count > 0)
                {
                    fragment = this.GetShapesAsXmlString(_DocRoot);
                }

                _UndoList.AddFirst(new UndoState(fragment, _HasUnsavedData));
                _RedoList.RemoveFirst();

                // Reload shape collection from this Xml formated (persistence) undo state
                RecreateShapeCollectionFromXml(parentOfShapes, undoState.DocRoot);

                _HasUnsavedData = undoState.HasUnsavedData;

                State = ModelState.Ready;

                NotifyPropertyChanged(() => HasUndoData);
                NotifyPropertyChanged(() => HasRedoData);
                NotifyPropertyChanged(() => HasUnsavedData);
            }
        }
Пример #5
0
    //Play current process' next
    public void PlayNext()
    {
        if (process[currentProcess].state < 15)
        {
            //Stack the simulator current state so it can be undone
            UndoState state = new UndoState();
            state.Snapshot();
            undoStack.Push(state);

            if (process[currentProcess].state < 15)
            {
                if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8)
                {
                    codeLine[process[currentProcess].state].color = new Color(0.625f, 0.125f, 0.125f);
                }
                else
                {
                    codeLine[process[currentProcess].state].color = Color.white;
                }
            }
            process[currentProcess].Play(process[currentProcess].state);

            if (process[currentProcess].state < 15)
            {
                if (process[currentProcess].state >= 6 && process[currentProcess].state <= 8)
                {
                    codeLine[process[currentProcess].state].color = new Color(1f, 0.5f, 0.5f);
                }
                else
                {
                    codeLine[process[currentProcess].state].color = new Color(1f, 1f, 0f);
                }
            }
        }
    }
Пример #6
0
        private void PushUndo(List <UndoState> state)
        {
            currentUndo = state[0];
            undoStack.Push(state);

            undoStackModified?.Invoke();
        }
Пример #7
0
        public new void Redo()
        {
            if (!CanRedo)
            {
                return;
            }
            UndoElem ue      = undoBuffer[undoBufferIndex++];
            string   newText = Text;

            if (ue.UndoData != null)
            {
                newText = newText.Remove(ue.Pos, ue.UndoData.Length);
            }
            if (ue.RedoData != null)
            {
                newText = newText.Insert(ue.Pos, ue.RedoData);
            }
            UndoSelectionStart = ue.Pos + (ue.RedoData != null ? ue.RedoData.Length : 0);
            undoState          = UndoState.Redo;
            EnableRedrawLock(true);
            Text      = newText;
            undoState = UndoState.None;
            BeginInvoke((MethodInvoker) delegate()
            {
                EnableRedrawLock(false);
                SelectionStart = UndoSelectionStart;
            });
        }
Пример #8
0
    public void UpdateLock()
    {
        //Stack the simulator current state so it can be undone
        UndoState state = new UndoState();

        state.Snapshot();
        undoStack.Push(state);

        if (!string.IsNullOrEmpty(lockInput.text))
        {
            lockVar       = int.Parse(lockInput.text);
            doorText.text = "Lock\n" + lockVar;

            if (lockVar >= 1)
            {
                toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(1f, 0.5f, 0.5f, 0.5f);
            }
            else
            {
                toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(0.5f, 1f, 0.5f, 0.5f);
            }
        }
        else
        {
            lockInput.text = "0";
            doorText.text  = "Lock\n0";
            lockVar        = 0;
            toiletDoor.GetComponentInChildren <Renderer>().material.color = new Color(0.5f, 1f, 0.5f, 0.5f);
        }
    }
Пример #9
0
 private void ApplyUndo(UndoState buffer, bool redo)
 {
     img.setRawData(redo ? buffer.After : buffer.Before);
     RenderBuffer();
     RenderZoomCache();
     drawingBox.Invalidate();
 }
Пример #10
0
        public static UndoState <T> Savepoint <T>(this T obj) where T : class
        {
            var undo = new UndoState <T>(obj);

            InternalSavepoint(obj, undo);

            return(undo);
        }
Пример #11
0
        private void setPendingUndoState()
        {
            VerifyAccess();

            VerifyState(ModelState.Ready, ModelState.Invalid);

            _pendingUndoState = new UndoState(_documentRoot, _hasUnsavedData);
        }
Пример #12
0
 void UpdateAssemblySavedState(int newCurrentCommandCounter, UndoState executedGroup)
 {
     currentCommandCounter = newCurrentCommandCounter;
     foreach (var asm in executedGroup.ModifiedAssemblies)
     {
         Debug.Assert(asm.SavedCommand != 0);
         asm.IsDirty = IsModifiedCounter(asm, currentCommandCounter);
     }
 }
Пример #13
0
 void UpdateAssemblySavedState(int newCurrentCommandCounter, UndoState executedGroup)
 {
     currentCommandCounter = newCurrentCommandCounter;
     foreach (var obj in executedGroup.ModifiedObjects)
     {
         Debug.Assert(obj.SavedCommand != 0);
         obj.IsDirty = IsModifiedCounter(obj, currentCommandCounter);
     }
 }
Пример #14
0
        private void Redo()
        {
            UndoState ThisUndo = RedoBuffer.Pop();

            ApplyUndo(ThisUndo, true);
            UndoBuffer.Push(ThisUndo);
            undoButton.Enabled = (UndoBuffer.Count > 0);
            redoButton.Enabled = (RedoBuffer.Count > 0);
        }
Пример #15
0
        private void PushUndo(List <UndoState> state)
        {
            currentUndo = state[0];
            undoStack.Push(state);

            if (undoStackModified != null)
            {
                undoStackModified();
            }
        }
Пример #16
0
        private void StartUndo()
        {
            RedoBuffer.Clear();
            redoButton.Enabled = (RedoBuffer.Count > 0);
            if (NewUndo == null)
            {
                NewUndo        = new UndoState();
                NewUndo.Before = (byte[])img.getRawData().Clone();
//                Console.WriteLine("Created undo state");
            }
        }
Пример #17
0
    void StartRotateSingleSelection()
    {
        GetFocusActor().RequestOwnership();
        hitOffset       = GetFocusActor().transform.InverseTransformPoint(targetPosition);
        targetRigidbody = GetFocusActor().GetComponent <Rigidbody>();
        internalTransform.SetPositionAndRotation(GetFocusActor().transform.position, GetFocusActor().transform.rotation);
        FindNormalLineSingleSelection();

        actorUndoStates.Clear();
        actorUndoStates[GetFocusActor()] = new UndoState(GetFocusActor());
    }
Пример #18
0
        void BeginAddInternal()
        {
            Debug.Assert(currentCommands == null);
            if (currentCommands != null)
            {
                throw new InvalidOperationException();
            }

            int prev = currentCommandCounter;

            commandCounter++;
            currentCommands = new UndoState(prev, commandCounter);
        }
Пример #19
0
        private void CommitUndo()
        {
            if (NewUndo != null && NewUndo.ContainsChanges)
            {
                NewUndo.After = (byte[])img.getRawData().Clone();
                UndoBuffer.Push(NewUndo);
                NewUndo = null;
//                Console.WriteLine("Committed undo state");
                // enforce a limit.. how?
                //if (UndoBuffer.Count > 36) ...
                undoButton.Enabled = (UndoBuffer.Count > 0);
            }
        }
Пример #20
0
    /// <summary>
    /// Record undo
    /// </summary>
    public void RecordUndo()
    {
        var st = new UndoState(this);

        if (undoStack.Count == 0 || !UndoState.IsEqual(st, undoStack[undoStack.Count - 1]))
        {
            undoStack.Add(st);
            // maybe the cap is too subjective
            if (undoStack.Count > 15)
            {
                undoStack.RemoveAt(0);
            }
        }
    }
Пример #21
0
        //////////////////////////////////////////////////////////////////////////
        public bool SaveUndoState(string Name)
        {
            IsDirty = true;

            string StrState = GetCurrentStateForUndo();

            if (StrState == null)
            {
                return(false);
            }

            UndoPointer++;

            while (UndoStates.Count > UndoPointer)
            {
                UndoStates.RemoveAt(UndoStates.Count - 1);
            }

            try
            {
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                byte[] OrigBuf = enc.GetBytes(StrState);
                byte[] CompBuf = WUtils.CompressBuffer(OrigBuf);

                UndoState State;
                if (CompBuf != null)
                {
                    State = new UndoState(Name, CompBuf, true, OrigBuf.Length);
                }
                else
                {
                    State = new UndoState(Name, OrigBuf, false, OrigBuf.Length);
                }

                UndoStates.Add(State);

                if (UndoStates.Count > MaxUndoLevel)
                {
                    UndoStates.RemoveAt(0);
                    UndoPointer--;
                }

                return(true);
            }
            catch
            {
                UndoPointer--;
                return(false);
            }
        }
Пример #22
0
        static void RedoHandler([NotNull] Player player, [NotNull] CommandReader cmd)
        {
            if (cmd.HasNext)
            {
                CdRedo.PrintUsage(player);
                return;
            }

            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            UndoState redoState = player.RedoPop();

            if (redoState == null)
            {
                player.MessageNow("There is currently nothing to redo.");
                return;
            }

            string msg = "Redo: ";

            if (redoState.Op != null && !redoState.Op.IsDone)
            {
                redoState.Op.Cancel();
                msg += String.Format("Cancelled {0} (was {1}% done). ",
                                     redoState.Op.Description,
                                     redoState.Op.PercentDone);
            }

            // no need to set player.drawingInProgress here because this is done on the user thread
            Logger.Log(LogType.UserActivity,
                       "Player {0} initiated /Redo affecting {1} blocks (on world {2})",
                       player.Name,
                       redoState.Buffer.Count,
                       playerWorld.Name);

            msg += String.Format("Restoring {0} blocks. Type &H/Undo&S to reverse.",
                                 redoState.Buffer.Count);
            player.MessageNow(msg);

            var op = new UndoDrawOperation(player, redoState, true);

            op.Prepare(new Vector3I[0]);
            op.Begin();
        }
Пример #23
0
        private void setPendingUndoState()
        {
            this.VerifyAccess();

            this.VerifyState(ModelState.Ready, ModelState.Invalid);

            string fragment = string.Empty;

            if (this.mDocRoot.Count > 0)
            {
                fragment = this.GetShapesAsXmlString(this.mDocRoot);
            }

            this.mPendingUndoState = new UndoState(fragment, this.mHasUnsavedData);
        }
Пример #24
0
    void undo()
    {
        if (undoStack.Count == 0)
        {
            return;
        }
        UndoState prevGradientState = undoStack.Pop();

        //Simply reassigning biomeGradient to prevGradientState.gradient seems to break the link between the gradient and the biome. I think it may have to do with serialization
        biomeGradient.mimic(prevGradientState.gradient);

        selectedKeyIndex = prevGradientState.selectedIndex;
        redrawEditorNoiseMap();
        Repaint();
    }
Пример #25
0
 void OnExecutedOneCommand(UndoState group)
 {
     foreach (var asm in group.ModifiedAssemblies)
     {
         var module = asm.ModuleDefinition;
         if (module != null)
         {
             module.ResetTypeDefFindCache();
         }
         if (asm.SavedCommand == 0)
         {
             asm.SavedCommand = group.PrevCommandCounter;
         }
         Utils.NotifyModifiedAssembly(asm);
     }
 }
Пример #26
0
        private List <UndoState> PopUndo()
        {
            List <UndoState> states = Pop(undoStack);

            if (states == null || undoStack.Count < 1)
            {
                currentUndo = null;
            }
            else
            {
                currentUndo = ((List <UndoState>)undoStack.Peek())[0];
            }

            undoStackModified?.Invoke();

            return(states);
        }
Пример #27
0
        private void SaveUndo(byte dest, int nextPC)
        {
            if (maxUndoDepth > 0)
            {
                UndoState curState = new UndoState(zmem, romStart, stack, callStack, nextPC, dest);
                if (undoStates.Count >= maxUndoDepth)
                {
                    undoStates.RemoveAt(0);
                }
                undoStates.Add(curState);

                StoreResult(dest, 1);
            }
            else
            {
                StoreResult(dest, 0);
            }
        }
Пример #28
0
    public void UpdateToilet()
    {
        //Stack the simulator current state so it can be undone
        UndoState state = new UndoState();

        state.Snapshot();
        undoStack.Push(state);

        if (!string.IsNullOrEmpty(toiletInput.text))
        {
            toilet = int.Parse(toiletInput.text);
        }
        else
        {
            toiletInput.text = "0";
            toilet           = 0;
        }
    }
Пример #29
0
 private void RestoreUndo(byte dest, int failurePC)
 {
     if (undoStates.Count == 0)
     {
         StoreResult(dest, 0);
         pc = failurePC;
     }
     else
     {
         int       i         = undoStates.Count - 1;
         UndoState lastState = undoStates[i];
         undoStates.RemoveAt(i);
         lastState.Restore(zmem, stack, callStack, out pc, out dest);
         SetTopFrame();
         ResetHeaderFields(false);
         StoreResult(dest, 2);
     }
 }
Пример #30
0
        /// <summary>
        /// Roll forward to the next state.
        /// </summary>
        public void Redo()
        {
            base.VerifyAccess();

            VerifyState(ModelState.Ready, ModelState.Invalid);

            if (HasRedoData)
            {
                UndoState us = _redoList.First.Value;
                _undoList.AddFirst(new UndoState(_documentRoot, _hasUnsavedData));
                _redoList.RemoveFirst();
                setDocumentRoot(us.DocumentRoot);
                _hasUnsavedData = us.HasUnsavedData;

                base.State = ModelState.Ready;

                base.SendPropertyChanged("DocumentRoot", "ObservableDocumentRoot", "HasUndoData", "HasRedoData", "HasUnsavedData");
            }
        }
Пример #31
0
        void BeginAddInternal()
        {
            Debug.Assert(currentCommands == null);
            if (currentCommands != null)
                throw new InvalidOperationException();

            int prev = currentCommandCounter;
            commandCounter++;
            currentCommands = new UndoState(prev, commandCounter);
        }
        //////////////////////////////////////////////////////////////////////////
        public bool SaveUndoState(string Name)
        {
            IsDirty = true;

            string StrState = GetCurrentStateForUndo();
            if (StrState == null) return false;

            UndoPointer++;

            while (UndoStates.Count > UndoPointer)
                UndoStates.RemoveAt(UndoStates.Count - 1);

            try
            {
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                byte[] OrigBuf = enc.GetBytes(StrState);
                byte[] CompBuf = WUtils.CompressBuffer(OrigBuf);

                UndoState State;
                if (CompBuf != null)
                    State = new UndoState(Name, CompBuf, true, OrigBuf.Length);
                else
                    State = new UndoState(Name, OrigBuf, false, OrigBuf.Length);

                UndoStates.Add(State);

                if(UndoStates.Count > MaxUndoLevel)
                {
                    UndoStates.RemoveAt(0);
                    UndoPointer--;
                }

                return true;
            }
            catch
            {
                UndoPointer--;
                return false;
            }
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (_previousText == null)
            {
                _previousText = Text;
            }

            _currentUndoState = new UndoState
            {
                Value = Text,
                SelectionStart = SelectionStart,
                SelectionLength = SelectionLength
            };

            if ((keyData & Keys.Control) != Keys.Control
                || ((keyData & Keys.V) != Keys.V
                    && (keyData & Keys.Z) != Keys.Z
                    && (keyData & Keys.Y) != Keys.Y))
            {
                return base.ProcessCmdKey(ref msg, keyData);
            }

            if ((keyData & Keys.V) == Keys.V)
            {
                // If the user has pasted via Ctrl + V, don't paste the text with its formatting, just the text itself.
                var data = Clipboard.GetDataObject();

                if (data == null || !data.GetDataPresent(DataFormats.Text))
                {
                    return base.ProcessCmdKey(ref msg, keyData);
                }

                var contents = Clipboard.GetText();
                Clipboard.SetData(DataFormats.Text, contents);
                Paste();

                return true;
            }

            // We need to handle the Undo/Redo stack ourselves, since the native RichTextBox Undo/Redo is kinda wonky.

            if ((keyData & Keys.Z) == Keys.Z)
            {
                if (_undoStack.Count > 0)
                {
                    _redoStack.Push(_currentUndoState);
                    var undo = _undoStack.Pop();
                    _isUndoingOrRedoing = true;
                    Text = undo.Value;
                    SelectionStart = undo.SelectionStart;
                    SelectionLength = undo.SelectionLength;
                    _isUndoingOrRedoing = false;
                }

                return true;
            }

            if ((keyData & Keys.Y) == Keys.Y)
            {
                if (_redoStack.Count > 0)
                {
                    _undoStack.Push(_currentUndoState);
                    var redo = _redoStack.Pop();
                    _isUndoingOrRedoing = true;
                    Text = redo.Value;
                    SelectionStart = redo.SelectionStart;
                    SelectionLength = redo.SelectionLength;
                    _isUndoingOrRedoing = false;
                }

                return true;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }
Пример #34
0
 public virtual void Undo()
 {
     m_state = UndoState.ReadyForRedo;
 }
Пример #35
0
 void UpdateAssemblySavedState(int newCurrentCommandCounter, UndoState executedGroup)
 {
     currentCommandCounter = newCurrentCommandCounter;
     foreach (var obj in executedGroup.ModifiedObjects) {
         Debug.Assert(obj.SavedCommand != 0);
         obj.IsDirty = IsModifiedCounter(obj, currentCommandCounter);
     }
 }
Пример #36
0
		void UpdateAssemblySavedState(int newCurrentCommandCounter, UndoState executedGroup)
		{
			currentCommandCounter = newCurrentCommandCounter;
			foreach (var asm in executedGroup.ModifiedAssemblies) {
				Debug.Assert(asm.SavedCommand != 0);
				asm.IsDirty = IsModifiedCounter(asm, currentCommandCounter);
			}
		}
Пример #37
0
        //------------------------------------------------------
        //
        //  Protected Methods
        //
        //------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// State of the Undo Service
        /// </summary>
        /// <param name="value">
        /// UndoState to which State is to be set
        /// </param>
        protected void SetState(UndoState value)
        {
            _state = value;
        }
Пример #38
0
		void OnExecutedOneCommand(UndoState group) {
			foreach (var obj in group.ModifiedObjects) {
				if (obj.SavedCommand == 0)
					obj.SavedCommand = group.PrevCommandCounter;

				bool found = false;
				foreach (var up in undoableDocumentsProviders) {
					found = up.Value.OnExecutedOneCommand(obj);
					if (found)
						break;
				}

				Debug.Assert(found, string.Format("Unknown modified object: {0}: {1}", obj == null ? null : obj.GetType(), obj));
			}
		}
Пример #39
0
 private void CommitUndo()
 {
     if (NewUndo != null && NewUndo.ContainsChanges) {
         NewUndo.After = (byte[])img.getRawData().Clone();
         UndoBuffer.Push(NewUndo);
         NewUndo = null;
     //                Console.WriteLine("Committed undo state");
         // enforce a limit.. how?
         //if (UndoBuffer.Count > 36) ...
         undoButton.Enabled = (UndoBuffer.Count > 0);
     }
 }
Пример #40
0
 private void StartUndo()
 {
     RedoBuffer.Clear();
     redoButton.Enabled = (RedoBuffer.Count > 0);
     if (NewUndo == null) {
         NewUndo = new UndoState();
         NewUndo.Before = (byte[])img.getRawData().Clone();
     //                Console.WriteLine("Created undo state");
     }
 }
Пример #41
0
 private void ApplyUndo(UndoState buffer, bool redo)
 {
     img.setRawData(redo ? buffer.After : buffer.Before);
     RenderBuffer();
     RenderZoomCache();
     drawingBox.Invalidate();
 }
Пример #42
0
        private void SaveUndo(byte dest, int nextPC)
        {
            if (maxUndoDepth > 0)
            {
                UndoState curState = new UndoState(zmem, romStart, stack, callStack, nextPC, dest);
                if (undoStates.Count >= maxUndoDepth)
                    undoStates.RemoveAt(0);
                undoStates.Add(curState);

                StoreResult(dest, 1);
            }
            else
            {
                StoreResult(dest, 0);
            }
        }
Пример #43
0
		void EndAddInternal()
		{
			Debug.Assert(currentCommands != null);
			if (currentCommands == null)
				throw new InvalidOperationException();

			currentCommands.Commands.TrimExcess();
			undoCommands.Add(currentCommands);
			Clear(redoCommands);
			UpdateAssemblySavedStateRedo(currentCommands);
			currentCommands = null;
		}
Пример #44
0
        void EndAddInternal()
        {
            Debug.Assert(currentCommands != null);
            if (currentCommands == null)
                throw new InvalidOperationException();

            currentCommands.Commands.TrimExcess();
            undoCommands.Add(currentCommands);

            bool callGc = NeedsToCallGc(redoCommands);
            Clear(redoCommands);
            if (callGc)
                CallGc();

            UpdateAssemblySavedStateRedo(currentCommands);
            currentCommands = null;
            NotifyEvent(UndoCommandManagerEventType.Add);
        }
Пример #45
0
 protected void AddUndo(UndoState val)
 {
     this._redoCol.Clear();
     this._undoCol.Add(val);
 }
Пример #46
0
        void OnExecutedOneCommand(UndoState group)
        {
            foreach (var obj in group.ModifiedObjects) {
                if (obj.SavedCommand == 0)
                    obj.SavedCommand = group.PrevCommandCounter;

                var asm = obj as LoadedAssembly;
                if (asm != null) {
                    var module = asm.ModuleDefinition;
                    if (module != null)
                        module.ResetTypeDefFindCache();
                    Utils.NotifyModifiedAssembly(asm);
                    continue;
                }

                Debug.Assert(obj is AsmEdHexDocument, string.Format("Unknown modified object: {0}: {1}", obj == null ? null : obj.GetType(), obj));
            }
        }
Пример #47
0
		void OnExecutedOneCommand(UndoState group) {
			foreach (var obj in group.ModifiedObjects) {
				if (obj.SavedCommand == 0)
					obj.SavedCommand = group.PrevCommandCounter;

				var file = TryGetDnSpyFile(obj);
				if (file != null) {
					var module = file.ModuleDef;
					if (module != null)
						module.ResetTypeDefFindCache();
					Utils.NotifyModifiedAssembly(file);
					continue;
				}

				Debug.Assert(TryGetAsmEdHexDocument(obj) != null, string.Format("Unknown modified object: {0}: {1}", obj == null ? null : obj.GetType(), obj));
			}
		}
Пример #48
0
 void UpdateAssemblySavedStateUndo(UndoState executedGroup)
 {
     UpdateAssemblySavedState(executedGroup.PrevCommandCounter, executedGroup);
 }
Пример #49
0
		void OnExecutedOneCommand(UndoState group)
		{
			foreach (var asm in group.ModifiedAssemblies) {
				var module = asm.ModuleDefinition;
				if (module != null)
					module.ResetTypeDefFindCache();
				if (asm.SavedCommand == 0)
					asm.SavedCommand = group.PrevCommandCounter;
				Utils.NotifyModifiedAssembly(asm);
			}
		}