Example #1
0
        public void HistoryStackTestEmptyHistory()
        {
            var stack = new HistoryStack(50);

            Assert.AreEqual(null, stack.PopHistory());
            Assert.AreEqual(null, stack.PopReverse());
        }
Example #2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (mouseDown)
            {
                OnMouseMove(e);
                mouseDown = false;

                if (savedRects.Count > 0)
                {
                    Rectangle[] savedScans   = this.savedRects.ToArray();
                    PdnRegion   saveMeRegion = Utility.RectanglesToRegion(savedScans);

                    HistoryMemento ha = new BitmapHistoryMemento(Name, Image, DocumentWorkspace,
                                                                 ActiveLayerIndex, saveMeRegion, ScratchSurface);

                    HistoryStack.PushNewMemento(ha);
                    saveMeRegion.Dispose();
                    this.savedRects.Clear();
                    ClearSavedMemory();
                }

                tracePoints = null;
            }
        }
Example #3
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            using (PdnGraphicsPath path = new PdnGraphicsPath())
            {
                path.AddPolygons(polygonSet);

                using (PdnRegion fillRegion = new PdnRegion(path))
                {
                    Rectangle boundingBox = fillRegion.GetBoundsInt();

                    Surface        surface = ((BitmapLayer)ActiveLayer).Surface;
                    RenderArgs     ra      = new RenderArgs(surface);
                    HistoryMemento ha;

                    using (PdnRegion affected = Utility.SimplifyAndInflateRegion(fillRegion))
                    {
                        ha = new BitmapHistoryMemento(Name, Image, DocumentWorkspace, DocumentWorkspace.ActiveLayerIndex, affected);
                    }

                    ra.Graphics.CompositingMode = AppEnvironment.GetCompositingMode();
                    ra.Graphics.FillRegion(brush, fillRegion.GetRegionReadOnly());

                    HistoryStack.PushNewMemento(ha);
                    ActiveLayer.Invalidate(boundingBox);
                    Update();
                }
            }
        }
Example #4
0
        private void ConfigDialog_Load(object sender, EventArgs e)
        {
            brushcollection = new PngBrushCollection(Services, Smudge.RawName);
            CreateDefaultBrushes();
            OnBrushesChanged();

            for (int i = 0; i < brushcollection.Count; i++)
            {
                brushcombobox.Items.Add(brushcollection[i]);
            }
            brushcombobox.Items.Add("Add/Remove Brushes...");

            this.BackColor   = SystemColors.Control;
            this.Text        = Smudge.StaticDialogName;
            surface          = EffectSourceSurface.Clone();
            canvas.Surface   = surface;
            canvas.Selection = Selection;
            historystack     = new HistoryStack(surface, false);

            InitializeRenderer();

            this.DesktopLocation = Owner.PointToScreen(new Point(0, 30));
            this.Size            = new Size(Owner.ClientSize.Width, Owner.ClientSize.Height - 30);
            this.WindowState     = Owner.WindowState;
        }
        private void FlushHistoryMementos(string name)
        {
            if (this.currentHistoryMementos.Count > 0)
            {
                CompoundHistoryMemento cha = new CompoundHistoryMemento(null, null,
                                                                        this.currentHistoryMementos.ToArray());

                string haName;

                if (name == null)
                {
                    haName = this.Name;
                }
                else
                {
                    haName = name;
                }

                ImageResource image = this.Image;

                CompoundToolHistoryMemento ctha = new CompoundToolHistoryMemento(cha, DocumentWorkspace, haName, image);

                ctha.SeriesGuid = context.seriesGuid;
                HistoryStack.PushNewMemento(ctha);

                this.currentHistoryMementos.Clear();
            }
        }
Example #6
0
        private bool LoadHistory()
        {
            if (null != _history)
            {
                return(false);
            }

            _history = new HistoryStack();
            IEnumerable <ErrorRecord> error;
            var items = _executor.ExecuteCommand("get-history", out error, ExecutionOptions.DoNotRaisePipelineException);

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

            items.ToList().ForEach(
                item =>
            {
                var o = item.BaseObject ?? item;
                if (null == o)
                {
                    return;
                }
                _history.Add(o.ToString());
            });
            _index = _history.Count;

            return(true);
        }
 private void Initialize()
 {
     _historyStack = new HistoryStack();
     _historyStack.CurrentIndexChanged += OnHistoryStackCurrentIndexChanged;
     _projectProperties = new ProjectPropertiesMain(this, _historyStack);
     _projectProperties.SetUI(this);
 }
