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 GraphViewChanged(L"GraphViewChanged");
StringReference FunctionRemoved(L"FunctionRemoved");
StringReference GraphViewBestFitChanged(L"GraphViewBestFitChanged");
}
}
@ -170,3 +171,12 @@ NarratorAnnouncement ^ CalculatorAnnouncement::GetFunctionRemovedAnnouncement(St
AutomationNotificationKind::ItemRemoved,
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 ^ GetGraphViewChangedAnnouncement(Platform::String ^ announcement);
static NarratorAnnouncement ^ GetGraphViewBestFitChangedAnnouncement(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);
}
void TraceLogger::LogGraphButtonClicked(GraphButton buttonName)
void TraceLogger::LogGraphButtonClicked(GraphButton buttonName, GraphButtonValue buttonValue)
{
auto fields = ref new LoggingFields();
fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE));
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);
}

View File

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

View File

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

Binary file not shown.

View File

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

View File

@ -3867,17 +3867,25 @@
<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>
</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>
<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 name="zoomResetButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Reset View (Ctrl + 0)</value>
<comment>This is the tool tip automation name for the Calculator zoom reset button.</comment>
<data name="graphViewButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Refresh view automatically (Ctrl + 0)</value>
<comment>This is the tool tip automation name for the Calculator graph view button.</comment>
</data>
<data name="zoomResetButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Reset View</value>
<comment>Screen reader prompt for the reset zoom button.</comment>
<data name="graphViewButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Graph View</value>
<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 name="zoomInButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Zoom In (Ctrl + plus)</value>

View File

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

View File

@ -286,6 +286,79 @@
</Setter.Value>
</Setter>
</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 -->
<Color x:Key="LightThemeAxisColor">#000000</Color>
@ -296,6 +369,7 @@
<Color x:Key="DarkThemeGridLinesColor">#4F4F4F</Color>
<converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/>
<converters:BooleanNegationConverter x:Name="BooleanNegationConverter"/>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
@ -323,7 +397,11 @@
TargetType="ToggleButton">
<Setter Property="Foreground" Value="#FFFFFF"/>
</Style>
<Style x:Key="ThemedGraphViewToggleButtonStyle"
BasedOn="{StaticResource GraphViewToggleButtonStyle}"
TargetType="ToggleButton">
<Setter Property="Foreground" Value="#FFFFFF"/>
</Style>
<Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="BorderBrush" Value="#e0e0e0"/>
<Setter Property="BorderThickness" Value="1"/>
@ -356,6 +434,9 @@
<Style x:Key="ThemedGraphToggleButtonStyle"
BasedOn="{StaticResource GraphToggleButtonStyle}"
TargetType="ToggleButton"/>
<Style x:Key="ThemedGraphViewToggleButtonStyle"
BasedOn="{StaticResource GraphViewToggleButtonStyle}"
TargetType="ToggleButton"/>
<Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="Background" Value="{ThemeResource SystemControlAcrylicElementBrush}"/>
<Setter Property="BorderBrush" Value="#e0e0e0"/>
@ -381,6 +462,9 @@
<Style x:Key="ThemedGraphToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Margin" Value="1"/>
</Style>
<Style x:Key="ThemedGraphViewToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Margin" Value="1"/>
</Style>
<Style x:Key="GraphTooltipStyle" TargetType="Border">
<Setter Property="BorderBrush" Value="{ThemeResource ToolTipBorderBrush}"/>
<Setter Property="BorderThickness" Value="{ThemeResource ToolTipBorderThemeThickness}"/>
@ -504,6 +588,7 @@
ForceProportionalAxes="False"
GraphPlottedEvent="GraphingControl_GraphPlottedEvent"
GraphViewChangedEvent="GraphingControl_GraphViewChangedEvent"
IsKeepCurrentView="{x:Bind IsManualAdjustment, Mode=TwoWay}"
LosingFocus="GraphingControl_LosingFocus"
LostFocus="GraphingControl_LostFocus"
RequestedTheme="Light"
@ -613,19 +698,30 @@
</RepeatButton.KeyboardAccelerators>
</RepeatButton>
<Button x:Uid="zoomResetButton"
<ToggleButton x:Uid="graphViewButton"
MinHeight="40"
Style="{ThemeResource ThemedGraphButtonStyle}"
MinWidth="40"
Style="{ThemeResource ThemedGraphViewToggleButtonStyle}"
contract7Present:CornerRadius="{ThemeResource BottomButtonCornerRadius}"
AutomationProperties.AutomationId="zoomResetButton"
Command="{x:Bind ZoomResetButtonPressed, Mode=OneTime}">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}"
AutomationProperties.AutomationId="graphViewButton"
Click="GraphViewButton_Click"
IsChecked="{x:Bind IsManualAdjustment, Mode=TwoWay}">
<ToggleButton.Content>
<Grid>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
FontSize="14"
Glyph="&#xE895;"/>
<Button.KeyboardAccelerators>
Glyph="&#xE45E;"/>
<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"/>
</Button.KeyboardAccelerators>
</Button>
</ToggleButton.KeyboardAccelerators>
</ToggleButton>
</StackPanel>
</Border>
<Border x:Name="TraceValuePopup"

View File

