Merge master into feature/GraphingCalculator branch (#585)

* Merge master into feature/GraphingCalculator branch
This commit is contained in:
Stephanie Anderl
2019-07-15 11:17:21 -07:00
committed by GitHub
parent 1475b49120
commit a418777f02
447 changed files with 18056 additions and 19323 deletions

View File

@@ -1,29 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "Common/KeyboardShortcutManager.h"
namespace CalculatorApp
{
namespace Controls
{
public ref class AppBar sealed : public Windows::UI::Xaml::Controls::AppBar
{
public:
AppBar()
{}
protected:
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override
{
Windows::UI::Xaml::Controls::AppBar::OnKeyDown(e);
if (e->Key == Windows::System::VirtualKey::Escape)
{
Common::KeyboardShortcutManager::IgnoreEscape(true);
}
}
};
}
}

View File

@@ -50,13 +50,13 @@ DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayStringExpression);
StringReference CalculationResult::s_FocusedState(L"Focused");
StringReference CalculationResult::s_UnfocusedState(L"Unfocused");
CalculationResult::CalculationResult():
m_isScalingText(false),
m_haveCalculatedMax(false)
CalculationResult::CalculationResult()
: m_isScalingText(false)
, m_haveCalculatedMax(false)
{
}
Platform::String^ CalculationResult::GetRawDisplayValue()
Platform::String ^ CalculationResult::GetRawDisplayValue()
{
std::wstring rawValue;
@@ -72,18 +72,19 @@ 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);
// We want to know when the size of the container changes so
// we can rescale the textbox
m_textContainerLayoutChangedToken = m_textContainer->LayoutUpdated += ref new EventHandler<Object^>(this, &CalculationResult::OnTextContainerLayoutUpdated);
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_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"));
if (m_scrollLeft && m_scrollRight)
{
m_scrollLeft->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
@@ -91,7 +92,7 @@ void CalculationResult::OnApplyTemplate()
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;
@@ -101,7 +102,7 @@ void CalculationResult::OnApplyTemplate()
VisualStateManager::GoToState(this, s_UnfocusedState, false);
}
void CalculationResult::OnPointerPressed(PointerRoutedEventArgs^ e)
void CalculationResult::OnPointerPressed(PointerRoutedEventArgs ^ e)
{
if (m_scrollLeft && m_scrollRight && e->Pointer->PointerDeviceType == PointerDeviceType::Touch)
{
@@ -109,7 +110,7 @@ void CalculationResult::OnPointerPressed(PointerRoutedEventArgs^ e)
}
}
void CalculationResult::OnTextContainerLayoutUpdated(Object^ /*sender*/, Object^ /*e*/)
void CalculationResult::OnTextContainerLayoutUpdated(Object ^ /*sender*/, Object ^ /*e*/)
{
if (m_isScalingText)
{
@@ -117,7 +118,7 @@ void CalculationResult::OnTextContainerLayoutUpdated(Object^ /*sender*/, Object^
}
}
void CalculationResult::TextContainerSizeChanged(Object^ /*sender*/, SizeChangedEventArgs^ /*e*/)
void CalculationResult::TextContainerSizeChanged(Object ^ /*sender*/, SizeChangedEventArgs ^ /*e*/)
{
UpdateTextState();
}
@@ -127,7 +128,7 @@ void CalculationResult::OnIsActivePropertyChanged(bool /*oldValue*/, bool /*newV
UpdateVisualState();
}
void CalculationResult::OnAccentColorPropertyChanged(Brush^ /*oldValue*/, Brush^ /*newValue*/)
void CalculationResult::OnAccentColorPropertyChanged(Brush ^ /*oldValue*/, Brush ^ /*newValue*/)
{
// Force the "Active" transition to happen again
if (IsActive)
@@ -137,7 +138,7 @@ void CalculationResult::OnAccentColorPropertyChanged(Brush^ /*oldValue*/, Brush^
}
}
void CalculationResult::OnDisplayValuePropertyChanged(String^ /*oldValue*/, String^ /*newValue*/)
void CalculationResult::OnDisplayValuePropertyChanged(String ^ /*oldValue*/, String ^ /*newValue*/)
{
UpdateTextState();
}
@@ -198,8 +199,8 @@ void CalculationResult::UpdateTextState()
}
auto containerSize = m_textContainer->ActualWidth;
String^ oldText = m_textBlock->Text;
String^ newText = Utils::LRO + DisplayValue + Utils::PDF;
String ^ oldText = m_textBlock->Text;
String ^ newText = Utils::LRO + DisplayValue + Utils::PDF;
// Initiate the scaling operation
// UpdateLayout will keep calling us until we make it through the below 2 if-statements
@@ -241,11 +242,11 @@ void CalculationResult::UpdateTextState()
m_isScalingText = false;
if (IsOperatorCommand)
{
m_textContainer->ChangeView(0.0,nullptr,nullptr);
m_textContainer->ChangeView(0.0, nullptr, nullptr);
}
else
{
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth,nullptr,nullptr);
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth, nullptr, nullptr);
}
if (m_scrollLeft && m_scrollRight)
@@ -292,7 +293,7 @@ void CalculationResult::ScrollRight()
}
}
void CalculationResult::OnKeyDown(KeyRoutedEventArgs^ e)
void CalculationResult::OnKeyDown(KeyRoutedEventArgs ^ e)
{
if (m_scrollLeft != nullptr && m_scrollRight != nullptr)
{
@@ -308,9 +309,9 @@ void CalculationResult::OnKeyDown(KeyRoutedEventArgs^ e)
}
}
void CalculationResult::OnScrollClick(Object^ sender, RoutedEventArgs^ /*e*/)
void CalculationResult::OnScrollClick(Object ^ sender, RoutedEventArgs ^ /*e*/)
{
auto clicked = dynamic_cast<HyperlinkButton^>(sender);
auto clicked = dynamic_cast<HyperlinkButton ^>(sender);
if (clicked == m_scrollLeft)
{
this->ScrollLeft();
@@ -321,7 +322,7 @@ void CalculationResult::OnScrollClick(Object^ sender, RoutedEventArgs^ /*e*/)
}
}
void CalculationResult::OnPointerEntered(Platform::Object^ sender, PointerRoutedEventArgs^ e)
void CalculationResult::OnPointerEntered(Platform::Object ^ sender, PointerRoutedEventArgs ^ e)
{
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse && m_textBlock->ActualWidth >= m_textContainer->ActualWidth)
{
@@ -358,7 +359,7 @@ void CalculationResult::UpdateScrollButtons()
}
}
void CalculationResult::OnPointerExited(Platform::Object^ sender, PointerRoutedEventArgs^ e)
void CalculationResult::OnPointerExited(Platform::Object ^ sender, PointerRoutedEventArgs ^ e)
{
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
{
@@ -366,7 +367,7 @@ void CalculationResult::OnPointerExited(Platform::Object^ sender, PointerRoutedE
}
}
void CalculationResult::ModifyFontAndMargin(TextBlock^ textBox, double fontChange)
void CalculationResult::ModifyFontAndMargin(TextBlock ^ textBox, double fontChange)
{
double cur = textBox->FontSize;
double newFontSize = 0.0;
@@ -387,18 +388,18 @@ void CalculationResult::UpdateAllState()
UpdateTextState();
}
void CalculationResult::OnTapped(TappedRoutedEventArgs^ e)
void CalculationResult::OnTapped(TappedRoutedEventArgs ^ e)
{
this->Focus(::FocusState::Programmatic);
RaiseSelectedEvent();
}
void CalculationResult::OnRightTapped(RightTappedRoutedEventArgs^ e)
void CalculationResult::OnRightTapped(RightTappedRoutedEventArgs ^ e)
{
this->Focus(::FocusState::Programmatic);
}
void CalculationResult::OnGotFocus(RoutedEventArgs^ e)
void CalculationResult::OnGotFocus(RoutedEventArgs ^ e)
{
if (this->FocusState == ::FocusState::Keyboard)
{
@@ -406,12 +407,12 @@ void CalculationResult::OnGotFocus(RoutedEventArgs^ e)
}
}
void CalculationResult::OnLostFocus(RoutedEventArgs^ e)
void CalculationResult::OnLostFocus(RoutedEventArgs ^ e)
{
VisualStateManager::GoToState(this, s_UnfocusedState, true);
}
AutomationPeer^ CalculationResult::OnCreateAutomationPeer()
AutomationPeer ^ CalculationResult::OnCreateAutomationPeer()
{
return ref new CalculationResultAutomationPeer(this);
}

View File

@@ -9,9 +9,11 @@ namespace CalculatorApp
{
namespace Controls
{
public delegate void SelectedEventHandler(Platform::Object^ sender);
public
delegate void SelectedEventHandler(Platform::Object ^ sender);
public ref class CalculationResult sealed: public Windows::UI::Xaml::Controls::Control
public
ref class CalculationResult sealed : public Windows::UI::Xaml::Controls::Control
{
public:
CalculationResult();
@@ -24,45 +26,44 @@ namespace CalculatorApp
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Thickness, DisplayMargin);
DEPENDENCY_PROPERTY(int, MaxExpressionHistoryCharacters);
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsActive);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::Media::Brush^, AccentColor);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String^, DisplayValue);
DEPENDENCY_PROPERTY(Platform::String^, DisplayStringExpression);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::Media::Brush ^, AccentColor);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String ^, DisplayValue);
DEPENDENCY_PROPERTY(Platform::String ^, DisplayStringExpression);
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsInError);
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsOperatorCommand, false);
event SelectedEventHandler^ Selected;
event SelectedEventHandler ^ Selected;
void ProgrammaticSelect();
internal:
void UpdateTextState();
Platform::String^ GetRawDisplayValue();
internal : void UpdateTextState();
Platform::String ^ GetRawDisplayValue();
protected:
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
virtual void OnApplyTemplate() override;
virtual void OnTapped(Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) override;
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
virtual void OnRightTapped(Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ e) override;
virtual void OnGotFocus(Windows::UI::Xaml::RoutedEventArgs^ e) override;
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs^ e) override;
virtual void OnTapped(Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e) override;
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
virtual void OnRightTapped(Windows::UI::Xaml::Input::RightTappedRoutedEventArgs ^ e) override;
virtual void OnGotFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
private:
void OnIsActivePropertyChanged(bool oldValue, bool newValue);
void OnAccentColorPropertyChanged(Windows::UI::Xaml::Media::Brush^ oldValue, Windows::UI::Xaml::Media::Brush^ newValue);
void OnDisplayValuePropertyChanged(Platform::String^ oldValue, Platform::String^ newValue);
void OnAccentColorPropertyChanged(Windows::UI::Xaml::Media::Brush ^ oldValue, Windows::UI::Xaml::Media::Brush ^ newValue);
void OnDisplayValuePropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue);
void OnIsInErrorPropertyChanged(bool oldValue, bool newValue);
void OnMinFontSizePropertyChanged(double oldValue, double newValue);
void OnMaxFontSizePropertyChanged(double oldValue, double newValue);
void TextContainerSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
void OnTextContainerLayoutUpdated(Object^ sender, Object^ e);
void TextContainerSizeChanged(Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnTextContainerLayoutUpdated(Object ^ sender, Object ^ e);
void UpdateVisualState();
void UpdateAllState();
void OnScrollClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnPointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void OnPointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void ModifyFontAndMargin(Windows::UI::Xaml::Controls::TextBlock^ textBlock, double fontChange);
void OnScrollClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnPointerEntered(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
void OnPointerExited(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
void ModifyFontAndMargin(Windows::UI::Xaml::Controls::TextBlock ^ textBlock, double fontChange);
void ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
void UpdateScrollButtons();
void ScrollLeft();
@@ -73,10 +74,10 @@ namespace CalculatorApp
static Platform::StringReference s_FocusedState;
static Platform::StringReference s_UnfocusedState;
Windows::UI::Xaml::Controls::ScrollViewer^ m_textContainer;
Windows::UI::Xaml::Controls::TextBlock^ m_textBlock;
Windows::UI::Xaml::Controls::HyperlinkButton^ m_scrollLeft;
Windows::UI::Xaml::Controls::HyperlinkButton^ m_scrollRight;
Windows::UI::Xaml::Controls::ScrollViewer ^ m_textContainer;
Windows::UI::Xaml::Controls::TextBlock ^ m_textBlock;
Windows::UI::Xaml::Controls::HyperlinkButton ^ m_scrollLeft;
Windows::UI::Xaml::Controls::HyperlinkButton ^ m_scrollRight;
double scrollRatio = 0.7;
bool m_isScalingText;
bool m_haveCalculatedMax;

View File

@@ -9,16 +9,17 @@ using namespace Windows::UI::Xaml::Automation::Peers;
namespace CalculatorApp::Controls
{
CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement^ owner) :
FrameworkElementAutomationPeer(owner)
{ }
CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement ^ owner)
: FrameworkElementAutomationPeer(owner)
{
}
AutomationControlType CalculationResultAutomationPeer::GetAutomationControlTypeCore()
{
return AutomationControlType::Text;
}
Platform::Object^ CalculationResultAutomationPeer::GetPatternCore(PatternInterface pattern)
Platform::Object ^ CalculationResultAutomationPeer::GetPatternCore(PatternInterface pattern)
{
if (pattern == PatternInterface::Invoke)
{
@@ -30,7 +31,7 @@ namespace CalculatorApp::Controls
void CalculationResultAutomationPeer::Invoke()
{
auto owner = static_cast<CalculationResult^>(this->Owner);
auto owner = static_cast<CalculationResult ^>(this->Owner);
owner->ProgrammaticSelect();
}
}

View File

@@ -9,14 +9,15 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class CalculationResultAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer,
Windows::UI::Xaml::Automation::Provider::IInvokeProvider
public
ref class CalculationResultAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer,
Windows::UI::Xaml::Automation::Provider::IInvokeProvider
{
public:
CalculationResultAutomationPeer(Windows::UI::Xaml::FrameworkElement^ owner);
CalculationResultAutomationPeer(Windows::UI::Xaml::FrameworkElement ^ owner);
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override;
virtual Platform::Object^ GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface pattern) override;
virtual Platform::Object ^ GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface pattern) override;
virtual void Invoke();
};
}