Example #8
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            base.OnStylusUp(e);

            Cursor = cursorMouseUp;

            if (moveOriginMode)
            {
                moveOriginMode = false;
            }
            else if (mouseDown)
            {
                bool doCommit = OnShapeEnd();

                if (doCommit)
                {
                    CommitShape();
                }
                else
                {
                    // place a 'sentinel' history action on the stack that will be filled in later
                    CompoundHistoryMemento cha = new CompoundHistoryMemento(Name, Image, new List <HistoryMemento>());
                    HistoryStack.PushNewMemento(cha);
                    this.chaAlreadyOnStack = cha;
                }
            }
        }
Example #9
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (this.inCurveMode)
            {
                switch (e.KeyChar)
                {
                case '\r':     // Enter
                    e.Handled = true;
                    CommitShape();
                    break;

                case (char)27:     // Escape
                    // Only recognize if the user is not pressing Ctrl.
                    // Reason for this is that Ctrl+[ ends up being sent
                    // to us as (char)27 as well, but the user probably
                    // wants to use that for the decrease brush size
                    // shortcut, not cancel :)
                    if ((ModifierKeys & Keys.Control) == 0)
                    {
                        e.Handled = true;
                        HistoryStack.StepBackward();
                    }
                    break;
                }
            }

            base.OnKeyPress(e);
        }
Example #10
0
        public static void TestHistoryStack()
        {
            var historyStack = new HistoryStack <string>(20);

            Assert.Equal(0, historyStack.UndoCount);
            Assert.Equal(0, historyStack.RedoCount);

            historyStack.Push("first item");
            historyStack.Push("second item");
            Assert.Equal(2, historyStack.UndoCount);
            Assert.Equal(0, historyStack.RedoCount);

            Assert.Equal("second item", historyStack.Undo("second item"));
            Assert.Equal("first item", historyStack.Undo("first item"));
            Assert.Equal(0, historyStack.UndoCount);
            Assert.Equal(2, historyStack.RedoCount);

            Assert.Equal("first item", historyStack.Redo("first item"));
            Assert.Equal(1, historyStack.UndoCount);
            Assert.Equal(1, historyStack.RedoCount);

            // Pushing a new item should invalidate the RedoCount
            historyStack.Push("third item");
            Assert.Equal(2, historyStack.UndoCount);
            Assert.Equal(0, historyStack.RedoCount);

            // Check for the correct exception when the Redo/Undo stack is empty.
            Assert.Throws <InvalidOperationException>(() => historyStack.Redo("bar"));
            historyStack.Undo("third item");
            historyStack.Undo("first item");
            Assert.Equal(0, historyStack.UndoCount);
            Assert.Throws <InvalidOperationException>(() => historyStack.Undo("foo"));
        }
Example #11
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            base.OnStylusUp(e);

            Cursor = cursorMouseUp;

            if (mouseDown)
            {
                this.previewRenderer.Visible = true;
                mouseDown = false;

                if (this.savedRects.Count > 0)
                {
                    PdnRegion      saveMeRegion = Utility.RectanglesToRegion(this.savedRects.ToArray());
                    HistoryMemento ha           = new BitmapHistoryMemento(Name, Image, DocumentWorkspace,
                                                                           ActiveLayerIndex, saveMeRegion, this.ScratchSurface);
                    HistoryStack.PushNewMemento(ha);
                    saveMeRegion.Dispose();
                    this.savedRects.Clear();
                    this.ClearSavedMemory();
                }

                this.brush.Dispose();
                this.brush = null;
            }
        }
Example #12
0
 void RecordHistory(Item item, HistoryStack history)
 {
     if (!history.MoveToTop(item))
     {
         history.Push(item);
     }
 }
