Code cleaning: Remove all properties/functions not used in CalculationResult (#649)
This commit is contained in:
@@ -26,16 +26,12 @@ using namespace Windows::UI::Xaml::Automation::Peers;
|
||||
using namespace std;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, IsActive);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, AccentColor);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, MinFontSize);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, MaxFontSize);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayMargin);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, MaxExpressionHistoryCharacters);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, ExpressionVisibility);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayValue);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, IsInError);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, IsOperatorCommand);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayStringExpression);
|
||||
|
||||
#define SCALEFACTOR 0.357143
|
||||
#define SMALLHEIGHTSCALEFACTOR 0
|
||||
@@ -46,6 +42,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayStringExpression);
|
||||
#define WIDTHTOFONTOFFSET 3
|
||||
#define WIDTHCUTOFF 50
|
||||
#define FONTTOLERANCE 0.001
|
||||
#define SCROLL_RATIO 0.7
|
||||
|
||||
// We need a safety margin to guarantee we correctly always show/hide ScrollLeft and ScrollRight buttons when necessary.
|
||||
// In rare cases, ScrollViewer::HorizontalOffset is a little low by a few (sub)pixels when users scroll to one of the extremity
|
||||
@@ -120,12 +117,12 @@ void CalculationResult::OnApplyTemplate()
|
||||
m_scrollLeft = dynamic_cast<HyperlinkButton ^>(GetTemplateChild("ScrollLeft"));
|
||||
if (m_scrollLeft)
|
||||
{
|
||||
m_scrollLeftClickToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
|
||||
m_scrollLeftClickToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollLeftClick);
|
||||
}
|
||||
m_scrollRight = dynamic_cast<HyperlinkButton ^>(GetTemplateChild("ScrollRight"));
|
||||
if (m_scrollRight)
|
||||
{
|
||||
m_scrollRightClickToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
|
||||
m_scrollRightClickToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollRightClick);
|
||||
}
|
||||
m_textBlock = dynamic_cast<TextBlock ^>(GetTemplateChild("NormalOutput"));
|
||||
if (m_textBlock)
|
||||
@@ -156,16 +153,6 @@ void CalculationResult::OnIsActivePropertyChanged(bool /*oldValue*/, bool /*newV
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
void CalculationResult::OnAccentColorPropertyChanged(Brush ^ /*oldValue*/, Brush ^ /*newValue*/)
|
||||
{
|
||||
// Force the "Active" transition to happen again
|
||||
if (IsActive)
|
||||
{
|
||||
VisualStateManager::GoToState(this, "Normal", true);
|
||||
VisualStateManager::GoToState(this, "Active", true);
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnDisplayValuePropertyChanged(String ^ /*oldValue*/, String ^ /*newValue*/)
|
||||
{
|
||||
UpdateTextState();
|
||||
@@ -287,7 +274,7 @@ void CalculationResult::ScrollLeft()
|
||||
}
|
||||
if (m_textContainer->HorizontalOffset > 0)
|
||||
{
|
||||
double offset = m_textContainer->HorizontalOffset - (scrollRatio * m_textContainer->ViewportWidth);
|
||||
double offset = m_textContainer->HorizontalOffset - (SCROLL_RATIO * m_textContainer->ViewportWidth);
|
||||
m_textContainer->ChangeView(offset, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
@@ -301,7 +288,7 @@ void CalculationResult::ScrollRight()
|
||||
|
||||
if (m_textContainer->HorizontalOffset < m_textContainer->ExtentWidth - m_textContainer->ViewportWidth)
|
||||
{
|
||||
double offset = m_textContainer->HorizontalOffset + (scrollRatio * m_textContainer->ViewportWidth);
|
||||
double offset = m_textContainer->HorizontalOffset + (SCROLL_RATIO * m_textContainer->ViewportWidth);
|
||||
m_textContainer->ChangeView(offset, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
@@ -319,17 +306,14 @@ void CalculationResult::OnKeyDown(KeyRoutedEventArgs ^ e)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnScrollClick(Object ^ sender, RoutedEventArgs ^ /*e*/)
|
||||
void CalculationResult::OnScrollLeftClick(Object ^ sender, RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
auto clicked = dynamic_cast<HyperlinkButton ^>(sender);
|
||||
if (clicked == m_scrollLeft)
|
||||
{
|
||||
this->ScrollLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ScrollRight();
|
||||
}
|
||||
ScrollLeft();
|
||||
}
|
||||
|
||||
void CalculationResult::OnScrollRightClick(Object ^ sender, RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
ScrollRight();
|
||||
}
|
||||
|
||||
void CalculationResult::UpdateScrollButtons()
|
||||
|
@@ -20,15 +20,11 @@ namespace CalculatorApp
|
||||
|
||||
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);
|
||||
|
||||
@@ -48,7 +44,6 @@ namespace CalculatorApp
|
||||
|
||||
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);
|
||||
@@ -58,7 +53,11 @@ namespace CalculatorApp
|
||||
void OnTextContainerLayoutUpdated(Object ^ sender, Object ^ e);
|
||||
void OnTextContainerOnViewChanged(Object ^ sender, Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^ e);
|
||||
void UpdateVisualState();
|
||||
void OnScrollClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void UpdateAllState();
|
||||
void OnScrollLeftClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnScrollRightClick(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 UpdateScrollButtons();
|
||||
void ScrollLeft();
|
||||
@@ -69,7 +68,6 @@ namespace CalculatorApp
|
||||
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;
|
||||
|
@@ -547,7 +547,6 @@
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Results.MaxFontSize" Value="72"/>
|
||||
<Setter Target="Results.MaxExpressionHistoryCharacters" Value="51"/>
|
||||
<Setter Target="RowResult.MinHeight" Value="108"/>
|
||||
<Setter Target="RowResult.Height" Value="72*"/>
|
||||
</VisualState.Setters>
|
||||
@@ -558,7 +557,6 @@
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Results.MaxFontSize" Value="46"/>
|
||||
<Setter Target="Results.MaxExpressionHistoryCharacters" Value="30"/>
|
||||
<Setter Target="RowResult.MinHeight" Value="72"/>
|
||||
<Setter Target="RowResult.Height" Value="72*"/>
|
||||
</VisualState.Setters>
|
||||
@@ -569,7 +567,6 @@
|
||||
</VisualState.StateTriggers>
|
||||
<VisualState.Setters>
|
||||
<Setter Target="Results.MaxFontSize" Value="26"/>
|
||||
<Setter Target="Results.MaxExpressionHistoryCharacters" Value="30"/>
|
||||
<Setter Target="RowResult.MinHeight" Value="42"/>
|
||||
<Setter Target="RowResult.Height" Value="42*"/>
|
||||
</VisualState.Setters>
|
||||
@@ -615,9 +612,7 @@
|
||||
AutomationProperties.Name="{x:Bind Model.CalculationResultAutomationName, Mode=OneWay}"
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
DisplayStringExpression="{x:Bind Model.DisplayStringExpression, Mode=OneWay}"
|
||||
DisplayValue="{x:Bind Model.DisplayValue, Mode=OneWay}"
|
||||
ExpressionVisibility="Visible"
|
||||
IsInError="{x:Bind Model.IsInError, Mode=OneWay}"
|
||||
IsOperatorCommand="{x:Bind Model.IsOperatorCommand, Mode=OneWay}"
|
||||
TabIndex="1"
|
||||
|
@@ -559,7 +559,6 @@
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
DisplayValue="{x:Bind Model.Value1, Mode=OneWay}"
|
||||
ExpressionVisibility="Collapsed"
|
||||
FlowDirection="{x:Bind LayoutDirection}"
|
||||
IsActive="{Binding Value1Active, Mode=TwoWay}"
|
||||
KeyDown="OnValueKeyDown"
|
||||
@@ -610,7 +609,6 @@
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
DisplayValue="{x:Bind Model.Value2, Mode=OneWay}"
|
||||
ExpressionVisibility="Collapsed"
|
||||
FlowDirection="{x:Bind LayoutDirection}"
|
||||
IsActive="{Binding Value2Active, Mode=TwoWay}"
|
||||
KeyDown="OnValueKeyDown"
|
||||
|
Reference in New Issue
Block a user