View File

@@ -26,12 +26,12 @@ CalculatorButton::CalculatorButton()
{
// Set the default bindings for this button, these can be overwritten by Xaml if needed
// These are a replacement for binding in styles
Binding^ commandBinding = ref new Binding();
Binding ^ commandBinding = ref new Binding();
commandBinding->Path = ref new PropertyPath("ButtonPressed");
this->SetBinding(Button::CommandProperty, commandBinding);
}
void CalculatorButton::OnKeyDown(KeyRoutedEventArgs^ e)
void CalculatorButton::OnKeyDown(KeyRoutedEventArgs ^ e)
{
// Ignore the Enter key
if (e->Key == VirtualKey::Enter)
@@ -42,7 +42,7 @@ void CalculatorButton::OnKeyDown(KeyRoutedEventArgs^ e)
Button::OnKeyDown(e);
}
void CalculatorButton::OnKeyUp(KeyRoutedEventArgs^ e)
void CalculatorButton::OnKeyUp(KeyRoutedEventArgs ^ e)
{
// Ignore the Enter key
if (e->Key == VirtualKey::Enter)
@@ -53,16 +53,12 @@ void CalculatorButton::OnKeyUp(KeyRoutedEventArgs^ e)
Button::OnKeyUp(e);
}
void CalculatorButton::OnButtonIdPropertyChanged(
NumbersAndOperatorsEnum /*oldValue*/,
NumbersAndOperatorsEnum newValue)
void CalculatorButton::OnButtonIdPropertyChanged(NumbersAndOperatorsEnum /*oldValue*/, NumbersAndOperatorsEnum newValue)
{
this->CommandParameter = ref new CalculatorButtonPressedEventArgs(AuditoryFeedback, newValue);
}
void CalculatorButton::OnAuditoryFeedbackPropertyChanged(
String^ /*oldValue*/,
String^ newValue)
void CalculatorButton::OnAuditoryFeedbackPropertyChanged(String ^ /*oldValue*/, String ^ newValue)
{
this->CommandParameter = ref new CalculatorButtonPressedEventArgs(newValue, ButtonId);
}

