Skip to content

Commit

Permalink
feat(Mute): Add notification for microphone muted
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed Apr 2, 2021
1 parent ab9f6a7 commit 6eb124f
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .idea/.idea.SoundSwitch/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ public interface INotification : IEnumImpl<NotificationTypeEnum>
/// <param name="profile"></param>
/// <param name="processId"></param>
void NotifyProfileChanged(Profile.Profile profile, uint? processId);

/// <summary>
/// Notify about the mute state having changed
/// </summary>
void NotifyMuteChanged(string microphoneName, bool newState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,10 @@ public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
//Ignored
}
}

public void NotifyMuteChanged(string microphoneName, bool newState)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ public bool IsAvailable()
public void NotifyProfileChanged(Profile.Profile profile, uint? processId)
{
}

public void NotifyMuteChanged(string microphoneName, bool newState)
{

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

public void NotifyMuteChanged(string microphoneName, bool newState)
{

}

private Stream GetStreamCopy()
{
lock (this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 21 additions & 1 deletion SoundSwitch/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SoundSwitch/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,10 @@
<data name="default_profile_image" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\default_profile_image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="microphone_muted" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\microphone-alt-slash-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="microphone_unmuted" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\microphone-alt-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

0 comments on commit 6eb124f

Please sign in to comment.