Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
 public GroupEditForm(int newId)
 {
     InitializeComponent();
     Group             = new HotkeyGroup();
     Group.Id          = newId;
     this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
        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();
            }
        }
Exemplo n.º 9
0
        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();
            }
        }
Exemplo n.º 10
0
 public void DeleteHotkey(Hotkey hotkey, HotkeyGroup group)
 {
     DeleteHotkey(hotkey.Modifier, hotkey.Key, group.Id);
 }
Exemplo n.º 11
0
 public void DeleteHotkeyGroup(HotkeyGroup hotkeyGroup)
 {
     DeleteHotkeyGroup((int)hotkeyGroup.Id);
 }
Exemplo n.º 12
0
 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)));
 }
Exemplo n.º 13
0
 public static Hotkey Register(KeyGesture keyGesture, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler)
 {
     return(Register(new Hotkey(keyGesture, description, action, group, handler)));
 }
Exemplo n.º 14
0
 public Hotkey(Key key, ModifierKeys modifierKeys, string description, MyAction action, HotkeyGroup group, HotkeyHandler handler) :
     this(new KeyGesture(key, modifierKeys), description, action, group, handler)
 {
 }