Exemplo n.º 1
0
        private void StartRandom()
        {
            int            index;
            CharacterModel character;

            while (true)
            {
                index     = Random.Next(Characters.Count);
                character = Characters[index];
                if (character.IsSelected && !(PreventDuplicates && character.WasPlayed) && character.IsAvailable)
                {
                    break;
                }
            }
            character.WasPlayed = PreventDuplicates;
            if (Characters.All(c => !c.IsSelected || c.WasPlayed))
            {
                foreach (var characterModel in Characters)
                {
                    characterModel.WasPlayed = false;
                }
            }
            while (index < Characters.CountAvaiblable() * 2 + 1)
            {
                index += Characters.CountAvaiblable() + 1;
            }
            for (int i = 0; i < index; i++)
            {
                Keylogger.PostKey(Keys.Right);
                Task.Delay(Math.Max(50, i * i / 4)).Wait();
            }
            NewPlayStarted?.Invoke(this, character);
            if (StartAfterSelection)
            {
                Task.Delay(66).Wait();
                Keylogger.PostKey(Keys.Enter);
            }
        }
Exemplo n.º 2
0
 private void Keylogger_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.LControlKey || e.KeyCode == Keys.LMenu)
     {
         return;
     }
     if (KeyCombinationChangedCommand.Executing)
     {
         return;
     }
     if (Keylogger.IsKeyDown(Keys.LControlKey))
     {
         if (Keylogger.IsKeyDown(Keys.LMenu))
         {
             var key    = char.ToUpper((char)e.KeyValue);
             var target = StartKeyCombination.Split('+')[2][0];
             if (key == target)
             {
                 StartRandom();
             }
         }
     }
 }
Exemplo n.º 3
0
 public App()
 {
     Keylogger.Start();
 }