public void RegisterAllOpeToHotKey(IntPtr hWnd) { bool hasProblem = false; try { foreach (DataRow item in Rows) { if (item["HotKeyObject"] == DBNull.Value) { continue; } if (item["HotKeyObject"] is ComboKey) { bool result = ComboKey.RegisterComboKeys((ComboKey)item["HotKeyObject"]); if (result == false) { Rows[Rows.IndexOf(item)]["Enabled"] = false; hasProblem = true; } else { Rows[Rows.IndexOf(item)]["Enabled"] = true; } } else { bool result = HotKey.RegisterHotKey( hWnd, int.Parse(item["ID"].ToString()), (uint)((HotKey)item["HotKeyObject"]).ModKeys, (uint)(KeyInterop.VirtualKeyFromKey(((HotKey)item["HotKeyObject"]).Key))); if (result == false) { Rows[Rows.IndexOf(item)]["Enabled"] = false; hasProblem = true; } else { Rows[Rows.IndexOf(item)]["Enabled"] = true; } } } } catch (HotKey.HotKeyException exception) { MessageBox.Show(exception.Message); } if (hasProblem) { MessageBox.Show("Some hotkey was failed to register." + Environment.NewLine + "Please check setting that had been gray-outed."); } }
public static bool RegisterComboKeys(ComboKey combo_key) { if (ComboList.Find(x => x.Priority == combo_key.Priority) != null) { return(false); } ComboList.Add(combo_key); ComboList.OrderBy(x => - x.Priority); return(true); }
public static bool SetComboKey(string combo_setting, DataRow row) { List <int> combo_seq; int priorty; if (ComboKey.CanSet(combo_setting, out combo_seq, out priorty) == false) { return(false); } ComboKey combo_key = new ComboKey((int)row["ID"], combo_seq, priorty); row["HotKey"] = combo_key.MyToString(); row["HotKeyObject"] = combo_key; return(true); }
private void ThreadPreprocessMessageMethod(ref MSG msg, ref bool handled) { const int WM_HOTKEY = 0x0312; switch (msg.message) { case WM_HOTKEY: int id = msg.wParam.ToInt32(); int combo_id; if (ComboKey.FindComboToFire(id, out combo_id)) { OpeInfoTable.GetInstance().DoOpeScript(combo_id); } else { OpeInfoTable.GetInstance().DoOpeScript(id); } handled = true; break; } }
public void UnregisterAllOpeToHotKey(IntPtr hWnd) { try { foreach (DataRow item in Rows) { if (item["HotkeyObject"] is ComboKey) { ComboKey.UnregisterComboKeys(item["HotkeyObject"] as ComboKey); } else { // We don't care the failure of hotkey unregistration // because there is nothing to do for. HotKey.UnregisterHotKey(hWnd, int.Parse(item["ID"].ToString())); } } } catch (HotKey.HotKeyException exception) { MessageBox.Show(exception.Message); } }
public static bool UnregisterComboKeys(ComboKey combo) { return(ComboList.Remove(combo)); }
private void dgOpeList_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e) { if (e.Column.Header.ToString() != "HotKey") { return; } if (e.EditingElement is TextBox) { if (((TextBox)e.EditingElement).Text.StartsWith("combo") == false) { ((TextBox)e.EditingElement).Text = String.Format("combo({{}}, {0})", ComboKey.GetNextHighestPriority()); ((TextBox)e.EditingElement).CaretIndex = "combo({".Length; } } }