예제 #1
0
        private void OnPreviewKeyDown(object sender, KeyEventArgs keyEventArgs)
        {
            keyEventArgs.Handled = true;
            KeySettingViewModel keySetting = DataContext as KeySettingViewModel;

            if (keySetting != null)
            {
                keySetting.Key = keyEventArgs.Key;
            }
            DisplayKey(); // Needed because PropertyChanged doesn't work on Key :/
        }
예제 #2
0
        private void DisplayKey()
        {
            FontStyle  = FontStyles.Normal;
            Foreground = new SolidColorBrush(Colors.Black);
            KeySettingViewModel keySetting = DataContext as KeySettingViewModel;

            if (keySetting != null)
            {
                Text = keySetting.KeyDescription;
            }
        }
예제 #3
0
        private static Commands MapKeyToCommand(Key key)
        {
            KeySettingViewModel keySetting = ClientOptionsViewModel.Instance.KeySettings.FirstOrDefault(x => x.Key == key);

            if (keySetting != null)
            {
                return(keySetting.Command);
            }
            switch (key)
            {
            case Key.H:
                return(Commands.Hold);

            case Key.Space:
                return(Commands.Drop);

            case Key.Down:
                return(Commands.Down);

            case Key.Left:
                return(Commands.Left);

            case Key.Right:
                return(Commands.Right);

            case Key.Up:
                return(Commands.RotateCounterclockwise);

            case Key.PageDown:
                return(Commands.RotateClockwise);

            case Key.D:
                return(Commands.DiscardFirstSpecial);

            case Key.NumPad1:
            case Key.D1:
                return(Commands.UseSpecialOn1);

            case Key.NumPad2:
            case Key.D2:
                return(Commands.UseSpecialOn2);

            case Key.NumPad3:
            case Key.D3:
                return(Commands.UseSpecialOn3);

            case Key.NumPad4:
            case Key.D4:
                return(Commands.UseSpecialOn4);

            case Key.NumPad5:
            case Key.D5:
                return(Commands.UseSpecialOn5);

            case Key.NumPad6:
            case Key.D6:
                return(Commands.UseSpecialOn6);

            case Key.Enter:
                return(Commands.UseSpecialOn6);
            }
            return(Commands.Invalid);
        }