Skip to content

Commit eed50e8

Browse files
Merge pull request #2169 from vallcrist/master
Added "Show unknow devices in hotkey list" option
2 parents d283eaf + e5a3112 commit eed50e8

6 files changed

Lines changed: 1031 additions & 982 deletions

File tree

FortyOne.AudioSwitcher/AudioSwitcher.Designer.cs

Lines changed: 985 additions & 970 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FortyOne.AudioSwitcher/AudioSwitcher.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ private void LoadSettings()
769769
chkNotifyUpdates.Checked = Program.Settings.UpdateNotificationsEnabled;
770770

771771
chkShowDiabledDevices.Checked = Program.Settings.ShowDisabledDevices;
772+
chkShowUnknownDevicesInHotkeyList.Checked = Program.Settings.ShowUnknownDevicesInHotkeyList;
772773
chkShowDisconnectedDevices.Checked = Program.Settings.ShowDisconnectedDevices;
773774
chkShowDPDeviceIconInTray.Checked = Program.Settings.ShowDPDeviceIconInTray;
774775

@@ -1463,5 +1464,19 @@ private async void listBoxRecording_MouseDoubleClick(object sender, MouseEventAr
14631464
await SelectedRecordingDevice.SetAsDefaultAsync();
14641465
PostRecordingMenuClick(id);
14651466
}
1466-
}
1467+
1468+
private void chkShowUnknownDevicesInHotkeyList_CheckedChanged(object sender, EventArgs e)
1469+
{
1470+
Program.Settings.ShowUnknownDevicesInHotkeyList = chkShowUnknownDevicesInHotkeyList.Checked;
1471+
1472+
if (IsHandleCreated)
1473+
{
1474+
BeginInvoke((Action)(() =>
1475+
{
1476+
HotKeyManager.RefreshHotkeys();
1477+
RefreshGrid();
1478+
}));
1479+
}
1480+
}
1481+
}
14671482
}

FortyOne.AudioSwitcher/AudioSwitcher.resx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,11 @@
123123
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124124
<value>1006, 17</value>
125125
</metadata>
126-
<metadata name="recordingStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127-
<value>172, 17</value>
128-
</metadata>
129126
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130127
<value>713, 17</value>
131128
</metadata>
132-
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
133-
<value>1006, 17</value>
129+
<metadata name="recordingStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130+
<value>172, 17</value>
134131
</metadata>
135132
<metadata name="hotKeyBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
136133
<value>545, 17</value>
@@ -1031,9 +1028,6 @@
10311028
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
10321029
<value>1249, 17</value>
10331030
</metadata>
1034-
<metadata name="hotKeyBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
1035-
<value>545, 17</value>
1036-
</metadata>
10371031
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
10381032
<value>
10391033
AAABAA0AMDAQAAEABABoBgAA1gAAACAgEAABAAQA6AIAAD4HAAAYGBAAAQAEAOgBAAAmCgAAEBAQAAEA

FortyOne.AudioSwitcher/Configuration/ConfigurationSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class ConfigurationSettings
2323
public const string SETTING_STARTUPPLAYBACKDEVICE = "StartupPlaybackDeviceID";
2424
public const string SETTING_DUALSWITCHMODE = "DualSwitchMode";
2525
public const string SETTING_SHOWDISABLEDDEVICES = "ShowDisabledDevices";
26+
public const string SETTING_SHOWUNKNOWNDEVICESINHOTKEYLIST = "ShowUnknownDevicesInHotkeyList";
2627
public const string SETTING_SHOWDISCONNECTEDDDEVICES = "ShowDisconnectedDevices";
2728
public const string SETTING_SHOWDPDEVICEIICONINTRAY = "ShowDPDeviceIconInTray";
2829
public const string SETTING_UPDATE_NOTIFICATIONS_ENABLED = "UpdateNotificationsEnabled";
@@ -104,6 +105,16 @@ public bool ShowDisabledDevices
104105
set { _configWriter.Set(SETTING_SHOWDISABLEDDEVICES, value.ToString()); }
105106
}
106107

108+
public bool ShowUnknownDevicesInHotkeyList
109+
{
110+
get
111+
{
112+
return
113+
Convert.ToBoolean(_configWriter.Get(SETTING_SHOWUNKNOWNDEVICESINHOTKEYLIST));
114+
}
115+
set { _configWriter.Set(SETTING_SHOWUNKNOWNDEVICESINHOTKEYLIST, value.ToString()); }
116+
}
117+
107118
public bool ShowDisconnectedDevices
108119
{
109120
get
@@ -278,6 +289,9 @@ public void CreateDefaults()
278289
if (!SettingExists(SETTING_SHOWDISABLEDDEVICES))
279290
ShowDisabledDevices = false;
280291

292+
if (!SettingExists(SETTING_SHOWUNKNOWNDEVICESINHOTKEYLIST))
293+
ShowUnknownDevicesInHotkeyList = false;
294+
281295
if (!SettingExists(SETTING_SHOWDISCONNECTEDDDEVICES))
282296
ShowDisconnectedDevices = false;
283297

@@ -300,6 +314,7 @@ public void LoadFrom(ConfigurationSettings otherSettings)
300314
HotKeys = otherSettings.HotKeys;
301315
PollForUpdates = otherSettings.PollForUpdates;
302316
ShowDisabledDevices = otherSettings.ShowDisabledDevices;
317+
ShowUnknownDevicesInHotkeyList = otherSettings.ShowUnknownDevicesInHotkeyList;
303318
ShowDisconnectedDevices = otherSettings.ShowDisconnectedDevices;
304319
StartMinimized = otherSettings.StartMinimized;
305320
StartupPlaybackDeviceID = otherSettings.StartupPlaybackDeviceID;

FortyOne.AudioSwitcher/HotKeyData/HotKey.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ public IDevice Device
4242

4343
public string DeviceName
4444
{
45-
get { return Device.FullName; }
45+
get
46+
{
47+
if (Device == null)
48+
return "Unknown Device";
49+
return Device.FullName;
50+
}
4651
}
4752

4853
public string HotKeyString

FortyOne.AudioSwitcher/HotKeyData/HotKeyManager.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,15 @@ public static bool AddHotKey(HotKey hk)
114114
return true;
115115
}
116116

117-
private static void RefreshHotkeys()
117+
public static void RefreshHotkeys()
118118
{
119119
HotKeys.Clear();
120-
foreach (var k in _hotkeys.Where(x => x.Device != null))
120+
var filterInvalid = !Program.Settings.ShowUnknownDevicesInHotkeyList;
121+
IEnumerable<HotKey> hotkeyList = _hotkeys;
122+
if (filterInvalid)
123+
hotkeyList = hotkeyList.Where(x => x.Device != null);
124+
125+
foreach (var k in hotkeyList)
121126
{
122127
HotKeys.Add(k);
123128
}

0 commit comments

Comments
 (0)