View File

@@ -10,29 +10,27 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class CalculatorButton sealed: Windows::UI::Xaml::Controls::Button
public
ref class CalculatorButton sealed : Windows::UI::Xaml::Controls::Button
{
public:
CalculatorButton();
DEPENDENCY_PROPERTY_OWNER(CalculatorButton);
DEPENDENCY_PROPERTY_WITH_CALLBACK(NumbersAndOperatorsEnum, ButtonId);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String^, AuditoryFeedback);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverForeground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressForeground);
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String ^, AuditoryFeedback);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverForeground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressForeground);
protected:
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
private:
void OnButtonIdPropertyChanged(NumbersAndOperatorsEnum oldValue, NumbersAndOperatorsEnum newValue);
void OnAuditoryFeedbackPropertyChanged(Platform::String^ oldValue, Platform::String^ newValue);
void OnAuditoryFeedbackPropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue);
};
}
}

View File

@@ -19,8 +19,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, HoverForeground);
DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, PressBackground);
DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, PressForeground);
void FlipButtons::OnKeyDown(KeyRoutedEventArgs^ e)
void FlipButtons::OnKeyDown(KeyRoutedEventArgs ^ e)
{
// Ignore the Enter key
if (e->Key == VirtualKey::Enter)
@@ -31,7 +30,7 @@ void FlipButtons::OnKeyDown(KeyRoutedEventArgs^ e)
ToggleButton::OnKeyDown(e);
}
void FlipButtons::OnKeyUp(KeyRoutedEventArgs^ e)
void FlipButtons::OnKeyUp(KeyRoutedEventArgs ^ e)
{
// Ignore the Enter key
if (e->Key == VirtualKey::Enter)
@@ -42,10 +41,7 @@ void FlipButtons::OnKeyUp(KeyRoutedEventArgs^ e)
ToggleButton::OnKeyUp(e);
}
void FlipButtons::OnButtonIdPropertyChanged(
NumbersAndOperatorsEnum /*oldValue*/,
NumbersAndOperatorsEnum newValue)
void FlipButtons::OnButtonIdPropertyChanged(NumbersAndOperatorsEnum /*oldValue*/, NumbersAndOperatorsEnum newValue)
{
this->CommandParameter = newValue;
}

