Esempio n. 1
0
        public static void CallHotkey(Hotkey hotkey, HKID hkID, ref bool hkOK, Action hkAction)
        {
            bool once = false;

            if (!hotkey.Double)
            {
                once = true;
            }
            if (hotkey.ID == (int)hkID && hotkey.Enabled)
            {
                if (hkOK || once)
                {
                    Logging.Log("Hotkey [" + Enum.GetName(typeof(HKID), hkID) + "] fired.");
                    if (MahouUI.BlockHKWithCtrl && ContainsModifier((int)hotkey.Modifiers, (int)WinAPI.MOD_CONTROL))
                    {
                    }
                    else
                    {
                        if (hotkey.Modifiers > 0 && MahouUI.RePress)
                        {
                            KMHook.hotkeywithmodsfired = true;
                            KMHook.RePressAfter(Convert.ToInt32(hotkey.Modifiers));
                        }
                    }
                    if (hotkey.ID <= (int)Hotkey.HKID.TransliterateSelection || hotkey.ID == (int)Hotkey.HKID.ShowSelectionTranslation ||
                        hotkey.ID == (int)Hotkey.HKID.CycleCase
                        )
                    {
                        KMHook.SendModsUp(Convert.ToInt32(hotkey.Modifiers));
                    }
                    KMHook.IfKeyIsMod((System.Windows.Forms.Keys)hotkey.VirtualKeyCode);
                    hkAction();
                    if (MahouUI.RePress)
                    {
                        KMHook.RePress();
                    }
                }
                else if (hotkey.Double)
                {
                    Logging.Log("Waiting for second hotkey [" + Enum.GetName(typeof(HKID), hkID) + "] press.");
                    hkOK = true;
                    KMHook.doublekey.Interval = MMain.mahou.DoubleHKInterval;
                    KMHook.doublekey.Start();
                }
            }
        }