Exemple #1
0
        public SkinManager(string filePath, PictureBox pictureBox)
        {
            _pictureBox = pictureBox;

            // Brushes
            _brushPerType = new Dictionary<ComponentType, Brush>
            {
                {ComponentType.Key, new SolidBrush(Color.FromArgb(Alpha, Color.Blue))},
                {ComponentType.Screen, new SolidBrush(Color.FromArgb(Alpha, Color.Red))},
                {ComponentType.Maximized, new SolidBrush(Color.FromArgb(Alpha, Color.Green))}
            };

            // Path
            SkinPath = filePath;

            _undo = new UndoRedoManager<Skin>(10);
            _skin = new Skin(SkinPath);
            _undo.SaveState(_skin);
            _undo.UndoRedoStateChanged += (o, args) => OnComponentsChanged();

            _pictureBox.Size = new Size(_skin.SkinSize.Width * 3, _skin.SkinSize.Height * 3);

            // PictureBox events
            pictureBox.Paint += (o, args) => Paint(args.Graphics);
            pictureBox.MouseDown += pictureBox_MouseDown;
            pictureBox.MouseUp += pictureBox_MouseUp;
            pictureBox.MouseLeave += pictureBox_MouseLeave;
            pictureBox.MouseMove += pictureBox_MouseMove;
        }
Exemple #2
0
        public Board(Point mapSize, Point centerPoint, MultiBoard parent, ContextMenuStrip menu, ItemTypes visibleTypes, ItemTypes editedTypes)
        {
            this.uid = Interlocked.Increment(ref uidCounter);
            this.MapSize = mapSize;
            this.centerPoint = centerPoint;
            this.parent = parent;
            this.visibleTypes = visibleTypes;
            this.editedTypes = editedTypes;
            this.menu = menu;

            boardItems = new BoardItemsManager(this);
            undoRedoMan = new UndoRedoManager(this);
            mouse = new Mouse(this);
            serMan = new SerializationManager(this);
        }
        public void UndoRedoManagerCanRedo()
        {
            UndoRedoManager undoRedoManager = new UndoRedoManager();

             BookCollection myBooks = new BookCollection();
             myBooks.Name = "A few of my favorite books";
             myBooks.Library.Add( ClockWorkOrange );
             myBooks.Library.Add( DarwinsGod );
             myBooks.Library.Add( SoftwareEstimates );
             myBooks.FavoriteBook = ClockWorkOrange;

             // Originally, cannot redo, there is nothing to redo.
             Assert.IsFalse( undoRedoManager.CanRedo );

             // Add an item, still nothing to redo
             myBooks.Name = "Some Books";
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, String>( myBooks, "Name", UndoableActions.Modify, "A few of my favorite books", "Some Books" ) );
             Assert.IsFalse( undoRedoManager.CanRedo );

             // Undo this item, we now have something to redo
             undoRedoManager.Undo();
             Assert.IsTrue( undoRedoManager.CanRedo );

             // Redo it, and we no longer have anything to redo
             undoRedoManager.Redo();
             Assert.IsFalse( undoRedoManager.CanRedo );

             // Undo it, make a change, undo that one, have two items to redo
             undoRedoManager.Undo();
             myBooks.FavoriteBook = MereChristianity;
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "FavoriteBook", UndoableActions.Modify, ClockWorkOrange, MereChristianity ) );
             undoRedoManager.Undo();

             Assert.IsTrue( undoRedoManager.CanRedo );
             undoRedoManager.Redo();
             Assert.IsTrue( undoRedoManager.CanRedo );
             undoRedoManager.Redo();
             Assert.IsFalse( undoRedoManager.CanRedo );
        }
        public void UndoRedoManagerCanUndo()
        {
            UndoRedoManager undoRedoManager = new UndoRedoManager();

             BookCollection myBooks = new BookCollection();
             myBooks.Name = "A few of my favorite books";
             myBooks.Library.Add( ClockWorkOrange );
             myBooks.Library.Add( DarwinsGod );
             myBooks.Library.Add( SoftwareEstimates );
             myBooks.FavoriteBook = ClockWorkOrange;

             // Originally, cannot undo, there is nothing to undo.
             Assert.IsFalse( undoRedoManager.CanUndo );

             // Add an item, can now undo
             myBooks.Name = "Some Books";
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, String>( myBooks, "Name", UndoableActions.Modify, "A few of my favorite books", "Some Books" ) );
             Assert.IsTrue( undoRedoManager.CanUndo );

             // After undoing the one change, there is nothing to undo
             undoRedoManager.Undo();
             Assert.IsFalse( undoRedoManager.CanUndo );

             // After redoing, we should be able to undo it again
             undoRedoManager.Redo();
             Assert.IsTrue( undoRedoManager.CanUndo );

             // Make another change, then undo it, should still be able to undo as the first one is still in there.
             myBooks.FavoriteBook = MereChristianity;
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "FavoriteBook", UndoableActions.Modify, ClockWorkOrange, MereChristianity ) );
             Assert.IsTrue( undoRedoManager.CanUndo );

             undoRedoManager.Undo();
             Assert.IsTrue( undoRedoManager.CanUndo );

             undoRedoManager.Undo();
             Assert.IsFalse( undoRedoManager.CanUndo );
        }
Exemple #5
0
 private void menuEditRedo_Click(object sender, EventArgs e)
 {
     UndoRedoManager.Redo();
 }
