Merge pull request #56 from nventive/dev/dr/ResultScale

Enable result text scalling when too long
This commit is contained in:
David 2019-05-24 23:52:46 -04:00 committed by GitHub
commit 336080169e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 18 deletions

View file

@ -60,7 +60,7 @@ namespace CalculatorApp
propertyType: typeof(double), propertyType: typeof(double),
ownerType: typeof(CalculationResult), ownerType: typeof(CalculationResult),
typeMetadata: new PropertyMetadata( typeMetadata: new PropertyMetadata(
defaultValue: 30.0, defaultValue: 42.0,
propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnMaxFontSizePropertyChanged( propertyChangedCallback: (s, e) => (s as CalculationResult)?.OnMaxFontSizePropertyChanged(
(double)e.OldValue, (double)e.OldValue,
(double)e.NewValue))); (double)e.NewValue)));
@ -216,7 +216,9 @@ namespace CalculatorApp
m_textContainer.SizeChanged += TextContainerSizeChanged; m_textContainer.SizeChanged += TextContainerSizeChanged;
// We want to know when the size of the container changes so // We want to know when the size of the container changes so
// we can rescale the textbox // we can rescale the textbox
#if NETFX_CORE // TODO UNO: We listen on m_textBlock instead
m_textContainer.LayoutUpdated += OnTextContainerLayoutUpdated; m_textContainer.LayoutUpdated += OnTextContainerLayoutUpdated;
#endif
m_textContainer.ChangeView(m_textContainer.ExtentWidth - m_textContainer.ViewportWidth, null, null); m_textContainer.ChangeView(m_textContainer.ExtentWidth - m_textContainer.ViewportWidth, null, null);
m_scrollLeft = (HyperlinkButton)(GetTemplateChild("ScrollLeft")); m_scrollLeft = (HyperlinkButton)(GetTemplateChild("ScrollLeft"));
@ -233,6 +235,9 @@ namespace CalculatorApp
if (m_textBlock != null) if (m_textBlock != null)
{ {
m_textBlock.Visibility = Visibility.Visible; m_textBlock.Visibility = Visibility.Visible;
#if !NETFX_CORE // TODO UNO: We should be listening on m_textContainer
m_textBlock.LayoutUpdated += OnTextContainerLayoutUpdated;
#endif
} }
} }
UpdateAllState(); UpdateAllState();
@ -337,7 +342,9 @@ namespace CalculatorApp
var containerSize = m_textContainer.ActualWidth; var containerSize = m_textContainer.ActualWidth;
string oldText = m_textBlock.Text; string oldText = m_textBlock.Text;
string newText = Utils.LRO + DisplayValue + Utils.PDF; //string newText = Utils.LRO + DisplayValue + Utils.PDF;
// TODO UNO
string newText = DisplayValue;
// Initiate the scaling operation // Initiate the scaling operation
// UpdateLayout will keep calling us until we make it through the below 2 if-statements // UpdateLayout will keep calling us until we make it through the below 2 if-statements

View file