Example #13
0
        private void OnEnable()
        {
            EditorSceneManager.activeSceneChangedInEditMode += OnActiveSceneChanged;
            PrefabStage.prefabStageOpened += OnPrefabStageOpened;

            _forwardIcon  = EditorGUIUtility.IconContent("d_forward"); // d_forward d_forward@2x"
            _backIcon     = EditorGUIUtility.IconContent("d_back");    // d_back d_back@2x
            _dropdownIcon = EditorGUIUtility.IconContent("icon dropdown");

            _buttonOptions   = new[] { GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.MinWidth(16f), GUILayout.MaxWidth(40) };
            _dropdownOptions = new[] { GUILayout.Height(EditorGUIUtility.singleLineHeight) };

            if (_selectionHistory == null)
            {
                _selectionHistory = new HistoryStack(40);
            }
            if (_prefabHistory == null)
            {
                _prefabHistory = new HistoryStack(20);
            }
            if (_sceneHistory == null)
            {
                _sceneHistory = new HistoryStack(15);
            }

            RecordHistory(new Item(SceneManager.GetActiveScene()), _sceneHistory);
        }
Example #14
0
 public ProjectPropertiesDebug(HistoryStack historyStack, ILuaEditDocumentProject prjDoc)
 {
     _prjDoc       = prjDoc;
     _historyStack = historyStack;
     InitializeComponent();
     cboStartupFile.DisplayMember = "NodeText";
 }
 public ProjectPropertiesMain(ILuaEditDocumentProject parentDoc, HistoryStack prjHistoryStack, string title)
     : this(parentDoc)
 {
     this.Text        = title;
     _prjHistoryStack = prjHistoryStack;
     _prjHistoryStack.CurrentIndexChanged += OnHistoryStackIndexChanged;
     ConstructPageControl();
 }
        public Board(bool init = true)
        {
            // state history
            history = new HistoryStack <State>(24, i => new State());
            state   = history.Next();
            data    = new IPiece[64];

            if (init)
            {
                white  = new List <IPiece>(new IPiece[16]);
                black  = new List <IPiece>(new IPiece[16]);
                pieces = new List <IPiece>(new IPiece[32]);
                //captured = new List<IPiece>(32);

                pieces[0] = black[0] = this[0, 0] = new Rook(this, new Square(0, 0), Player.Black);
                pieces[1] = black[1] = this[0, 1] = new Knight(this, new Square(1, 0), Player.Black);
                pieces[2] = black[2] = this[0, 2] = new Bishop(this, new Square(2, 0), Player.Black);
                pieces[3] = black[3] = this[0, 3] = new Queen(this, new Square(3, 0), Player.Black);
                pieces[4] = black[4] = this[0, 4] = blackKing = new King(this, new Square(4, 0), Player.Black);
                pieces[5] = black[5] = this[0, 5] = new Bishop(this, new Square(5, 0), Player.Black);
                pieces[6] = black[6] = this[0, 6] = new Knight(this, new Square(6, 0), Player.Black);
                pieces[7] = black[7] = this[0, 7] = new Rook(this, new Square(7, 0), Player.Black);

                pieces[8]  = black[8] = this[1, 0] = new Pawn(this, new Square(0, 1), Player.Black);
                pieces[9]  = black[9] = this[1, 1] = new Pawn(this, new Square(1, 1), Player.Black);
                pieces[10] = black[10] = this[1, 2] = new Pawn(this, new Square(2, 1), Player.Black);
                pieces[11] = black[11] = this[1, 3] = new Pawn(this, new Square(3, 1), Player.Black);
                pieces[12] = black[12] = this[1, 4] = new Pawn(this, new Square(4, 1), Player.Black);
                pieces[13] = black[13] = this[1, 5] = new Pawn(this, new Square(5, 1), Player.Black);
                pieces[14] = black[14] = this[1, 6] = new Pawn(this, new Square(6, 1), Player.Black);
                pieces[15] = black[15] = this[1, 7] = new Pawn(this, new Square(7, 1), Player.Black);
                pieces[16] = white[0] = this[6, 0] = new Pawn(this, new Square(0, 6), Player.White);
                pieces[17] = white[1] = this[6, 1] = new Pawn(this, new Square(1, 6), Player.White);
                pieces[18] = white[2] = this[6, 2] = new Pawn(this, new Square(2, 6), Player.White);
                pieces[19] = white[3] = this[6, 3] = new Pawn(this, new Square(3, 6), Player.White);
                pieces[20] = white[4] = this[6, 4] = new Pawn(this, new Square(4, 6), Player.White);
                pieces[21] = white[5] = this[6, 5] = new Pawn(this, new Square(5, 6), Player.White);
                pieces[22] = white[6] = this[6, 6] = new Pawn(this, new Square(6, 6), Player.White);
                pieces[23] = white[7] = this[6, 7] = new Pawn(this, new Square(7, 6), Player.White);
                pieces[24] = white[8] = this[7, 0] = new Rook(this, new Square(0, 7), Player.White);
                pieces[25] = white[9] = this[7, 1] = new Knight(this, new Square(1, 7), Player.White);
                pieces[26] = white[10] = this[7, 2] = new Bishop(this, new Square(2, 7), Player.White);
                pieces[27] = white[11] = this[7, 3] = new Queen(this, new Square(3, 7), Player.White);
                pieces[28] = white[12] = this[7, 4] = whiteKing = new King(this, new Square(4, 7), Player.White);
                pieces[29] = white[13] = this[7, 5] = new Bishop(this, new Square(5, 7), Player.White);
                pieces[30] = white[14] = this[7, 6] = new Knight(this, new Square(6, 7), Player.White);
                pieces[31] = white[15] = this[7, 7] = new Rook(this, new Square(7, 7), Player.White);

                Start();
            }
            else
            {
                white  = new List <IPiece>();
                black  = new List <IPiece>();
                pieces = new List <IPiece>();
                //captured = new List<IPiece>();
            }
        }
        public void Redo()
        {
            if (RedoStack.Count == 0)
            {
                throw new InvalidOperationException("This is the lastest Version ");
            }

            HistoryStack.Push(Current);
            Current = RedoStack.Pop();
        }
        public void Rollback()
        {
            if (HistoryStack.Count == 0)
            {
                throw new InvalidOperationException("This is the first Version");
            }

            RedoStack.Push(Current);
            Current = HistoryStack.Pop();
        }