View File

@@ -10,27 +10,24 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class FlipButtons sealed: Windows::UI::Xaml::Controls::Primitives::ToggleButton
public
ref class FlipButtons sealed : Windows::UI::Xaml::Controls::Primitives::ToggleButton
{
public:
DEPENDENCY_PROPERTY_OWNER(FlipButtons);
DEPENDENCY_PROPERTY_WITH_CALLBACK(NumbersAndOperatorsEnum, ButtonId);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverForeground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressForeground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverForeground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressBackground);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressForeground);
protected:
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
private:
void OnButtonIdPropertyChanged(
NumbersAndOperatorsEnum oldValue,
NumbersAndOperatorsEnum newValue);
void OnButtonIdPropertyChanged(NumbersAndOperatorsEnum oldValue, NumbersAndOperatorsEnum newValue);
};
}
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
@@ -12,6 +12,8 @@
using namespace std;
using namespace CalculatorApp::Controls;
using namespace Windows::Foundation;
using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Automation::Peers;
Size HorizontalNoOverflowStackPanel::MeasureOverride(Size availableSize)
{
@@ -55,16 +57,17 @@ Size HorizontalNoOverflowStackPanel::ArrangeOverride(Size finalSize)
float itemWidth = item->DesiredSize.Width;
if (widthAvailable > 0 && itemWidth <= widthAvailable)
{
//stack the items horizontally (left to right)
// stack the items horizontally (left to right)
item->Arrange(Rect(posX, 0, itemWidth, finalSize.Height));
AutomationProperties::SetAccessibilityView(item, ::AccessibilityView::Content);
posX += item->RenderSize.Width;
}
else
{
//Not display the item
// Not display the item
item->Arrange(Rect(0, 0, 0, 0));
AutomationProperties::SetAccessibilityView(item, ::AccessibilityView::Raw);
}
}
return finalSize;
}

