Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored XAML x:Names #433

Merged
merged 4 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/Calculator/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@
<Setter Property="ZoomMode" Value="Disabled"/>
</Style>

<Style x:Key="CalculationResultStyle" TargetType="Controls:CalculationResult">
<Style x:Key="CalculationResultStyle"
TargetType="Controls:CalculationResult">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlPageTextBaseHighBrush}"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
Expand All @@ -368,7 +369,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Controls:CalculationResult">
<Grid x:Name="border" Background="{TemplateBinding Background}">
<Grid x:Name="Border" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="12"/>
<ColumnDefinition/>
Expand All @@ -378,19 +379,19 @@
<VisualStateGroup x:Name="ActiveStates">
<VisualState x:Name="Active">
<VisualState.Setters>
<Setter Target="normalOutput.FontWeight" Value="SemiBold"/>
<Setter Target="normalOutput.IsTextSelectionEnabled" Value="True"/>
<Setter Target="NormalOutput.FontWeight" Value="SemiBold"/>
<Setter Target="NormalOutput.IsTextSelectionEnabled" Value="True"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ScrollViewer x:Name="textContainer"
<ScrollViewer x:Name="TextContainer"
Grid.Column="1"
Padding="0,0,0,0"
Style="{ThemeResource ResultsScrollerSnapped}"
AutomationProperties.AccessibilityView="Raw">
<TextBlock x:Name="normalOutput"
<TextBlock x:Name="NormalOutput"
Margin="{TemplateBinding DisplayMargin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Expand All @@ -402,7 +403,7 @@
TextAlignment="{TemplateBinding HorizontalContentAlignment}"
TextWrapping="NoWrap"/>
</ScrollViewer>
<HyperlinkButton x:Name="scrollLeft"
<HyperlinkButton x:Name="ScrollLeft"
Grid.Column="0"
Width="20"
MinWidth="20"
Expand All @@ -415,12 +416,12 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0"
Visibility="Collapsed">
<FontIcon x:Name="scrollLeftText"
<FontIcon x:Name="ScrollLeftText"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12"
Glyph="&#xE26C;"/>
</HyperlinkButton>
<HyperlinkButton x:Name="scrollRight"
<HyperlinkButton x:Name="ScrollRight"
Grid.Column="2"
Width="20"
MinWidth="20"
Expand All @@ -433,7 +434,7 @@
Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
BorderThickness="0"
Visibility="Collapsed">
<FontIcon x:Name="scrollRightText"
<FontIcon x:Name="ScrollRightText"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12"
Glyph="&#xE26B;"/>
Expand Down
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
8 changes: 4 additions & 4 deletions src/Calculator/Controls/OverflowTextBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ void OverflowTextBlock::OnApplyTemplate()
{
UnregisterEventHandlers();

auto uiElement = GetTemplateChild("expressionContainer");
auto uiElement = GetTemplateChild("ExpressionContainer");
if (uiElement != nullptr)
{
m_expressionContainer = safe_cast<ScrollViewer^>(uiElement);
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
m_containerViewChangedToken = m_expressionContainer->ViewChanged += ref new EventHandler<ScrollViewerViewChangedEventArgs ^>(this, &OverflowTextBlock::OnViewChanged);
}

uiElement = GetTemplateChild("scrollLeft");
uiElement = GetTemplateChild("ScrollLeft");
if (uiElement != nullptr)
{
m_scrollLeft = safe_cast<Button^>(uiElement);
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
}

uiElement = GetTemplateChild("scrollRight");
uiElement = GetTemplateChild("ScrollRight");
if (uiElement != nullptr)
{
m_scrollRight = safe_cast<Button^>(GetTemplateChild("scrollRight"));
m_scrollRight = safe_cast<Button^>(uiElement);
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Calculator/Views/Calculator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
</DataTemplate>

<!-- TextBox Styles -->

<Style TargetType="controls:OverflowTextBlock">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:OverflowTextBlock">
<Grid x:Name="tokenContainer" Background="{TemplateBinding Background}">
<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 All @@ -70,7 +70,7 @@
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
<Button x:Name="scrollLeft"
<Button x:Name="ScrollLeft"
x:Uid="scrollLeft"
Grid.Column="0"
Margin="-4,3,-4,0"
Expand All @@ -79,7 +79,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 @@ -289,7 +289,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 @@ -316,7 +316,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 @@ -376,7 +376,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 @@ -454,7 +454,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 @@ -563,7 +563,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
4 changes: 2 additions & 2 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 @@ -695,7 +695,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
20 changes: 10 additions & 10 deletions src/Calculator/Views/CalculatorProgrammerDisplayPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
<VisualState x:Name="NoErrorLayout"/>
<VisualState x:Name="ErrorLayout">
<VisualState.Setters>
<Setter Target="qwordButton.IsEnabled" Value="False"/>
<Setter Target="dwordButton.IsEnabled" Value="False"/>
<Setter Target="wordButton.IsEnabled" Value="False"/>
<Setter Target="byteButton.IsEnabled" Value="False"/>
<Setter Target="QwordButton.IsEnabled" Value="False"/>
<Setter Target="DwordButton.IsEnabled" Value="False"/>
<Setter Target="WordButton.IsEnabled" Value="False"/>
<Setter Target="ByteButton.IsEnabled" Value="False"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
Expand All @@ -59,13 +59,13 @@
<ColumnDefinition Width="1*" MaxWidth="80"/>
</Grid.ColumnDefinitions>

<RadioButton x:Name="fullKeypad"
<RadioButton x:Name="FullKeypad"
x:Uid="fullKeypad"
Style="{StaticResource ProgKeypadRadioButtonStyle}"
AutomationProperties.AutomationId="fullKeypad"
Content="&#xe75f;"
IsChecked="{x:Bind Model.IsBitFlipChecked, Converter={StaticResource BooleanNegationConverter}, Mode=TwoWay}"/>
<RadioButton x:Name="bitFlip"
<RadioButton x:Name="BitFlip"
x:Uid="bitFlip"
Grid.Column="1"
Style="{StaticResource ProgKeypadRadioButtonStyle}"
Expand All @@ -75,7 +75,7 @@
IsChecked="{x:Bind Model.IsBitFlipChecked, Mode=TwoWay}"/>
</Grid>

<Button x:Name="qwordButton"
<Button x:Name="QwordButton"
x:Uid="qwordButton"
Grid.Column="0"
Grid.ColumnSpan="7"
Expand All @@ -84,7 +84,7 @@
Command="{x:Bind BitLengthButtonPressed, Mode=OneTime}"
CommandParameter="0"
Content="QWORD"/>
<Button x:Name="dwordButton"
<Button x:Name="DwordButton"
x:Uid="dwordButton"
Grid.Column="0"
Grid.ColumnSpan="7"
Expand All @@ -94,7 +94,7 @@
CommandParameter="1"
Content="DWORD"
Visibility="Collapsed"/>
<Button x:Name="wordButton"
<Button x:Name="WordButton"
x:Uid="wordButton"
Grid.Column="0"
Grid.ColumnSpan="7"
Expand All @@ -104,7 +104,7 @@
CommandParameter="2"
Content="WORD"
Visibility="Collapsed"/>
<Button x:Name="byteButton"
<Button x:Name="ByteButton"
x:Uid="byteButton"
Grid.Column="0"
Grid.ColumnSpan="7"
Expand Down
24 changes: 12 additions & 12 deletions src/Calculator/Views/CalculatorProgrammerDisplayPanel.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,42 @@ void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object^ paramete
TraceLogger::GetInstance().LogBitLengthButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
String^ buttonId = parameter->ToString();

qwordButton->Visibility = ::Visibility::Collapsed;
dwordButton->Visibility = ::Visibility::Collapsed;
wordButton->Visibility = ::Visibility::Collapsed;
byteButton->Visibility = ::Visibility::Collapsed;
QwordButton->Visibility = ::Visibility::Collapsed;
DwordButton->Visibility = ::Visibility::Collapsed;
WordButton->Visibility = ::Visibility::Collapsed;
ByteButton->Visibility = ::Visibility::Collapsed;
if (buttonId == "0")
{
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Dword);
dwordButton->Visibility = ::Visibility::Visible;
dwordButton->Focus(::FocusState::Programmatic);
DwordButton->Visibility = ::Visibility::Visible;
DwordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = true;
Model->IsWordEnabled = true;
}
else if (buttonId == "1")
{
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Word);
wordButton->Visibility = ::Visibility::Visible;
wordButton->Focus(::FocusState::Programmatic);
WordButton->Visibility = ::Visibility::Visible;
WordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = false;
Model->IsWordEnabled = true;
}
else if (buttonId == "2")
{
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Byte);
byteButton->Visibility = ::Visibility::Visible;
byteButton->Focus(::FocusState::Programmatic);
ByteButton->Visibility = ::Visibility::Visible;
ByteButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = false;
Model->IsDwordEnabled = false;
Model->IsWordEnabled = false;
}
else if (buttonId == "3")
{
Model->ButtonPressed->Execute(NumbersAndOperatorsEnum::Qword);
qwordButton->Visibility = ::Visibility::Visible;
qwordButton->Focus(::FocusState::Programmatic);
QwordButton->Visibility = ::Visibility::Visible;
QwordButton->Focus(::FocusState::Programmatic);
Model->IsQwordEnabled = true;
Model->IsDwordEnabled = true;
Model->IsWordEnabled = true;
Expand Down
Loading