From d0193b2469b775419e768f1446d828e8886e658e Mon Sep 17 00:00:00 2001 From: dbuechel Date: Thu, 17 Aug 2017 14:47:54 +0200 Subject: [PATCH] Fixed bug in and enhanced layout of PowerSupplyControl. --- .../Controls/PowerSupplyControl.xaml | 6 +++--- .../Controls/PowerSupplyControl.xaml.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml b/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml index fca76ce7..89a2ec09 100644 --- a/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml +++ b/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml @@ -14,9 +14,9 @@ - + - + @@ -29,7 +29,7 @@ + Foreground="White" Margin="0,0,0,5" Template="{StaticResource ResourceKey=TaskbarButton}" Width="20">X diff --git a/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml.cs index 2c19e22b..1bd6c646 100644 --- a/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface/Controls/PowerSupplyControl.xaml.cs @@ -33,8 +33,14 @@ namespace SafeExamBrowser.UserInterface.Controls { Dispatcher.Invoke(() => { - BatteryCharge.Width = BATTERY_CHARGE_MAX_WIDTH * charge; - BatteryCharge.Fill = status == BatteryChargeStatus.Low ? (status == BatteryChargeStatus.Critical ? Brushes.Red : Brushes.Orange) : Brushes.Green; + var width = BATTERY_CHARGE_MAX_WIDTH * charge; + + width = width > BATTERY_CHARGE_MAX_WIDTH ? BATTERY_CHARGE_MAX_WIDTH : width; + width = width < 0 ? 0 : width; + + BatteryCharge.Width = width; + BatteryCharge.Fill = status == BatteryChargeStatus.Low ? Brushes.Orange : BatteryCharge.Fill; + BatteryCharge.Fill = status == BatteryChargeStatus.Critical ? Brushes.Red : BatteryCharge.Fill; Warning.Visibility = status == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed; }); }