Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Square[] squares = new Square[20];

            squares[0] = new Square(0, 10);
            squares[1] = new Square(1, 15);

            Invoker invoker = new Invoker();

            AbstractCommand command = new MoveCommand(squares[0], 5, 5);

            invoker.execute(command);
            command = new ScaleCommand(squares[0], 2);
            invoker.execute(command);
            command = new PrintCommand(squares[0]);
            invoker.execute(command);

            command = new ScaleCommand(squares[1], 3);
            invoker.execute(command);
            command = new PrintCommand(squares[1]);
            invoker.execute(command);

            invoker.undo();
            command = new PrintCommand(squares[0]);
            invoker.execute(command);
            command = new PrintCommand(squares[1]);
            invoker.execute(command);
        }
Exemplo n.º 2
0
	private void ExecuteScaleCommand(ScaleCommand command)
	{
        if (command.scaleVector != Vector2.zero)
        {
            LeanTween.scale(gameObject, command.scaleVector, command.scaleTime).setDelay(command.delay).setEase(LeanTweenType.easeInOutQuad);
        }
    }
Exemplo n.º 3
0
        private void DoWork()
        {
            var army = new VehiclesGroup(Id, VehicleIds, VehicleRegistry, CommandManager);

            army
            .Select(Id)
            .ResetIdleness()
            .Scale(0.1);
            command = CommandManager.PeekLastCommand(Id) as ScaleCommand;
        }
Exemplo n.º 4
0
 private void ScaleObject()
 {
     LastCommand?.Deactivate(Application.Current.MainWindow);
     LastCommand          = new ScaleCommand(Application.Current.MainWindow, SelectedObject);
     LastCommand.OnApply += () =>
     {
         LastCommand.Deactivate(Application.Current.MainWindow);
         LastCommand = null;
     };
 }
Exemplo n.º 5
0
 public PhotoViewModel(IMessenger messenger, IImageService imageService, PhotoModel model)
 {
     Messenger       = messenger;
     ImageService    = imageService;
     Model           = model;
     FullScale       = false;
     NextCommand     = new NextCommand(this);
     PreviousCommand = new PreviousCommand(this);
     ScaleCommand    = new ScaleCommand(this);
     CloseCommand    = new CloseCommand(this);
     PrepareIcons();
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Square[] squares = new Square[20];

            squares[0] = new Square(0, 10);
            squares[1] = new Square(1, 15);

            Invoker invoker = new Invoker();

            AbstractCommand command = new MoveCommand(squares[0], 5, 5);

            invoker.execute(command);
            command = new ScaleCommand(squares[0], 2);
            invoker.execute(command);
            command = new ScaleCommand(squares[1], 3);
            invoker.execute(command);

            command = new PrintCommand(squares[0]);
            invoker.execute(command);
            command = new PrintCommand(squares[1]);
            invoker.execute(command);
            System.Console.WriteLine();

            for (int i = 1; i <= 3; i++)
            {
                invoker.undo();
                command = new PrintCommand(squares[0]);
                invoker.execute(command);
                command = new PrintCommand(squares[1]);
                invoker.execute(command);
                System.Console.WriteLine();
            }
            for (int i = 1; i <= 3; i++)
            {
                invoker.redo();
                command = new PrintCommand(squares[0]);
                invoker.execute(command);
                command = new PrintCommand(squares[1]);
                invoker.execute(command);
                System.Console.WriteLine();
            }

            invoker.flush();
            command = new PrintCommand(squares[0]);
            invoker.execute(command);
            command = new PrintCommand(squares[1]);
            invoker.execute(command);

            invoker.undo();
            invoker.redo();
        }
Exemplo n.º 7
0
        public void CommandTestScale()
        {
            //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);
            shape.Size     = new SizeF(50, 50);
            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
            ScaleCommand command = controller.CommandFactory.CreateScaleCommand();

            command.Elements = new ElementList(true);
            command.Elements.Add(shape);
            command.MouseElements             = new MouseElements();
            command.MouseElements.MouseHandle = new Handle(HandleType.BottomRight);
            command.Dx = 10;
            command.Dy = 20;

            //Translate the action and execute the command
            command.Scale();
            command.Execute();
            Assert.IsTrue(shape.Size == new SizeF(60, 70), "Scale command not applied correctly to shape.");

            command.Undo();
            Assert.IsTrue(shape.Size == new SizeF(50, 50), "Scale command not undone correctly for shape.");

            command.Redo();
            Assert.IsTrue(shape.Size == new SizeF(60, 70), "Scale command not redone correctly for shape.");
        }
Exemplo n.º 8
0
        public void undo()
        {
            if (lastCommand == null)
            {
                System.Console.WriteLine("No command exist for undo");
                return;
            }

            if (lastCommand.getCommand().Equals("move"))
            {
                MoveCommand move_cmd = (MoveCommand)lastCommand;
                move_cmd.getSquare().move_undo(move_cmd.getJ(), move_cmd.getK());
            }
            else if (lastCommand.getCommand().Equals("scale"))
            {
                ScaleCommand scale_cmd = (ScaleCommand)lastCommand;
                scale_cmd.getSquare().scale_undo(scale_cmd.getJ());
            }
            else
            {
                System.Console.WriteLine("Invalid Command");
            }
            lastCommand = null;
        }
Exemplo n.º 9
0
 internal override void BuildAction(string action)
 {
     base.BuildAction(action);
     this.scaleCommand = new ScaleCommand(this.CommandArguments, this.SessionService.Object, this.FilterService.Object);
 }