From 6eb124f31b417c4fc7beb50d030761ecf5a7b389 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Fri, 2 Apr 2021 16:12:41 -0400 Subject: [PATCH] feat(Mute): Add notification for microphone muted --- .../.idea.SoundSwitch/.idea/contentModel.xml | 2 ++ .../Notification/INotification.cs | 5 +++++ .../Notification/NotificationBanner.cs | 16 ++++++++++++++ .../Notification/NotificationCustom.cs | 5 +++++ .../Notification/NotificationNone.cs | 5 +++++ .../Notification/NotificationSound.cs | 5 +++++ .../Notification/NotificationWindows.cs | 6 +++++ .../NotificationManager.cs | 5 +++++ SoundSwitch/Properties/Resources.Designer.cs | 22 ++++++++++++++++++- SoundSwitch/Properties/Resources.resx | 6 +++++ 10 files changed, 76 insertions(+), 1 deletion(-) diff --git a/.idea/.idea.SoundSwitch/.idea/contentModel.xml b/.idea/.idea.SoundSwitch/.idea/contentModel.xml index 65b132afac..47c8324e98 100644 --- a/.idea/.idea.SoundSwitch/.idea/contentModel.xml +++ b/.idea/.idea.SoundSwitch/.idea/contentModel.xml @@ -281,6 +281,8 @@ + + diff --git a/SoundSwitch/Framework/NotificationManager/Notification/INotification.cs b/SoundSwitch/Framework/NotificationManager/Notification/INotification.cs index 94e78e8768..f527865139 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/INotification.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/INotification.cs @@ -62,5 +62,10 @@ public interface INotification : IEnumImpl /// /// void NotifyProfileChanged(Profile.Profile profile, uint? processId); + + /// + /// Notify about the mute state having changed + /// + void NotifyMuteChanged(string microphoneName, bool newState); } } \ No newline at end of file diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs index 96ff1be1f9..3ad04d1d4e 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationBanner.cs @@ -62,6 +62,22 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId) _bannerManager.ShowNotification(bannerData); } + public void NotifyMuteChanged(string microphoneName, bool newState) + { + var title = newState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName); + + var icon = newState ? Resources.microphone_muted : Resources.microphone_unmuted; + + var bannerData = new BannerData + { + Priority = 1, + Image = icon, + Title = title + + }; + _bannerManager.ShowNotification(bannerData); + } + public void NotifyDefaultChanged(MMDevice audioDevice) { var icon = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioDevice, true); diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationCustom.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationCustom.cs index 027a2a2444..5d4ed7b02a 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationCustom.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationCustom.cs @@ -81,5 +81,10 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId) //Ignored } } + + public void NotifyMuteChanged(string microphoneName, bool newState) + { + + } } } \ No newline at end of file diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationNone.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationNone.cs index f195e8b7ad..0a07dcf6be 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationNone.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationNone.cs @@ -49,5 +49,10 @@ public bool IsAvailable() public void NotifyProfileChanged(Profile.Profile profile, uint? processId) { } + + public void NotifyMuteChanged(string microphoneName, bool newState) + { + + } } } \ No newline at end of file diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationSound.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationSound.cs index 1c94af91b8..a4aaef0ab4 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationSound.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationSound.cs @@ -82,6 +82,11 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId) } } + public void NotifyMuteChanged(string microphoneName, bool newState) + { + + } + private Stream GetStreamCopy() { lock (this) diff --git a/SoundSwitch/Framework/NotificationManager/Notification/NotificationWindows.cs b/SoundSwitch/Framework/NotificationManager/Notification/NotificationWindows.cs index 330d98dd46..ef05c0d6b1 100644 --- a/SoundSwitch/Framework/NotificationManager/Notification/NotificationWindows.cs +++ b/SoundSwitch/Framework/NotificationManager/Notification/NotificationWindows.cs @@ -70,5 +70,11 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId) var text = string.Join("\n", profile.Devices.Select(wrapper => wrapper.DeviceInfo.NameClean)); Configuration.Icon.ShowBalloonTip(1000, title, text, ToolTipIcon.Info); } + + public void NotifyMuteChanged(string microphoneName, bool newState) + { + var title = newState ? string.Format(SettingsStrings.notification_microphone_muted, microphoneName) : string.Format(SettingsStrings.notification_microphone_unmuted, microphoneName); + Configuration.Icon.ShowBalloonTip(1000, title, "", ToolTipIcon.Info); + } } } \ No newline at end of file diff --git a/SoundSwitch/Framework/NotificationManager/NotificationManager.cs b/SoundSwitch/Framework/NotificationManager/NotificationManager.cs index 74b24a3f7a..26d508aa7b 100644 --- a/SoundSwitch/Framework/NotificationManager/NotificationManager.cs +++ b/SoundSwitch/Framework/NotificationManager/NotificationManager.cs @@ -101,6 +101,11 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId) _notification.NotifyProfileChanged(profile, processId); } + public void NotifyMuteChanged(string microphoneName, bool newState) + { + _notification.NotifyMuteChanged(microphoneName, newState); + } + ~NotificationManager() { _model.DefaultDeviceChanged -= ModelOnDefaultDeviceChanged; diff --git a/SoundSwitch/Properties/Resources.Designer.cs b/SoundSwitch/Properties/Resources.Designer.cs index a218f80040..e016ff8a56 100644 --- a/SoundSwitch/Properties/Resources.Designer.cs +++ b/SoundSwitch/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace SoundSwitch.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -150,6 +150,26 @@ internal static System.Drawing.Bitmap InfoHelp { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap microphone_muted { + get { + object obj = ResourceManager.GetObject("microphone_muted", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap microphone_unmuted { + get { + object obj = ResourceManager.GetObject("microphone_unmuted", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/SoundSwitch/Properties/Resources.resx b/SoundSwitch/Properties/Resources.resx index 76bc9553da..730cc88d32 100644 --- a/SoundSwitch/Properties/Resources.resx +++ b/SoundSwitch/Properties/Resources.resx @@ -184,4 +184,10 @@ ..\Resources\default_profile_image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\microphone-alt-slash-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\microphone-alt-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file