Exemple #6
0
        private void PerformUserDrawAction()
        {
            Tileset tileset = this.SelectedTileset.Res;

            if (tileset == null)
            {
                return;
            }

            TilesetAutoTileInput autoTile = this.SelectedAutoTile;

            if (autoTile == null)
            {
                return;
            }

            int tileIndex = this.TilesetView.HoveredTileIndex;

            if (tileIndex < 0 || tileIndex > tileset.TileCount)
            {
                return;
            }

            // Determine data before the operation, and set up data for afterwards
            bool lastIsBaseTile           = autoTile.BaseTileIndex == tileIndex;
            bool newIsBaseTile            = lastIsBaseTile;
            TilesetAutoTileItem lastInput = (autoTile.TileInput.Count > tileIndex) ?
                                            autoTile.TileInput[tileIndex] :
                                            default(TilesetAutoTileItem);
            TilesetAutoTileItem newInput = lastInput;

            // Determine how data is modified due to our user operation
            if (this.userDrawMode == AutoTileDrawMode.Add)
            {
                if (this.isExternalDraw)
                {
                    newInput.Neighbours         = TileConnection.None;
                    newInput.ConnectsToAutoTile = true;
                    newInput.IsAutoTile         = false;
                    newIsBaseTile = false;
                }
                else if (this.isBaseTileDraw)
                {
                    newInput.Neighbours         = TileConnection.All;
                    newInput.IsAutoTile         = true;
                    newInput.ConnectsToAutoTile = false;
                    newIsBaseTile = true;
                }
                else
                {
                    newInput.Neighbours        |= this.hoveredArea;
                    newInput.IsAutoTile         = true;
                    newInput.ConnectsToAutoTile = false;
                }
            }
            else if (this.userDrawMode == AutoTileDrawMode.Remove)
            {
                if (this.isExternalDraw || this.isBaseTileDraw || this.hoveredArea == TileConnection.None)
                {
                    newInput.Neighbours         = TileConnection.None;
                    newInput.ConnectsToAutoTile = false;
                    newInput.IsAutoTile         = false;
                    newIsBaseTile = false;
                }
                else
                {
                    newInput.Neighbours &= ~this.hoveredArea;
                    newInput.IsAutoTile  = (newInput.Neighbours != TileConnection.None);
                }
            }

            // Apply the new, modified data to the actual data using an UndoRedo operation
            if (newIsBaseTile != lastIsBaseTile)
            {
                UndoRedoManager.Do(new EditPropertyAction(
                                       null,
                                       TilemapsReflectionInfo.Property_TilesetAutoTileInput_BaseTile,
                                       new object[] { autoTile },
                                       new object[] { newIsBaseTile?tileIndex: -1 }));
            }
            if (!object.Equals(lastInput, newInput))
            {
                UndoRedoManager.Do(new EditTilesetAutoTileItemAction(
                                       tileset,
                                       autoTile,
                                       tileIndex,
                                       newInput));
            }
        }
 private void EditorListIndexSetter(PropertyInfo indexer, IEnumerable <object> targetObjects, IEnumerable <object> values, int index)
 {
     UndoRedoManager.Do(new EditPropertyAction(this, indexer, targetObjects, values, new object[] { index }));
 }
 private void EditorMemberPropertySetter(PropertyInfo property, IEnumerable <object> targetObjects, IEnumerable <object> values)
 {
     UndoRedoManager.Do(new EditPropertyAction(this, property, targetObjects, values));
 }
 public HaRepackerMainPanel()
 {
     InitializeComponent();
     MainSplitContainer.Parent = MainDockPanel;
     undoRedoMan = new UndoRedoManager(this);
 }
Exemple #10
0
 /// <summary>Initializes the document. </summary>
 /// <param name="data">The JSON data. </param>
 /// <param name="dispatcher">The UI dispatcher. </param>
 public void Initialize(JsonObjectModel data, IDispatcher dispatcher)
 {
     UndoRedoManager = new UndoRedoManager(data, dispatcher);
     Data            = data;
 }
Exemple #11
0
 public virtual void Redo()
 {
     UndoRedoManager.Redo();
 }
