/// <summary> /// 初始化软件软件热键列表,这个方法留着做使用示例吧 /// </summary> private void Init_Software_Hotkey_List() { Software_Hotkey.Setting setting = new Software_Hotkey.Setting { title_regexMatch = @".*?(Microsoft Visual Studio)", title_MatchValue = "Microsoft Visual Studio", title_MatchGroup = 1, class_regexMatch = @"^(HwndWrapper)\[DefaultDomain", class_MatchValue = "HwndWrapper", class_MatchGroup = 1, softwareName = "Visual Studio" }; Software_Hotkey vSh = new Software_Hotkey(setting); vSh.next.HotKey[0].Add(Keys.LShiftKey); vSh.next.HotKey[0].Add(Keys.F5); vSh.last.HotKey[0].Add(Keys.F5); Software_Hotkey.HotKey_Execute vHe1 = new Software_Hotkey.HotKey_Execute(); Software_Hotkey.HotKey_Execute vHe2 = new Software_Hotkey.HotKey_Execute(); vHe1.HotKey[0].Add(Keys.F5); vHe1.comment = "开始"; vHe2.HotKey[0].Add(Keys.LShiftKey); vHe2.HotKey[0].Add(Keys.F5); vHe2.comment = "停止"; vSh.key_List.Add(vHe1); vSh.key_List.Add(vHe2); //JSON.stringify() vShm.Software_Hotkey_List.Add(vSh); vShm.Save_Config(); }
/// <summary> /// 获取当前选中的软件配置 /// </summary> /// <returns></returns> private Software_Hotkey Get_Selection_Software() { int index = win.comboBox_software_list.SelectedIndex; Software_Hotkey ret = win.v_kma.vShm.Software_Hotkey_List[index]; return(ret); }
/// <summary> /// 添加软件 /// </summary> public void Add_software(String softwareName) { if (softwareName == "") { return; } Software_Hotkey.Setting setting = new Software_Hotkey.Setting() { softwareName = softwareName }; Software_Hotkey v_sh = new Software_Hotkey(setting); win.v_kma.vShm.Software_Hotkey_List.Add(v_sh); win.v_kma.vShm.Save_Config(); win.comboBox_software_list.Items.Add(softwareName); }
/// <summary> /// 重命名 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBox_software_name_TextChanged(object sender, EventArgs e) { TextBox textbox = (TextBox)sender; string softwareName = textbox.Text; if (softwareName == "") { softwareName = "未命名"; } int index = win.comboBox_software_list.SelectedIndex; Software_Hotkey v_sh = win.v_kma.vShm.Software_Hotkey_List[index]; v_sh.setting.softwareName = softwareName; win.comboBox_software_list.Items.RemoveAt(index); win.comboBox_software_list.Items.Insert(index, softwareName); win.comboBox_software_list.SelectedIndex = index; win.v_kma.vShm.Save_Config(); //保存配置 }
/// <summary> /// 添加热键项 /// </summary> public void Add_hotKey_item() { string comment = win.textBox_hotKey_comment.Text; int index = win.comboBox_software_list.SelectedIndex; Software_Hotkey v_sh = win.v_kma.vShm.Software_Hotkey_List[index]; Software_Hotkey.HotKey_Execute v_shhe = new Software_Hotkey.HotKey_Execute(); v_shhe.comment = comment; for (var i = 0; i < v_shhe.HotKey.Length; i++) { v_shhe.HotKey[i] = new List <Keys>(win.v_hotKey[i]); } v_sh.key_List.Add(v_shhe); //假装触发一次事件,让列表刷新 win.v_ce.ComboBox_software_list_SelectionChangeCommitted(win.comboBox_software_list, EventArgs.Empty); win.v_kma.vShm.Save_Config(); //保存配置 }