From de3a1cdff7e3a2cb2e130cd41660450042c0eb3b Mon Sep 17 00:00:00 2001 From: Pepe Rivera Date: Wed, 4 Mar 2020 16:25:50 -0800 Subject: [PATCH] Allow copying graph as image (#1051) --- src/Calculator/Resources/en-US/Resources.resw | 28 +++++++++---------- .../GraphingCalculator.xaml | 10 ++++++- .../GraphingCalculator.xaml.cpp | 10 +++++++ .../GraphingCalculator.xaml.h | 1 + 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index e6a3580..abeb7b7 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -3948,7 +3948,7 @@ Label for the Line Color section of the style picker - Key Graph Features + Function analysis Title for KeyGraphFeatures Control @@ -4115,16 +4115,16 @@ This is the automation name for the back button in the equation analysis page in the graphing calculator - Analyze equation - This is the tooltip for the analyze equation button + Analyze function + This is the tooltip for the analyze function button - Analyze equation - This is the automation name for the analyze equation button + Analyze function + This is the automation name for the analyze function button - Analyze equation - This is the text for the for the analyze equation context menu command + Analyze function + This is the text for the for the analyze function context menu command Remove equation @@ -4203,8 +4203,8 @@ Announcement used in Graphing Calculator when switching to the graph mode - Grid - Heading for grid extents on the settings + Window + Heading for window extents on the settings Degrees @@ -4238,10 +4238,6 @@ Y-Min Y minimum value header - - Enter an equation - Used in the Graphing Calculator to indicate to users that they can enter an equation in the textbox - Grid options This is the tooltip text for the grid options button in Graphing Calculator @@ -4255,7 +4251,11 @@ Heading for the Graph Options flyout in Graphing mode. - Enter an equation + Enter an expression this is the placeholder text used by the textbox to enter an equation + + Copy + Copy menu item for the graph context menu + diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml index bf6fea2..612324d 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml @@ -476,7 +476,15 @@ LostFocus="GraphingControl_LostFocus" RequestedTheme="Light" UseSystemFocusVisuals="True" - VariablesUpdated="GraphingControl_VariablesUpdated"/> + VariablesUpdated="GraphingControl_VariablesUpdated"> + + + + + + 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); +} diff --git a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h index 2960daa..66b79ee 100644 --- a/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h +++ b/src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h @@ -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); }; }