private void btnOk_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn == null) return; AbstractIdGengerator gen = new IncreatableIdGengerator("notices"); GlobalVar.Helper.Update(_table,gen); lock (GlobalVar.Instanse.Trigers) { List<ITrigerable> list = GlobalVar.Instanse.Trigers; //去掉原来的通知 for (int i = 0; i < list.Count; i++) { ITrigerable t = list[i]; if (t is Notice) { list.Remove(t); i--; } } //加上新的通知 foreach (ListViewItem item in lvNotices.Items) { DataRow row = item.Tag as DataRow; Notice n = new Notice(); GlobalVar.Helper.Row2DbObj(row, n); GlobalVar.Instanse.Trigers.Add(n); } } //GlobalVar.Instanse.NeedToSaveNotice = true; btn.Enabled = false; }
private void btnSave_Click(object sender, EventArgs e) { AbstractIdGengerator gen = new IncreatableIdGengerator("hotkeys"); GlobalVar.Helper.Update(_tbl,gen); foreach (KeyValuePair<int, string> p in HotKeys) { RunFrm.UnregisterHotKey(HotKeyHandle, p.Key); } int iStart = _StartId; HotKeys.Clear(); foreach (DataRow row in _tbl.Rows) { uint mc = Convert.ToUInt32(row["modifier_code"]); uint kc = Convert.ToUInt32(row["key_code"]); if (RunFrm.RegisterHotKey(HotKeyHandle, iStart, mc, kc)) { HotKeys.Add(iStart, row.Field<string>("cmd")); iStart++; } } }