Esempio n. 1
0
 /// <summary>
 /// 清空
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Clear_e_Click(object sender, EventArgs e)
 {
     exchangeList.Clear();
     foreach (Model.ExchangeInfo model in exchangeList)
     {
         SystemHotKey.UnRegHotKey(this.Handle, model.HotKeyID.Value);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Delete_e_Click(object sender, EventArgs e)
 {
     if (dgv_KeyTextPair.SelectedRows.Count < 0)
     {
         return;
     }
     exchangeModel = GetDataRowModel(dgv_KeyTextPair.SelectedRows[0]);
     exchangeList.RemoveAll(i => i.RecordID == exchangeModel.RecordID);
     SystemHotKey.UnRegHotKey(this.Handle, exchangeModel.HotKeyID.Value);
     exchangeList.RemoveAll(i => i.RecordID == exchangeModel.RecordID);
 }
Esempio n. 3
0
 /// <summary>
 /// 注销热键
 /// </summary>
 private void UnRegHotKeys()
 {
     SystemHotKey.UnRegHotKey(this.Handle, 7001);
     SystemHotKey.UnRegHotKey(this.Handle, 7002);
     SystemHotKey.UnRegHotKey(this.Handle, 7003);
     SystemHotKey.UnRegHotKey(this.Handle, 7004);
     foreach (Model.ExchangeInfo model in exchangeList)
     {
         SystemHotKey.UnRegHotKey(this.Handle, model.HotKeyID.Value);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Save_e_Click(object sender, EventArgs e)
 {
     if (cmb_RecvKey_Shift.Text == "None" && cmb_RecvKey_Main.Text == "None")
     {
         return;
     }
     if (exchangeModel != null)
     {
         exchangeModel.ExchangeText = txt_PrintText_e.Text;
         exchangeModel.ShiftKey     = cmb_RecvKey_Shift.Text;
         exchangeModel.MainKey      = cmb_RecvKey_Main.Text;
         exchangeList.RemoveAll(i => i.RecordID == exchangeModel.RecordID);
         exchangeList.Add(exchangeModel);
         exchangeBll.Update(exchangeModel);
         SystemHotKey.UnRegHotKey(this.Handle, exchangeModel.HotKeyID.Value);
     }
     else
     {
         exchangeModel = new Model.ExchangeInfo();
         for (int i = 7010; i < 10000; i++)
         {
             if (!exchangeList.Select(m => m.HotKeyID).Contains(i))
             {
                 exchangeModel.HotKeyID = i;
                 break;
             }
         }
         exchangeModel.ExchangeText = txt_PrintText_e.Text;
         exchangeModel.ShiftKey     = cmb_RecvKey_Shift.Text;
         exchangeModel.MainKey      = cmb_RecvKey_Main.Text;
         exchangeList.Add(exchangeModel);
         exchangeBll.Add(exchangeModel);
     }
     if (!SystemHotKey.RegisterHotKey(this.Handle, exchangeModel.HotKeyID.Value, (EnumClass.KeyModifiers)Enum.Parse(typeof(EnumClass.KeyModifiers), exchangeModel.ShiftKey), (Keys)Enum.Parse(typeof(Keys), exchangeModel.MainKey)))
     {
         MessageBox.Show("热键注册失败");
     }
     dgv_KeyTextPair.DataSource = exchangeList.ToArray();
     dgv_KeyTextPair.Columns["Key"].HeaderText   = "接收按键";
     dgv_KeyTextPair.Columns["Value"].HeaderText = "输出文本";
 }