View File

@@ -13,12 +13,15 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class HorizontalNoOverflowStackPanel : public Windows::UI::Xaml::Controls::Panel
public
ref class HorizontalNoOverflowStackPanel : public Windows::UI::Xaml::Controls::Panel
{
DEPENDENCY_PROPERTY_OWNER(HorizontalNoOverflowStackPanel);
//Prioritize the last item over all other items (except the first one)
internal:
HorizontalNoOverflowStackPanel() {}
// Prioritize the last item over all other items (except the first one)
internal : HorizontalNoOverflowStackPanel()
{
}
protected:
virtual Windows::Foundation::Size MeasureOverride(Windows::Foundation::Size availableSize) override;
virtual Windows::Foundation::Size ArrangeOverride(Windows::Foundation::Size finalSize) override;

View File

@@ -1,58 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "OperandTextBox.h"
#include "regex"
using namespace CalculatorApp;
using namespace CalculatorApp::Controls;
using namespace Platform;
using namespace std;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Devices::Input;
using namespace Windows::System;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
void OperandTextBox::OnApplyTemplate()
{
this->IsEnabled = false;
this->IsHitTestVisible = false;
this->IsTapEnabled = false;
this->MaxLength = 50;
this->IsRightTapEnabled = false;
this->IsTabStop = false;
auto parent = VisualTreeHelper::GetParent(this);
ListViewItem^ listViewItem;
ListView^ listView;
while (parent != nullptr)
{
if (listViewItem == nullptr)
{
listViewItem = dynamic_cast<ListViewItem^>(parent);
}
listView = dynamic_cast<ListView^>(parent);
if (listView != nullptr)
{
break;
}
parent = VisualTreeHelper::GetParent(parent);
}
if (listView != nullptr)
{
listViewItem->IsEnabled = false;
listViewItem->IsHitTestVisible = false;
listViewItem->IsTapEnabled = false;
}
TextBox::OnApplyTemplate();
}

View File

@@ -1,19 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
namespace CalculatorApp
{
namespace Controls
{
public ref class OperandTextBox sealed : public Windows::UI::Xaml::Controls::TextBox
{
public:
OperandTextBox() { }
protected:
virtual void OnApplyTemplate() override;
};
}
}

View File

@@ -1,59 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "OperatorTextBox.h"
#include "regex"
using namespace CalculatorApp;
using namespace CalculatorApp::Controls;
using namespace Platform;
using namespace std;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Devices::Input;
using namespace Windows::System;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
void OperatorTextBox::OnApplyTemplate()
{
this->IsEnabled = false;
this->IsHitTestVisible = false;
this->IsTapEnabled = false;
this->MaxLength = 50;
this->IsReadOnly = true;
this->IsRightTapEnabled = false;
this->IsTabStop = false;
auto parent = VisualTreeHelper::GetParent(this);
ListViewItem^ listViewItem;
ListView^ listView;
while (parent != nullptr)
{
if (listViewItem == nullptr)
{
listViewItem = dynamic_cast<ListViewItem^>(parent);
}
listView = dynamic_cast<ListView^>(parent);
if (listView != nullptr)
{
break;
}
parent = VisualTreeHelper::GetParent(parent);
}
if (listView != nullptr)
{
listViewItem->IsEnabled = false;
listViewItem->IsHitTestVisible = false;
listViewItem->IsTapEnabled = false;
}
TextBox::OnApplyTemplate();
}

View File

@@ -1,19 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
namespace CalculatorApp
{
namespace Controls
{
public ref class OperatorTextBox sealed : public Windows::UI::Xaml::Controls::TextBox
{
public:
OperatorTextBox() { }
protected:
virtual void OnApplyTemplate() override;
};
}
}

View File

@@ -30,48 +30,62 @@ DEPENDENCY_PROPERTY_INITIALIZATION(OverflowTextBlock, TokensUpdated);
void OverflowTextBlock::OnApplyTemplate()
{
assert(((m_scrollLeft == nullptr) && (m_scrollRight == nullptr)) || ((m_scrollLeft != nullptr) && (m_scrollRight != nullptr)));
UnregisterEventHandlers();
m_expressionContainer = safe_cast<ScrollViewer^>(GetTemplateChild("expressionContainer"));
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
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);
}
m_scrollLeft = safe_cast<Button^>(GetTemplateChild("scrollLeft"));
m_scrollRight = safe_cast<Button^>(GetTemplateChild("scrollRight"));
uiElement = GetTemplateChild("ScrollLeft");
if (uiElement != nullptr)
{
m_scrollLeft = safe_cast<Button ^>(uiElement);
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
}
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
uiElement = GetTemplateChild("ScrollRight");
if (uiElement != nullptr)
{
m_scrollRight = safe_cast<Button ^>(uiElement);
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
}
m_scrollingLeft = false;
m_scrollingRight = false;
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);
m_listView = safe_cast<ListView^>(GetTemplateChild("TokenList"));
uiElement = GetTemplateChild("TokenList");
if (uiElement != nullptr)
{
m_itemsControl = safe_cast<ItemsControl ^>(uiElement);
}
UpdateAllState();
}
AutomationPeer^ OverflowTextBlock::OnCreateAutomationPeer()
AutomationPeer ^ OverflowTextBlock::OnCreateAutomationPeer()
{
return ref new OverflowTextBlockAutomationPeer(this);
}
void OverflowTextBlock::OnTokensUpdatedPropertyChanged(bool /*oldValue*/, bool newValue)
{
if ((m_listView != nullptr) && (newValue))
if (m_expressionContainer != nullptr && newValue)
{
unsigned int tokenCount = m_listView->Items->Size;
if (tokenCount > 0)
{
m_listView->UpdateLayout();
m_listView->ScrollIntoView(m_listView->Items->GetAt(tokenCount - 1));
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
}
m_expressionContainer->UpdateLayout();
m_expressionContainer->ChangeView(m_expressionContainer->ScrollableWidth, nullptr, nullptr, true);
}
AutomationProperties::SetAccessibilityView(this,
m_listView != nullptr && m_listView->Items->Size > 0 ? AccessibilityView::Control : AccessibilityView::Raw);
auto newIsAccessibilityViewControl = m_itemsControl != nullptr && m_itemsControl->Items->Size > 0;
if (m_isAccessibilityViewControl != newIsAccessibilityViewControl)
{
m_isAccessibilityViewControl = newIsAccessibilityViewControl;
AutomationProperties::SetAccessibilityView(this, newIsAccessibilityViewControl ? AccessibilityView::Control : AccessibilityView::Raw);
}
UpdateScrollButtons();
}
void OverflowTextBlock::UpdateAllState()
@@ -93,7 +107,7 @@ void OverflowTextBlock::UpdateVisualState()
void OverflowTextBlock::ScrollLeft()
{
if (m_expressionContainer->HorizontalOffset > 0)
if (m_expressionContainer != nullptr && m_expressionContainer->HorizontalOffset > 0)
{
m_scrollingLeft = true;
double offset = m_expressionContainer->HorizontalOffset - (scrollRatio * m_expressionContainer->ViewportWidth);
@@ -105,7 +119,7 @@ void OverflowTextBlock::ScrollLeft()
void OverflowTextBlock::ScrollRight()
{
if (m_expressionContainer->HorizontalOffset < m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)
if (m_expressionContainer != nullptr && m_expressionContainer->HorizontalOffset < m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)
{
m_scrollingRight = true;
double offset = m_expressionContainer->HorizontalOffset + (scrollRatio * m_expressionContainer->ViewportWidth);
@@ -115,9 +129,9 @@ void OverflowTextBlock::ScrollRight()
}
}
void OverflowTextBlock::OnScrollClick(_In_ Object^ sender, _In_ RoutedEventArgs^)
void OverflowTextBlock::OnScrollClick(_In_ Object ^ sender, _In_ RoutedEventArgs ^)
{
auto clicked = safe_cast<Button^>(sender);
auto clicked = safe_cast<Button ^>(sender);
if (clicked == m_scrollLeft)
{
ScrollLeft();
@@ -128,31 +142,22 @@ void OverflowTextBlock::OnScrollClick(_In_ Object^ sender, _In_ RoutedEventArgs^
}
}
void OverflowTextBlock::OnPointerEntered(_In_ Object^, _In_ PointerRoutedEventArgs^ e)
{
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
{
UpdateScrollButtons();
}
}
void OverflowTextBlock::OnPointerExited(_In_ Object^, _In_ PointerRoutedEventArgs^ e)
{
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
{
UpdateScrollButtons();
}
}
void OverflowTextBlock::UpdateScrollButtons()
{
if (m_itemsControl == nullptr || m_expressionContainer == nullptr)
{
return;
}
// When the width is smaller than the container, don't show any
if (m_listView->ActualWidth <= m_expressionContainer->ActualWidth)
if (m_itemsControl->ActualWidth <= m_expressionContainer->ActualWidth)
{
ShowHideScrollButtons(::Visibility::Collapsed, ::Visibility::Collapsed);
}
// We have more number on both side. Show both arrows
else if ((m_expressionContainer->HorizontalOffset > 0) && (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)))
else if (
(m_expressionContainer->HorizontalOffset > 0)
&& (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)))
{
ShowHideScrollButtons(::Visibility::Visible, ::Visibility::Visible);
}
@@ -163,7 +168,10 @@ void OverflowTextBlock::UpdateScrollButtons()
if (m_scrollingLeft)
{
m_scrollingLeft = false;
m_scrollRight->Focus(::FocusState::Programmatic);
if (m_scrollRight != nullptr)
{
m_scrollRight->Focus(::FocusState::Programmatic);
}
}
}
else // Width is larger than the container and right most part of the number is shown. Should be able to scroll left.
@@ -172,7 +180,10 @@ void OverflowTextBlock::UpdateScrollButtons()
if (m_scrollingRight)
{
m_scrollingRight = false;
m_scrollLeft->Focus(::FocusState::Programmatic);
if (m_scrollLeft != nullptr)
{
m_scrollLeft->Focus(::FocusState::Programmatic);
}
}
}
}
@@ -199,12 +210,13 @@ void OverflowTextBlock::UnregisterEventHandlers()
m_scrollRight->Click -= m_scrollRightClickEventToken;
}
auto borderContainer = safe_cast<Border^>(GetTemplateChild("expressionborder"));
// Adding an extra check, in case the returned template is null
if (borderContainer != nullptr)
if (m_expressionContainer != nullptr)
{
borderContainer->PointerEntered -= m_pointerEnteredEventToken;
borderContainer->PointerExited -= m_pointerExitedEventToken;
m_expressionContainer->ViewChanged -= m_containerViewChangedToken;
}
}
void OverflowTextBlock::OnViewChanged(_In_opt_ Object ^ /*sender*/, _In_opt_ ScrollViewerViewChangedEventArgs ^ /*args*/)
{
UpdateScrollButtons();
}

