Skip to content

Commit

Permalink
Completed View (Calculator.xaml)
Browse files Browse the repository at this point in the history
Completed View (CalculatorProgrammerDisplayBoard)

Completed View (CalculatorProgrammerOperators)

Completed View (CalculatorProgrammerRadixOperators.xaml)

Completed View (CaclulatorScientificAngleButtons)

Completed View (CaclulatorScientificOperators.xaml)

Completed View (CalculatorStandardOperators)

Completed View (HistoryList)

Completed View (MainPage)

Completed View (NumberPad)

Completed View (UnitConverter)

Cleared all remaining camel-case x:Names
  • Loading branch information
Lance McCarthy committed Apr 17, 2019
1 parent 853704c commit c5381f7
Show file tree
Hide file tree
Showing 22 changed files with 825 additions and 544 deletions.
196 changes: 187 additions & 9 deletions src/Calculator/App.xaml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/Calculator/Controls/CalculationResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void CalculationResult::OnApplyTemplate()
{
m_textContainer->LayoutUpdated -= m_textContainerLayoutChangedToken;
}
m_textContainer = dynamic_cast<ScrollViewer^>(GetTemplateChild("textContainer"));
m_textContainer = dynamic_cast<ScrollViewer^>(GetTemplateChild("TextContainer"));
if (m_textContainer)
{
m_textContainer->SizeChanged += ref new SizeChangedEventHandler(this, &CalculationResult::TextContainerSizeChanged);
Expand All @@ -81,17 +81,17 @@ void CalculationResult::OnApplyTemplate()
m_textContainerLayoutChangedToken = m_textContainer->LayoutUpdated += ref new EventHandler<Object^>(this, &CalculationResult::OnTextContainerLayoutUpdated);

m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth,nullptr,nullptr);
m_scrollLeft = dynamic_cast<HyperlinkButton^>(GetTemplateChild("scrollLeft"));
m_scrollRight = dynamic_cast<HyperlinkButton^>(GetTemplateChild("scrollRight"));
auto borderContainer = dynamic_cast<UIElement^>(GetTemplateChild("border"));
m_scrollLeft = dynamic_cast<HyperlinkButton^>(GetTemplateChild("ScrollLeft"));
m_scrollRight = dynamic_cast<HyperlinkButton^>(GetTemplateChild("ScrollRight"));
auto borderContainer = dynamic_cast<UIElement^>(GetTemplateChild("Border"));
if (m_scrollLeft && m_scrollRight)
{
m_scrollLeft->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
m_scrollRight->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
borderContainer->PointerEntered += ref new PointerEventHandler(this, &CalculationResult::OnPointerEntered);
borderContainer->PointerExited += ref new PointerEventHandler(this, &CalculationResult::OnPointerExited);
}
m_textBlock = dynamic_cast<TextBlock^>(m_textContainer->FindName("normalOutput"));
m_textBlock = dynamic_cast<TextBlock^>(m_textContainer->FindName("NormalOutput"));
if (m_textBlock)
{
m_textBlock->Visibility = ::Visibility::Visible;
Expand Down
10 changes: 5 additions & 5 deletions src/Calculator/Controls/OverflowTextBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ void OverflowTextBlock::OnApplyTemplate()
{
assert(((m_scrollLeft == nullptr) && (m_scrollRight == nullptr)) || ((m_scrollLeft != nullptr) && (m_scrollRight != nullptr)));

m_expressionContainer = safe_cast<ScrollViewer^>(GetTemplateChild("expressionContainer"));
m_expressionContainer = safe_cast<ScrollViewer^>(GetTemplateChild("ExpressionContainer"));
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);

m_scrollLeft = safe_cast<Button^>(GetTemplateChild("scrollLeft"));
m_scrollRight = safe_cast<Button^>(GetTemplateChild("scrollRight"));
m_scrollLeft = safe_cast<Button^>(GetTemplateChild("ScrollLeft"));
m_scrollRight = safe_cast<Button^>(GetTemplateChild("ScrollRight"));

m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);

m_scrollingLeft = false;
m_scrollingRight = false;

auto borderContainer = safe_cast<Border^>(GetTemplateChild("expressionborder"));
auto borderContainer = safe_cast<Border^>(GetTemplateChild("ExpressionBorder"));
m_pointerEnteredEventToken = borderContainer->PointerEntered += ref new PointerEventHandler(this, &OverflowTextBlock::OnPointerEntered);
m_pointerExitedEventToken = borderContainer->PointerExited += ref new PointerEventHandler(this, &OverflowTextBlock::OnPointerExited);