Example #19
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            SelectionHistoryMemento undoAction = new SelectionHistoryMemento(this.Name, this.Image, this.DocumentWorkspace);

            Selection.PerformChanging();
            Selection.SetContinuation(polygonSet, this.combineMode);
            Selection.CommitContinuation();
            Selection.PerformChanged();

            HistoryStack.PushNewMemento(undoAction);
        }
Example #20
0
        internal SessionStateInternal(SessionStateInternal parent, bool linkToGlobal, ExecutionContext context)
        {
            if (context == null)
            {
                throw PSTraceSource.NewArgumentNullException(nameof(context));
            }

            ExecutionContext = context;

            // Create the working directory stack. This
            // is used for the pushd and popd commands

            _workingLocationStack = new Dictionary <string, Stack <PathInfo> >(StringComparer.OrdinalIgnoreCase);

            // Conservative choice to limit the Set-Location history in order to limit memory impact in case of a regression.
            const int locationHistoryLimit = 20;

            _setLocationHistory = new HistoryStack <PathInfo>(locationHistoryLimit);

            GlobalScope   = new SessionStateScope(null);
            ModuleScope   = GlobalScope;
            _currentScope = GlobalScope;

            InitializeSessionStateInternalSpecialVariables(false);

            // Create the push the global scope on as
            // the starting script scope.  That way, if you dot-source a script
            // that uses variables qualified by script: it works.
            GlobalScope.ScriptScope = GlobalScope;

            if (parent != null)
            {
                GlobalScope.Parent = parent.GlobalScope;

                // Copy the drives and providers from the parent...
                CopyProviders(parent);
                // During loading of core modules, providers are not populated.
                // We set the drive information later
                if (Providers != null && Providers.Count > 0)
                {
                    CurrentDrive = parent.CurrentDrive;
                }

                // Link it to the global scope...
                if (linkToGlobal)
                {
                    GlobalScope = parent.GlobalScope;
                }
            }
            else
            {
                _currentScope.LocalsTuple = MutableTuple.MakeTuple(Compiler.DottedLocalsTupleType, Compiler.DottedLocalsNameIndexMap);
            }
        }
Example #21
0
 public void HistoryStackTestExceptions()
 {
     var stack = new HistoryStack(50);
     for (int i = 0; i < 80; i++)
     {
         stack.Push(new HistoryTestObject(i));
     }
     Assert.ExceptionExpected(typeof(ArgumentOutOfRangeException), () => { stack.TravelBack(-5); });
     Assert.ExceptionExpected(typeof(ArgumentOutOfRangeException), () => { stack.TravelBack(0); });
     Assert.ExceptionExpected(typeof(ArgumentOutOfRangeException), () => { stack.TravelReverse(-5); });
     Assert.ExceptionExpected(typeof(ArgumentOutOfRangeException), () => { stack.TravelReverse(0); });
 }
