コード例 #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
ファイル: HotKeyForm.cs プロジェクト: rivnam/AudioSwitcher_v1
        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
ファイル: HotKeyForm.cs プロジェクト: rivnam/AudioSwitcher_v1
        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
ファイル: HotKey.cs プロジェクト: quintesse/AudioSwitcher_v1
 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
ファイル: HotKey.cs プロジェクト: thop/AudioSwitcher_v1
 public HotKeyNativeWindow(HotKey owner)
 {
     Owner = owner;
 }