Expand Down Expand Up @@ -199,7 +199,7 @@ void OverflowTextBlock::UnregisterEventHandlers()
m_scrollRight->Click -= m_scrollRightClickEventToken;
}

auto borderContainer = safe_cast<Border^>(GetTemplateChild("expressionborder"));
auto borderContainer = safe_cast<Border^>(GetTemplateChild("ExpressionBorder"));

// Adding an extra check, in case the returned template is null
if (borderContainer != nullptr)
Expand Down
123 changes: 113 additions & 10 deletions src/Calculator/Views/Calculator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,123 @@
</DataTemplate>

<!-- TextBox Styles -->
<<<<<<< HEAD

=======

<Style x:Key="OperandTextBoxStyle" TargetType="controls:OperandTextBox">
<Setter Property="MinWidth" Value="32"/>
<Setter Property="MinHeight" Value="20"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="SelectionHighlightColor" Value="{ThemeResource SystemControlBackgroundAccentBrush}"/>
<Setter Property="FontSize" Value="{ThemeResource BodyFontSize}"/>
<Setter Property="IsTextScaleFactorEnabled" Value="False"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="Padding" Value="2,0,3,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:OperandTextBox">
<Grid x:Name="BackgroundElement" Background="{ThemeResource SystemControlBackgroundAltHighBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled"/>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Target="ContentElement.Foreground" Value="{ThemeResource SystemControlForegroundAccentBrush}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="BackgroundElement.Background" Value="{ThemeResource SystemControlHighlightListAccentLowBrush}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Focused">
<VisualState.Setters>
<Setter Target="BackgroundElement.Background" Value="{ThemeResource SystemControlForegroundChromeWhiteBrush}"/>
<Setter Target="ContentElement.Foreground" Value="{ThemeResource SystemControlBackgroundChromeBlackHighBrush}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ScrollViewer x:Name="ContentElement"
Padding="{TemplateBinding Padding}"
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
HorizontalScrollBarVisibility="Hidden"
HorizontalScrollMode="Disabled"
IsDeferredScrollingEnabled="False"
IsHorizontalRailEnabled="True"
IsTabStop="False"
IsVerticalRailEnabled="False"
VerticalScrollBarVisibility="Disabled"
VerticalScrollMode="Disabled"
ZoomMode="Disabled"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="OperatorTextBoxStyle" TargetType="controls:OperatorTextBox">
<Setter Property="MinWidth" Value="4"/>
<Setter Property="MinHeight" Value="20"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:OperatorTextBox">
<Grid x:Name="BackgroundElement" Background="{ThemeResource SystemControlBackgroundAltHighBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled"/>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Target="TextElement.Foreground" Value="{ThemeResource SystemControlPageTextBaseMediumBrush}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="BackgroundElement.Background" Value="{ThemeResource SystemControlHighlightListAccentLowBrush}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Focused">
<VisualState.Setters>
<Setter Target="BackgroundElement.Background" Value="{ThemeResource SystemControlBackgroundAccentBrush}"/>
<Setter Target="TextElement.Foreground" Value="{ThemeResource SystemControlForegroundChromeWhiteBrush}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBlock x:Name="TextElement"
Margin="0,-2,0,2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{TemplateBinding Foreground}"
FontSize="16"
IsHitTestVisible="True"
IsTextScaleFactorEnabled="False"
Text="{Binding Token}"
TextAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