Exemple #12
0
        public override bool OnKeyDown(KeyboardKeyEventArgs e)
        {
            if (ModifierKeys.AltPressed || !IsFocused)
            {
                return(false);
            }

            //base.OnKeyDown (e);

            switch (e.Key)
            {
            case Key.ShiftLeft:
            case Key.ShiftRight:
                //ResetSelection ();
                return(true);

            case Key.Left:
                if (e.Control)
                {
                    MovePrevWord();
                }
                else
                {
                    MovePrevChar();
                }
                SetSelection(e.Shift);
                break;

            case Key.Right:
                if (e.Control)
                {
                    MoveNextWord();
                }
                else
                {
                    MoveNextChar();
                }
                SetSelection(e.Shift);
                break;

            case Key.Home:
                MoveHome();
                SetSelection(e.Shift);
                break;

            case Key.End:
                MoveEnd();
                SetSelection(e.Shift);
                break;

            case Key.PageUp:
            case Key.PageDown:
                SetSelection(e.Shift);
                return(true);

            case Key.BackSpace:
                if (SelLength > 0)
                {
                    //this.SetUndoDelete (CursorPosition, 0);
                    Delete();
                }
                else if (CursorPosition > 0)
                {
                    UndoRedoManager.Do(new UndoRedoBackspaceMemento {
                        ScrollOffset = ScrollOffset,
                        SelStart     = SelStart,
                        SelLength    = SelLength,
                        SelectedText = SelectedText,
                        Position     = CursorPosition - 1,
                        Data         = Text.StrMid(CursorPosition, 1),
                    });
                    DeleteChar(--CursorPosition);
                }
                ResetSelection();
                break;

            case Key.C:
                if (e.Control)
                {
                    Copy();
                }
                break;

            case Key.V:
                if (e.Control)
                {
                    Paste();
                }
                break;

            case Key.X:
                if (e.Control)
                {
                    Cut();
                }
                break;

            case Key.Delete:
                if (e.Shift)
                {
                    Cut();
                }
                else
                {
                    Delete();
                }
                break;

            case Key.Insert:
                if (e.Control)
                {
                    Copy();
                }
                else if (e.Shift)
                {
                    Paste();
                }
                break;

            case Key.A:
                if (e.Control)
                {
                    SelectAll();
                }
                break;

            case Key.Y:                 // OpenTK sends an Y for a Z
                if (e.Control)
                {
                    Undo();
                }
                break;

            case Key.Z:             // OpenTK sends an Z for a Y
                if (e.Control)
                {
                    Redo();
                }
                break;

            case Key.Escape:
                if (HideSelection)
                {
                    SelectNone();
                }
                return(false);

            case Key.Enter:
                return(false);

            /***
             * case Key.Tab:
             *      if (!AllowTabKey)
             *              return false;
             *      InsertString (CursorPosition++, new String (' ', 4));
             *      CursorPosition += 3;
             *      break;
             ***/
            default:
                //this.LogDebug ("OnKeyDown not handled: {0}", e.Key.ToString ());
                //return false;
                break;
            }

            EnsureCursorVisible();
            CursorOn = true;
            Invalidate();
            return(true);
        }
Exemple #13
0
        /***
         * public void InsertRange (string text)
         * {
         *      InsertString (CursorPosition, text);
         * }
         ***/

        protected override void CleanupManagedResources()
        {
            UndoRedoManager.Dispose();
            base.CleanupManagedResources();
        }
Exemple #14
0
        private void GenerateTilemaps()
        {
            // Create a parent transform object, so we don't clutter the Scene too much
            GameObject rootObject = new GameObject("Map");

            rootObject.AddComponent <Transform>();

            // Generate all tilemap layers
            List <Tilemap> generatedTilemaps = new List <Tilemap>();

            for (int i = 0; i < this.settings.LayerCount; i++)
            {
                string layerName =
                    (i == 0 ? "BaseLayer" :
                     (i == this.settings.LayerCount - 1 ? "TopLayer" :
                      (this.settings.LayerCount == 3 ? "UpperLayer" :
                       ("UpperLayer" + i.ToString()))));

                GameObject layerObj = new GameObject(layerName, rootObject);
                layerObj.AddComponent <Transform>();

                Tilemap tilemap = layerObj.AddComponent <Tilemap>();
                TilemapsSetupUtility.SetupTilemap(
                    tilemap,
                    this.settings.Tileset,
                    this.settings.MapSize.X,
                    this.settings.MapSize.Y,
                    i > 0);

                TilemapRenderer renderer = layerObj.AddComponent <TilemapRenderer>();
                renderer.DepthOffset = -0.01f * i;
                if (this.settings.DeepTilemap)
                {
                    renderer.TileDepthMode  = TileDepthOffsetMode.World;
                    renderer.TileDepthScale = 0.01f;
                }
                else
                {
                    renderer.TileDepthMode  = TileDepthOffsetMode.Flat;
                    renderer.TileDepthScale = 0.0f;
                }

                generatedTilemaps.Add(tilemap);
            }

            // Generate a collision layer when requested
            if (this.settings.GenerateCollisionShapes)
            {
                GameObject layerObj = new GameObject("WorldGeometry", rootObject);
                layerObj.AddComponent <Transform>();

                RigidBody body = layerObj.AddComponent <RigidBody>();
                body.BodyType = BodyType.Static;

                TilemapCollider          collider         = layerObj.AddComponent <TilemapCollider>();
                TilemapCollisionSource[] collisionSources = new TilemapCollisionSource[generatedTilemaps.Count];
                for (int i = 0; i < generatedTilemaps.Count; i++)
                {
                    collisionSources[i].Layers        = TileCollisionLayer.Layer0;
                    collisionSources[i].SourceTilemap = generatedTilemaps[i];
                }
                collider.RoundedCorners  = true;
                collider.CollisionSource = collisionSources;
            }

            // Add the new objects to the current Scene as an UndoRedo operation.
            UndoRedoManager.Do(new CreateGameObjectAction(
                                   null,
                                   rootObject));
        }
