Пример #1
0
        public static void LoadHotKeys()
        {
            try
            {
                foreach (var hk in _hotkeys)
                {
                    hk.UnregisterHotkey();
                }

                _hotkeys.Clear();

                var hotkeydata = Program.Settings.HotKeys;
                if (string.IsNullOrEmpty(hotkeydata))
                {
                    RefreshHotkeys();
                    return;
                }

                var entries = hotkeydata.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries);

                for (var i = 0; i < entries.Length; i++)
                {
                    var key       = int.Parse(entries[i++]);
                    var modifiers = int.Parse(entries[i++]);
                    var hk        = new HotKey();

                    var r       = new Regex(ConfigurationSettings.GUID_REGEX);
                    var matches = r.Matches(entries[i]);
                    if (matches.Count == 0)
                    {
                        continue;
                    }
                    hk.DeviceId = new Guid(matches[0].ToString());

                    hk.Modifiers = (Modifiers)modifiers;
                    hk.Key       = (Keys)key;
                    _hotkeys.Add(hk);
                    hk.HotKeyPressed += hk_HotKeyPressed;
                    hk.RegisterHotkey();
                }
            }
            catch
            {
                Program.Settings.HotKeys = "";
            }
        }
Пример #2
0
        public static bool AddHotKey(HotKey hk)
        {
            //Check that there is no duplicate
            if (DuplicateHotKey(hk))
                return false;

            hk.HotKeyPressed += hk_HotKeyPressed;
            hk.RegisterHotkey();

            if (!hk.IsRegistered)
                return false;

            _hotkeys.Add(hk);

            SaveHotKeys();
            return true;
        }
Пример #3
0
        public static bool AddHotKey(HotKey hk)
        {
            //Check that there is no duplicate
            if (DuplicateHotKey(hk))
            {
                return(false);
            }

            hk.HotKeyPressed += hk_HotKeyPressed;
            hk.RegisterHotkey();

            if (!hk.IsRegistered)
            {
                return(false);
            }

            _hotkeys.Add(hk);

            SaveHotKeys();
            return(true);
        }
Пример #4
0
        public static void LoadHotKeys()
        {
            try
            {
                foreach (HotKey hk in _hotkeys)
                {
                    hk.UnregsiterHotkey();
                }

                string hotkeydata = ConfigurationSettings.HotKeys;
                if (string.IsNullOrEmpty(hotkeydata))
                {
                    return;
                }

                string[] entries = hotkeydata.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries);

                _hotkeys.Clear();

                for (int i = 0; i < entries.Length; i++)
                {
                    int key       = int.Parse(entries[i++]);
                    int modifiers = int.Parse(entries[i++]);
                    var hk        = new HotKey();
                    hk.DeviceID  = entries[i];
                    hk.Modifiers = (Modifiers)modifiers;
                    hk.Key       = (Keys)key;
                    _hotkeys.Add(hk);
                    hk.HotKeyPressed += hk_HotKeyPressed;
                    hk.RegisterHotkey();
                }
            }
            catch
            {
                ConfigurationSettings.HotKeys = "";
            }
        }
Пример #5
0
        public static void LoadHotKeys()
        {
            try
            {
                foreach (HotKey hk in _hotkeys)
                {
                    hk.UnregsiterHotkey();
                }

                string hotkeydata = ConfigurationSettings.HotKeys;
                if (string.IsNullOrEmpty(hotkeydata))
                    return;

                string[] entries = hotkeydata.Split(new[] {",", "[", "]"}, StringSplitOptions.RemoveEmptyEntries);

                _hotkeys.Clear();

                for (int i = 0; i < entries.Length; i++)
                {
                    int key = int.Parse(entries[i++]);
                    int modifiers = int.Parse(entries[i++]);
                    var hk = new HotKey();
                    hk.DeviceID = entries[i];
                    hk.Modifiers = (Modifiers) modifiers;
                    hk.Key = (Keys) key;
                    _hotkeys.Add(hk);
                    hk.HotKeyPressed += hk_HotKeyPressed;
                    hk.RegisterHotkey();
                }
            }
            catch
            {
                ConfigurationSettings.HotKeys = "";
            }
        }
Пример #6
0
        public static void LoadHotKeys()
        {
            try
            {
                foreach (var hk in _hotkeys)
                {
                    hk.UnregsiterHotkey();
                }

                _hotkeys.Clear();

                var hotkeydata = Program.Settings.HotKeys;
                if (string.IsNullOrEmpty(hotkeydata))
                {
                    RefreshHotkeys();
                    return;
                }

                var entries = hotkeydata.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries);

                for (var i = 0; i < entries.Length; i++)
                {
                    var key = int.Parse(entries[i++]);
                    var modifiers = int.Parse(entries[i++]);
                    var hk = new HotKey();

                    var r = new Regex(ConfigurationSettings.GUID_REGEX);
                    var matches = r.Matches(entries[i]);
                    if (matches.Count == 0)
                        continue;
                    hk.DeviceId = new Guid(matches[0].ToString());

                    hk.Modifiers = (Modifiers)modifiers;
                    hk.Key = (Keys)key;
                    _hotkeys.Add(hk);
                    hk.HotKeyPressed += hk_HotKeyPressed;
                    hk.RegisterHotkey();
                }
            }
            catch
            {
                Program.Settings.HotKeys = "";
            }
        }