Skip to content

Commit

Permalink
GPU status phrasing
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Jun 28, 2022
1 parent b4216fc commit e03414e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
9 changes: 4 additions & 5 deletions LenovoLegionToolkit.Lib/Controllers/GPUController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,14 @@ private async Task RefreshStateAsync()
try
{
var stateId = gpu.PerformanceStatesInfo.CurrentPerformanceState.StateId.ToString().GetUntilOrEmpty("_");
if (string.IsNullOrEmpty(stateId))
_performanceState = "On";
else
_performanceState = $"On, {stateId}";
_performanceState = "Powered On";
if (!string.IsNullOrWhiteSpace(stateId))
_performanceState += $", {stateId}";

}
catch (Exception ex) when (ex.Message == "NVAPI_GPU_NOT_POWERED")
{
_performanceState = "Off";
_performanceState = "Powered Off";
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion LenovoLegionToolkit.WPF/Controls/CardHeaderControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override void OnInitialized(EventArgs e)

private void RefreshLayout()
{
if (string.IsNullOrEmpty(Subtitle))
if (string.IsNullOrWhiteSpace(Subtitle))
{
Grid.SetRowSpan(_titleTextBlock, 2);
_subtitleTextBlock.Visibility = Visibility.Collapsed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private async void DiscreteGPUControl_IsVisibleChanged(object sender, Dependency

private void GpuController_Refreshed(object? sender, GPUController.RefreshedEventArgs e) => Dispatcher.Invoke(() =>
{
var performanceStateText = $"Performance state: {e.PerformanceState ?? "Unknown"}";
var performanceStateText = $"Performance state:\n{e.PerformanceState ?? "Unknown"}";

if (e.Status == GPUController.Status.Unknown || e.Status == GPUController.Status.NVIDIAGPUNotFound)
{
Expand All @@ -57,9 +57,27 @@ private void GpuController_Refreshed(object? sender, GPUController.RefreshedEven
else if (e.IsActive)
{
var status = "Active";
var processes = string.Empty;

if (e.ProcessCount > 0)
{
status += $" ({e.ProcessCount} app{(e.ProcessCount > 1 ? "s" : "")})";
var processes = e.ProcessCount < 1 ? "No processes" : ("Processes:\n" + string.Join("\n", e.Processes.Select(p => p.ProcessName)));
processes += "Processes:";

foreach (var p in e.Processes)
{
try
{
processes += $"\n{p.ProcessName}";
}
catch { }
}
}
else
{
processes += "No processes";

}

_discreteGPUStatusDescription.Text = status;
_discreteGPUStatusDescription.ToolTip = $"{performanceStateText}\n\n{processes}";
Expand Down

0 comments on commit e03414e

Please sign in to comment.