Exemple #15
0
        protected override void okButton_Click(object sender, EventArgs e)
        {
            lock (item.Board.ParentControl)
            {
                List <UndoRedoAction> actions = new List <UndoRedoAction>();
                if (xInput.Value != item.X || yInput.Value != item.Y)
                {
                    actions.Add(UndoRedoManager.ItemMoved(item, new Microsoft.Xna.Framework.Point(item.X, item.Y), new Microsoft.Xna.Framework.Point((int)xInput.Value, (int)yInput.Value)));
                    item.Move((int)xInput.Value, (int)yInput.Value);
                }
                if (actions.Count > 0)
                {
                    item.Board.UndoRedoMan.AddUndoBatch(actions);
                }

                item.pt = Program.InfoManager.PortalTypeById[ptComboBox.SelectedIndex];
                switch (item.pt)
                {
                case PortalType.PORTALTYPE_STARTPOINT:
                    item.pn               = "sp";
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = null;
                    item.script           = null;
                    item.onlyOnce         = null;
                    item.hideTooltip      = null;
                    break;

                case PortalType.PORTALTYPE_INVISIBLE:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_VISIBLE:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_COLLISION:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = GetOptionalInt(rangeEnable, hRangeBox);
                    item.vRange           = GetOptionalInt(rangeEnable, vRangeBox);
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_CHANGABLE:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_CHANGABLE_INVISIBLE:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_TOWNPORTAL_POINT:
                    item.pn               = "tp";
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = null;
                    item.script           = null;
                    item.onlyOnce         = null;
                    item.hideTooltip      = null;
                    break;

                case PortalType.PORTALTYPE_SCRIPT:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = null;
                    item.script           = scriptBox.Text;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_SCRIPT_INVISIBLE:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = null;
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_COLLISION_SCRIPT:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = scriptBox.Text;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_HIDDEN:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_SCRIPT_HIDDEN:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_COLLISION_VERTICAL_JUMP:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = null;
                    item.verticalImpact   = null;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_COLLISION_CUSTOM_IMPACT:
                    item.pn               = pnBox.Text;
                    item.tm               = 999999999;
                    item.tn               = "";
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = GetOptionalInt(hImpactEnable, hImpactBox);
                    item.verticalImpact   = (int)vImpactBox.Value;
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;

                case PortalType.PORTALTYPE_COLLISION_UNKNOWN_PCIG:
                    item.pn               = pnBox.Text;
                    item.tm               = thisMap.Checked ? item.Board.MapInfo.id : (int)tmBox.Value;
                    item.tn               = tnBox.Text;
                    item.hRange           = null;
                    item.vRange           = null;
                    item.horizontalImpact = GetOptionalInt(hImpactEnable, hImpactBox);
                    item.verticalImpact   = GetOptionalInt(vImpactEnable, vImpactBox);
                    item.delay            = GetOptionalInt(delayEnable, delayBox);
                    item.script           = null;
                    item.onlyOnce         = onlyOnce.Checked;
                    item.hideTooltip      = hideTooltip.Checked;
                    break;
                }

                if (portalImageList.SelectedItem != null && Program.InfoManager.GamePortals.ContainsKey(Program.InfoManager.PortalTypeById[ptComboBox.SelectedIndex]))
                {
                    item.image = (string)portalImageList.SelectedItem;
                }
            }
            Close();
        }
Exemple #16
0
        public override DataItem LoadData(XElement element, UndoRedoManager undoRedo)
        {
            var item = new StructItem(this, undoRedo);

            if (Collapse)
            {
                var split = element.Value.Split(new string[] { Seperator }, StringSplitOptions.None);

                if (split.Length == Children.Count)
                {
                    for (int i = 0; i < split.Length; i++)
                    {
                        var      data      = split[i];
                        var      def       = Children[i] as PrimitiveDataDefinition;
                        DataItem childItem = def.LoadFromString(data, undoRedo);
                        item.Children.Add(childItem);
                    }
                }
                else
                {
                    foreach (var def in Children)
                    {
                        var child = def.CreateData(undoRedo);
                        item.Children.Add(child);
                    }
                }
            }
            else
            {
                var createdChildren = new List <DataItem>();

                var commentTexts = Children.Where(e => e is CommentDefinition).Select(e => (e as CommentDefinition).Text);

                foreach (var def in Children)
                {
                    var name = def.Name;

                    var els = element.Elements(name);

                    if (els.Count() > 0)
                    {
                        var prev = els.First().PreviousNode as XComment;
                        if (prev != null)
                        {
                            var comment = new CommentDefinition().LoadData(prev, undoRedo);
                            if (!commentTexts.Contains(comment.TextValue))
                            {
                                item.Children.Add(comment);
                            }
                        }

                        if (def is CollectionDefinition)
                        {
                            CollectionItem childItem = (CollectionItem)def.LoadData(els.First(), undoRedo);
                            if (childItem.Children.Count == 0)
                            {
                                var dummyEl = new XElement(els.First().Name);
                                foreach (var el in els)
                                {
                                    dummyEl.Add(el);
                                }

                                childItem = (CollectionItem)def.LoadData(dummyEl, undoRedo);
                            }

                            item.Children.Add(childItem);
                        }
                        else
                        {
                            DataItem childItem = def.LoadData(els.First(), undoRedo);
                            item.Children.Add(childItem);
                        }
                    }
                    else
                    {
                        DataItem childItem = def.CreateData(undoRedo);
                        item.Children.Add(childItem);
                    }
                }

                if (element.LastNode is XComment)
                {
                    var comment = new CommentDefinition().LoadData(element.LastNode as XComment, undoRedo);
                    if (!commentTexts.Contains(comment.TextValue))
                    {
                        item.Children.Add(comment);
                    }
                }
            }

            foreach (var att in Attributes)
            {
                var      el      = element.Attribute(att.Name);
                DataItem attItem = null;

                if (el != null)
                {
                    attItem = att.LoadData(new XElement(el.Name, el.Value.ToString()), undoRedo);
                }
                else
                {
                    attItem = att.CreateData(undoRedo);
                }
                item.Attributes.Add(attItem);
            }

            foreach (var child in item.Attributes)
            {
                child.UpdateVisibleIfBinding();
            }
            foreach (var child in item.Children)
            {
                child.UpdateVisibleIfBinding();
            }

            return(item);
        }
 /// <summary>
 /// Met à jour les états des boutons UI liés à la gestion d'historique
 /// </summary>
 /// <param name="manager">Le gestionnaire d'historique courant</param>
 private void RefreshUndoRedoButtonState(UndoRedoManager<MemoryStream> manager)
 {
     this.toolStripButtonUndo.Enabled = manager != null ? manager.CanUndo : false;
     this.toolStripButtonRedo.Enabled = manager != null ? manager.CanRedo : false;
     this.toolStripMenuItemUndo.Enabled = manager != null ? manager.CanUndo : false;
     this.toolStripMenuItemRedo.Enabled = manager != null ? manager.CanRedo : false;
 }
        /// <summary>
        /// Initialise tous les attributs de l'objet et créer les liens
        /// </summary>
        private void Initialize()
        {
            this.InitializeComponent();
            this.HideOnClose = false;
            this.AllowEndUserDocking = false;
            this.mapOrigin = new GameVector2();
            this.IsGridActived = true;
            this.IsSaved = false;
            this.IsTilesetSelectionShown = true;
            this.State = GameEditorState.Default;
            this.gridColor = GridPenColor;
            this.gridColor.DashStyle = DashStyle.Dash;
            this.gridColor.Alignment = PenAlignment.Center;
            this.gridColor.DashOffset = 3.4f;
            this.mouseLocation = new Point();
            this.location = new GameVector2();
            this.oldLocation = new Point();
            this.selectedLayerIndex = 0;
            this.mouseReleased = true;

            this.undoRedoManager = new UndoRedoManager<MemoryStream>();
            this.undoRedoManager.UndoHappened += UndoRedoSystem_UndoHappened;
            this.undoRedoManager.RedoHappened += UndoRedoSystem_RedoHappened;

            this.RefreshScrollComponents();
        }
