コード例 #1
0
        private void OnKeyDown(object sender, KeyEventArgs e, HotKeyToAction hotKeyToAction)
        {
            Logger.Log(_hotKeysManager.GetCurrentStates() + ", " + e.KeyCode, LogLevel.Debug);

            if (!_settingManager.HotKeysActive)
            {
                return;
            }

            SlotManager slotManager = null;

            if (tabControl1.SelectedTab == tabPageSlot1)
            {
                slotManager = _slot1;
            }

            if (tabControl1.SelectedTab == tabPageSlot2)
            {
                slotManager = _slot2;
            }

            if (tabControl1.SelectedTab == tabPageSlot3)
            {
                slotManager = _slot3;
            }

            if (slotManager != null)
            {
                switch (hotKeyToAction.Action)
                {
                case HotKeyAction.MapPrevious:
                    slotManager.MapSelectPrevious();
                    e.Handled = true;
                    break;

                case HotKeyAction.MapNext:
                    slotManager.MapSelectNext();
                    e.Handled = true;
                    break;

                case HotKeyAction.SaveFirst:
                    slotManager.SaveSelectFirst();
                    e.Handled = true;
                    break;

                case HotKeyAction.SaveLast:
                    slotManager.SaveSelectLast();
                    e.Handled = true;
                    break;

                case HotKeyAction.SavePrevious:
                    slotManager.SaveSelectPrevious();
                    e.Handled = true;
                    break;

                case HotKeyAction.SaveNext:
                    slotManager.SaveSelectNext();
                    e.Handled = true;
                    break;

                case HotKeyAction.SaveRestore:
                    if (slotManager.ActionSaveRestore())
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlaySuccess();
                        }
                    }
                    else
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlayError();
                        }
                    }

                    e.Handled = true;
                    break;

                case HotKeyAction.SaveBackup:
                    if (slotManager.ActionSaveBackup(false))
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlaySuccess();
                        }
                    }
                    else
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlayError();
                        }
                    }

                    e.Handled = true;
                    break;

                case HotKeyAction.SaveDelete:
                    if (slotManager.ActionSaveDelete())
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlaySuccess();
                        }
                    }
                    else
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlayError();
                        }
                    }

                    e.Handled = true;
                    break;

                case HotKeyAction.SettingSwitchAutoBackup:
                    if (slotManager.ActionSettingSwitchAutoBackup())
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlaySuccess();
                        }
                    }
                    else
                    {
                        if (_settingManager.HotKeysSound)
                        {
                            SoundManager.PlayError();
                        }
                    }

                    e.Handled = true;
                    break;
                }
            }
        }