Skip to content

Commit

Permalink
boost(Systray::Tooltip): Add volume % when hovering the SoundSwitch i…
Browse files Browse the repository at this point in the history
…con.
  • Loading branch information
Belphemur committed Sep 4, 2021
1 parent 2406d6c commit 9b1aba3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class DeviceFullInfo : DeviceInfo
public System.Drawing.Icon LargeIcon => AudioDeviceIconExtractor.ExtractIconFromPath(IconPath, Type, true);
public System.Drawing.Icon SmallIcon => AudioDeviceIconExtractor.ExtractIconFromPath(IconPath, Type, false);

public int Volume { get; } = 0;

[JsonConstructor]
public DeviceFullInfo(string name, string id, DataFlow type, string iconPath, DeviceState state, bool isUsb) : base(name, id, type, isUsb, DateTime.UtcNow)
{
Expand All @@ -24,6 +26,14 @@ public DeviceFullInfo(MMDevice device) : base(device)
{
IconPath = device.IconPath;
State = device.State;
try
{
Volume = (int)(device.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
}
catch
{
//Ignored
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public string TextToDisplay()
var playbackDefaultDevice = AudioSwitcher.Instance.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eConsole);
return playbackDefaultDevice == null
? null
: string.Format(SettingsStrings.activePlayback, playbackDefaultDevice.NameClean);
: string.Format(SettingsStrings.activePlayback + " - {1}%", playbackDefaultDevice.NameClean, playbackDefaultDevice.Volume);
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public string TextToDisplay()
var recordingDevice = AudioSwitcher.Instance.GetDefaultAudioEndpoint(EDataFlow.eCapture, ERole.eConsole);
return recordingDevice == null
? null
: string.Format(SettingsStrings.activeRecording, recordingDevice.NameClean);
: string.Format(SettingsStrings.activePlayback + " - {1}%", recordingDevice.NameClean, recordingDevice.Volume);
}

public override string ToString()
Expand Down

0 comments on commit 9b1aba3

Please sign in to comment.