Exemple #19
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            GameObject selGameObj   = this.selectedBody != null ? this.selectedBody.GameObj : null;
            Transform  selTransform = selGameObj != null ? selGameObj.Transform : null;

            if (selTransform == null)
            {
                return;
            }

            Vector3 spaceCoord = this.GetSpaceCoord(new Vector3(e.X, e.Y, selTransform.Pos.Z));
            Vector2 localPos   = selTransform.GetLocalPoint(spaceCoord).Xy;

            if ((this.SnapToUserGuides & UserGuideType.Position) != UserGuideType.None)
            {
                localPos = this.EditingUserGuide.SnapPosition(localPos);
            }

            if (this.mouseState == CursorState.CreateCircle)
            {
                #region CreateCircle
                if (e.Button == MouseButtons.Left)
                {
                    CircleShapeInfo newShape = new CircleShapeInfo(1.0f, localPos, 1.0f);

                    UndoRedoManager.BeginMacro();
                    UndoRedoManager.Do(new CreateRigidBodyShapeAction(this.selectedBody, newShape));

                    this.createAction = true;
                    this.LeaveCursorState();
                    this.SelectObjects(new[] { SelShape.Create(newShape) });
                    this.BeginAction(ObjectAction.Scale);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    this.LeaveCursorState();
                }
                #endregion
            }
            else if (this.mouseState == CursorState.CreatePolygon)
            {
                #region CreatePolygon
                if (e.Button == MouseButtons.Left)
                {
                    bool success = false;
                    if (!this.allObjSel.Any(sel => sel is SelPolyShape))
                    {
                        PolyShapeInfo newShape = new PolyShapeInfo(new Vector2[] { localPos, localPos, localPos }, 1.0f);
                        UndoRedoManager.Do(new CreateRigidBodyShapeAction(this.selectedBody, newShape));
                        this.SelectObjects(new[] { SelShape.Create(newShape) });
                        this.createPolyIndex++;
                    }
                    else
                    {
                        SelPolyShape  selPolyShape = this.allObjSel.OfType <SelPolyShape>().First();
                        PolyShapeInfo polyShape    = selPolyShape.ActualObject as PolyShapeInfo;
                        if (this.createPolyIndex <= 2 || MathF.IsPolygonConvex(polyShape.Vertices))
                        {
                            Vector2 lockedPos = this.createPolyIndex > 0 ? polyShape.Vertices[this.createPolyIndex - 1] : Vector2.Zero;
                            MathF.TransformCoord(ref lockedPos.X, ref lockedPos.Y, selTransform.Angle);
                            MathF.TransformCoord(ref localPos.X, ref localPos.Y, selTransform.Angle);
                            localPos = this.ApplyAxisLock(localPos, lockedPos);
                            MathF.TransformCoord(ref localPos.X, ref localPos.Y, -selTransform.Angle);

                            if (polyShape.Vertices.Length < PolyShapeInfo.MaxVertices)
                            {
                                List <Vector2> vertices = polyShape.Vertices.ToList();

                                vertices[this.createPolyIndex] = localPos;
                                if (this.createPolyIndex >= vertices.Count - 1)
                                {
                                    vertices.Add(localPos);
                                }

                                polyShape.Vertices = vertices.ToArray();
                                selPolyShape.UpdatePolyStats();
                                this.createPolyIndex++;
                            }
                            else
                            {
                                Vector2[] vertices = polyShape.Vertices;

                                vertices[this.createPolyIndex] = localPos;
                                polyShape.Vertices             = vertices;
                                selPolyShape.UpdatePolyStats();

                                this.LeaveCursorState();
                            }
                        }
                    }

                    if (success)
                    {
                        DualityEditorApp.NotifyObjPropChanged(this,
                                                              new ObjectSelection(this.selectedBody),
                                                              ReflectionInfo.Property_RigidBody_Shapes);
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (this.allObjSel.Any(sel => sel is SelPolyShape))
                    {
                        SelPolyShape   selPolyShape = this.allObjSel.OfType <SelPolyShape>().First();
                        PolyShapeInfo  polyShape    = selPolyShape.ActualObject as PolyShapeInfo;
                        List <Vector2> vertices     = polyShape.Vertices.ToList();

                        vertices.RemoveAt(this.createPolyIndex);
                        if (vertices.Count < 3 || this.createPolyIndex < 2)
                        {
                            this.DeleteObjects(new SelPolyShape[] { selPolyShape });
                        }
                        else
                        {
                            polyShape.Vertices = vertices.ToArray();
                            selPolyShape.UpdatePolyStats();
                        }

                        DualityEditorApp.NotifyObjPropChanged(this,
                                                              new ObjectSelection(this.selectedBody),
                                                              ReflectionInfo.Property_RigidBody_Shapes);
                    }

                    this.LeaveCursorState();
                }
                #endregion
            }
            else if (this.mouseState == CursorState.CreateLoop)
            {
                #region CreateLoop
                if (e.Button == MouseButtons.Left)
                {
                    bool success = false;
                    if (!this.allObjSel.Any(sel => sel is SelLoopShape))
                    {
                        LoopShapeInfo newShape = new LoopShapeInfo(new Vector2[] { localPos, localPos + Vector2.UnitX, localPos + Vector2.One });
                        UndoRedoManager.Do(new CreateRigidBodyShapeAction(this.selectedBody, newShape));
                        this.SelectObjects(new[] { SelShape.Create(newShape) });
                        success = true;
                    }
                    else
                    {
                        SelLoopShape   selPolyShape = this.allObjSel.OfType <SelLoopShape>().First();
                        LoopShapeInfo  polyShape    = selPolyShape.ActualObject as LoopShapeInfo;
                        List <Vector2> vertices     = polyShape.Vertices.ToList();
                        Vector2        lockedPos    = this.createPolyIndex > 0 ? vertices[this.createPolyIndex - 1] : Vector2.Zero;
                        MathF.TransformCoord(ref lockedPos.X, ref lockedPos.Y, selTransform.Angle);
                        MathF.TransformCoord(ref localPos.X, ref localPos.Y, selTransform.Angle);
                        localPos = this.ApplyAxisLock(localPos, lockedPos);
                        MathF.TransformCoord(ref localPos.X, ref localPos.Y, -selTransform.Angle);

                        vertices[this.createPolyIndex] = localPos;
                        if (this.createPolyIndex >= vertices.Count - 1)
                        {
                            vertices.Add(localPos);
                        }

                        polyShape.Vertices = vertices.ToArray();
                        selPolyShape.UpdateLoopStats();
                        success = true;
                    }

                    if (success)
                    {
                        this.createPolyIndex++;
                        DualityEditorApp.NotifyObjPropChanged(this,
                                                              new ObjectSelection(this.selectedBody),
                                                              ReflectionInfo.Property_RigidBody_Shapes);
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (this.allObjSel.Any(sel => sel is SelLoopShape))
                    {
                        SelLoopShape   selPolyShape = this.allObjSel.OfType <SelLoopShape>().First();
                        LoopShapeInfo  polyShape    = selPolyShape.ActualObject as LoopShapeInfo;
                        List <Vector2> vertices     = polyShape.Vertices.ToList();

                        vertices.RemoveAt(this.createPolyIndex);
                        if (vertices.Count < 3 || this.createPolyIndex < 2)
                        {
                            this.DeleteObjects(new SelLoopShape[] { selPolyShape });
                        }
                        else
                        {
                            polyShape.Vertices = vertices.ToArray();
                            selPolyShape.UpdateLoopStats();
                        }

                        DualityEditorApp.NotifyObjPropChanged(this,
                                                              new ObjectSelection(this.selectedBody),
                                                              ReflectionInfo.Property_RigidBody_Shapes);
                    }

                    this.LeaveCursorState();
                }
                #endregion
            }
        }
Exemple #20
0
 /// <summary>
 /// Normalize rectangle
 /// </summary>
 public override void Normalize()
 {
     UndoRedoManager.Instance().Push(r => rectangle = DrawRectangle.GetNormalizedRectangle(r), rectangle);
     rectangle = DrawRectangle.GetNormalizedRectangle(rectangle);
 }
Exemple #21
0
 /// <summary>
 /// コンストラクター
 /// </summary>
 public mgrMapObject(UndoRedoManager undoRedo)
 {
     this.SwitchLayers = new bool[Common.GetEnumCount <Map.Layer>()];
     this.UndoRedo     = undoRedo;
     this.ToolInit();
 }
Exemple #22
0
 Task ICommandHandler <RedoCommandDefinition> .Run(Command command)
 {
     UndoRedoManager.Redo(1);
     return(TaskUtility.Completed);
 }
 protected override void PostSetValue()
 {
     base.PostSetValue();
     UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromFirst);
 }
 protected override void PrepareSetValue()
 {
     base.PrepareSetValue();
     UndoRedoManager.BeginMacro();
 }
