コード例 #1
0
        public void RedoTest() //tests the redo by editing a class, undoing it then redoing it
        {
            _testInvoker.Start();
            Point      Location1 = new Point(100, 102);
            AddCommand command1  = new AddCommand("Class", Location1, Location1, testDrawing);

            _testInvoker.EnqueueCommandForExecution(command1);
            System.Threading.Thread.Sleep(1000);

            //change the color, size and name
            Color  newColor = Color.Azure;
            string newName  = "New Name";
            Size   newSize  = new Size(90, 90);

            EditClassCommand cmd = new EditClassCommand(testDrawing._ClassSymbols[0], newName, newSize, newColor, testDrawing);

            _testInvoker.EnqueueCommandForExecution(cmd);
            System.Threading.Thread.Sleep(1000);

            UndoCommand undo = new UndoCommand();

            _testInvoker.EnqueueCommandForExecution(undo);
            System.Threading.Thread.Sleep(1000);

            RedoCommand redo = new RedoCommand();

            _testInvoker.EnqueueCommandForExecution(redo);
            System.Threading.Thread.Sleep(1000);

            Assert.AreEqual(newName, testDrawing._ClassSymbols[0].label);
            Assert.AreEqual(newSize, testDrawing._ClassSymbols[0].Size);
            Assert.AreEqual(newColor, testDrawing._ClassSymbols[0].ClassColor);
        }
コード例 #2
0
        private void AcceptButton_Click(object sender, EventArgs e)
        {
            int              newWidth  = Convert.ToInt32(WidthTextBox.Text);
            int              newHeight = Convert.ToInt32(HeightTextBox1.Text);
            Size             newSize   = new Size(newWidth, newHeight);
            EditClassCommand command   = new EditClassCommand(EditedSymbol, NameTextBox.Text, newSize, receivedColor, TargetDrawing);

            _invoker.EnqueueCommandForExecution(command);
            this.Hide();
        }