예제 #1
0
 void Globals_KeyDown(object sender, KeyEventArgs e)
 {
     if (((ControlType)sender) == ControlType.UserInterface && isCurrentControl) // PITFALL
     {
         if (e.Control && e.KeyCode == Keys.Z)                                   // Ctrl + Z
         {
             undoRedo = true;
             UndoRedoItem undoRedoItem = UndoRedo.Undo(tableName);
             if (undoRedoItem != null)
             {
                 LabelProperty labelProp = (LabelProperty)undoRedoItem.oldValue;
                 labelProp.UpdateLabelObject();
             }
         }
         else if (e.Control && e.KeyCode == Keys.Y) // Ctrl + Y
         {
             undoRedo = true;
             UndoRedoItem undoRedoItem = UndoRedo.Redo(tableName);
             if (undoRedoItem != null)
             {
                 LabelProperty labelProp = (LabelProperty)undoRedoItem.newValue;
                 labelProp.UpdateLabelObject();
             }
         }
         else if (e.KeyCode == Keys.Delete)
         {
         }
     }
     undoRedo = false;
 }
예제 #2
0
            public void AddHistory(UndoRedoItem <T> history)
            {
                _undoStack.Push(history);
                _redoStack.Clear();

                //AddChangeLog(history);
            }
예제 #3
0
        // ITypedList Members

        PropertyDescriptorCollection ITypedList.GetItemProperties(
            PropertyDescriptor[] listAccessors)
        {
            if (properties == null)
            {
                properties = UndoRedoItem.GetProperties(typeof(T));
            }

            return(properties);
        }
예제 #4
0
            public void Redo()
            {
                UndoRedoItem <T> top = (UndoRedoItem <T>)_redoStack.Pop();

                top.Cmd.Execute(top);

                top.SwapOldAndNew();
                _undoStack.Push(top);
                //RemoveChangeLog(top);
            }
예제 #5
0
 private void LabelPropertyChanged()
 {
     if (undoRedo == false)
     {
         UndoRedoItem undoRedoItem = new UndoRedoItem();
         undoRedoItem.dlgName        = tableName;
         undoRedoItem.undoRedoStatus = UndoRedoStatus.New;
         undoRedoItem.newValue       = currentValue;
         undoRedoItem.oldValue       = oldValue;
         UndoRedo.AddItem(undoRedoItem);
     }
 }
예제 #6
0
            public bool Equals(UndoRedoItem other)
            {
                if ((object)other == null)
                {
                    return(false);
                }

                if ((object)this == (object)other)
                {
                    return(true);
                }

                return((owner == other.owner) && Instance.Equals(other.Instance));
            }
예제 #7
0
            public void Undo(bool canRedo)
            {
                UndoRedoItem <T> top = _undoStack.Pop();

                top.Cmd.UnExecute(top);

                if (canRedo == true)
                {
                    top.SwapOldAndNew();
                    _redoStack.Push(top);
                }

                //AddChangeLog(top);
            }
 public void RestoreUndoRedo()
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         this.panelGrid.Visible = false;
         List <UndoRedoItem> items    = this.UndoRedoFrames[this.UndoRedoCursor].Items;
         List <Control>      controls = new List <Control>(this.panelGrid.Controls.Cast <Control>().Where(item => item is Tile));
         foreach (Tile tile in controls)
         {
             UndoRedoItem bak = items.FirstOrDefault(item => item.OriginalTileHandle == tile.Handle);
             if (bak == null)
             {
                 this.panelGrid.Controls.Remove(tile);
             }
             else
             {
                 if (bak.Left != (int)(tile.Left * this._zoomFactor))
                 {
                     tile.Left = (int)(bak.Left * this._zoom);
                 }
                 if (bak.Top != (int)(tile.Top * this._zoomFactor))
                 {
                     tile.Top = (int)(bak.Top * this._zoom);
                 }
             }
         }
         foreach (UndoRedoItem bak in items.Where(item => !controls.Any(p => p.Handle == item.OriginalTileHandle)))
         {
             this.AddTile(bak.SpriteData, new Point(bak.Left, bak.Top), bak.Attribute);
         }
         this.panelGrid.Visible = true;
         this.panelGrid.Focus();
         this._pickingTiles.Clear();
         this._isPicking = false;
         this.UpdateStatusbar();
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }