Exemplo n.º 1
0
 void ExecuteOnRelease(IonianTone?tone)
 {
     if (ReleaseCommand?.CanExecute(tone) ?? false)
     {
         ReleaseCommand.Execute(tone);
     }
 }
        private IEventCommand ReadNextEvent(IValueReader reader, ScriptCommandType commandType)
        {
            IEventCommand command = null;

            switch(commandType)
            {
                case ScriptCommandType.Jump:
                    command = new JumpCommand ();
                    break;
                case ScriptCommandType.Lock:
                    command = new LockCommand ();
                    break;
                case ScriptCommandType.Pause:
                    command = new PauseCommand ();
                    break;
                case ScriptCommandType.PauseEvent:
                    command = new PauseEventCommand ();
                    break;
                case ScriptCommandType.ApplyMovement:
                    command = new ApplyMovementCommand ();
                    break;
                case ScriptCommandType.Release:
                    command = new ReleaseCommand ();
                    break;
                default:
                    break;
            }

            if(command == null)
                throw new ArgumentOutOfRangeException ("commandType", "The specified event was not found.");

            command.Deserialize (reader);
            return command;
        }
Exemplo n.º 3
0
 private void ExecuteReleaseCommand()
 {
     if (CanExecuteReleaseCommand())
     {
         ReleaseCommand.Execute(ReleaseCommandParameter);
     }
 }
Exemplo n.º 4
0
        public void ConstructorOne()
        {
            var button = Button.Down;

            var command = new ReleaseCommand(button);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(TimeSpan.Zero, command.Timestamp);
        }
Exemplo n.º 5
0
 private void ReleaseKey()
 {
     if (ReleaseCommand?.CanExecute(this) ?? false)
     {
         ReleaseCommand.Execute(this);
         attacked       = false;
         Rectangle.Fill = Sharp ? SharpDefaultKeyFill : DefaultKeyFill;
     }
 }
Exemplo n.º 6
0
        public void ConstructorTwo()
        {
            var button    = Button.Down;
            var timestamp = TimeSpan.FromSeconds(3);

            var command = new ReleaseCommand(button, timestamp);

            Assert.AreEqual(button, command.Button);
            Assert.AreEqual(timestamp, command.Timestamp);
        }
Exemplo n.º 7
0
        void ExecuteOnRelease(PianoKey view)
        {
            var tone = new IonianTone()
            {
                Scale  = view.Scale,
                Sharp  = view.Sharp,
                Octave = view.Scale == IonianScale.A || view.Scale == IonianScale.B ? Octave + 1 : Octave,
            };

            if (ReleaseCommand?.CanExecute(tone) ?? false)
            {
                ReleaseCommand.Execute(tone);
            }
        }
Exemplo n.º 8
0
        public void Execute()
        {
            int releases = 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(() => Assert.Fail());
            actuatorRepo.Setup(x => x.Release(It.IsAny <Button>())).Callback(() => releases++);

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

            command.Execute(actuatorRepo.Object);

            Assert.AreEqual(1, releases);
        }
Exemplo n.º 9
0
 private bool CanExecuteReleaseCommand()
 {
     return(IsLatchActive && !IsLatched && ReleaseCommand != null && ReleaseCommand.CanExecute(ReleaseCommandParameter));
 }