Exemple #25
0
 Task ICommandHandler <RedoCommandDefinition> .Run(Command command)
 {
     UndoRedoManager.Redo(1);
     return(Task.FromResult(true));
 }
 protected override void OnEditingFinished(PropertyEditorValueEventArgs e)
 {
     base.OnEditingFinished(e);
     UndoRedoManager.Finish();
 }
Exemple #27
0
        protected override void OnPropertySet(PropertyInfo property, IEnumerable <object> targets)
        {
            base.OnPropertySet(property, targets);

            UndoRedoManager.Do(new EditPropertyAction(this.ParentGrid, ReflectionInfo.Property_SoundEmitter_Sources, this.parentEmitter, null));
        }
 private void EditorMemberFieldSetter(FieldInfo field, IEnumerable <object> targetObjects, IEnumerable <object> values)
 {
     UndoRedoManager.Do(new EditFieldAction(this, field, targetObjects, values));
 }
Exemple #29
0
 /// <summary>
 /// Constructor setting the source <see cref="UndoRedoManager"/>
 /// </summary>
 /// <param name="source">The source <see cref="UndoRedoManager"/></param>
 public TransactionEndedEventArgs(UndoRedoManager source, CompositeCommand command)
     : base(source, command)
 {
 }
 private void EditorDictionaryKeySetter(PropertyInfo indexer, IEnumerable <object> targetObjects, IEnumerable <object> values, object key)
 {
     UndoRedoManager.Do(new EditPropertyAction(this, indexer, targetObjects, values, new object[] { key }));
 }