View File

@@ -9,7 +9,8 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class OverflowTextBlock sealed : public Windows::UI::Xaml::Controls::Control
public
ref class OverflowTextBlock sealed : public Windows::UI::Xaml::Controls::Control
{
public:
OverflowTextBlock()
@@ -20,20 +21,21 @@ namespace CalculatorApp
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, TokensUpdated);
DEPENDENCY_PROPERTY(bool, IsActive);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style^, TextStyle);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style ^, TextStyle);
void UpdateScrollButtons();
void UnregisterEventHandlers();
protected:
virtual void OnApplyTemplate() override;
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
private:
void OnScrollClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
void OnPointerEntered(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void OnPointerExited(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void OnScrollClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnPointerEntered(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
void OnPointerExited(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
void ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
void OnTokensUpdatedPropertyChanged(bool oldValue, bool newValue);
void OnViewChanged(_In_opt_ Platform::Object ^ sender, _In_opt_ Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^ args);
void UpdateVisualState();
void UpdateExpressionState();
@@ -44,15 +46,15 @@ namespace CalculatorApp
double scrollRatio = 0.7;
bool m_scrollingLeft;
bool m_scrollingRight;
Windows::UI::Xaml::Controls::ListView^ m_listView;
Windows::UI::Xaml::Controls::ScrollViewer^ m_expressionContainer;
Windows::UI::Xaml::Controls::Button^ m_scrollLeft;
Windows::UI::Xaml::Controls::Button^ m_scrollRight;
bool m_isAccessibilityViewControl;
Windows::UI::Xaml::Controls::ItemsControl ^ m_itemsControl;
Windows::UI::Xaml::Controls::ScrollViewer ^ m_expressionContainer;
Windows::UI::Xaml::Controls::Button ^ m_scrollLeft;
Windows::UI::Xaml::Controls::Button ^ m_scrollRight;
Windows::Foundation::EventRegistrationToken m_scrollLeftClickEventToken;
Windows::Foundation::EventRegistrationToken m_scrollRightClickEventToken;
Windows::Foundation::EventRegistrationToken m_pointerEnteredEventToken;
Windows::Foundation::EventRegistrationToken m_pointerExitedEventToken;
Windows::Foundation::EventRegistrationToken m_containerViewChangedToken;
};
}
}

View File

@@ -10,16 +10,17 @@ using namespace Windows::Foundation::Collections;
namespace CalculatorApp::Controls
{
OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock^ owner) :
FrameworkElementAutomationPeer(owner)
{ }
OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner)
: FrameworkElementAutomationPeer(owner)
{
}
AutomationControlType OverflowTextBlockAutomationPeer::GetAutomationControlTypeCore()
{
return AutomationControlType::Text;
}
IVector<AutomationPeer^>^ OverflowTextBlockAutomationPeer::GetChildrenCore()
IVector<AutomationPeer ^> ^ OverflowTextBlockAutomationPeer::GetChildrenCore()
{
return nullptr;
}

