Key graph features (#704)
* Added IGraphAnalyzer * Key Graph Features called and getting returned to the client. To do put all strings into the Equation object * Updated UpdateKeyGraphFeatures to add function analysis data to all properties in Equation object * Update KGF when variables are updated * Key graph features ui started * Added MathRichEditBox and started hooking up key graph features to the UI * Updated EquationViewModel to include parity and periodicity * Updated key graph features to update the EquationViewModel * updated key graph features to display more values * Key graph features populating uing MathRichEdit mode * moved KeyGraphFeatures control to GraphingCalculator.xaml * Use MathML formatting instead of MathRichEdit for strings passed back from the engine * cleaned up project targeting and equation.h comments * Updated equation edit box to populate for KeyGraphFeatures * Fixed vcxproj files to have the correct targeting and certificates. KGF Title strings moved to x:Uid instead of the code behind * Updated per PR feedback * Update MathRichEditBox to detect if the string is a mathml string and use the appropriate set method to set the text * fixed the issue where parity, periodicity and monotonicity could be set with an old value if the next one is empty * KGF control UI adjustments and error handling * Error control updates * Error handling added when analysis fails * fixed alignment on rich edit boxes * Add monotonicity direction into the mathml string and only have 1 richeditbox * Set hover state on KGF EquationEditBox to change button opacity and fixed spacing in Monotonicity RichEditBox * remove sideload package certificate info VS added * updated logic for setting error strings to be in the viewmodel * Updated KeyGraphFeatures to populate dynamically using a ListView and TemplateSelector * Update periodicity to not show if it isn't supported * Fixed issue where y-intercept was using the x-intercept value * Remove ItemsControl ItemsContainerStyle * Updated per pr feedback. Fixed bug where analysis error would not reset * Update MathRichEdit box to remove selection when focus is lost * Updated mathrichedit to get LAF access for Dev, Release and Graphing projects * Remove OnLostFocus in MathRichEdit, Change KGF ItemsControl back to ListView * Clean up styles for KGF and ensure the match the comps * Moved formatoptions logic to the Grapher constructor and reverted LineColor.Text resource that was mistakenly taken out * Add copyright header to KGF Files * fixed issue where asymptote values were not populating * Disable KGF button when there is no equation. Fixed issue where equation populated in a new equationtextbox after the previous one was deleted * Removed formatoptions testing lines used for debugging
This commit is contained in:
@@ -20,13 +20,12 @@ using namespace Windows::UI::Xaml::Input;
|
||||
using namespace Windows::UI::Xaml::Controls::Primitives;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, EquationColor);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, KeyGraphFeaturesContent);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(EquationTextBox, ColorChooserFlyout);
|
||||
|
||||
void EquationTextBox::OnApplyTemplate()
|
||||
{
|
||||
m_equationButton = dynamic_cast<Button ^>(GetTemplateChild("EquationButton"));
|
||||
m_richEditBox = dynamic_cast<RichEditBox ^>(GetTemplateChild("EquationTextBox"));
|
||||
m_richEditBox = dynamic_cast<MathRichEditBox ^>(GetTemplateChild("EquationTextBox"));
|
||||
m_deleteButton = dynamic_cast<Button ^>(GetTemplateChild("DeleteButton"));
|
||||
m_removeButton = dynamic_cast<Button ^>(GetTemplateChild("RemoveButton"));
|
||||
m_functionButton = dynamic_cast<Button ^>(GetTemplateChild("FunctionButton"));
|
||||
@@ -34,7 +33,6 @@ void EquationTextBox::OnApplyTemplate()
|
||||
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->Loaded += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxLoaded);
|
||||
m_richEditBox->GotFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxGotFocus);
|
||||
m_richEditBox->LostFocus += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxLostFocus);
|
||||
m_richEditBox->TextChanged += ref new RoutedEventHandler(this, &EquationTextBox::OnRichEditBoxTextChanged);
|
||||
@@ -64,6 +62,7 @@ void EquationTextBox::OnApplyTemplate()
|
||||
if (m_functionButton != nullptr)
|
||||
{
|
||||
m_functionButton->Click += ref new RoutedEventHandler(this, &EquationTextBox::OnFunctionButtonClicked);
|
||||
m_functionButton->IsEnabled = false;
|
||||
}
|
||||
|
||||
if (ColorChooserFlyout != nullptr)
|
||||
@@ -104,6 +103,10 @@ void EquationTextBox::OnKeyDown(KeyRoutedEventArgs ^ e)
|
||||
if (e->Key == VirtualKey::Enter)
|
||||
{
|
||||
EquationSubmitted(this, ref new RoutedEventArgs());
|
||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
||||
{
|
||||
m_functionButton->IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +115,10 @@ void EquationTextBox::OnLostFocus(RoutedEventArgs ^ e)
|
||||
if (!m_richEditBox->ContextFlyout->IsOpen)
|
||||
{
|
||||
EquationSubmitted(this, ref new RoutedEventArgs());
|
||||
if (m_functionButton && m_richEditBox->MathText != L"")
|
||||
{
|
||||
m_functionButton->IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,15 +135,6 @@ void EquationTextBox::OnColorFlyoutClosed(Object ^ sender, Object ^ e)
|
||||
UpdateCommonVisualState();
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRichEditBoxLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
LimitedAccessFeatures::TryUnlockFeature(
|
||||
"com.microsoft.windows.richeditmath",
|
||||
"H6wflFFz3gkOsAHtG/D9Tg==",
|
||||
"8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.");
|
||||
m_richEditBox->TextDocument->SetMathMode(::RichEditMathMode::MathOnly);
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRichEditBoxTextChanged(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UpdateDeleteButtonVisualState();
|
||||
@@ -163,17 +161,32 @@ void EquationTextBox::OnDeleteButtonClicked(Object ^ sender, RoutedEventArgs ^ e
|
||||
{
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->TextDocument->SetMath(L"");
|
||||
m_richEditBox->MathText = L"";
|
||||
if (m_functionButton)
|
||||
{
|
||||
m_functionButton->IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EquationTextBox::OnEquationButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
EquationButtonClicked(this, ref new RoutedEventArgs());
|
||||
}
|
||||
|
||||
void EquationTextBox::OnRemoveButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->MathText = L"";
|
||||
}
|
||||
|
||||
RemoveButtonClicked(this, ref new RoutedEventArgs());
|
||||
|
||||
if (m_functionButton)
|
||||
{
|
||||
m_functionButton->IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void EquationTextBox::OnColorChooserButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||
@@ -186,10 +199,7 @@ void EquationTextBox::OnColorChooserButtonClicked(Object ^ sender, RoutedEventAr
|
||||
|
||||
void EquationTextBox::OnFunctionButtonClicked(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
auto equationViewModel = static_cast<EquationViewModel ^>(DataContext);
|
||||
equationViewModel->KeyGraphFeaturesVisibility =
|
||||
(equationViewModel->KeyGraphFeaturesVisibility == ::Visibility::Collapsed) ? ::Visibility::Visible : ::Visibility::Collapsed;
|
||||
UpdateCommonVisualState();
|
||||
KeyGraphFeaturesButtonClicked(this, ref new RoutedEventArgs());
|
||||
}
|
||||
|
||||
void EquationTextBox::UpdateDeleteButtonVisualState()
|
||||
@@ -239,7 +249,7 @@ Platform::String ^ EquationTextBox::GetEquationText()
|
||||
range->CharacterFormat->Underline = UnderlineType::None;
|
||||
}
|
||||
|
||||
m_richEditBox->TextDocument->GetMath(&text);
|
||||
text = m_richEditBox->MathText;
|
||||
}
|
||||
|
||||
return text;
|
||||
@@ -249,7 +259,7 @@ void EquationTextBox::SetEquationText(Platform::String ^ equationText)
|
||||
{
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->TextDocument->SetMath(equationText);
|
||||
m_richEditBox->MathText = equationText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +269,7 @@ bool EquationTextBox::ShouldDeleteButtonBeVisible()
|
||||
|
||||
if (m_richEditBox != nullptr)
|
||||
{
|
||||
m_richEditBox->TextDocument->GetMath(&text);
|
||||
text = m_richEditBox->MathText;
|
||||
}
|
||||
return (!text->IsEmpty() && m_isFocused);
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
#include "CalcViewModel/GraphingCalculator/EquationViewModel.h"
|
||||
#include "Calculator/Controls/MathRichEditBox.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
@@ -19,11 +20,12 @@ namespace CalculatorApp
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(EquationTextBox);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::SolidColorBrush^, EquationColor);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::UIElement^, KeyGraphFeaturesContent);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Controls::Flyout^, ColorChooserFlyout);
|
||||
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ RemoveButtonClicked;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ KeyGraphFeaturesButtonClicked;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ EquationSubmitted;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ EquationButtonClicked;
|
||||
|
||||
Platform::String^ GetEquationText();
|
||||
void SetEquationText(Platform::String^ equationText);
|
||||
@@ -42,10 +44,8 @@ namespace CalculatorApp
|
||||
void UpdateDeleteButtonVisualState();
|
||||
bool ShouldDeleteButtonBeVisible();
|
||||
|
||||
void OnRichEditBoxLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnRichEditBoxGotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnRichEditBoxLostFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnRichEditBoxLosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ e);
|
||||
void OnRichEditBoxTextChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
void OnDeleteButtonClicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
@@ -57,7 +57,7 @@ namespace CalculatorApp
|
||||
void OnColorFlyoutOpened(Platform::Object^ sender, Platform::Object^ e);
|
||||
void OnColorFlyoutClosed(Platform::Object^ sender, Platform::Object^ e);
|
||||
|
||||
Windows::UI::Xaml::Controls::RichEditBox^ m_richEditBox;
|
||||
CalculatorApp::Controls::MathRichEditBox^ m_richEditBox;
|
||||
Windows::UI::Xaml::Controls::Button^ m_equationButton;
|
||||
Windows::UI::Xaml::Controls::Button^ m_deleteButton;
|
||||
Windows::UI::Xaml::Controls::Button^ m_removeButton;
|
||||
|
66
src/Calculator/Controls/MathRichEditBox.cpp
Normal file
66
src/Calculator/Controls/MathRichEditBox.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "MathRichEditBox.h"
|
||||
|
||||
using namespace Platform;
|
||||
using namespace CalculatorApp;
|
||||
using namespace CalculatorApp::Common;
|
||||
using namespace CalculatorApp::Controls;
|
||||
using namespace std;
|
||||
using namespace Windows::ApplicationModel;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(MathRichEditBox, MathText);
|
||||
|
||||
MathRichEditBox::MathRichEditBox()
|
||||
{
|
||||
static LimitedAccessFeatureStatus m_lafResultStatus;
|
||||
String ^ packageName = Package::Current->Id->Name;
|
||||
|
||||
if (packageName == L"Microsoft.WindowsCalculator.Dev")
|
||||
{
|
||||
m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature(
|
||||
"com.microsoft.windows.richeditmath",
|
||||
"BeDD/jxKhz/yfVNA11t4uA==", // Microsoft.WindowsCalculator.Dev
|
||||
"8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status;
|
||||
}
|
||||
|
||||
else if (packageName == L"Microsoft.WindowsCalculator")
|
||||
{
|
||||
m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature(
|
||||
"com.microsoft.windows.richeditmath",
|
||||
"pfanNuxnzo+mAkBQ3N/rGQ==", // Microsoft.WindowsCalculator
|
||||
"8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status;
|
||||
}
|
||||
|
||||
else if (packageName == L"Microsoft.WindowsCalculator.Graphing")
|
||||
{
|
||||
m_lafResultStatus = LimitedAccessFeatures::TryUnlockFeature(
|
||||
"com.microsoft.windows.richeditmath",
|
||||
"H6wflFFz3gkOsAHtG/D9Tg==", // Microsoft.WindowsCalculator.Graphing
|
||||
"8wekyb3d8bbwe has registered their use of com.microsoft.windows.richeditmath with Microsoft and agrees to the terms of use.")->Status;
|
||||
}
|
||||
|
||||
TextDocument->SetMathMode(Windows::UI::Text::RichEditMathMode::MathOnly);
|
||||
}
|
||||
|
||||
String ^ MathRichEditBox::GetMathTextProperty()
|
||||
{
|
||||
String ^ text;
|
||||
this->TextDocument->GetMath(&text);
|
||||
return text;
|
||||
}
|
||||
|
||||
void MathRichEditBox::SetMathTextProperty(String ^ newValue)
|
||||
{
|
||||
bool readOnlyState = this->IsReadOnly;
|
||||
this->IsReadOnly = false;
|
||||
|
||||
TextDocument->SetMath(newValue);
|
||||
|
||||
this->IsReadOnly = readOnlyState;
|
||||
}
|
49
src/Calculator/Controls/MathRichEditBox.h
Normal file
49
src/Calculator/Controls/MathRichEditBox.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
#include "CalcViewModel/Common/Utils.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public
|
||||
ref class MathRichEditBox sealed : Windows::UI::Xaml::Controls::RichEditBox
|
||||
{
|
||||
public:
|
||||
MathRichEditBox();
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(MathRichEditBox);
|
||||
|
||||
static property Windows::UI::Xaml::DependencyProperty ^ MathTextProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty ^ get() {
|
||||
return s_MathTextProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String ^ MathText
|
||||
{
|
||||
Platform::String ^ get()
|
||||
{
|
||||
return GetMathTextProperty();
|
||||
}
|
||||
void set(Platform::String^ value)
|
||||
{
|
||||
SetMathTextProperty(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private :
|
||||
Platform::String ^ GetMathTextProperty();
|
||||
void SetMathTextProperty(Platform::String ^ newValue);
|
||||
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_MathTextProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ InitializeMathTextProperty()
|
||||
{
|
||||
return Utils::RegisterDependencyProperty<DependencyPropertiesOwner, Platform::String ^>(L"MathText");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user