Exemple #31
0
 private void SetColor(Color color)
 {
     // 存储上一次Cube颜色
     UndoRedoManager.Instance().Push(SetColor, GetComponent <Renderer>().material.color, "新增颜色");
     GetComponent <Renderer>().material.color = color;
 }
Exemple #32
0
 private void contextMenu_ResetComponent(object sender, EventArgs e)
 {
     UndoRedoManager.Do(new ResetComponentAction(this.GetValue().Cast <Component>()));
 }
Exemple #33
0
 private void DestroyCube(GameObject cube)
 {
     Destroy(cube);
     UndoRedoManager.Instance().Push(CreateCube, Cube, "Destroy Cube");
 }
Exemple #34
0
 private void MapPanel_UndoRedoUpdated(object sender, UndoRedoManager <MemoryStream> manager)
 {
     this.RefreshUndoRedoButtonState(manager);
 }
 void redoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UndoRedoManager.Redo();
 }
 private void MapPanel_UndoRedoUpdated(object sender, UndoRedoManager<MemoryStream> manager)
 {
     this.RefreshUndoRedoButtonState(manager);
 }
Exemple #37
0
        public override DataItem LoadData(XElement element, UndoRedoManager undoRedo)
        {
            var item = new GraphStructItem(this, undoRedo);

            item.X       = TryParseFloat(element, MetaNS + "X");
            item.Y       = TryParseFloat(element, MetaNS + "Y");
            item.GUID    = element.Attribute("GUID")?.Value?.ToString();
            item.Comment = element.Attribute(MetaNS + "Comment")?.Value?.ToString();

            var commentTexts = Children.Where(e => e is CommentDefinition).Select(e => (e as CommentDefinition).Text);

            var createdChildren = new List <DataItem>();

            foreach (var def in Children)
            {
                var name = def.Name;

                var els = element.Elements(name);

                if (els.Count() > 0)
                {
                    var prev = els.First().PreviousNode as XComment;
                    if (prev != null)
                    {
                        var comment = new CommentDefinition().LoadData(prev, undoRedo);
                        if (!commentTexts.Contains(comment.TextValue))
                        {
                            item.Children.Add(comment);
                        }
                    }

                    if (def is CollectionDefinition)
                    {
                        CollectionItem childItem = (CollectionItem)def.LoadData(els.First(), undoRedo);
                        if (childItem.Children.Count == 0)
                        {
                            var dummyEl = new XElement(els.First().Name);
                            foreach (var el in els)
                            {
                                dummyEl.Add(el);
                            }

                            childItem = (CollectionItem)def.LoadData(dummyEl, undoRedo);
                        }

                        item.Children.Add(childItem);
                    }
                    else
                    {
                        DataItem childItem = def.LoadData(els.First(), undoRedo);
                        item.Children.Add(childItem);
                    }
                }
                else
                {
                    DataItem childItem = def.CreateData(undoRedo);
                    item.Children.Add(childItem);
                }
            }

            if (element.LastNode is XComment)
            {
                var comment = new CommentDefinition().LoadData(element.LastNode as XComment, undoRedo);
                if (!commentTexts.Contains(comment.TextValue))
                {
                    item.Children.Add(comment);
                }
            }

            foreach (var att in Attributes)
            {
                var      el      = element.Attribute(att.Name);
                DataItem attItem = null;

                if (el != null)
                {
                    attItem = att.LoadData(new XElement(el.Name, el.Value.ToString()), undoRedo);
                }
                else
                {
                    attItem = att.CreateData(undoRedo);
                }
                item.Attributes.Add(attItem);
            }

            item.Children.OrderBy(e => Children.IndexOf(e.Definition));

            foreach (var child in item.Attributes)
            {
                child.UpdateVisibleIfBinding();
            }
            foreach (var child in item.Children)
            {
                child.UpdateVisibleIfBinding();
            }

            return(item);
        }