>>>>>>> f6848a5... Completed View (Calculator.xaml)
<Style TargetType="controls:OverflowTextBlock">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:OverflowTextBlock">
<Border x:Name="expressionborder" Background="Transparent">
<Grid x:Name="tokenContainer" Background="{TemplateBinding Background}">
<Border x:Name="ExpressionBorder" Background="Transparent">
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="12"/>
<ColumnDefinition/>
<ColumnDefinition Width="12"/>
</Grid.ColumnDefinitions>
<ScrollViewer x:Name="expressionContainer"
<ScrollViewer x:Name="ExpressionContainer"
Grid.Column="1"
Padding="0,0,0,0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Expand Down Expand Up @@ -82,7 +185,7 @@
</ListView.ItemContainerTransitions>
</ListView>
</ScrollViewer>
<Button x:Name="scrollLeft"
<Button x:Name="ScrollLeft"
x:Uid="scrollLeft"
Grid.Column="0"
Margin="-4,3,-4,0"
Expand All @@ -91,7 +194,7 @@
FontSize="12"
Glyph="&#xE26C;"/>
</Button>
<Button x:Name="scrollRight"
<Button x:Name="ScrollRight"
x:Uid="scrollRight"
Grid.Column="2"
Margin="0,3,-9,0"
Expand Down Expand Up @@ -356,7 +459,7 @@
<Setter Target="MemRecall.IsEnabled" Value="False"/>
<Setter Target="MemPlus.IsEnabled" Value="False"/>
<Setter Target="MemMinus.IsEnabled" Value="False"/>
<Setter Target="memButton.IsEnabled" Value="False"/>
<Setter Target="MemButton.IsEnabled" Value="False"/>
</VisualState.Setters>
<Storyboard Completed="OnErrorLayoutCompleted"/>
</VisualState>
Expand All @@ -383,7 +486,7 @@
<Setter Target="M4.MaxWidth" Value="99999"/>
<Setter Target="M5.Width" Value="1*"/>
<Setter Target="M5.MaxWidth" Value="80"/>
<Setter Target="memButton.(Grid.Column)" Value="5"/>
<Setter Target="MemButton.(Grid.Column)" Value="5"/>
<Setter Target="MemoryButton.(Grid.Column)" Value="6"/>
<Setter Target="HistoryButton.Visibility" Value="Collapsed"/>
</VisualState.Setters>
Expand Down Expand Up @@ -443,7 +546,7 @@
<Setter Target="MemRecall.Style" Value="{StaticResource CaptionButtonStyle}"/>
<Setter Target="MemPlus.Style" Value="{StaticResource CaptionButtonStyle}"/>
<Setter Target="MemMinus.Style" Value="{StaticResource CaptionButtonStyle}"/>
<Setter Target="memButton.Style" Value="{StaticResource CaptionButtonStyle}"/>
<Setter Target="MemButton.Style" Value="{StaticResource CaptionButtonStyle}"/>
<Setter Target="MemoryButton.MinHeight" Value="0"/>
</VisualState.Setters>
<Storyboard Completed="OnLayoutStateChanged"/>
Expand Down Expand Up @@ -521,7 +624,7 @@
IsInError="{x:Bind Model.IsInError, Mode=OneWay}"
IsOperatorCommand="{x:Bind Model.IsOperatorCommand, Mode=OneWay}"
TabIndex="1"/>
<controls:OverflowTextBlock x:Name="expressionText"
<controls:OverflowTextBlock x:Name="ExpressionText"
Grid.Row="1"
Margin="6,0,6,0"
VerticalAlignment="Bottom"
Expand Down Expand Up @@ -630,7 +733,7 @@
Content="M-"
TabIndex="13"
Visibility="{Binding IsProgrammer, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/>
<controls:CalculatorButton x:Name="memButton"
<controls:CalculatorButton x:Name="MemButton"
x:Uid="memButton"
Grid.Column="4"
Style="{StaticResource CaptionButtonStyle}"
Expand Down
6 changes: 3 additions & 3 deletions src/Calculator/Views/Calculator.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ void Calculator::OnHideMemoryClicked()

void Calculator::EnableMemoryControls(bool enable)
{
memButton->IsEnabled = enable;
MemButton->IsEnabled = enable;
MemMinus->IsEnabled = enable;
MemPlus->IsEnabled = enable;
if (!Model->IsMemoryEmpty)
Expand Down Expand Up @@ -661,7 +661,7 @@ void Calculator::OnHistoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEve

void Calculator::expressionContainer_LayoutUpdated(_In_ Object^ sender, _In_ Object^ e)
{
expressionText->UpdateScrollButtons();
ExpressionText->UpdateScrollButtons();
}

bool Calculator::IsValidRegularExpression(std::wstring str)
Expand Down Expand Up @@ -700,7 +700,7 @@ void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs^ e)

void Calculator::UnregisterEventHandlers()
{
expressionText->UnregisterEventHandlers();
ExpressionText->UnregisterEventHandlers();
}

void Calculator::OnErrorLayoutCompleted(_In_ Object^ sender, _In_ Object^ e)
Expand Down
Loading

0 comments on commit c5381f7

Please sign in to comment.