mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
Update share output (#782)
* fix share bugs * PR feedback * PR feedback and merge fix * Fix spacing and use explicit break * Fix extra space
This commit is contained in:
parent
afc1b2146c
commit
b55659f236
8 changed files with 177 additions and 75 deletions
|
@ -264,6 +264,71 @@ void Utils::TrimBack(wstring& value)
|
||||||
}).base(), value.end());
|
}).base(), value.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String^ Utils::EscapeHtmlSpecialCharacters(String^ originalString, shared_ptr<vector<wchar_t>> specialCharacters)
|
||||||
|
{
|
||||||
|
// Construct a default special characters if not provided.
|
||||||
|
if (specialCharacters == nullptr)
|
||||||
|
{
|
||||||
|
specialCharacters = make_shared<vector<wchar_t>>();
|
||||||
|
specialCharacters->push_back(L'&');
|
||||||
|
specialCharacters->push_back(L'\"');
|
||||||
|
specialCharacters->push_back(L'\'');
|
||||||
|
specialCharacters->push_back(L'<');
|
||||||
|
specialCharacters->push_back(L'>');
|
||||||
|
}
|
||||||
|
|
||||||
|
bool replaceCharacters = false;
|
||||||
|
const wchar_t* pCh;
|
||||||
|
String^ replacementString = nullptr;
|
||||||
|
|
||||||
|
// First step is scanning the string for special characters.
|
||||||
|
// If there isn't any special character, we simply return the original string
|
||||||
|
for (pCh = originalString->Data(); *pCh; pCh++)
|
||||||
|
{
|
||||||
|
if (std::find(specialCharacters->begin(), specialCharacters->end(), *pCh) != specialCharacters->end())
|
||||||
|
{
|
||||||
|
replaceCharacters = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (replaceCharacters)
|
||||||
|
{
|
||||||
|
// If we indeed find a special character, we step back one character (the special
|
||||||
|
// character), and we create a new string where we replace those characters one by one
|
||||||
|
pCh--;
|
||||||
|
wstringstream buffer;
|
||||||
|
buffer << wstring(originalString->Data(), pCh);
|
||||||
|
|
||||||
|
for (; *pCh; pCh++)
|
||||||
|
{
|
||||||
|
switch (*pCh)
|
||||||
|
{
|
||||||
|
case L'&':
|
||||||
|
buffer << L"&";
|
||||||
|
break;
|
||||||
|
case L'\"':
|
||||||
|
buffer << L""";
|
||||||
|
break;
|
||||||
|
case L'\'':
|
||||||
|
buffer << L"'";
|
||||||
|
break;
|
||||||
|
case L'<':
|
||||||
|
buffer << L"<";
|
||||||
|
break;
|
||||||
|
case L'>':
|
||||||
|
buffer << L">";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buffer << *pCh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replacementString = ref new String(buffer.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return replaceCharacters ? replacementString : originalString;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(const Color& color1, const Color& color2)
|
bool operator==(const Color& color1, const Color& color2)
|
||||||
{
|
{
|
||||||
return equal_to<Color>()(color1, color2);
|
return equal_to<Color>()(color1, color2);
|
||||||
|
|
|
@ -430,6 +430,7 @@ namespace Utils
|
||||||
void TrimFront(std::wstring& value);
|
void TrimFront(std::wstring& value);
|
||||||
void TrimBack(std::wstring& value);
|
void TrimBack(std::wstring& value);
|
||||||
|
|
||||||
|
Platform::String ^ EscapeHtmlSpecialCharacters(Platform::String ^ originalString, std::shared_ptr<std::vector<wchar_t>> specialCharacters = nullptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3507,9 +3507,17 @@
|
||||||
<value>Look what I graphed.</value>
|
<value>Look what I graphed.</value>
|
||||||
<comment>Sent as part of the shared content. The title for the share.</comment>
|
<comment>Sent as part of the shared content. The title for the share.</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="EmptyEquationString" xml:space="preserve">
|
<data name="EquationsShareHeader" xml:space="preserve">
|
||||||
<value>Empty graph equation</value>
|
<value>Equations:</value>
|
||||||
<comment>When sharing and one of the equations has no content this will be shown in the graph key for that equation.</comment>
|
<comment>Header that appears over the equations section when sharing</comment>
|
||||||
|
</data>
|
||||||
|
<data name="VariablesShareHeader" xml:space="preserve">
|
||||||
|
<value>Variables:</value>
|
||||||
|
<comment>Header that appears over the variables section when sharing</comment>
|
||||||
|
</data>
|
||||||
|
<data name="GraphImageAltText" xml:space="preserve">
|
||||||
|
<value>Image of a graph with equations</value>
|
||||||
|
<comment>Alt text for the graph image when output via Share</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="VaiablesHeader.Text" xml:space="preserve">
|
<data name="VaiablesHeader.Text" xml:space="preserve">
|
||||||
<value>Variables</value>
|
<value>Variables</value>
|
||||||
|
|
|
@ -50,10 +50,10 @@
|
||||||
<graphControl:Grapher Name="GraphingControl"
|
<graphControl:Grapher Name="GraphingControl"
|
||||||
EquationsSource="{x:Bind ViewModel.Equations, Mode=OneWay}"
|
EquationsSource="{x:Bind ViewModel.Equations, Mode=OneWay}"
|
||||||
ForceProportionalAxes="True"
|
ForceProportionalAxes="True"
|
||||||
LosingFocus="OnLoosingFocus"
|
LosingFocus="GraphingControl_LosingFocus"
|
||||||
LostFocus="OnGraphLostFocus"
|
LostFocus="GraphingControl_LostFocus"
|
||||||
UseSystemFocusVisuals="True"
|
UseSystemFocusVisuals="True"
|
||||||
VariablesUpdated="GraphVariablesUpdated">
|
VariablesUpdated="GraphingControl_VariablesUpdated">
|
||||||
<graphControl:Grapher.Background>
|
<graphControl:Grapher.Background>
|
||||||
<SolidColorBrush Color="White"/>
|
<SolidColorBrush Color="White"/>
|
||||||
</graphControl:Grapher.Background>
|
</graphControl:Grapher.Background>
|
||||||
|
|
|
@ -2,17 +2,21 @@
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "CalcViewModel/Common/TraceLogger.h"
|
|
||||||
#include "GraphingCalculator.xaml.h"
|
#include "GraphingCalculator.xaml.h"
|
||||||
|
#include "CalcViewModel/Common/TraceLogger.h"
|
||||||
|
#include "CalcViewModel/Common/LocalizationSettings.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
||||||
#include "Controls/CalculationResult.h"
|
#include "Controls/CalculationResult.h"
|
||||||
#include "Calculator\Controls\EquationTextBox.h"
|
#include "CalcManager/NumberFormattingUtils.h"
|
||||||
#include "Calculator\Views\GraphingCalculator\EquationInputArea.xaml.h"
|
#include "Calculator/Controls/EquationTextBox.h"
|
||||||
|
#include "Calculator/Views/GraphingCalculator/EquationInputArea.xaml.h"
|
||||||
|
#include "CalcViewModel/Common/Utils.h"
|
||||||
|
|
||||||
using namespace CalculatorApp;
|
using namespace CalculatorApp;
|
||||||
using namespace CalculatorApp::Common;
|
using namespace CalculatorApp::Common;
|
||||||
using namespace CalculatorApp::Controls;
|
using namespace CalculatorApp::Controls;
|
||||||
using namespace CalculatorApp::ViewModel;
|
using namespace CalculatorApp::ViewModel;
|
||||||
|
using namespace CalcManager::NumberFormattingUtils;
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
using namespace GraphControl;
|
using namespace GraphControl;
|
||||||
using namespace Platform;
|
using namespace Platform;
|
||||||
|
@ -21,6 +25,7 @@ using namespace std;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace Windows::ApplicationModel::DataTransfer;
|
using namespace Windows::ApplicationModel::DataTransfer;
|
||||||
|
using namespace Windows::ApplicationModel::Resources;
|
||||||
using namespace Windows::Foundation;
|
using namespace Windows::Foundation;
|
||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
using namespace Windows::Storage::Streams;
|
using namespace Windows::Storage::Streams;
|
||||||
|
@ -109,79 +114,94 @@ void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object ^ sender,
|
||||||
// data to be shared. We will request the current graph image from the grapher as a stream that will pass to the share request.
|
// data to be shared. We will request the current graph image from the grapher as a stream that will pass to the share request.
|
||||||
void GraphingCalculator::OnDataRequested(DataTransferManager ^ sender, DataRequestedEventArgs ^ args)
|
void GraphingCalculator::OnDataRequested(DataTransferManager ^ sender, DataRequestedEventArgs ^ args)
|
||||||
{
|
{
|
||||||
auto resourceLoader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
|
auto resourceLoader = ResourceLoader::GetForCurrentView();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get our title from the localized resources
|
std::wstringstream rawHtml;
|
||||||
auto EmptyEquationString = resourceLoader->GetString(L"EmptyEquationString");
|
std::wstringstream equationHtml;
|
||||||
|
|
||||||
std::wstring rawHtml = L"<p><img src='graph.png'></p>";
|
rawHtml << L"<p><img src='graph.png' width='600' alt='" << resourceLoader->GetString(L"GraphImageAltText")->Data() << "'></p>";
|
||||||
|
|
||||||
auto equations = ViewModel->Equations;
|
auto equations = ViewModel->Equations;
|
||||||
rawHtml += L"<p><table cellpadding=\"10\">";
|
bool hasEquations = false;
|
||||||
rawHtml += L"<col width=\"20\">";
|
|
||||||
rawHtml += L"<row height=\"20\">";
|
if (equations->Size > 0)
|
||||||
for (unsigned i = 0; i < equations->Size; i++)
|
|
||||||
{
|
{
|
||||||
auto expression = equations->GetAt(i)->Expression->Data();
|
equationHtml << L"<span style=\"color: rgb(68, 114, 196); font-style: bold; font-size : 13pt;\">";
|
||||||
auto color = equations->GetAt(i)->LineColor->Color;
|
equationHtml << resourceLoader->GetString(L"EquationsShareHeader")->Data();
|
||||||
|
equationHtml << L"</span>";
|
||||||
|
equationHtml << L"<table cellpadding=\"0\">";
|
||||||
|
|
||||||
if (equations->GetAt(i)->Expression->Length() == 0)
|
for (auto equation : equations)
|
||||||
{
|
{
|
||||||
expression = EmptyEquationString->Data();
|
auto expression = equation->Expression;
|
||||||
|
if (expression->IsEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto color = equation->LineColor->Color;
|
||||||
|
hasEquations = true;
|
||||||
|
|
||||||
|
expression = GraphingControl->ConvertToLinear(expression);
|
||||||
|
|
||||||
|
std::wstringstream equationColorHtml;
|
||||||
|
equationColorHtml << L"color:rgb(" << color.R.ToString()->Data() << L"," << color.G.ToString()->Data() << L"," << color.B.ToString()->Data()
|
||||||
|
<< L");";
|
||||||
|
|
||||||
|
equationHtml << L"<tr><td><span style=\"line-height: 0; font-size: 24pt;" << equationColorHtml.str()
|
||||||
|
<< L"\">■</span></td><td><div style=\"margin: 4pt 0pt 0pt 0pt; \">";
|
||||||
|
equationHtml << EscapeHtmlSpecialCharacters(expression)->Data();
|
||||||
|
equationHtml << L"</div></td>";
|
||||||
}
|
}
|
||||||
|
equationHtml << L"</table>";
|
||||||
rawHtml += L"<tr>";
|
}
|
||||||
|
|
||||||
rawHtml += L"<td style=\"background-color:rgb(";
|
if (hasEquations)
|
||||||
rawHtml += color.R.ToString()->Data();
|
{
|
||||||
rawHtml += L",";
|
rawHtml << equationHtml.str();
|
||||||
rawHtml += color.G.ToString()->Data();
|
|
||||||
rawHtml += L",";
|
|
||||||
rawHtml += color.B.ToString()->Data();
|
|
||||||
rawHtml += L"); \">";
|
|
||||||
rawHtml += L"</td>";
|
|
||||||
rawHtml += L"<td>";
|
|
||||||
rawHtml += expression;
|
|
||||||
rawHtml += L"</td>";
|
|
||||||
|
|
||||||
rawHtml += L"</tr>";
|
|
||||||
}
|
}
|
||||||
rawHtml += L"</table></p>";
|
|
||||||
|
|
||||||
auto variables = ViewModel->Variables;
|
auto variables = ViewModel->Variables;
|
||||||
rawHtml += L"<p><table cellpadding=\"10\">";
|
|
||||||
rawHtml += L"<col width=\"20\">";
|
if (variables->Size > 0)
|
||||||
rawHtml += L"<row height=\"20\">";
|
|
||||||
for (unsigned i = 0; i < variables->Size; i++)
|
|
||||||
{
|
{
|
||||||
auto name = variables->GetAt(i)->Name;
|
auto localizedSeperator = LocalizationSettings::GetInstance().GetListSeparator() + L" ";
|
||||||
auto value = variables->GetAt(i)->Value;
|
|
||||||
|
|
||||||
if (name->Length() >= 0)
|
rawHtml << L"<span style=\"color: rgb(68, 114, 196); font-style: bold; font-size: 13pt;\">";
|
||||||
|
rawHtml << resourceLoader->GetString(L"VariablesShareHeader")->Data();
|
||||||
|
rawHtml << L"</span><br><span>";
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < variables->Size; i++)
|
||||||
{
|
{
|
||||||
rawHtml += L"<tr>";
|
auto name = variables->GetAt(i)->Name;
|
||||||
|
auto value = variables->GetAt(i)->Value;
|
||||||
|
|
||||||
rawHtml += L"<td>";
|
rawHtml << name->Data();
|
||||||
rawHtml += name->Data();
|
rawHtml << L"=";
|
||||||
rawHtml += L"</td>";
|
auto formattedValue = to_wstring(value);
|
||||||
rawHtml += L"<td>";
|
TrimTrailingZeros(formattedValue);
|
||||||
rawHtml += std::to_wstring(value);
|
rawHtml << formattedValue;
|
||||||
rawHtml += L"</td>";
|
|
||||||
|
|
||||||
rawHtml += L"</tr>";
|
if (variables->Size - 1 != i)
|
||||||
|
{
|
||||||
|
rawHtml << localizedSeperator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rawHtml << L"</span>";
|
||||||
}
|
}
|
||||||
rawHtml += L"</table></p>";
|
|
||||||
|
rawHtml << L"<br><br>";
|
||||||
|
|
||||||
// Shortcut to the request data
|
// Shortcut to the request data
|
||||||
auto requestData = args->Request->Data;
|
auto requestData = args->Request->Data;
|
||||||
|
|
||||||
DataPackage ^ dataPackage = ref new DataPackage();
|
DataPackage ^ dataPackage = ref new DataPackage();
|
||||||
auto html = HtmlFormatHelper::CreateHtmlFormat(ref new String(rawHtml.c_str()));
|
auto html = HtmlFormatHelper::CreateHtmlFormat(ref new String(rawHtml.str().c_str()));
|
||||||
|
|
||||||
auto titleString = resourceLoader->GetString(L"ShareActionTitle");
|
requestData->Properties->Title = resourceLoader->GetString(L"ShareActionTitle");
|
||||||
requestData->Properties->Title = titleString;
|
|
||||||
|
|
||||||
requestData->SetHtmlFormat(html);
|
requestData->SetHtmlFormat(html);
|
||||||
|
|
||||||
|
@ -191,26 +211,21 @@ void GraphingCalculator::OnDataRequested(DataTransferManager ^ sender, DataReque
|
||||||
|
|
||||||
// Set the thumbnail image (in case the share target can't handle HTML)
|
// Set the thumbnail image (in case the share target can't handle HTML)
|
||||||
requestData->Properties->Thumbnail = bitmapStream;
|
requestData->Properties->Thumbnail = bitmapStream;
|
||||||
|
|
||||||
// And the bitmap (in case the share target can't handle HTML)
|
|
||||||
requestData->SetBitmap(bitmapStream);
|
|
||||||
}
|
}
|
||||||
catch (Exception ^ ex)
|
catch (Exception ^ ex)
|
||||||
{
|
{
|
||||||
TraceLogger::GetInstance().LogPlatformException(ViewMode::Graphing, __FUNCTIONW__, ex);
|
TraceLogger::GetInstance().LogPlatformException(ViewMode::Graphing, __FUNCTIONW__, ex);
|
||||||
|
|
||||||
// Something went wrong, notify the user.
|
// Something went wrong, notify the user.
|
||||||
auto errorTitleString = resourceLoader->GetString(L"ShareActionErrorMessage");
|
|
||||||
auto errorOkString = resourceLoader->GetString(L"ShareActionErrorOk");
|
|
||||||
auto errDialog = ref new Windows::UI::Xaml::Controls::ContentDialog();
|
|
||||||
|
|
||||||
errDialog->Content = errorTitleString;
|
auto errDialog = ref new ContentDialog();
|
||||||
errDialog->CloseButtonText = errorOkString;
|
errDialog->Content = resourceLoader->GetString(L"ShareActionErrorMessage");
|
||||||
|
errDialog->CloseButtonText = resourceLoader->GetString(L"ShareActionErrorOk");
|
||||||
errDialog->ShowAsync();
|
errDialog->ShowAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphingCalculator::GraphVariablesUpdated(Object ^, Object ^)
|
void GraphingCalculator::GraphingControl_VariablesUpdated(Object ^, Object ^)
|
||||||
{
|
{
|
||||||
m_viewModel->UpdateVariables(GraphingControl->Variables);
|
m_viewModel->UpdateVariables(GraphingControl->Variables);
|
||||||
}
|
}
|
||||||
|
@ -287,14 +302,14 @@ void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
|
||||||
GraphingControl->ResetGrid();
|
GraphingControl->ResetGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphingCalculator::OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
void GraphingCalculator::OnActiveTracingClick(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
// The focus change to this button will have turned off the tracing if it was on
|
// The focus change to this button will have turned off the tracing if it was on
|
||||||
ActiveTracingOn = !ActiveTracingOn;
|
ActiveTracingOn = !ActiveTracingOn;
|
||||||
GraphingControl->ActiveTracing = ActiveTracingOn;
|
GraphingControl->ActiveTracing = ActiveTracingOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorApp::GraphingCalculator::OnGraphLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
void GraphingCalculator::GraphingControl_LostFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||||
{
|
{
|
||||||
// If the graph is losing focus while we are in active tracing we need to turn it off so we don't try to eat keys in other controls.
|
// If the graph is losing focus while we are in active tracing we need to turn it off so we don't try to eat keys in other controls.
|
||||||
if (GraphingControl->ActiveTracing)
|
if (GraphingControl->ActiveTracing)
|
||||||
|
@ -304,9 +319,9 @@ void CalculatorApp::GraphingCalculator::OnGraphLostFocus(Platform::Object ^ send
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculatorApp::GraphingCalculator::OnLoosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args)
|
void GraphingCalculator::GraphingControl_LosingFocus(UIElement ^ sender, LosingFocusEventArgs ^ args)
|
||||||
{
|
{
|
||||||
FrameworkElement ^ newFocusElement = (FrameworkElement ^) args->NewFocusedElement;
|
auto newFocusElement = dynamic_cast<FrameworkElement ^>(args->NewFocusedElement);
|
||||||
if (newFocusElement == nullptr || newFocusElement->Name == nullptr)
|
if (newFocusElement == nullptr || newFocusElement->Name == nullptr)
|
||||||
{
|
{
|
||||||
// Because clicking on the swap chain panel will try to move focus to a control that can't actually take focus
|
// Because clicking on the swap chain panel will try to move focus to a control that can't actually take focus
|
||||||
|
|
|
@ -33,7 +33,6 @@ namespace CalculatorApp
|
||||||
private:
|
private:
|
||||||
void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement^ sender, Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
void GraphingCalculator_DataContextChanged(Windows::UI::Xaml::FrameworkElement^ sender, Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
||||||
|
|
||||||
void GraphVariablesUpdated(Platform::Object^ sender, Object^ args);
|
|
||||||
void OnVariableChanged(Platform::Object^ sender, CalculatorApp::ViewModel::VariableChangedEventArgs args);
|
void OnVariableChanged(Platform::Object^ sender, CalculatorApp::ViewModel::VariableChangedEventArgs args);
|
||||||
|
|
||||||
void TextBoxLosingFocus(Windows::UI::Xaml::Controls::TextBox^ textbox, Windows::UI::Xaml::Input::LosingFocusEventArgs^ args);
|
void TextBoxLosingFocus(Windows::UI::Xaml::Controls::TextBox^ textbox, Windows::UI::Xaml::Input::LosingFocusEventArgs^ args);
|
||||||
|
@ -60,8 +59,9 @@ namespace CalculatorApp
|
||||||
|
|
||||||
void TextBoxGotFocus(Windows::UI::Xaml::Controls::TextBox^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
void TextBoxGotFocus(Windows::UI::Xaml::Controls::TextBox^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||||
void OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnGraphLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void GraphingControl_LostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnLoosingFocus(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 OnEquationKeyGraphFeaturesVisibilityChanged(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnEquationKeyGraphFeaturesVisibilityChanged(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnKeyGraphFeaturesClosed(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
bool ActiveTracingOn;
|
bool ActiveTracingOn;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace
|
||||||
|
|
||||||
constexpr auto s_X = L"x";
|
constexpr auto s_X = L"x";
|
||||||
constexpr auto s_Y = L"y";
|
constexpr auto s_Y = L"y";
|
||||||
|
constexpr auto s_defaultFormatType = FormatType::MathML;
|
||||||
constexpr auto s_getGraphOpeningTags = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>show2d</mi><mfenced separators=\"\">";
|
constexpr auto s_getGraphOpeningTags = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>show2d</mi><mfenced separators=\"\">";
|
||||||
constexpr auto s_getGraphClosingTags = L"</mfenced></mrow></math>";
|
constexpr auto s_getGraphClosingTags = L"</mfenced></mrow></math>";
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace GraphControl
|
||||||
, m_graph{ m_solver->CreateGrapher() }
|
, m_graph{ m_solver->CreateGrapher() }
|
||||||
, m_Moving{ false }
|
, m_Moving{ false }
|
||||||
{
|
{
|
||||||
m_solver->ParsingOptions().SetFormatType(FormatType::MathML);
|
m_solver->ParsingOptions().SetFormatType(s_defaultFormatType);
|
||||||
m_solver->FormatOptions().SetFormatType(FormatType::MathML);
|
m_solver->FormatOptions().SetFormatType(FormatType::MathML);
|
||||||
m_solver->FormatOptions().SetMathMLPrefix(wstring(L"mml"));
|
m_solver->FormatOptions().SetMathMLPrefix(wstring(L"mml"));
|
||||||
|
|
||||||
|
@ -1009,3 +1009,15 @@ void Grapher::HandleTracingMovementTick(Object ^ sender, Object ^ e)
|
||||||
ActiveTraceCursorPosition = curPos;
|
ActiveTraceCursorPosition = curPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ^ Grapher::ConvertToLinear(String ^ mmlString)
|
||||||
|
{
|
||||||
|
m_solver->FormatOptions().SetFormatType(FormatType::LinearInput);
|
||||||
|
|
||||||
|
auto expression = m_solver->ParseInput(mmlString->Data());
|
||||||
|
auto linearExpression = m_solver->Serialize(expression.get());
|
||||||
|
|
||||||
|
m_solver->FormatOptions().SetFormatType(s_defaultFormatType);
|
||||||
|
|
||||||
|
return ref new String(linearExpression.c_str());
|
||||||
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ public
|
||||||
|
|
||||||
event Windows::Foundation::EventHandler<Windows::Foundation::Collections::IMap<Platform::String ^, double> ^> ^ VariablesUpdated;
|
event Windows::Foundation::EventHandler<Windows::Foundation::Collections::IMap<Platform::String ^, double> ^> ^ VariablesUpdated;
|
||||||
void SetVariable(Platform::String ^ variableName, double newValue);
|
void SetVariable(Platform::String ^ variableName, double newValue);
|
||||||
|
Platform::String ^ ConvertToLinear(Platform::String ^ mmlString);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#pragma region Control Overrides
|
#pragma region Control Overrides
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue