Update Icons Implement the Graph View Button (#1149)

* Update icon file

* function analysis and negate button icons updated

* Replace zoom reset button with graph view button

* Fixed issue where the window settings did not update after panning/zooming

* Updated icon styling and added logic for updating the graph view button state when user manipulates the graph and when all equations are removed

* updated LogGraphButton clicked to have an enum for the button value instead of a string

* Updated the logic for how to set the IsManualAdjustment, ensured graphsettings now update IsManualAdjustment when changed
This commit is contained in:
Stephanie Anderl 2020-04-14 12:37:23 -07:00 committed by GitHub
parent 7612b69949
commit 3a8fcaa18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 220 additions and 60 deletions

View File

@ -26,6 +26,7 @@ namespace CalculatorApp::Common::Automation
StringReference GraphModeChanged(L"GraphModeChanged"); StringReference GraphModeChanged(L"GraphModeChanged");
StringReference GraphViewChanged(L"GraphViewChanged"); StringReference GraphViewChanged(L"GraphViewChanged");
StringReference FunctionRemoved(L"FunctionRemoved"); StringReference FunctionRemoved(L"FunctionRemoved");
StringReference GraphViewBestFitChanged(L"GraphViewBestFitChanged");
} }
} }
@ -170,3 +171,12 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetFunctionRemovedAnnouncement(St
AutomationNotificationKind::ItemRemoved, AutomationNotificationKind::ItemRemoved,
AutomationNotificationProcessing::MostRecent); AutomationNotificationProcessing::MostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetGraphViewBestFitChangedAnnouncement(Platform::String ^ announcement)
{
return ref new NarratorAnnouncement(
announcement,
CalculatorActivityIds::GraphViewBestFitChanged,
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::MostRecent);
}

View File

@ -69,6 +69,7 @@ public
static NarratorAnnouncement ^ GetGraphModeChangedAnnouncement(Platform::String ^ announcement); static NarratorAnnouncement ^ GetGraphModeChangedAnnouncement(Platform::String ^ announcement);
static NarratorAnnouncement ^ GetGraphViewChangedAnnouncement(Platform::String ^ announcement); static NarratorAnnouncement ^ GetGraphViewChangedAnnouncement(Platform::String ^ announcement);
static NarratorAnnouncement ^ GetGraphViewBestFitChangedAnnouncement(Platform::String ^ announcement);
static NarratorAnnouncement ^ GetFunctionRemovedAnnouncement(Platform::String ^ announcement); static NarratorAnnouncement ^ GetFunctionRemovedAnnouncement(Platform::String ^ announcement);

View File

@ -272,11 +272,12 @@ namespace CalculatorApp
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_SHOW_HIDE_BUTTON_CLICKED), fields); TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_SHOW_HIDE_BUTTON_CLICKED), fields);
} }
void TraceLogger::LogGraphButtonClicked(GraphButton buttonName) void TraceLogger::LogGraphButtonClicked(GraphButton buttonName, GraphButtonValue buttonValue)
{ {
auto fields = ref new LoggingFields(); auto fields = ref new LoggingFields();
fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE)); fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE));
fields->AddInt16(StringReference(L"ButtonName"), static_cast<int16>(buttonName)); fields->AddInt16(StringReference(L"ButtonName"), static_cast<int16>(buttonName));
fields->AddInt16(StringReference(L"ButtonValue"), static_cast<int16>(buttonValue));
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_GRAPH_BUTTON_CLICKED), fields); TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_GRAPH_BUTTON_CLICKED), fields);
} }

View File

