calculator/src/Calculator/Controls/CalculationResult.h
Stephanie Anderl a418777f02
Merge master into feature/GraphingCalculator branch (#585)
* Merge master into feature/GraphingCalculator branch
2019-07-15 11:17:21 -07:00

88 lines
4.4 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "CalcViewModel/Common/Utils.h"
namespace CalculatorApp
{
namespace Controls
{
public
delegate void SelectedEventHandler(Platform::Object ^ sender);
public
ref class CalculationResult sealed : public Windows::UI::Xaml::Controls::Control
{
public:
CalculationResult();
DEPENDENCY_PROPERTY_OWNER(CalculationResult);
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Visibility, ExpressionVisibility);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MinFontSize, 0.0);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, MaxFontSize, 30.0);
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(bool, IsInError);
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsOperatorCommand, false);
event SelectedEventHandler ^ Selected;
void ProgrammaticSelect();
internal : void UpdateTextState();
Platform::String ^ GetRawDisplayValue();
protected:
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 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 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 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 ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
void UpdateScrollButtons();
void ScrollLeft();
void ScrollRight();
void RaiseSelectedEvent();
// Visual states for focused
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;
double scrollRatio = 0.7;
bool m_isScalingText;
bool m_haveCalculatedMax;
Windows::Foundation::EventRegistrationToken m_textContainerLayoutChangedToken;
};
}
}