@ -174,6 +174,11 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
{
GraphingControl->Equations->RemoveAt(event->Index);
if (GraphingControl->Equations->Size == 1 && GraphingControl->Equations->GetAt(0)->Expression->IsEmpty())
{
IsManualAdjustment = false;
}
return;
}
}
@ -249,7 +254,7 @@ void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object ^ sender,
{
// Ask the OS to start a share action.
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
@ -381,19 +386,13 @@ void GraphingCalculator::OnVariableChanged(Platform::Object ^ sender, VariableCh
void GraphingCalculator::OnZoomInCommand(Object ^ /* parameter */)
{
GraphingControl->ZoomFromCenter(zoomInScale);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomIn);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomIn, GraphButtonValue::None);
}
void GraphingCalculator::OnZoomOutCommand(Object ^ /* parameter */)
{
GraphingControl->ZoomFromCenter(zoomOutScale);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomOut);
}
void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
{
GraphingControl->ResetGrid();
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomReset);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomOut, GraphButtonValue::None);
}
String ^ GraphingCalculator::GetTracingLegend(Platform::IBox<bool> ^ isTracing)
@ -558,7 +557,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
KeyboardShortcutManager::IgnoreEscape(false);
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)
@ -577,7 +576,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object
KeyboardShortcutManager::HonorEscape();
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)
@ -592,7 +591,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::C
void GraphingCalculator::GraphSettingsButton_Click(Object ^ sender, RoutedEventArgs ^ e)
{
DisplayGraphSettings();
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphSettings);
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphSettings, GraphButtonValue::None);
}
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();
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);
COMMAND_FOR_METHOD(ZoomOutButtonPressed, GraphingCalculator::OnZoomOutCommand);
COMMAND_FOR_METHOD(ZoomInButtonPressed, GraphingCalculator::OnZoomInCommand);
COMMAND_FOR_METHOD(ZoomResetButtonPressed, GraphingCalculator::OnZoomResetCommand);
OBSERVABLE_PROPERTY_R(bool, IsKeyGraphFeaturesVisible);
DEPENDENCY_PROPERTY(bool, IsSmallState);
DEPENDENCY_PROPERTY(Platform::String ^, GraphControlAutomationName);
OBSERVABLE_PROPERTY_R(bool, IsMatchAppTheme);
OBSERVABLE_PROPERTY_RW(bool, IsManualAdjustment);
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 OnZoomOutCommand(Object ^ parameter);
void OnZoomResetCommand(Object ^ parameter);
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_LosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ 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 OnEquationKeyGraphFeaturesRequested(Platform::Object ^ sender, CalculatorApp::ViewModel::EquationViewModel ^ 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 GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ 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"
ButtonId="Negate"
Click="Button_Clicked"
Content="&#xF898;"
Content="&#xE3B5;"
IsTabStop="false"/>
<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, GridLinesColor);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, LineWidth);
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, IsKeepCurrentView);
namespace
{
@ -87,7 +88,7 @@ namespace GraphControl
void Grapher::ZoomFromCenter(double scale)
{
ScaleRange(0, 0, scale);
GraphViewChangedEvent(this, ref new RoutedEventArgs());
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
}
void Grapher::ScaleRange(double centerX, double centerY, double scale)
@ -103,7 +104,7 @@ namespace GraphControl
m_renderMain->GetCriticalSection().unlock();
m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, ref new RoutedEventArgs());
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
}
else
{
@ -122,7 +123,7 @@ namespace GraphControl
if (SUCCEEDED(renderer->ResetRange()))
{
m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, ref new RoutedEventArgs());
GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
}
}
}
@ -207,7 +208,6 @@ namespace GraphControl
{
return;
}
bool keepCurrentView = true;
// If the equation has changed, the IsLineEnabled state is reset.
@ -254,7 +254,7 @@ namespace GraphControl
void Grapher::PlotGraph(bool keepCurrentView)
{
TryPlotGraph(keepCurrentView, false);
TryPlotGraph(keepCurrentView,false);
}
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
if (!shouldKeepPreviousGraph)
{
initResult = m_graph->TryInitialize();
initResult = TryInitializeGraph(false, nullptr);
if (initResult != nullopt)
{
UpdateGraphOptions(m_graph->GetOptions(), vector<Equation ^>());
@ -711,7 +711,7 @@ namespace GraphControl
const auto [centerX, centerY] = PointerPositionToGraphPosition(pos.X, pos.Y, ActualWidth, ActualHeight);
ScaleRange(centerX, centerY, scale);
GraphViewChangedEvent(this, ref new RoutedEventArgs());
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
e->Handled = true;
}
@ -793,7 +793,7 @@ namespace GraphControl
if (needsRenderPass)
{
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)
{
if (keepCurrentView)
if (keepCurrentView || IsKeepCurrentView)
{
double xMin, xMax, yMin, yMax;
m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax);

View File

@ -25,6 +25,12 @@ public
public
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
: public Windows::UI::Xaml::Controls::Control,
public Windows::UI::Xaml::Data::INotifyPropertyChanged
@ -33,7 +39,7 @@ public
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
event TracingChangedEventHandler ^ TracingChangedEvent;
event Windows::UI::Xaml::RoutedEventHandler ^ GraphViewChangedEvent;
event Windows::Foundation::EventHandler<GraphViewChangedReason> ^ GraphViewChangedEvent;
event Windows::UI::Xaml::RoutedEventHandler ^ GraphPlottedEvent;
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, 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(double, LineWidth, 2.0);
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsKeepCurrentView, false);
// Pass active tracing turned on or off down to the renderer
property bool ActiveTracing
{
@ -249,6 +256,7 @@ public
if (m_renderMain)
{
m_renderMain->RunRenderPass();
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
}
}
}
@ -304,6 +312,7 @@ public
void SetEquationErrors();
std::optional<std::vector<std::shared_ptr<Graphing::IEquation>>> TryInitializeGraph(bool keepCurrentView, _In_ const Graphing::IExpression* graphingExp = nullptr);
private:
DX::RenderMain ^ m_renderMain = nullptr;