@ -629,7 +629,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Controls:CalculationResult"> <ControlTemplate TargetType="Controls:CalculationResult">
<Grid x:Name="border" <Grid x:Name="Border"
Background="{TemplateBinding Background}"> Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="12" /> <ColumnDefinition Width="12" />
@ -641,18 +641,18 @@
<VisualState x:Name="Active" /> <VisualState x:Name="Active" />
<VisualState x:Name="Normal"> <VisualState x:Name="Normal">
<VisualState.Setters> <VisualState.Setters>
<Setter Target="normalOutput.FontWeight" <Setter Target="NormalOutput.FontWeight"
Value="Light" /> Value="Light" />
</VisualState.Setters> </VisualState.Setters>
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<ScrollViewer x:Name="textContainer" <ScrollViewer x:Name="TextContainer"
Grid.Column="1" Grid.Column="1"
Padding="0,0,0,0" Padding="0,0,0,0"
Style="{ThemeResource ResultsScrollerSnapped}" Style="{ThemeResource ResultsScrollerSnapped}"
AutomationProperties.AccessibilityView="Raw"> AutomationProperties.AccessibilityView="Raw">
<TextBlock x:Name="normalOutput" <TextBlock x:Name="NormalOutput"
Margin="{TemplateBinding DisplayMargin}" Margin="{TemplateBinding DisplayMargin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
@ -664,7 +664,7 @@
TextAlignment="{TemplateBinding HorizontalContentAlignment}" TextAlignment="{TemplateBinding HorizontalContentAlignment}"
TextWrapping="NoWrap" /> TextWrapping="NoWrap" />
</ScrollViewer> </ScrollViewer>
<HyperlinkButton x:Name="scrollLeft" <HyperlinkButton x:Name="ScrollLeft"
Grid.Column="0" Grid.Column="0"
Width="20" Width="20"
MinWidth="20" MinWidth="20"
@ -677,12 +677,12 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}" Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0" BorderThickness="0"
Visibility="Collapsed"> Visibility="Collapsed">
<FontIcon x:Name="scrollLeftText" <FontIcon x:Name="ScrollLeftText"
FontFamily="{ThemeResource SymbolThemeFontFamily}" FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12" FontSize="12"
Glyph="&#xE26C;" /> Glyph="&#xE26C;" />
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="scrollRight" <HyperlinkButton x:Name="ScrollRight"
Grid.Column="2" Grid.Column="2"
Width="20" Width="20"
MinWidth="20" MinWidth="20"
@ -695,7 +695,7 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}" Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0" BorderThickness="0"
Visibility="Collapsed"> Visibility="Collapsed">
<FontIcon x:Name="scrollRightText" <FontIcon x:Name="ScrollRightText"
FontFamily="{ThemeResource SymbolThemeFontFamily}" FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12" FontSize="12"
Glyph="&#xE26B;" /> Glyph="&#xE26B;" />
@ -730,7 +730,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Controls:CalculationResult"> <ControlTemplate TargetType="Controls:CalculationResult">
<Grid x:Name="border" <Grid x:Name="Border"
Background="{TemplateBinding Background}"> Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -744,20 +744,20 @@
<VisualState x:Name="Active" /> <VisualState x:Name="Active" />
<VisualState x:Name="Normal"> <VisualState x:Name="Normal">
<VisualState.Setters> <VisualState.Setters>
<Setter Target="normalOutput.FontWeight" <Setter Target="NormalOutput.FontWeight"
Value="Light" /> Value="Light" />
</VisualState.Setters> </VisualState.Setters>
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<ScrollViewer x:Name="textContainer" <ScrollViewer x:Name="TextContainer"
Grid.Column="1" Grid.Column="1"
Padding="0,0,0,0" Padding="0,0,0,0"
Style="{ThemeResource ResultsScrollerSnapped}" Style="{ThemeResource ResultsScrollerSnapped}"
AutomationProperties.AccessibilityView="Raw"> AutomationProperties.AccessibilityView="Raw">
<TextBlock x:Name="normalOutput" <TextBlock x:Name="NormalOutput"
Margin="{TemplateBinding DisplayMargin}" Margin="{TemplateBinding DisplayMargin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
@ -770,7 +770,7 @@
TextWrapping="NoWrap" /> TextWrapping="NoWrap" />
</ScrollViewer> </ScrollViewer>
<HyperlinkButton x:Name="scrollLeft" <HyperlinkButton x:Name="ScrollLeft"
Grid.Column="0" Grid.Column="0"
Width="20" Width="20"
MinWidth="20" MinWidth="20"
@ -783,13 +783,13 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}" Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0" BorderThickness="0"
Visibility="Collapsed"> Visibility="Collapsed">
<FontIcon x:Name="scrollLeftText" <FontIcon x:Name="ScrollLeftText"
FontFamily="{ThemeResource SymbolThemeFontFamily}" FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12" FontSize="12"
Glyph="&#xE26C;" /> Glyph="&#xE26C;" />
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="scrollRight" <HyperlinkButton x:Name="ScrollRight"
Grid.Column="2" Grid.Column="2"
Width="20" Width="20"
MinWidth="20" MinWidth="20"
@ -802,7 +802,7 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}" Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0" BorderThickness="0"
Visibility="Collapsed"> Visibility="Collapsed">
<FontIcon x:Name="scrollRightText" <FontIcon x:Name="ScrollRightText"
FontFamily="{ThemeResource SymbolThemeFontFamily}" FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12" FontSize="12"
Glyph="&#xE26B;" /> Glyph="&#xE26B;" />