@ -41,7 +41,14 @@ namespace CalculatorApp
Share, Share,
ZoomIn, ZoomIn,
ZoomOut, ZoomOut,
ZoomReset GraphView
};
public enum class GraphButtonValue
{
None,
AutomaticBestFit,
ManualAdjustment
}; };
public enum class LineStyleType public enum class LineStyleType
@ -70,7 +77,7 @@ namespace CalculatorApp
void LogNavBarOpened(); void LogNavBarOpened();
void LogError(CalculatorApp::Common::ViewMode mode, Platform::String ^ functionName, Platform::String ^ errorString); void LogError(CalculatorApp::Common::ViewMode mode, Platform::String ^ functionName, Platform::String ^ errorString);
void LogShowHideButtonClicked(bool isHideButton); void LogShowHideButtonClicked(bool isHideButton);
void LogGraphButtonClicked(GraphButton buttonName); void LogGraphButtonClicked(GraphButton buttonName, GraphButtonValue buttonValue);
void LogGraphLineStyleChanged(LineStyleType style); void LogGraphLineStyleChanged(LineStyleType style);
void LogVariableChanged(Platform::String ^ inputChangedType, Platform::String ^ variableName); void LogVariableChanged(Platform::String ^ inputChangedType, Platform::String ^ variableName);
void LogVariableSettingsChanged(Platform::String ^ setting); void LogVariableSettingsChanged(Platform::String ^ setting);

View File

@ -56,19 +56,19 @@ void GraphingSettingsViewModel::InitRanges()
m_YMaxValue = yMax; m_YMaxValue = yMax;
auto valueStr = to_wstring(m_XMinValue); auto valueStr = to_wstring(m_XMinValue);
TrimTrailingZeros(valueStr); TrimTrailingZeros(valueStr);
m_XMin = ref new String(valueStr.c_str()); XMin = ref new String(valueStr.c_str());
valueStr = to_wstring(m_XMaxValue); valueStr = to_wstring(m_XMaxValue);
TrimTrailingZeros(valueStr); TrimTrailingZeros(valueStr);
m_XMax = ref new String(valueStr.c_str()); XMax = ref new String(valueStr.c_str());
valueStr = to_wstring(m_YMinValue); valueStr = to_wstring(m_YMinValue);
TrimTrailingZeros(valueStr); TrimTrailingZeros(valueStr);
m_YMin = ref new String(valueStr.c_str()); YMin = ref new String(valueStr.c_str());
valueStr = to_wstring(m_YMaxValue); valueStr = to_wstring(m_YMaxValue);
TrimTrailingZeros(valueStr); TrimTrailingZeros(valueStr);
m_YMax = ref new String(valueStr.c_str()); YMax = ref new String(valueStr.c_str());
m_dontUpdateDisplayRange = false; m_dontUpdateDisplayRange = false;
} }

Binary file not shown.

View File

@ -272,7 +272,7 @@ void EquationTextBox::OnRemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e
IsEquationLineDisabled = false; IsEquationLineDisabled = false;
} }
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::RemoveFunction); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::RemoveFunction, GraphButtonValue::None);
VisualStateManager::GoToState(this, "Normal", true); VisualStateManager::GoToState(this, "Normal", true);
} }
@ -282,7 +282,7 @@ void EquationTextBox::OnColorChooserButtonClicked(Object ^ sender, RoutedEventAr
if (ColorChooserFlyout != nullptr && m_richEditBox != nullptr) if (ColorChooserFlyout != nullptr && m_richEditBox != nullptr)
{ {
ColorChooserFlyout->ShowAt(m_richEditBox); ColorChooserFlyout->ShowAt(m_richEditBox);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::StylePicker); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::StylePicker, GraphButtonValue::None);
} }
} }

View File

@ -3867,17 +3867,25 @@
<value>^</value> <value>^</value>
<comment>{Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum.</comment> <comment>{Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum.</comment>
</data> </data>
<data name="zoomResetButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlChord" xml:space="preserve"> <data name="graphViewButton.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyControlChord" xml:space="preserve">
<value>Home</value> <value>Home</value>
<comment>{Locked}This is the shortcut for the zoom reset button.</comment> <comment>{Locked}This is the shortcut for the graph view button.</comment>
</data> </data>
<data name="zoomResetButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="graphViewButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Reset View (Ctrl + 0)</value> <value>Refresh view automatically (Ctrl + 0)</value>
<comment>This is the tool tip automation name for the Calculator zoom reset button.</comment> <comment>This is the tool tip automation name for the Calculator graph view button.</comment>
</data> </data>
<data name="zoomResetButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve"> <data name="graphViewButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Reset View</value> <value>Graph View</value>
<comment>Screen reader prompt for the reset zoom button.</comment> <comment>Screen reader prompt for the graph view button.</comment>
</data>
<data name="GraphViewAutomaticBestFitAnnouncement" xml:space="preserve">
<value>Automatic Best Fit</value>
<comment>Announcement used in Graphing Calculator when button is clicked and automatic best fit is set</comment>
</data>
<data name="GraphViewManualAdjustmentAnnouncement" xml:space="preserve">
<value>Manual Adjustment</value>
<comment>Announcement used in Graphing Calculator when button is clicked and manual adjustment is set</comment>
</data> </data>
<data name="zoomInButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> <data name="zoomInButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Zoom In (Ctrl + plus)</value> <value>Zoom In (Ctrl + plus)</value>

View File

@ -570,7 +570,7 @@
<MenuFlyoutSeparator/> <MenuFlyoutSeparator/>
<MenuFlyoutItem x:Name="FunctionAnalysisMenuItem"> <MenuFlyoutItem x:Name="FunctionAnalysisMenuItem">
<MenuFlyoutItem.Icon> <MenuFlyoutItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xE3B5;"/> <FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xE945;"/>
</MenuFlyoutItem.Icon> </MenuFlyoutItem.Icon>
</MenuFlyoutItem> </MenuFlyoutItem>
<MenuFlyoutItem x:Name="ChangeFunctionStyleMenuItem"> <MenuFlyoutItem x:Name="ChangeFunctionStyleMenuItem">
@ -596,7 +596,7 @@
Style="{ThemeResource ButtonRevealStyle}" Style="{ThemeResource ButtonRevealStyle}"
FontFamily="{StaticResource CalculatorFontFamily}" FontFamily="{StaticResource CalculatorFontFamily}"
AutomationProperties.AccessibilityView="Raw" AutomationProperties.AccessibilityView="Raw"
Content="&#xE3B5;" Content="&#xE945;"
IsTabStop="False" IsTabStop="False"
Visibility="Collapsed"> Visibility="Collapsed">
<Button.Resources> <Button.Resources>

View File

@ -286,6 +286,79 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<Style x:Name="GraphViewToggleButtonStyle"
BasedOn="{StaticResource GraphToggleButtonStyle}"
TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<ContentPresenter x:Name="ContentPresenter">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Checked"/>
<VisualState x:Name="CheckedPointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundPointerOver}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="CheckedPressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBackgroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonBorderBrushPressed}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ToggleButtonForegroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Graph Theme Colors --> <!-- Graph Theme Colors -->
<Color x:Key="LightThemeAxisColor">#000000</Color> <Color x:Key="LightThemeAxisColor">#000000</Color>
@ -296,6 +369,7 @@
<Color x:Key="DarkThemeGridLinesColor">#4F4F4F</Color> <Color x:Key="DarkThemeGridLinesColor">#4F4F4F</Color>
<converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/> <converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/>
<converters:BooleanNegationConverter x:Name="BooleanNegationConverter"/>
<ResourceDictionary.ThemeDictionaries> <ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default"> <ResourceDictionary x:Key="Default">
@ -323,7 +397,11 @@
TargetType="ToggleButton"> TargetType="ToggleButton">
<Setter Property="Foreground" Value="#FFFFFF"/> <Setter Property="Foreground" Value="#FFFFFF"/>
</Style> </Style>
<Style x:Key="ThemedGraphViewToggleButtonStyle"
BasedOn="{StaticResource GraphViewToggleButtonStyle}"
TargetType="ToggleButton">
<Setter Property="Foreground" Value="#FFFFFF"/>
</Style>
<Style x:Key="GraphTooltipStyle" TargetType="Border"> <Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="BorderBrush" Value="#e0e0e0"/> <Setter Property="BorderBrush" Value="#e0e0e0"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
@ -356,6 +434,9 @@
<Style x:Key="ThemedGraphToggleButtonStyle" <Style x:Key="ThemedGraphToggleButtonStyle"
BasedOn="{StaticResource GraphToggleButtonStyle}" BasedOn="{StaticResource GraphToggleButtonStyle}"
TargetType="ToggleButton"/> TargetType="ToggleButton"/>
<Style x:Key="ThemedGraphViewToggleButtonStyle"
BasedOn="{StaticResource GraphViewToggleButtonStyle}"
TargetType="ToggleButton"/>
<Style x:Key="GraphTooltipStyle" TargetType="Border"> <Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="Background" Value="{ThemeResource SystemControlAcrylicElementBrush}"/> <Setter Property="Background" Value="{ThemeResource SystemControlAcrylicElementBrush}"/>
<Setter Property="BorderBrush" Value="#e0e0e0"/> <Setter Property="BorderBrush" Value="#e0e0e0"/>
@ -381,6 +462,9 @@
<Style x:Key="ThemedGraphToggleButtonStyle" TargetType="ToggleButton"> <Style x:Key="ThemedGraphToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Margin" Value="1"/> <Setter Property="Margin" Value="1"/>
</Style> </Style>
<Style x:Key="ThemedGraphViewToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Margin" Value="1"/>
</Style>
<Style x:Key="GraphTooltipStyle" TargetType="Border"> <Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="BorderBrush" Value="{ThemeResource ToolTipBorderBrush}"/> <Setter Property="BorderBrush" Value="{ThemeResource ToolTipBorderBrush}"/>
<Setter Property="BorderThickness" Value="{ThemeResource ToolTipBorderThemeThickness}"/> <Setter Property="BorderThickness" Value="{ThemeResource ToolTipBorderThemeThickness}"/>
@ -504,6 +588,7 @@
ForceProportionalAxes="False" ForceProportionalAxes="False"
GraphPlottedEvent="GraphingControl_GraphPlottedEvent" GraphPlottedEvent="GraphingControl_GraphPlottedEvent"
GraphViewChangedEvent="GraphingControl_GraphViewChangedEvent" GraphViewChangedEvent="GraphingControl_GraphViewChangedEvent"
IsKeepCurrentView="{x:Bind IsManualAdjustment, Mode=TwoWay}"
LosingFocus="GraphingControl_LosingFocus" LosingFocus="GraphingControl_LosingFocus"
LostFocus="GraphingControl_LostFocus" LostFocus="GraphingControl_LostFocus"
RequestedTheme="Light" RequestedTheme="Light"
@ -613,19 +698,30 @@
</RepeatButton.KeyboardAccelerators> </RepeatButton.KeyboardAccelerators>
</RepeatButton> </RepeatButton>
<Button x:Uid="zoomResetButton" <ToggleButton x:Uid="graphViewButton"
MinHeight="40" MinHeight="40"
Style="{ThemeResource ThemedGraphButtonStyle}" MinWidth="40"
Style="{ThemeResource ThemedGraphViewToggleButtonStyle}"
contract7Present:CornerRadius="{ThemeResource BottomButtonCornerRadius}" contract7Present:CornerRadius="{ThemeResource BottomButtonCornerRadius}"
AutomationProperties.AutomationId="zoomResetButton" AutomationProperties.AutomationId="graphViewButton"
Command="{x:Bind ZoomResetButtonPressed, Mode=OneTime}"> Click="GraphViewButton_Click"
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" IsChecked="{x:Bind IsManualAdjustment, Mode=TwoWay}">
<ToggleButton.Content>
<Grid>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
FontSize="14" FontSize="14"
Glyph="&#xE895;"/> Glyph="&#xE45E;"/>
<Button.KeyboardAccelerators> <FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
FontSize="14"
Glyph="&#xE45D;"
Visibility="{x:Bind IsManualAdjustment, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/>
</Grid>
</ToggleButton.Content>
<ToggleButton.KeyboardAccelerators>
<KeyboardAccelerator Key="Number0" Modifiers="Control"/> <KeyboardAccelerator Key="Number0" Modifiers="Control"/>
</Button.KeyboardAccelerators> </ToggleButton.KeyboardAccelerators>
</Button>
</ToggleButton>
</StackPanel> </StackPanel>
</Border> </Border>
<Border x:Name="TraceValuePopup" <Border x:Name="TraceValuePopup"

View File

@ -174,6 +174,11 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
{ {
GraphingControl->Equations->RemoveAt(event->Index); GraphingControl->Equations->RemoveAt(event->Index);
if (GraphingControl->Equations->Size == 1 && GraphingControl->Equations->GetAt(0)->Expression->IsEmpty())
{
IsManualAdjustment = false;
}
return; return;
} }
} }
@ -249,7 +254,7 @@ void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object ^ sender,
{ {
// Ask the OS to start a share action. // Ask the OS to start a share action.
DataTransferManager::ShowShareUI(); DataTransferManager::ShowShareUI();
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::Share); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::Share, GraphButtonValue::None);
} }
// When share is invoked (by the user or programmatically) the event handler we registered will be called to populate the data package with the // When share is invoked (by the user or programmatically) the event handler we registered will be called to populate the data package with the
@ -381,19 +386,13 @@ void GraphingCalculator::OnVariableChanged(Platform::Object ^ sender, VariableCh
void GraphingCalculator::OnZoomInCommand(Object ^ /* parameter */) void GraphingCalculator::OnZoomInCommand(Object ^ /* parameter */)
{ {
GraphingControl->ZoomFromCenter(zoomInScale); GraphingControl->ZoomFromCenter(zoomInScale);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomIn); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomIn, GraphButtonValue::None);
} }
void GraphingCalculator::OnZoomOutCommand(Object ^ /* parameter */) void GraphingCalculator::OnZoomOutCommand(Object ^ /* parameter */)
{ {
GraphingControl->ZoomFromCenter(zoomOutScale); GraphingControl->ZoomFromCenter(zoomOutScale);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomOut); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomOut, GraphButtonValue::None);
}
void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
{
GraphingControl->ResetGrid();
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomReset);
} }
String ^ GraphingCalculator::GetTracingLegend(Platform::IBox<bool> ^ isTracing) String ^ GraphingCalculator::GetTracingLegend(Platform::IBox<bool> ^ isTracing)
@ -558,7 +557,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
KeyboardShortcutManager::IgnoreEscape(false); KeyboardShortcutManager::IgnoreEscape(false);
TracePointer->Visibility = ::Visibility::Visible; TracePointer->Visibility = ::Visibility::Visible;
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingChecked); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingChecked, GraphButtonValue::None);
} }
void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
@ -577,7 +576,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object
KeyboardShortcutManager::HonorEscape(); KeyboardShortcutManager::HonorEscape();
TracePointer->Visibility = ::Visibility::Collapsed; TracePointer->Visibility = ::Visibility::Collapsed;
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingUnchecked); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingUnchecked, GraphButtonValue::None);
} }
void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args) void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
@ -592,7 +591,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::C
void GraphingCalculator::GraphSettingsButton_Click(Object ^ sender, RoutedEventArgs ^ e) void GraphingCalculator::GraphSettingsButton_Click(Object ^ sender, RoutedEventArgs ^ e)
{ {
DisplayGraphSettings(); DisplayGraphSettings();
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphSettings); TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphSettings, GraphButtonValue::None);
} }
void GraphingCalculator::DisplayGraphSettings() void GraphingCalculator::DisplayGraphSettings()
@ -675,8 +674,17 @@ void GraphingCalculator::SetDefaultFocus()
} }
} }
void GraphingCalculator::GraphingControl_GraphViewChangedEvent(Object ^ sender, RoutedEventArgs ^ e) void GraphingCalculator::GraphingControl_GraphViewChangedEvent(Object ^ sender, GraphViewChangedReason reason)
{ {
if (reason == GraphViewChangedReason::Manipulation)
{
IsManualAdjustment = true;
}
else
{
IsManualAdjustment = false;
}
UpdateGraphAutomationName(); UpdateGraphAutomationName();
auto announcement = CalculatorAnnouncement::GetGraphViewChangedAnnouncement(GraphControlAutomationName); auto announcement = CalculatorAnnouncement::GetGraphViewChangedAnnouncement(GraphControlAutomationName);
@ -779,3 +787,23 @@ void GraphingCalculator::OnGraphThemeSettingChanged(Object ^ sender, bool isMatc
} }
})); }));
} }
void GraphingCalculator::GraphViewButton_Click(Object ^ sender, RoutedEventArgs ^ e)
{
auto narratorNotifier = ref new NarratorNotifier();
String ^ announcementText;
if (IsManualAdjustment)
{
announcementText = AppResourceProvider::GetInstance()->GetResourceString(L"GraphViewManualAdjustmentAnnouncement");
}
else
{
GraphingControl->ResetGrid();
announcementText = AppResourceProvider::GetInstance()->GetResourceString(L"GraphViewAutomaticBestFitAnnouncement");
}
auto announcement = CalculatorAnnouncement::GetGraphViewBestFitChangedAnnouncement(announcementText);
narratorNotifier->Announce(announcement);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphView, IsManualAdjustment ? GraphButtonValue::ManualAdjustment : GraphButtonValue::AutomaticBestFit);
}

View File

@ -25,11 +25,11 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
DEPENDENCY_PROPERTY_OWNER(GraphingCalculator); DEPENDENCY_PROPERTY_OWNER(GraphingCalculator);
COMMAND_FOR_METHOD(ZoomOutButtonPressed, GraphingCalculator::OnZoomOutCommand); COMMAND_FOR_METHOD(ZoomOutButtonPressed, GraphingCalculator::OnZoomOutCommand);
COMMAND_FOR_METHOD(ZoomInButtonPressed, GraphingCalculator::OnZoomInCommand); COMMAND_FOR_METHOD(ZoomInButtonPressed, GraphingCalculator::OnZoomInCommand);
COMMAND_FOR_METHOD(ZoomResetButtonPressed, GraphingCalculator::OnZoomResetCommand);
OBSERVABLE_PROPERTY_R(bool, IsKeyGraphFeaturesVisible); OBSERVABLE_PROPERTY_R(bool, IsKeyGraphFeaturesVisible);
DEPENDENCY_PROPERTY(bool, IsSmallState); DEPENDENCY_PROPERTY(bool, IsSmallState);
DEPENDENCY_PROPERTY(Platform::String ^, GraphControlAutomationName); DEPENDENCY_PROPERTY(Platform::String ^, GraphControlAutomationName);
OBSERVABLE_PROPERTY_R(bool, IsMatchAppTheme); OBSERVABLE_PROPERTY_R(bool, IsMatchAppTheme);
OBSERVABLE_PROPERTY_RW(bool, IsManualAdjustment);
property CalculatorApp::ViewModel::GraphingCalculatorViewModel^ ViewModel property CalculatorApp::ViewModel::GraphingCalculatorViewModel^ ViewModel
{ {
@ -53,7 +53,6 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void OnZoomInCommand(Object ^ parameter); void OnZoomInCommand(Object ^ parameter);
void OnZoomOutCommand(Object ^ parameter); void OnZoomOutCommand(Object ^ parameter);
void OnZoomResetCommand(Object ^ parameter);
void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
@ -68,7 +67,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void GraphingControl_LostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void GraphingControl_LostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void GraphingControl_LosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args); void GraphingControl_LosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
void GraphingControl_VariablesUpdated(Platform::Object ^ sender, Object ^ args); void GraphingControl_VariablesUpdated(Platform::Object ^ sender, Object ^ args);
void GraphingControl_GraphViewChangedEvent(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void GraphingControl_GraphViewChangedEvent(Platform::Object ^ sender, GraphControl::GraphViewChangedReason reason);
void GraphingControl_GraphPlottedEvent(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void GraphingControl_GraphPlottedEvent(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnEquationKeyGraphFeaturesRequested(Platform::Object ^ sender, CalculatorApp::ViewModel::EquationViewModel ^ e); void OnEquationKeyGraphFeaturesRequested(Platform::Object ^ sender, CalculatorApp::ViewModel::EquationViewModel ^ e);
void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
@ -105,6 +104,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e); void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e); void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
void GraphViewButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
}; };
} }

View File

@ -1282,7 +1282,7 @@
AutomationProperties.AutomationId="negateButton" AutomationProperties.AutomationId="negateButton"
ButtonId="Negate" ButtonId="Negate"
Click="Button_Clicked" Click="Button_Clicked"
Content="&#xF898;" Content="&#xE3B5;"
IsTabStop="false"/> IsTabStop="false"/>
<controls:CalculatorButton x:Name="Num0Button" <controls:CalculatorButton x:Name="Num0Button"

View File

@ -37,6 +37,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, AxesColor);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GraphBackground); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GraphBackground);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GridLinesColor); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GridLinesColor);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, LineWidth); DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, LineWidth);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, IsKeepCurrentView);
namespace namespace
{ {
@ -87,7 +88,7 @@ namespace GraphControl
void Grapher::ZoomFromCenter(double scale) void Grapher::ZoomFromCenter(double scale)
{ {
ScaleRange(0, 0, scale); ScaleRange(0, 0, scale);
GraphViewChangedEvent(this, ref new RoutedEventArgs()); GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
} }
void Grapher::ScaleRange(double centerX, double centerY, double scale) void Grapher::ScaleRange(double centerX, double centerY, double scale)
@ -103,7 +104,7 @@ namespace GraphControl
m_renderMain->GetCriticalSection().unlock(); m_renderMain->GetCriticalSection().unlock();
m_renderMain->RunRenderPass(); m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, ref new RoutedEventArgs()); GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
} }
else else
{ {
@ -122,7 +123,7 @@ namespace GraphControl
if (SUCCEEDED(renderer->ResetRange())) if (SUCCEEDED(renderer->ResetRange()))
{ {
m_renderMain->RunRenderPass(); m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, ref new RoutedEventArgs()); GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
} }
} }
} }
@ -207,7 +208,6 @@ namespace GraphControl
{ {
return; return;
} }
bool keepCurrentView = true; bool keepCurrentView = true;
// If the equation has changed, the IsLineEnabled state is reset. // If the equation has changed, the IsLineEnabled state is reset.
@ -254,7 +254,7 @@ namespace GraphControl
void Grapher::PlotGraph(bool keepCurrentView) void Grapher::PlotGraph(bool keepCurrentView)
{ {
TryPlotGraph(keepCurrentView, false); TryPlotGraph(keepCurrentView,false);
} }
task<void> Grapher::TryPlotGraph(bool keepCurrentView, bool shouldRetry) task<void> Grapher::TryPlotGraph(bool keepCurrentView, bool shouldRetry)
@ -405,7 +405,7 @@ namespace GraphControl
// Do not re-initialize the graph to empty if there are still valid equations graphed // Do not re-initialize the graph to empty if there are still valid equations graphed
if (!shouldKeepPreviousGraph) if (!shouldKeepPreviousGraph)
{ {
initResult = m_graph->TryInitialize(); initResult = TryInitializeGraph(false, nullptr);
if (initResult != nullopt) if (initResult != nullopt)
{ {
UpdateGraphOptions(m_graph->GetOptions(), vector<Equation ^>()); UpdateGraphOptions(m_graph->GetOptions(), vector<Equation ^>());
@ -711,7 +711,7 @@ namespace GraphControl
const auto [centerX, centerY] = PointerPositionToGraphPosition(pos.X, pos.Y, ActualWidth, ActualHeight); const auto [centerX, centerY] = PointerPositionToGraphPosition(pos.X, pos.Y, ActualWidth, ActualHeight);
ScaleRange(centerX, centerY, scale); ScaleRange(centerX, centerY, scale);
GraphViewChangedEvent(this, ref new RoutedEventArgs()); GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
e->Handled = true; e->Handled = true;
} }
@ -793,7 +793,7 @@ namespace GraphControl
if (needsRenderPass) if (needsRenderPass)
{ {
m_renderMain->RunRenderPass(); m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, ref new RoutedEventArgs()); GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
} }
} }
} }
@ -1086,7 +1086,7 @@ void Grapher::OnLineWidthPropertyChanged(double oldValue, double newValue)
optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bool keepCurrentView, const IExpression* graphingExp) optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bool keepCurrentView, const IExpression* graphingExp)
{ {
if (keepCurrentView) if (keepCurrentView || IsKeepCurrentView)
{ {
double xMin, xMax, yMin, yMax; double xMin, xMax, yMin, yMax;
m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax); m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax);

View File

@ -25,6 +25,12 @@ public
public public
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value); delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);
public enum class GraphViewChangedReason
{
Manipulation,
Reset
};
[Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed [Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed
: public Windows::UI::Xaml::Controls::Control, : public Windows::UI::Xaml::Controls::Control,
public Windows::UI::Xaml::Data::INotifyPropertyChanged public Windows::UI::Xaml::Data::INotifyPropertyChanged
@ -33,7 +39,7 @@ public
event TracingValueChangedEventHandler ^ TracingValueChangedEvent; event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
event PointerValueChangedEventHandler ^ PointerValueChangedEvent; event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
event TracingChangedEventHandler ^ TracingChangedEvent; event TracingChangedEventHandler ^ TracingChangedEvent;
event Windows::UI::Xaml::RoutedEventHandler ^ GraphViewChangedEvent; event Windows::Foundation::EventHandler<GraphViewChangedReason> ^ GraphViewChangedEvent;
event Windows::UI::Xaml::RoutedEventHandler ^ GraphPlottedEvent; event Windows::UI::Xaml::RoutedEventHandler ^ GraphPlottedEvent;
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged; virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
@ -51,8 +57,9 @@ public
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, AxesColor, Windows::UI::Colors::Transparent); DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, AxesColor, Windows::UI::Colors::Transparent);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GraphBackground, Windows::UI::Colors::Transparent); DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GraphBackground, Windows::UI::Colors::Transparent);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GridLinesColor, Windows::UI::Colors::Transparent); DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GridLinesColor, Windows::UI::Colors::Transparent);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, LineWidth, 2.0); DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, LineWidth, 2.0);
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsKeepCurrentView, false);
// Pass active tracing turned on or off down to the renderer // Pass active tracing turned on or off down to the renderer
property bool ActiveTracing property bool ActiveTracing
{ {
@ -249,6 +256,7 @@ public
if (m_renderMain) if (m_renderMain)
{ {
m_renderMain->RunRenderPass(); m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
} }
} }
} }
@ -304,6 +312,7 @@ public
void SetEquationErrors(); void SetEquationErrors();
std::optional<std::vector<std::shared_ptr<Graphing::IEquation>>> TryInitializeGraph(bool keepCurrentView, _In_ const Graphing::IExpression* graphingExp = nullptr); std::optional<std::vector<std::shared_ptr<Graphing::IEquation>>> TryInitializeGraph(bool keepCurrentView, _In_ const Graphing::IExpression* graphingExp = nullptr);
private: private:
DX::RenderMain ^ m_renderMain = nullptr; DX::RenderMain ^ m_renderMain = nullptr;