private void menuEdit_Redo_Click(object sender, EventArgs e) { UndoMgr undo = ActiveUndo(); if (undo == null) { return; } undo.ApplyRedo(); HandleEverythingChanged(); }
public void Test_AddSprite_draw_redo() { Sprite s = m_ss.AddSprite(1, 1, "sample", 0, "", 0, m_mgr); Assert.IsNotNull(s); Assert.AreEqual(1, m_mgr.Count); Assert.AreEqual(0, m_mgr.Current); Assert.IsTrue(m_mgr.CanUndo()); Assert.IsFalse(m_mgr.CanRedo()); // Draw a pixel. int x1 = 3, y1 = 4; int color1 = 1; s.SetPixel(x1, y1, color1); Assert.AreEqual(color1, s.GetPixel(x1, y1)); s.RecordUndoAction("pencil1", m_mgr); Assert.AreEqual(2, m_mgr.Count); Assert.AreEqual(1, m_mgr.Current); UndoAction_SpriteEdit u1 = m_mgr.GetCurrent() as UndoAction_SpriteEdit; Assert.AreEqual(0, u1.Before.tiles[0].pixels[x1, y1]); Assert.AreEqual(color1, u1.After.tiles[0].pixels[x1, y1]); Assert.IsTrue(m_mgr.CanUndo()); Assert.IsFalse(m_mgr.CanRedo()); // Undo the pixel draw. m_mgr.ApplyUndo(); Assert.AreEqual(2, m_mgr.Count); Assert.AreEqual(0, m_mgr.Current); // Pencil mark reverted. Assert.AreEqual(0, s.GetPixel(x1, y1)); Assert.IsTrue(m_mgr.CanUndo()); Assert.IsTrue(m_mgr.CanRedo()); // Redo the pixel draw. m_mgr.ApplyRedo(); Assert.AreEqual(2, m_mgr.Count); Assert.AreEqual(1, m_mgr.Current); Assert.AreEqual(color1, s.GetPixel(x1, y1)); Assert.IsTrue(m_mgr.CanUndo()); Assert.IsFalse(m_mgr.CanRedo()); }