public BindingList <HotkeyGroup> GetHotkeyGroups() { m_dbConnection.Open(); BindingList <HotkeyGroup> returnHotkeyGroups = new BindingList <HotkeyGroup>(); try { string sql = "select * from hotkeyGroups"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { HotkeyGroup group = new HotkeyGroup(); group.Id = int.Parse(reader["id"].ToString()); group.Name = reader["name"].ToString(); returnHotkeyGroups.Add(group); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { m_dbConnection.Close(); } return(returnHotkeyGroups); }
public void InsertHotkey(Hotkey hotkey, HotkeyGroup group) { m_dbConnection.Open(); try { string sql = "insert into hotkeys (groupId, modifier,key,command,extraData1,extraData2,extraData3) values (" + group.Id + "," + hotkey.Modifier + "," + hotkey.Key + "," + hotkey.Command + ",'" + hotkey.ExtraData1 + "','" + hotkey.ExtraData2 + "','" + hotkey.ExtraData3 + "')"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); foreach (int key in hotkey.AdditionalExtraData.Keys) { string value = hotkey.AdditionalExtraData[key]; sql = "insert into hotkeyAdditionalExtraData (groupId, modifier, key, command, keyName, dataValue) values (" + group.Id + "," + hotkey.Modifier + "," + hotkey.Key + "," + hotkey.Command + ",'" + key.ToString() + "','" + value + "')"; command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { m_dbConnection.Close(); } }
public GroupEditForm(int newId) { InitializeComponent(); Group = new HotkeyGroup(); Group.Id = newId; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; }
public void GetHotkeysForGroup(HotkeyGroup group) { ds.OpenConnection(); // doing this in the mean-time. this is no way to program. too lazy to fix factory being in the logic tier making the data reading rely on it SQLiteDataReader dataReader = ds.GetHotkeys(group); Hotkeys = new BindingList <Hotkey>(); if (dataReader != null) { while (dataReader.Read()) { int hotkeyCommand = int.Parse(dataReader["command"].ToString()); Hotkey newHotkey = HotkeyTypeFactory.GetHotkeyType(hotkeyCommand); newHotkey.Modifier = int.Parse(dataReader["modifier"].ToString()); newHotkey.Key = int.Parse(dataReader["key"].ToString()); newHotkey.Command = hotkeyCommand; newHotkey.ExtraData1 = dataReader["extraData1"].ToString(); newHotkey.ExtraData2 = dataReader["extraData2"].ToString(); newHotkey.ExtraData3 = dataReader["extraData3"].ToString(); Hotkeys.Add(newHotkey); } } ds.CloseConnection(); ds.OpenConnection(); SQLiteDataReader addtDataReader = ds.GetHotkeysAdditionalData(group); if (addtDataReader != null) { while (addtDataReader.Read()) { int currentModifier = int.Parse(addtDataReader["modifier"].ToString()); int currentKey = int.Parse(addtDataReader["key"].ToString()); int currentCommand = int.Parse(addtDataReader["command"].ToString()); Hotkey addedHotkey = Hotkeys.FirstOrDefault(hk => hk.Modifier == currentModifier && hk.Key == currentKey && hk.Command == currentCommand); if (addedHotkey != null) { string currentDataKey = addtDataReader["keyName"].ToString(); string currentDataValue = addtDataReader["dataValue"].ToString(); addedHotkey.AdditionalExtraData.Add(int.Parse(currentDataKey), currentDataValue); } } } ds.CloseConnection(); foreach (Hotkey currentHotkey in Hotkeys) { LoadHotKey(currentHotkey); } }
private void btnLoadGroup_Click(object sender, EventArgs e) { ml.UnloadAllCurrentHotkeys(); HotkeyGroup selectedGroup = (HotkeyGroup)cbGroups.SelectedItem; ml.GetHotkeysForGroup(selectedGroup); GroupLoaded = true; btnConfigure.Enabled = true; btnConfigure.Text = "Configure " + selectedGroup.Name; ml.CurrentGroup = selectedGroup; lblStatus.Text = "Loaded hotkeys for " + selectedGroup.Name; }
public Hotkey(KeyGesture keyGesture, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler) { KeyGesture = keyGesture; Description = description; Action = action; Group = group; Handler = handler; int virtualKeyCode = KeyInterop.VirtualKeyFromKey(KeyGesture.Key); Id = virtualKeyCode + ((int)KeyGesture.Modifiers * 0x10000); }
public SQLiteDataReader GetHotkeysAdditionalData(HotkeyGroup group) { try { string sql = "select * from hotkeyAdditionalExtraData where groupId = " + group.Id; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); return(reader); } catch (Exception e) { Console.WriteLine(e.ToString()); } //finally { // m_dbConnection.Close(); //} return(null); }
public void InsertHotkeyGroup(HotkeyGroup hotkeyGroup) { m_dbConnection.Open(); try { string sql = "insert into hotkeyGroups (id,name) values (" + hotkeyGroup.Id + ",'" + hotkeyGroup.Name + "')"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { m_dbConnection.Close(); } }
public void DeleteAllHotkeys(HotkeyGroup group) { m_dbConnection.Open(); try { string sql = "delete from hotkeys where groupId = " + group.Id; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); sql = "delete from hotkeyAdditionalExtraData where groupId = " + group.Id; command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { m_dbConnection.Close(); } }
public void DeleteHotkey(Hotkey hotkey, HotkeyGroup group) { DeleteHotkey(hotkey.Modifier, hotkey.Key, group.Id); }
public void DeleteHotkeyGroup(HotkeyGroup hotkeyGroup) { DeleteHotkeyGroup((int)hotkeyGroup.Id); }
public static Hotkey Register(Key key, ModifierKeys modifierKeys, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler) { return(Register(new Hotkey(key, modifierKeys, description, action, group, handler))); }
public static Hotkey Register(KeyGesture keyGesture, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler) { return(Register(new Hotkey(keyGesture, description, action, group, handler))); }
public Hotkey(Key key, ModifierKeys modifierKeys, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler) : this(new KeyGesture(key, modifierKeys), description, action, group, handler) { }