Fixed bug in and enhanced layout of PowerSupplyControl.

This commit is contained in:
dbuechel 2017-08-17 14:47:54 +02:00
parent d618556c6c
commit d0193b2469
2 changed files with 11 additions and 5 deletions

View file

@ -14,9 +14,9 @@
</UserControl.Resources>
<Grid>
<Popup x:Name="Popup" IsOpen="False" Placement="Top" PlacementTarget="{Binding ElementName=Button}" AllowsTransparency="True">
<Border BorderBrush="White" BorderThickness="0.5,0.5,0.5,0" MaxWidth="250" Padding="5">
<Border BorderBrush="White" BorderThickness="0.5,0.5,0.5,0" MaxWidth="250" Padding="20,10,20,20">
<Border.Background>
<SolidColorBrush Color="Black" Opacity="0.8" />
<SolidColorBrush Color="#404040" Opacity="0.8" />
</Border.Background>
<Grid>
<Grid.RowDefinitions>
@ -29,7 +29,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Background="Transparent" Click="Button_Click" Cursor="Hand" FontWeight="Bold"
Foreground="White" Template="{StaticResource ResourceKey=TaskbarButton}" Width="20">X</Button>
Foreground="White" Margin="0,0,0,5" Template="{StaticResource ResourceKey=TaskbarButton}" Width="20">X</Button>
</Grid>
<TextBlock Grid.Row="1" x:Name="PopupText" Foreground="White" TextWrapping="Wrap" />
</Grid>

View file

@ -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;
});
}