예제 #1
0
        public void CreateObjectsTest()
        {
            Assert.True(lis.Length > 2);
            commandStack.Do(new AddInstancesCommand(new uint[] { lis[0].DefinitionId }, new Point[] { new Point(5, 5) }));
            Assert.AreEqual(1, dl.Count);
            commandStack.Undo();
            Assert.AreEqual(0, dl.Count);
            commandStack.Undo();
            Assert.AreEqual(0, dl.Count);
            commandStack.Redo();
            Assert.AreEqual(1, dl.Count);
            commandStack.Redo();
            Assert.AreEqual(1, dl.Count);

            commandStack.Do(new AddInstancesCommand(new uint[] { lis[1].DefinitionId, lis[2].DefinitionId, lis[0].DefinitionId },
                                                    new Point[] { new Point(15, 15), new Point(135, 15), new Point(195, 15) }));
            Assert.AreEqual(4, dl.Count);
            commandStack.Undo();
            Assert.AreEqual(1, dl.Count);
            commandStack.Redo();
            Assert.AreEqual(4, dl.Count);

            MainForm.CurrentStage.CommandStack.Do(new SelectInstancesCommand(dl.InstanceIds, SelectionModifier.SetSelection));
            Assert.AreEqual(4, dl.Selected.Count);

            commandStack.Do(new DeleteInstancesCommand(dl.InstanceIds));
            Assert.AreEqual(0, dl.Count);
            Assert.AreEqual(0, dl.Selected.Count);
            commandStack.Undo();
            Assert.AreEqual(4, dl.Selected.Count);
            commandStack.Redo();
            Assert.AreEqual(0, dl.Selected.Count);
        }
 private void Undo()
 {
     try
     {
         _commandStack.Undo();
     }
     catch (Exception e)
     {
     }
 }
예제 #3
0
    public void HandleUndoFSClick()
    {
        tempcSt.Undo();
        Room r = controller.GetComponentInChildren <Room> ();

        foreach (Furniture f in r.furnitures)
        {
            if (f.gameObject.name.Equals(focusedObjectName))
            {
                focusedObject = f.transform;
            }
        }
    }
예제 #4
0
        /// <summary>
        /// Handles Control Click Events.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void BtnClick(object sender, EventArgs e)
        {
            ICommand currentCommand = null;

            if (sender.Equals(btnCancel))
            {
                this.Close();
            }
            else if (sender.Equals(btnUndo))
            {
                commandsList.Undo();
            }
            else if (sender.Equals(btnRedo))
            {
                commandsList.Redo();
            }
            else if (sender.Equals(btnSave))
            {
                SaveEnvironmentVariable();
            }
            else if (sender.Equals(btnExport))
            {
                ExportEnvironmentVariable();
            }
            else if (sender.Equals(btnImport))
            {
                ImportEnvironmentVariable();
            }
            else if (sender.Equals(tsmiLocate))
            {
                LocateInWindowsExplorer();
            }
            else if (sender.Equals(tsmiCut))
            {
                var index = dgvValuesList.SelectedRows[0].Index;
                if (index != -1)
                {
                    if (dgvValuesList[1, index].Value != null)
                    {
                        Clipboard.SetText(dgvValuesList[1, index].Value.ToString());
                        dgvValuesList.Rows.RemoveAt(index);
                    }
                }
            }
            else if (sender.Equals(tsmiCopy))
            {
                var index = dgvValuesList.SelectedRows[0].Index;
                if (index != -1)
                {
                    if (dgvValuesList[1, index].Value != null)
                    {
                        Clipboard.SetText(dgvValuesList[1, index].Value.ToString());
                    }
                }
            }
            else if (sender.Equals(tsmiPaste))
            {
                var index = dgvValuesList.SelectedRows[0].Index;
                if (index != -1)
                {
                    string dgvValue = Clipboard.GetText();
                    string cmdValue = dgvValuesList[1, index].Value as string;
                    if (cmdValue == null)
                    {
                        dgvValuesList[0, dgvValuesList.Rows.Add()].Value = Properties.Resources.ValTypeNull;
                    }
                    if (dgvValue != null && (cmdValue == null || cmdValue != dgvValue))
                    {
                        dgvValuesList[1, index].Value = dgvValue;
                        dgvHandler.SetRowIcon(index, dgvValue as string);
                        dgvHandler.SetCellToolTip(index, dgvValue as string);
                    }
                    else
                    {
                        if (cmdValue != null)
                        {
                            dgvValuesList[1, index].Value = cmdValue;
                        }
                        SetBtnState();
                    }
                }
            }
            else if (sender.Equals(btnDelete))
            {
                dgvValuesList_UserDeletingRow(null, null);
            }
            else if (sender.Equals(btnDelDupes))
            {
                dgvValuesList_UserDeletingDupedRows();
            }
            else if (sender.Equals(btnSortValues))
            {
                dgvValuesList_UserSortRows();
            }
            else if (sender.Equals(btnBrowse))
            {
                BrowseFolder();
            }
            #region Move Row
            else if (sender.Equals(btnMoveUp))
            {
                currentCommand = new DgvMoveUpCommand(dgvHandler);
            }
            else if (sender.Equals(btnMoveTop))
            {
                currentCommand = new DgvMoveToTopCommand(dgvHandler);
            }
            else if (sender.Equals(btnMoveDown))
            {
                currentCommand = new DgvMoveDownCommand(dgvHandler);
            }
            else if (sender.Equals(btnMoveBottom))
            {
                currentCommand = new DgvMoveToBottomCommand(dgvHandler);
            }
            #endregion Move Row

            if (!sender.Equals(btnCancel))
            {
                AddCommand(currentCommand);
            }
        }
예제 #5
0
 public void Undo()
 {
     cSt.Undo();
 }
예제 #6
0
 /// <summary>
 /// 撤销最近一次的操作
 /// </summary>
 public void Undo()
 {
     _cmdStack.Undo();
 }