コード例 #1
0
        protected override void undoToolStripMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (stack.Count == 0)
            {
                return;
            }

            imageList[imageIndex] = stack.Pop();
            displayImage();
        }
コード例 #2
0
        /// <summary>
        /// Command callback.
        /// Clears the kanji details view model.
        /// </summary>
        private void OnClearSelectedKanji()
        {
            SetKanjiDetailsVm(null);
            KanjiListVm.ClearSelection();

            int navigationHistorySize = _navigationHistory.Count;

            for (int i = 0; i < navigationHistorySize; i++)
            {
                _navigationHistory.Pop();
            }
            RaisePropertyChanged("CanNavigateBack");
        }
コード例 #3
0
        /// <summary>
        /// Command callback.
        /// Navigates back in the navigation history.
        /// </summary>
        private void OnNavigateBack()
        {
            try
            {
                KanjiNavigationEntry entry = _navigationHistory.Pop();
                RaisePropertyChanged("CanNavigateBack");

                // Apply the filter.
                _kanjiFilter = entry.KanjiFilter;
                KanjiFilterVm.SetFilter(_kanjiFilter);
                if (_kanjiDetailsVm != null)
                {
                    KanjiListVm.Navigate(_kanjiFilter,
                                         _kanjiDetailsVm.KanjiEntity.DbKanji);
                }
                else
                {
                    KanjiListVm.SetFilter(_kanjiFilter);
                }

                // Reset the kanji details viewmodel.
                SetKanjiDetailsVm(entry.KanjiDetailsVm);
            }
            catch (InvalidOperationException)
            {
                // The command was fired several times in a
                // row and the navigation history was empty.
                //
                // No problem, just ignore the exception.
            }
        }
コード例 #4
0
        public void TestPopOnlyItem()
        {
            _stack.Push("One");
            Assert.That(_stack.Count, Is.EqualTo(1));

            Assert.That(_stack.Peek(), Is.EqualTo("One"));
            Assert.That(_stack.Pop(), Is.EqualTo("One"));
            Assert.That(_stack.Count, Is.EqualTo(0));
            Assert.That(_stack.Peek(), Is.Null);

            _stack.Push("Two");
            Assert.That(_stack.Count, Is.EqualTo(1));

            var array = _stack.ToArray();

            Assert.That(array.Length, Is.EqualTo(1));
            Assert.That(array[0], Is.EqualTo("Two"));
        }
コード例 #5
0
        public void FixedSizeStack_CanPop()
        {
            FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
            stack.Push(1);
            Assert.AreEqual(1, stack.Count);

            int popped = stack.Pop();
            Assert.AreEqual(1, popped);
            Assert.AreEqual(0, stack.Count);
        }
コード例 #6
0
        protected override void Undo_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (stack.Count == 0)
            {
                return;
            }

            System.Drawing.Image image = stack.Pop();
            imageList[imageIndex] = image;
            displayImage();
        }
コード例 #7
0
ファイル: BTUndoSystem.cs プロジェクト: zhaocy1217/War-Clash
        public static void Redo()
        {
            if (m_redoStack.Count > 0)
            {
                BTUndoState undoState = m_redoStack.Pop();
                if (undoState.CanRedo)
                {
                    undoState.Redo();
                    if (undoState.CanUndo)
                    {
                        m_undoStack.Push(undoState);
                    }
                }

                while (m_redoStack.Count > 0 && !m_redoStack.Peek().CanRedo)
                {
                    m_redoStack.Pop();
                }
            }
        }
コード例 #8
0
ファイル: GUIWithImage.cs プロジェクト: dominhhai/VietOCR
        protected override void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (stack.Count == 0)
            {
                return;
            }

            Image image = stack.Pop();

            imageList[imageIndex]  = image;
            this.pictureBox1.Image = new Bitmap(image);
        }
コード例 #9
0
ファイル: PlayerUndo.cs プロジェクト: kremnev8/DSP-Mods
        internal bool TryUndo(out string message, out bool sound)
        {
            sound   = false;
            message = "";
            if (undoStack.Count <= 0)
            {
                sound   = true;
                message = "UndoHistoryEmptyMessage";
                return(true);
            }
            if (GameMain.localPlanet?.factory == null)
            {
                return(false);
            }
            if (GameMain.mainPlayer?.controller == null)
            {
                return(false);
            }

            PlanetFactory      factory     = GameMain.localPlanet.factory;
            PlayerAction_Build actionBuild = GameMain.mainPlayer.controller.actionBuild;

            IUndoAction action = undoStack.Pop();

            bool success = false;

            try
            {
                success = action.Undo(factory, actionBuild);
            }
            catch (Exception e)
            {
                BlueprintTweaksPlugin.logger.LogWarning($"Failed to undo, message: {e.Message}, stacktrace:\n{e.StackTrace}");
            }

            if (success)
            {
                message = "UndoSuccessText";
                redoStack.Push(action);
            }
            else
            {
                message = "UndoFailureText";
                sound   = true;
                notifyBuildListeners.Remove(action);
                notifyDismantleListeners.Remove(action);
            }

            return(true);
        }
コード例 #10
0
ファイル: BTUndoSystem.cs プロジェクト: zhaocy1217/War-Clash
        public static void BeginUndoGroup(string title)
        {
            if (m_undoStack.Count > 0)
            {
                BTUndoGroup oldGroup = m_undoStack.Peek() as BTUndoGroup;
                if (oldGroup != null && oldGroup.IsOpen)
                {
                    Debug.LogWarningFormat("You have to call BTUndoSystem.EndUndoGroup before begining a new group. Old group is '{0}', new group is '{1}'", oldGroup.Title, title);
                    if (oldGroup.IsEmpty)
                    {
                        m_undoStack.Pop();
                    }
                    else
                    {
                        oldGroup.Close();
                    }
                }
            }

            BTUndoGroup group = new BTUndoGroup(title);

            m_undoStack.Push(group);
        }
コード例 #11
0
        private BTNode PopNode()
        {
            var index = traversal.Pop();
            var node  = tree.Nodes[index];

            if (node.IsComposite())
            {
                for (int i = 0; i < node.ChildCount(); i++)
                {
                    node.GetChildAt(i).OnCompositeParentExit();
                }
            }

            node.OnExit();

            __debug($"exit *{LastExecutedStatus}* <color=green>{node.name}: {node.preOrderIndex}</color>");
            __debug($"------traversal pop: {string.Join(",", traversal)}");

            return(node);
        }
コード例 #12
0
 public void FixedSizeStack_PopThrowsWhenEmpty()
 {
     FixedSizeStack<int> stack = new FixedSizeStack<int>(1);
     try
     {
         stack.Pop();
         Assert.Fail("Pop did not throw an exception when the stack was empty.");
     }
     catch (InvalidOperationException)
     {
         // expected
     }
 }