View File

@@ -9,13 +9,14 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class OverflowTextBlockAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
public
ref class OverflowTextBlockAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
{
public:
OverflowTextBlockAutomationPeer(OverflowTextBlock^ owner);
OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner);
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override;
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer^>^ GetChildrenCore() override;
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer ^> ^ GetChildrenCore() override;
};
}
}

View File

@@ -16,10 +16,10 @@ using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Data;
String^ RadixButton::GetRawDisplayValue()
String ^ RadixButton::GetRawDisplayValue()
{
wstring rawValue;
String^ radixContent = Content->ToString();
String ^ radixContent = Content->ToString();
LocalizationSettings::GetInstance().RemoveGroupSeparators(radixContent->Data(), radixContent->Length(), &rawValue);
return ref new String(rawValue.c_str());
}

View File

@@ -7,12 +7,12 @@ namespace CalculatorApp
{
namespace Controls
{
public ref class RadixButton sealed : public Windows::UI::Xaml::Controls::RadioButton
public
ref class RadixButton sealed : public Windows::UI::Xaml::Controls::RadioButton
{
public:
RadixButton() {};
internal:
Platform::String^ GetRawDisplayValue();
RadixButton(){};
internal : Platform::String ^ GetRawDisplayValue();
};
}
}

View File

