Allow copying graph as image (#1051)

This commit is contained in:
Pepe Rivera 2020-03-04 16:25:50 -08:00 committed by GitHub
parent f1d53fba61
commit de3a1cdff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 15 deletions

View File

@ -3948,7 +3948,7 @@
<comment>Label for the Line Color section of the style picker</comment>
</data>
<data name="KeyGraphFeaturesLabel.Text" xml:space="preserve">
<value>Key Graph Features</value>
<value>Function analysis</value>
<comment>Title for KeyGraphFeatures Control</comment>
</data>
<data name="KGFHorizontalAsymptotesNone" xml:space="preserve">
@ -4115,16 +4115,16 @@
<comment>This is the automation name for the back button in the equation analysis page in the graphing calculator</comment>
</data>
<data name="functionAnalysisButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Analyze equation</value>
<comment>This is the tooltip for the analyze equation button</comment>
<value>Analyze function</value>
<comment>This is the tooltip for the analyze function button</comment>
</data>
<data name="functionAnalysisButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Analyze equation</value>
<comment>This is the automation name for the analyze equation button</comment>
<value>Analyze function</value>
<comment>This is the automation name for the analyze function button</comment>
</data>
<data name="functionAnalysisMenuItem" xml:space="preserve">
<value>Analyze equation</value>
<comment>This is the text for the for the analyze equation context menu command</comment>
<value>Analyze function</value>
<comment>This is the text for the for the analyze function context menu command</comment>
</data>
<data name="removeButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Remove equation</value>
@ -4203,8 +4203,8 @@
<comment>Announcement used in Graphing Calculator when switching to the graph mode</comment>
</data>
<data name="GridHeading.Text" xml:space="preserve">
<value>Grid</value>
<comment>Heading for grid extents on the settings </comment>
<value>Window</value>
<comment>Heading for window extents on the settings </comment>
</data>
<data name="TrigModeDegrees.Content" xml:space="preserve">
<value>Degrees</value>
@ -4238,10 +4238,6 @@
<value>Y-Min</value>
<comment>Y minimum value header</comment>
</data>
<data name="equationMathRichEditBox.PlaceholderText" xml:space="preserve">
<value>Enter an equation</value>
<comment>Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox</comment>
</data>
<data name="graphSettingsButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>Grid options</value>
<comment>This is the tooltip text for the grid options button in Graphing Calculator</comment>
@ -4255,7 +4251,11 @@
<comment>Heading for the Graph Options flyout in Graphing mode.</comment>
</data>
<data name="mathRichEditBox.PlaceholderText" xml:space="preserve">
<value>Enter an equation</value>
<value>Enter an expression</value>
<comment>this is the placeholder text used by the textbox to enter an equation</comment>
</data>
<data name="GraphCopyMenuItem.Text">
<value>Copy</value>
<comment>Copy menu item for the graph context menu</comment>
</data>
</root>

View File

@ -476,7 +476,15 @@
LostFocus="GraphingControl_LostFocus"
RequestedTheme="Light"
UseSystemFocusVisuals="True"
VariablesUpdated="GraphingControl_VariablesUpdated"/>
VariablesUpdated="GraphingControl_VariablesUpdated">
<graphControl:Grapher.ContextFlyout>
<MenuFlyout Placement="Bottom">
<MenuFlyoutItem x:Uid="GraphCopyMenuItem"
Click="GraphMenuFlyoutItem_Click"
Icon="Copy"/>
</MenuFlyout>
</graphControl:Grapher.ContextFlyout>
</graphControl:Grapher>
<Border MinHeight="36"
Margin="0,12,12,0"
HorizontalAlignment="Right"

View File

@ -619,3 +619,13 @@ void GraphingCalculator::SetDefaultFocus()
EquationInputAreaControl->Focus(::FocusState::Programmatic);
}
}
void GraphingCalculator::GraphMenuFlyoutItem_Click(Object ^ sender, RoutedEventArgs ^ e)
{
auto dataPackage = ref new DataPackage();
dataPackage->RequestedOperation = ::DataPackageOperation::Copy;
auto bitmapStream = GraphingControl->GetGraphBitmapStream();
dataPackage->SetBitmap(bitmapStream);
::Clipboard::SetContent(dataPackage);
}

View File

@ -91,6 +91,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void Canvas_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
};
}