Optimize and simplify CalculationResult to be able to update the FontSize and the DisplayMargin without fully updating the Style. (#217)

- Merge the 3 CalculationResultStyle(S|M|L) in App.xaml
- Only modify CalculationResult::*FontSize in Calculator.xaml instead of fully updating the style of the control.
- Create a new property MaxFontSize in order to be able to update it without being forced to fully update the Style (because m_startingFontSize was set in OnApplyTemplate)
- Modify how DisplayMargin is managed to prevent the textblock Margin to shift when we update its value (without fully updating the Style).
This commit is contained in:
Rudy Huyn
2019-04-05 13:04:39 -07:00
committed by Daniel Belcher
parent e7eace57f8
commit af41a183a7
7 changed files with 60 additions and 308 deletions

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="CalculatorApp.UnitConverter"
<UserControl x:Class="CalculatorApp.UnitConverter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.Common.Automation"
@@ -180,46 +180,30 @@
</Setter>
</Style>
<Style x:Key="ValueLargeStyle"
BasedOn="{StaticResource CalculationResultStyleL}"
<Style x:Key="ValueBaseStyle"
BasedOn="{StaticResource CalculationResultStyle}"
TargetType="controls:CalculationResult">
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundTransparentBrush}"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="FontSize" Value="46"/>
<Setter Property="MinFontSize" Value="{ThemeResource BodyFontSize}"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="MinFontSize" Value="{ThemeResource BodyFontSize}"/>
</Style>
<Style x:Key="ValueLargeStyle"
BasedOn="{StaticResource ValueBaseStyle}"
TargetType="controls:CalculationResult">
<Setter Property="MaxFontSize" Value="46"/>
<Setter Property="Margin" Value="-2,0,0,0"/>
<Setter Property="DisplayMargin" Value="0,0,0,12"/>
</Style>
<Style x:Key="ValueMediumStyle"
BasedOn="{StaticResource CalculationResultStyleM}"
BasedOn="{StaticResource ValueBaseStyle}"
TargetType="controls:CalculationResult">
<Setter Property="FontSize" Value="34"/>
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundTransparentBrush}"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="MinFontSize" Value="{ThemeResource BodyFontSize}"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="MaxFontSize" Value="34"/>
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="DisplayMargin" Value="0,0,0,4"/>
</Style>
<Style x:Key="ValueSmallStyle"
BasedOn="{StaticResource CalculationResultStyleS}"
TargetType="controls:CalculationResult">
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundTransparentBrush}"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/>
<Setter Property="FontSize" Value="24"/>
<Setter Property="MinFontSize" Value="{ThemeResource BodyFontSize}"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="DisplayMargin" Value="0,0,0,4"/>
</Style>
<Style x:Key="CurrencySymbolBaseStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="HorizontalAlignment" Value="Left"/>