Example #1
0
        public virtual void RemoveItem(List <UndoRedoAction> undoPipe)
        {
            lock (Board.ParentControl)
            {
                List <BoardItem> items = boundItems.Keys.ToList();
                foreach (BoardItem item in items)
                {
                    item.RemoveItem(undoPipe);
                }

                if (undoPipe != null)
                {
                    undoPipe.Add(UndoRedoManager.ItemDeleted(this));
                }
                if (parent != null)
                {
                    if (!(parent is Mouse) && undoPipe != null)
                    {
                        undoPipe.Add(UndoRedoManager.ItemsUnlinked(parent, this, (Microsoft.Xna.Framework.Point)parent.boundItems[this]));
                    }
                    parent.ReleaseItem(this);
                }
                Selected = false;
                board.BoardItems.Remove(this);
            }
        }
Example #2
0
        public virtual void RemoveItem(ref List <UndoRedoAction> undoPipe)
        {
            object[] keys = new object[boundItems.Keys.Count];
            boundItems.Keys.CopyTo(keys, 0);
            foreach (object key in keys)
            {
                ((BoardItem)key).RemoveItem(ref undoPipe);
            }

            undoPipe.Add(UndoRedoManager.ItemDeleted(this));
            if (parent != null)
            {
                if (!(parent is Mouse))
                {
                    undoPipe.Add(UndoRedoManager.ItemsUnlinked(parent, this, (Microsoft.Xna.Framework.Point)parent.boundItems[this]));
                }
                parent.ReleaseItem(this);
            }
            Selected = false;
            board.BoardItems.Remove(this);
        }
Example #3
0
        public void UndoRedo(out Board boardToSort)
        {
            boardToSort = null;
            Board board;
            List <UndoRedoAction> foo;

            switch (type)
            {
            case UndoRedoType.ItemDeleted:
                //item.Board.BoardItems.Add(item, true);
                item.InsertItem();
                break;

            case UndoRedoType.ItemAdded:
                foo = new List <UndoRedoAction>();    //the undoPipe here has no meaning, we don't need any undo info anyway
                item.RemoveItem(ref foo);
                break;

            case UndoRedoType.ItemMoved:
                Point oldPos = (Point)ParamA;
                item.Move(oldPos.X, oldPos.Y);
                break;

            case UndoRedoType.ItemFlipped:
                ((IFlippable)item).Flip = !((IFlippable)item).Flip;
                break;

            case UndoRedoType.LineRemoved:
                board = ((MapleDot)ParamB).Board;
                if (ParamC is FootholdLine)
                {
                    board.BoardItems.FootholdLines.Add((FootholdLine)ParamC);
                }
                else if (ParamC is RopeLine)
                {
                    board.BoardItems.RopeLines.Add((RopeLine)ParamC);
                }
                else
                {
                    throw new Exception("wrong type at undoredo, lineremoved");
                }
                ((MapleLine)ParamC).FirstDot  = (MapleDot)ParamA;
                ((MapleLine)ParamC).SecondDot = (MapleDot)ParamB;
                ((MapleDot)ParamA).connectedLines.Add((MapleLine)ParamC);
                ((MapleDot)ParamB).connectedLines.Add((MapleLine)ParamC);
                break;

            case UndoRedoType.LineAdded:
                foo   = new List <UndoRedoAction>();
                board = ((MapleDot)ParamB).Board;
                if (ParamC is FootholdLine)
                {
                    board.BoardItems.FootholdLines.Remove((FootholdLine)ParamC);
                }
                else if (ParamC is RopeLine)
                {
                    board.BoardItems.RopeLines.Remove((RopeLine)ParamC);
                }
                else
                {
                    throw new Exception("wrong type at undoredo, lineadded");
                }
                ((MapleLine)ParamC).Remove(false, ref foo);
                break;

            case UndoRedoType.ToolTipLinked:
                ((ToolTip)item).CharacterToolTip   = null;
                ((ToolTipChar)ParamA).BoundTooltip = null;
                break;

            case UndoRedoType.ToolTipUnlinked:
                ((ToolTipChar)ParamA).BoundTooltip = (ToolTip)item;
                break;

            case UndoRedoType.BackgroundMoved:
                ((BackgroundInstance)item).BaseX = ((Point)ParamA).X;
                ((BackgroundInstance)item).BaseY = ((Point)ParamA).Y;
                break;

            case UndoRedoType.ItemsLinked:
                item.ReleaseItem((BoardItem)ParamA);
                break;

            case UndoRedoType.ItemsUnlinked:
                item.BindItem((BoardItem)ParamA, (Microsoft.Xna.Framework.Point)ParamB);
                break;

            case UndoRedoType.ItemsLayerChanged:
                InputHandler.ClearSelectedItems(((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board);
                foreach (IContainsLayerInfo layerInfoItem in (List <IContainsLayerInfo>)ParamC)
                {
                    layerInfoItem.LayerNumber = (int)ParamA;
                }
                ((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board.Layers[(int)ParamA].RecheckTileSet();
                ((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board.Layers[(int)ParamB].RecheckTileSet();
                ((BoardItem)((List <IContainsLayerInfo>)ParamC)[0]).Board.ParentControl.RenderFrame();
                break;

            case UndoRedoType.RopeAdded:
                foo = new List <UndoRedoAction>();
                ((Rope)ParamA).Remove(ref foo);
                break;

            case UndoRedoType.RopeRemoved:
                ((Rope)ParamA).Create();
                break;

            case UndoRedoType.ItemZChanged:
                item.Z = (int)ParamA;
                item.Board.BoardItems.Sort();
                break;

            case UndoRedoType.VRChanged:
                //TODO
                break;

            case UndoRedoType.MapCenterChanged:
                //TODO
                break;
            }
        }