예제 #1
0
 public static void DeleteHotKey(HotKey hk)
 {
     //Ensure its unregistered
     hk.UnregsiterHotkey();
     _hotkeys.Remove(hk);
     SaveHotKeys();
 }
예제 #2
0
 public static bool DuplicateHotKey(HotKey hk)
 {
     foreach (HotKey k in _hotkeys)
     {
         if (hk.Key == k.Key && hk.Modifiers == k.Modifiers)
             //((int)hk.Key & (int)hk.Modifiers) == ((int)k.Key & (int)k.Modifiers))
             return true;
     }
     return false;
 }
예제 #3
0
        public HotKeyForm(HotKey hk)
            : this()
        {
            linkedHotKey = hk;

            hotkey.DeviceID = hk.DeviceID;
            hotkey.Key = hk.Key;
            hotkey.Modifiers = hk.Modifiers;

            txtHotKey.Text = hk.HotKeyString;
            FirstFocus = false;

            Mode = HotKeyFormMode.Edit;

            btnAdd.Text = "Save";
        }
예제 #4
0
        public HotKeyForm()
        {
            InitializeComponent();

            hotkey = new HotKey();

            cmbDevices.Items.Clear();
            foreach (AudioDevice ad in AudioDeviceManager.PlayBackDevices)
                cmbDevices.Items.Add(ad);

            foreach (AudioDevice ad in AudioDeviceManager.RecordingDevices)
                cmbDevices.Items.Add(ad);

            cmbDevices.DisplayMember = "FullName";
            cmbDevices.ValueMember = "ID";
        }
예제 #5
0
        public HotKeyForm()
        {
            InitializeComponent();

            _hotkey = new HotKey();

            cmbDevices.Items.Clear();
            foreach (var ad in AudioDeviceManager.Controller.GetPlaybackDevices())
                cmbDevices.Items.Add(ad);

            foreach (var ad in AudioDeviceManager.Controller.GetCaptureDevices())
                cmbDevices.Items.Add(ad);

            cmbDevices.DisplayMember = "FullName";
            cmbDevices.ValueMember = "ID";
        }
예제 #6
0
        public HotKeyForm(HotKey hk)
            : this()
        {
            _linkedHotKey = hk;

            _hotkey.DeviceId = hk.DeviceId;
            _hotkey.Key = hk.Key;
            _hotkey.Modifiers = hk.Modifiers;

            txtHotKey.Text = hk.HotKeyString;
            _firstFocus = false;

            _mode = HotKeyFormMode.Edit;

            btnAdd.Text = "Save";
        }
예제 #7
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;
        }
예제 #8
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 = "";
            }
        }
예제 #9
0
 public HotKeyNativeWindow(HotKey owner)
 {
     Owner = owner;
 }
예제 #10
0
 private void setHotKeyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HotKeyForm hkf = null;
     foreach (HotKey hk in HotKeyManager.HotKeys)
     {
         if (hk.DeviceID == SelectedRecordingDevice.ID)
         {
             hkf = new HotKeyForm(hk);
             hkf.ShowDialog(this);
             return;
         }
     }
     var newHotKey = new HotKey();
     newHotKey.DeviceID = SelectedRecordingDevice.ID;
     hkf = new HotKeyForm(newHotKey);
     hkf.ShowDialog(this);
 }
예제 #11
0
 public static bool DuplicateHotKey(HotKey hk)
 {
     return(_hotkeys.Any(k => hk.Key == k.Key && hk.Modifiers == k.Modifiers));
 }
예제 #12
0
        private void setHotKeyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedRecordingDevice == null)
                return;

            var hotkey = HotKeyManager.HotKeys.FirstOrDefault(x => x.DeviceId == SelectedRecordingDevice.Id);

            if (hotkey == null)
            {
                hotkey = new HotKey();
                hotkey.DeviceId = SelectedRecordingDevice.Id;
            }

            var hkf = new HotKeyForm(hotkey);
            hkf.ShowDialog(this);
        }
예제 #13
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 = "";
            }
        }
예제 #14
0
 public static bool DuplicateHotKey(HotKey hk)
 {
     return _hotkeys.Any(k => hk.Key == k.Key && hk.Modifiers == k.Modifiers);
 }
예제 #15
0
 public HotKeyNativeWindow(HotKey owner)
 {
     Owner = owner;
 }