Example #22
0
 public void HistoryStackTestDropReverse()
 {
     var stack = new HistoryStack(50);
     for (int i = 0; i < 40; i++)
     {
         stack.Push(new HistoryTestObject(i));
     }
     stack.TravelBack(5);
     stack.Push(new HistoryTestObject(100));
     Assert.AreEqual(0, stack.ReverseCount);
     Assert.AreEqual(36, stack.HistoryCount);
     Assert.AreEqual(100, (int)(HistoryTestObject)stack.PeekHistory());
     Assert.AreEqual(null, stack.PeekReverse());
 }
        internal void FromXml(XmlLuaProjectDocument objectToDeserialize)
        {
            base.FromXml(objectToDeserialize);

            // Deserialize project's properties
            if (objectToDeserialize.ProjectProperties != null)
            {
                _historyStack = new HistoryStack();
                _historyStack.CurrentIndexChanged += OnHistoryStackCurrentIndexChanged;
                _projectProperties = new ProjectPropertiesMain(this, _historyStack, objectToDeserialize.ProjectProperties);
            }

            _projectProperties.SetUI(this);
        }
Example #24
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            mouseUp = true;

            if (!mouseDownSettingCloneSource)
            {
                Cursor = cursorMouseUp;
            }

            if (IsMouseLeftDown(e))
            {
                this.rendererDst.Visible = true;

                if (savedRegion != null)
                {
                    //RestoreRegion(this.savedRegion);
                    ActiveLayer.Invalidate(this.savedRegion.GetBoundsInt());
                    savedRegion.Dispose();
                    savedRegion = null;
                    Update();
                }

                if (GetStaticData().takeFrom == Point.Empty || GetStaticData().lastMoved == Point.Empty)
                {
                    return;
                }

                if (historyRects.Count > 0)
                {
                    PdnRegion saveMeRegion;

                    Rectangle[] rectsRO;
                    int         rectsROLength;
                    this.historyRects.GetArrayReadOnly(out rectsRO, out rectsROLength);
                    saveMeRegion = Utility.RectanglesToRegion(rectsRO, 0, rectsROLength);

                    PdnRegion simplifiedRegion = Utility.SimplifyAndInflateRegion(saveMeRegion);
                    SaveRegion(simplifiedRegion, simplifiedRegion.GetBoundsInt());

                    historyRects = new Vector <Rectangle>();

                    HistoryMemento ha = new BitmapHistoryMemento(Name, Image, DocumentWorkspace, ActiveLayerIndex,
                                                                 simplifiedRegion, this.ScratchSurface);

                    HistoryStack.PushNewMemento(ha);
                    this.ClearSavedMemory();
                }
            }
        }
 public ProjectPropertiesMain(ILuaEditDocumentProject parentDoc, HistoryStack prjHistoryStack, XmlLuaProjectProperties xmlData)
     : this(parentDoc, prjHistoryStack)
 {
     this.BuildOutputDirectory  = xmlData.BuildOutputDir;
     this.CommandLineArguments  = xmlData.CmdLineArgs;
     this.ExternalProgram       = xmlData.ExternalProgram;
     this.PostBuildEventCmdLine = xmlData.PostBuildEventCmdLine;
     this.PreBuildEventCmdLine  = xmlData.PreBuildEventCmdLine;
     this.RemoteMachineName     = xmlData.RemoteMachineName;
     this.RemotePort            = xmlData.RemotePort;
     this.RunPostBuildEvent     = xmlData.RunPostBuildEvent;
     this.StartAction           = xmlData.StartAction;
     this.StartupFileName       = xmlData.StartupFileName;
     this.UseRemoteMachine      = xmlData.UseRemoteMachine;
     this.WorkingDirectory      = xmlData.WorkingDir;
 }