@@ -18,23 +18,23 @@ using namespace Platform;
using namespace Windows::Foundation::Collections;
using namespace std;
DependencyObject^ SupplementaryItemsControl::GetContainerForItemOverride()
DependencyObject ^ SupplementaryItemsControl::GetContainerForItemOverride()
{
return ref new SupplementaryContentPresenter();
}
void SupplementaryItemsControl::PrepareContainerForItemOverride(DependencyObject^ element, Object^ item)
void SupplementaryItemsControl::PrepareContainerForItemOverride(DependencyObject ^ element, Object ^ item)
{
ItemsControl::PrepareContainerForItemOverride(element, item);
auto supplementaryResult = dynamic_cast<SupplementaryResult^>(item);
auto supplementaryResult = dynamic_cast<SupplementaryResult ^>(item);
if (supplementaryResult)
{
AutomationProperties::SetName(element, supplementaryResult->GetLocalizedAutomationName());
}
}
AutomationPeer^ SupplementaryContentPresenter::OnCreateAutomationPeer()
{
return ref new SupplementaryContentPresenterAP(this);
}
AutomationPeer ^ SupplementaryContentPresenter::OnCreateAutomationPeer()
{
return ref new SupplementaryContentPresenterAP(this);
}

View File

@@ -3,45 +3,52 @@
#pragma once
namespace CalculatorApp { namespace Controls {
public ref class SupplementaryItemsControl sealed: public Windows::UI::Xaml::Controls::ItemsControl
namespace CalculatorApp
{
namespace Controls
{
public:
SupplementaryItemsControl()
{ }
protected:
virtual Windows::UI::Xaml::DependencyObject^ GetContainerForItemOverride() override;
virtual void PrepareContainerForItemOverride(Windows::UI::Xaml::DependencyObject^ element, Platform::Object^ item) override;
};
public ref class SupplementaryContentPresenter sealed: public Windows::UI::Xaml::Controls::ContentPresenter
{
public:
SupplementaryContentPresenter()
{ }
protected:
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
};
ref class SupplementaryContentPresenterAP sealed: public Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
{
protected:
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override
public
ref class SupplementaryItemsControl sealed : public Windows::UI::Xaml::Controls::ItemsControl
{
return Windows::UI::Xaml::Automation::Peers::AutomationControlType::Text;
}
public:
SupplementaryItemsControl()
{
}
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer^>^ GetChildrenCore() override
protected:
virtual Windows::UI::Xaml::DependencyObject ^ GetContainerForItemOverride() override;
virtual void PrepareContainerForItemOverride(Windows::UI::Xaml::DependencyObject ^ element, Platform::Object ^ item) override;
};
public
ref class SupplementaryContentPresenter sealed : public Windows::UI::Xaml::Controls::ContentPresenter
{
return nullptr;
}
public:
SupplementaryContentPresenter()
{
}
internal:
SupplementaryContentPresenterAP(SupplementaryContentPresenter^ owner):
Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer(owner)
{ }
};
}}
protected:
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
};
ref class SupplementaryContentPresenterAP sealed : public Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
{
protected:
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override
{
return Windows::UI::Xaml::Automation::Peers::AutomationControlType::Text;
}
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer ^> ^ GetChildrenCore() override
{
return nullptr;
}
internal : SupplementaryContentPresenterAP(SupplementaryContentPresenter ^ owner)
: Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer(owner)
{
}
};
}
}