Execute() public method

public Execute ( Context, context ) : void
context Context,
return void
 public void Initialize(INavigationParameters parameters)
 {
     InputText = parameters[ConfigPage.TranslatePage] as string;
     if (!string.IsNullOrWhiteSpace(InputText))
     {
         TranslateCommand.Execute();
     }
 }
Exemplo n.º 2
0
        public void CommandTestTranslate()
        {
            //Set up the model
            Model model = new Model();

            model.SetSize(new SizeF(1000, 1000)); //Set the container size so that the shape can be moved

            //Set up the shape element
            Shape shape = new Shape();

            shape.Location = new PointF(100, 100);
            model.Shapes.Add("Shape1", shape);

            //Set up the controller
            Controller controller = new Controller(model);

            //Set up the action
            shape.ActionElement = controller.CloneElement(shape);

            //Set up the command
            TranslateCommand command = controller.CommandFactory.CreateTranslateCommand();

            command.Elements = new ElementList(true);
            command.Elements.Add(shape);
            command.Dx = 20;
            command.Dy = 30;

            //Translate the action and execute the command
            command.Translate();
            command.Execute();
            Assert.IsTrue(shape.Location == new PointF(120, 130), "Translate command not applied correctly to shape.");

            command.Undo();
            Assert.IsTrue(shape.Location == new PointF(100, 100), "Translate command not undone correctly for shape.");

            command.Redo();
            Assert.IsTrue(shape.Location == new PointF(120, 130), "Translate command not redone correctly to shape.");
        }