Example #26
0
 public void HistoryStackTestBasic()
 {
     var stack = new HistoryStack(50);
     for (int i = 0; i < 80; i++)
     {
         stack.Push(new HistoryTestObject(i));
     }
     for (int i = 80 - 1; i >= 80 - 50; i--)
     {
         Assert.AreEqual(i, (int)(HistoryTestObject)stack.PopHistory());
         Assert.AreEqual(i, (int)(HistoryTestObject)stack.PeekReverse());
     }
     for (int i = 80 - 50; i < 80; i++)
     {
         Assert.AreEqual(i, (int)(HistoryTestObject)stack.PopReverse());
         Assert.AreEqual(i, (int)(HistoryTestObject)stack.PeekHistory());
     }
 }
 public ProjectPropertiesMain(ILuaEditDocumentProject parentDoc, HistoryStack prjHistoryStack, ILuaEditProjectProperties copy)
     : this(parentDoc, prjHistoryStack)
 {
     if (copy != null)
     {
         this.BuildOutputDirectory  = copy.BuildOutputDirectory;
         this.CommandLineArguments  = copy.CommandLineArguments;
         this.ExternalProgram       = copy.ExternalProgram;
         this.PostBuildEventCmdLine = copy.PostBuildEventCmdLine;
         this.PreBuildEventCmdLine  = copy.PreBuildEventCmdLine;
         this.RemoteMachineName     = copy.RemoteMachineName;
         this.RemotePort            = copy.RemotePort;
         this.RunPostBuildEvent     = copy.RunPostBuildEvent;
         this.StartAction           = copy.StartAction;
         this.StartupFileName       = copy.StartupFileName;
         this.UseRemoteMachine      = copy.UseRemoteMachine;
         this.WorkingDirectory      = copy.WorkingDirectory;
     }
 }
Example #28
0
        void ShowDropdown(Rect rect, HistoryStack history, bool isSelectionDropdown)
        {
            GenericMenu menu = new GenericMenu();

            history.RemoveInvalidItems();

            if (history.Count == 0)
            {
                menu.AddDisabledItem(new GUIContent("No History"));
            }
            else
            {
                for (int i = 0; i < history.Count; i++)
                {
                    AddDropdownChoice(menu, history[i].IsOpened(isSelectionDropdown), history[i].Name, OpenHistoryItem, history[i], history);
                }
            }

            menu.DropDown(rect);
        }
Example #29
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (this.inCurveMode)
            {
                switch (e.KeyChar)
                {
                case '\r':     // Enter
                    e.Handled = true;
                    CommitShape();
                    break;

                case (char)27:     // Escape
                    e.Handled = true;
                    HistoryStack.StepBackward();
                    break;
                }
            }

            base.OnKeyPress(e);
        }
Example #30
0
 public void HistoryStackTestTravel()
 {
     var stack = new HistoryStack(50);
     for (int i = 0; i < 80; i++)
     {
         stack.Push(new HistoryTestObject(i));
     }
     Assert.AreEqual(0, stack.ReverseCount);
     Assert.AreEqual(60, (int)(HistoryTestObject)stack.TravelBack(20));
     Assert.AreEqual(20, stack.ReverseCount);
     Assert.AreEqual(30, stack.HistoryCount);
     Assert.AreEqual(74, (int)(HistoryTestObject)stack.TravelReverse(15));
     Assert.AreEqual(5, stack.ReverseCount);
     Assert.AreEqual(45, stack.HistoryCount);
     Assert.AreEqual(79, (int)(HistoryTestObject)stack.TravelReverse(5));
     Assert.AreEqual(0, stack.ReverseCount);
     Assert.AreEqual(50, stack.HistoryCount);
     Assert.AreEqual(30, (int)(HistoryTestObject)stack.TravelBack(50));
     Assert.AreEqual(50, stack.ReverseCount);
     Assert.AreEqual(0, stack.HistoryCount);
 }
 public WorldHistory()
 {
     undoStack = new HistoryStack(MAX_HISTORY_ITEMS);
     redoStack = new HistoryStack(MAX_HISTORY_ITEMS);
 }
Example #32
0
 public void Reset()
 {
     _history = null;
     _index = 0;
 }
Example #33
0
        private bool LoadHistory()
        {
            if (null != _history)
            {
                return false;
            }

            _history = new HistoryStack();
            IEnumerable<ErrorRecord> error;
            var items = _executor.ExecuteCommand("get-history", out error, ExecutionOptions.DoNotRaisePipelineException);
            if (null == items)
            {
                return false;
            }

            items.ToList().ForEach(
                item =>
                    {
                        var o = item.BaseObject ?? item;
                        if (null == o)
                        {
                            return;
                        }
                        _history.Add(o.ToString());
                    });
            _index = _history.Count;

            return true;
        }