Exemple #38
0
 /// <summary>
 /// Move object
 /// </summary>
 /// <param name="deltaX"></param>
 /// <param name="deltaY"></param>
 public override void Move(int deltaX, int deltaY)
 {
     UndoRedoManager.Instance().Push((dummy) => Move(-deltaX, -deltaY), this);
     rectangle.X += deltaX;
     rectangle.Y += deltaY;
 }
        public void UndoRedoManagerUndoAndRedo()
        {
            UndoRedoManager undoRedoManager = new UndoRedoManager();

             BookCollection myBooks = new BookCollection();
             myBooks.Name = "A few of my favorite books";
             myBooks.Library.Add( DarwinsGod );
             myBooks.Library.Add( SoftwareEstimates );
             myBooks.FavoriteBook = ClockWorkOrange;

             DarwinsGod.Pages = 700;
             SoftwareEstimates.Pages = 800;

             Assert.AreEqual( "A few of my favorite books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( SoftwareEstimates ) );
             Assert.AreEqual( ClockWorkOrange, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             // Simulate the following editting that got to the state above:
             //    1 - Name -> "Some Books"
             //    2 - Library -> Add MereChristianity
             //    3 - Name -> "A few of my books"
             //    4 - Favorite -> DarwinsGod
             //    5 - Library -> Add DarwinsGod
             //    6 - DarwinsGod -> change pages to 700
             //    7 - SoftwareEstimates -> change pages to 800
             //    8 - Library -> Remove MereChristianity
             //    9 - Favorite -> ClockWorkOrange
             //   10 - Library -> Add SoftwareEstimates
             //   11 - Name -> "A few of my favorite books"
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, String>( myBooks, "Name", UndoableActions.Modify, null, "Some Books" ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "Library", UndoableActions.Add, null, MereChristianity ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, String>( myBooks, "Name", UndoableActions.Modify, "Some Books", "A few of my books" ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "FavoriteBook", UndoableActions.Modify, null, DarwinsGod ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "Library", UndoableActions.Add, null, DarwinsGod ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<Book, Int16>( DarwinsGod, "Pages", UndoableActions.Modify, 338, 700 ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<Book, Int16>( SoftwareEstimates, "Pages", UndoableActions.Modify, 308, 800 ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "Library", UndoableActions.Remove, MereChristianity, null ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "FavoriteBook", UndoableActions.Modify, DarwinsGod, ClockWorkOrange ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, Book>( myBooks, "Library", UndoableActions.Add, null, SoftwareEstimates ) );
             undoRedoManager.Add(
            new UndoablePropertyValue<BookCollection, String>( myBooks, "Name", UndoableActions.Modify, "A few of my books", "A few of my favorite books" ) );

             // Can undo, cannot redo.  Undo five items, verify undo() performed at each step.
             Assert.IsTrue( undoRedoManager.CanUndo );
             Assert.IsFalse( undoRedoManager.CanRedo );
             undoRedoManager.Undo(); // 11
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( SoftwareEstimates ) );
             Assert.AreEqual( ClockWorkOrange, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             undoRedoManager.Undo(); // 10
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 1, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.AreEqual( ClockWorkOrange, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             undoRedoManager.Undo(); // 9
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 1, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.AreEqual( DarwinsGod, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             undoRedoManager.Undo(); // 8
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( MereChristianity ) );
             Assert.AreEqual( DarwinsGod, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             undoRedoManager.Undo(); // 7
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( MereChristianity ) );
             Assert.AreEqual( DarwinsGod, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 308, SoftwareEstimates.Pages );

             // Redo two items
             undoRedoManager.Redo(); // 7
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( MereChristianity ) );
             Assert.AreEqual( DarwinsGod, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             undoRedoManager.Redo(); // 8
             Assert.AreEqual( "A few of my books", myBooks.Name );
             Assert.AreEqual( 1, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.AreEqual( DarwinsGod, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             // Undo all items
             undoRedoManager.Undo(); // 8
             undoRedoManager.Undo(); // 7
             undoRedoManager.Undo(); // 6
             undoRedoManager.Undo(); // 5
             undoRedoManager.Undo(); // 4
             undoRedoManager.Undo(); // 3
             undoRedoManager.Undo(); // 2
             undoRedoManager.Undo(); // 1
             Assert.IsFalse( undoRedoManager.CanUndo );
             Assert.IsTrue( String.IsNullOrEmpty( myBooks.Name ) );
             Assert.AreEqual( 0, myBooks.Library.Count );
             Assert.IsNull( myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 338, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 308, SoftwareEstimates.Pages );

             // Redo all items
             undoRedoManager.Redo(); //  1
             undoRedoManager.Redo(); //  2
             undoRedoManager.Redo(); //  3
             undoRedoManager.Redo(); //  4
             undoRedoManager.Redo(); //  5
             undoRedoManager.Redo(); //  6
             undoRedoManager.Redo(); //  7
             undoRedoManager.Redo(); //  8
             undoRedoManager.Redo(); //  9
             undoRedoManager.Redo(); // 10
             undoRedoManager.Redo(); // 11
             Assert.IsFalse( undoRedoManager.CanRedo );
             Assert.AreEqual( "A few of my favorite books", myBooks.Name );
             Assert.AreEqual( 2, myBooks.Library.Count );
             Assert.IsTrue( myBooks.Library.Contains( DarwinsGod ) );
             Assert.IsTrue( myBooks.Library.Contains( SoftwareEstimates ) );
             Assert.AreEqual( ClockWorkOrange, myBooks.FavoriteBook );
             Assert.AreEqual( 192, ClockWorkOrange.Pages );
             Assert.AreEqual( 700, DarwinsGod.Pages );
             Assert.AreEqual( 227, MereChristianity.Pages );
             Assert.AreEqual( 800, SoftwareEstimates.Pages );

             // Reset pages on potentially changed books
             DarwinsGod.Pages = 338;
             SoftwareEstimates.Pages = 308;
        }