Beispiel #1
0
 void FireCommand()
 {
     if (PressCommand != null && PressCommand.CanExecute(PressCommandParameter))
     {
         PressCommand.Execute(PressCommandParameter);
     }
 }
Beispiel #2
0
 private void ExecutePressCommand()
 {
     if (CanExecutePressCommand())
     {
         PressCommand.Execute(PressCommandParameter);
     }
 }
Beispiel #3
0
        public void ConstructorOne()
        {
            var button = Button.Down;

            var command = new PressCommand(button);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(TimeSpan.Zero, command.Timestamp);
        }
Beispiel #4
0
        public void ConstructorTwo()
        {
            var button    = Button.Down;
            var timestamp = TimeSpan.FromSeconds(3);

            var command = new PressCommand(button, timestamp);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(timestamp, command.Timestamp);
        }
 /// <summary>
 /// Default constructor registers mouse down and up events to fire commands
 /// </summary>
 public PressAndReleaseButton()
 {
     MouseDown += (o, a) =>
     {
         if (PressCommand.CanExecute(null))
         {
             PressCommand.Execute(null);
         }
     }
     MouseUp += (o, a) =>
     {
         if (ReleaseCommand.CanExecute(null))
         {
             ReleaseCommand.Execute(null);
         }
     }
 }
Beispiel #6
0
        public void Execute()
        {
            int presses = 0;

            var actuatorRepo = new Mock <IActuator>();

            actuatorRepo.Setup(x => x.Hit(It.IsAny <Button>())).Callback(() => Assert.Fail());
            actuatorRepo.Setup(x => x.Press(It.IsAny <Button>())).Callback(() => presses++);
            actuatorRepo.Setup(x => x.Release(It.IsAny <Button>())).Callback(() => Assert.Fail());

            var button    = Button.Down;
            var timestamp = TimeSpan.FromSeconds(3);
            var command   = new PressCommand(button, timestamp);

            command.Execute(actuatorRepo.Object);

            Assert.AreEqual(1, presses);
        }
 /// <summary>
 /// Default constructor registers mouse down and up events to fire commands
 /// </summary>
 public PressAndReleaseButton()
 {
     MouseDown += (o, a) => PressCommand.Execute(null);
     MouseUp   += (o, a) => ReleaseCommand.Execute(null);
 }
Beispiel #8
0
 private bool CanExecutePressCommand()
 {
     return(IsLatchActive && !IsLatched && PressCommand != null && PressCommand.CanExecute(PressCommandParameter));
 }