Skip to content

Commit

Permalink
feat(Mute): plug the service to the notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed Apr 2, 2021
1 parent 280428d commit bb4baa6
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ namespace SoundSwitch.Framework.Audio.Microphone
public class MicrophoneMuteToggler
{
private readonly AudioSwitcher _switcher;
private readonly NotificationManager.NotificationManager _notificationManager;

public MicrophoneMuteToggler(AudioSwitcher switcher)
public MicrophoneMuteToggler(AudioSwitcher switcher, NotificationManager.NotificationManager notificationManager)
{
_switcher = switcher;
_notificationManager = notificationManager;
}

/// <summary>
Expand All @@ -33,6 +35,7 @@ public MicrophoneMuteToggler(AudioSwitcher switcher)
{
var newMuteState = !microphone.AudioEndpointVolume.Mute;
device.AudioEndpointVolume.Mute = newMuteState;
_notificationManager.NotifyMuteChanged(device.FriendlyName, newMuteState);
return newMuteState;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public interface INotification : IEnumImpl<NotificationTypeEnum>
/// <summary>
/// Notify about the mute state having changed
/// </summary>
void NotifyMuteChanged(string microphoneName, bool newState);
void NotifyMuteChanged(string microphoneName, bool newMuteState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
_bannerManager.ShowNotification(bannerData);
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{
var title = newState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName);
var title = newMuteState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName);

var icon = newState ? Resources.microphone_muted : Resources.microphone_unmuted;
var icon = newMuteState ? Resources.microphone_muted : Resources.microphone_unmuted;

var bannerData = new BannerData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
}
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
{
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
}
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
Configuration.Icon.ShowBalloonTip(1000, title, text, ToolTipIcon.Info);
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{
var title = newState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName);
var title = newMuteState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName);
Configuration.Icon.ShowBalloonTip(1000, title, "", ToolTipIcon.Info);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
_notification.NotifyProfileChanged(profile, processId);
}

public void NotifyMuteChanged(string microphoneName, bool newState)
public void NotifyMuteChanged(string microphoneName, bool newMuteState)
{
_notification.NotifyMuteChanged(microphoneName, newState);
_notification.NotifyMuteChanged(microphoneName, newMuteState);
}

~NotificationManager()
Expand Down

0 comments on commit bb4baa6

Please sign in to comment.