Skip to content

Commit

Permalink
Added color to status text (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Aug 3, 2024
1 parent 7b42ac6 commit ec459f3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions InternetTest/InternetTest/Windows/AdapterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void InitUI()
{
{ Properties.Resources.DataConsumption, $"{Global.GetStorageUnit(AdapterInfo.BytesReceived + AdapterInfo.BytesSent).Item2:0.00} {Global.UnitToString(Global.GetStorageUnit(AdapterInfo.BytesReceived + AdapterInfo.BytesSent).Item1)}" },
{ Properties.Resources.InterfaceType, Global.GetInterfaceTypeName(AdapterInfo.NetworkInterfaceType) },
{ Properties.Resources.Status, AdapterInfo.Status switch { OperationalStatus.Up => Properties.Resources.ConnectedS, OperationalStatus.Down => Properties.Resources.Disconnected, _ => AdapterInfo.Status.ToString() } },
{ Properties.Resources.Status, AdapterInfo.Status },
{ Properties.Resources.IpVersion, AdapterInfo.IpVersion },
{ Properties.Resources.Speed, $"{Global.GetStorageUnit(AdapterInfo.Speed).Item2:0.00} {Global.UnitToString(Global.GetStorageUnit(AdapterInfo.Speed).Item1)}/s" }
};
Expand Down Expand Up @@ -99,8 +99,18 @@ private void InitUI()
foreach (var category in category1)
{
StackPanel stackPanel = new() { Margin = new(5) };
stackPanel.Children.Add(new TextBlock() { FontSize = 12, Text = category.Key, Foreground = Global.GetBrushFromResource("Foreground2") });
stackPanel.Children.Add(new TextBlock() { FontSize = 14, FontWeight = FontWeights.SemiBold, Text = category.Value.ToString() });

if (category.Key == Properties.Resources.Status)
{
stackPanel.Children.Add(new TextBlock() { FontSize = 12, Text = category.Key, Foreground = Global.GetBrushFromResource("Foreground2") });
stackPanel.Children.Add(new TextBlock() { FontSize = 14, FontWeight = FontWeights.SemiBold, Text = category.Value switch { OperationalStatus.Up => Properties.Resources.ConnectedS, OperationalStatus.Down => Properties.Resources.Disconnected, _ => AdapterInfo.Status.ToString() }, Foreground = Global.GetBrushFromResource(category.Value switch { OperationalStatus.Down => "Red", OperationalStatus.Unknown => "Gray", OperationalStatus.Up => "Green", _ => "Orange" }) });
}
else
{
stackPanel.Children.Add(new TextBlock() { FontSize = 12, Text = category.Key, Foreground = Global.GetBrushFromResource("Foreground2") });
stackPanel.Children.Add(new TextBlock() { FontSize = 14, FontWeight = FontWeights.SemiBold, Text = category.Value.ToString() });
}

Cat1Grid.Children.Add(stackPanel);
Grid.SetColumn(stackPanel, i % 2);
Grid.SetRow(stackPanel, i / 2);
Expand Down

0 comments on commit ec459f3

Please # to comment.