Skip to content

Commit 84b7b46

Browse files
committed
fix(Icon): Don't change icon when communication device is changed.
Fixes #1134
1 parent f657ddf commit 84b7b46

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

SoundSwitch/Framework/TrayIcon/Icon/Changer/AbstractIconChanger.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ protected virtual bool NeedsToChangeIcon(DeviceInfo deviceInfo)
2828
public void ChangeIcon(UI.Component.TrayIcon trayIcon)
2929
{
3030
var audio = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow)Flow, ERole.eConsole);
31-
ChangeIcon(trayIcon, audio);
31+
ChangeIcon(trayIcon, audio, ERole.eConsole);
3232
}
3333

34-
public void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo)
34+
public void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo, ERole role)
3535
{
3636
var log = _log.ForContext("Device", deviceInfo);
3737
log.Information("Changing icon");
@@ -40,6 +40,12 @@ public void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo
4040
return;
4141
}
4242

43+
//Don't change icon for communication device
44+
if (role == ERole.eCommunications)
45+
{
46+
return;
47+
}
48+
4349
if (!NeedsToChangeIcon(deviceInfo))
4450
{
4551
log.Information("No need to change icon");

SoundSwitch/Framework/TrayIcon/Icon/Changer/NeverIconIconChanger.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SoundSwitch.Common.Framework.Audio.Device;
1+
using SoundSwitch.Audio.Manager.Interop.Enum;
2+
using SoundSwitch.Common.Framework.Audio.Device;
23
using SoundSwitch.Localization;
34
using SoundSwitch.Properties;
45

@@ -14,7 +15,7 @@ public void ChangeIcon(UI.Component.TrayIcon trayIcon)
1415
trayIcon.ReplaceIcon(Resources.Switch_SoundWave);
1516
}
1617

17-
public void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo)
18+
public void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo, ERole role)
1819
{
1920
}
2021
}

SoundSwitch/Framework/TrayIcon/Icon/IIconChanger.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SoundSwitch.Common.Framework.Audio.Device;
1+
using SoundSwitch.Audio.Manager.Interop.Enum;
2+
using SoundSwitch.Common.Framework.Audio.Device;
23
using SoundSwitch.Framework.Factory;
34

45
namespace SoundSwitch.Framework.TrayIcon.Icon
@@ -15,6 +16,6 @@ public interface IIconChanger : IEnumImpl<IconChangerFactory.ActionEnum>
1516
/// <summary>
1617
/// Change icon to selected device if match the condition
1718
/// </summary>
18-
void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo);
19+
void ChangeIcon(UI.Component.TrayIcon trayIcon, DeviceFullInfo deviceInfo, ERole role);
1920
}
2021
}

SoundSwitch/UI/Component/TrayIcon.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private void SetEventHandlers()
225225
AppModel.Instance.DefaultDeviceChanged += (sender, audioChangeEvent) =>
226226
{
227227
var iconChanger = new IconChangerFactory().Get(AppConfigs.Configuration.SwitchIcon);
228-
iconChanger.ChangeIcon(this, audioChangeEvent.Device);
228+
iconChanger.ChangeIcon(this, audioChangeEvent.Device, (ERole)audioChangeEvent.Role);
229229
};
230230
AppModel.Instance.NewVersionReleased += (sender, @event) =>
231231
{

0 commit comments

Comments
 (0)