GraphControl: refactoring and optimizations (#831)
* GraphControl cleaning * replace textbox value after submission * rebase * rebase * rebase * Add filters * rebase! * rebase
This commit is contained in:
@@ -1,447 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Equation.h"
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
|
||||
using namespace Platform;
|
||||
using namespace std;
|
||||
using namespace Windows::UI;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
// Remove mml: formatting specific to RichEditBox control, which is not understood by the graph engine.
|
||||
static constexpr wstring_view s_mathPrefix = L"mml:";
|
||||
|
||||
DependencyProperty ^ Equation::s_expressionProperty;
|
||||
static constexpr auto s_propertyName_Expression = L"Expression";
|
||||
|
||||
DependencyProperty ^ Equation::s_lineColorProperty;
|
||||
static constexpr auto s_propertyName_LineColor = L"LineColor";
|
||||
|
||||
DependencyProperty ^ Equation::s_isLineEnabledProperty;
|
||||
static constexpr auto s_propertyName_IsLineEnabled = L"IsLineEnabled";
|
||||
|
||||
DependencyProperty ^ Equation::s_hasGraphErrorProperty;
|
||||
static constexpr auto s_propertyName_HasGraphError = L"HasGraphError";
|
||||
|
||||
DependencyProperty ^ Equation::s_isValidatedProperty;
|
||||
static constexpr auto s_propertyName_IsValidated = L"IsValidated";
|
||||
|
||||
DependencyProperty ^ Equation::s_xInterceptProperty;
|
||||
static constexpr auto s_propertyName_XIntercept = L"XIntercept";
|
||||
|
||||
DependencyProperty ^ Equation::s_yInterceptProperty;
|
||||
static constexpr auto s_propertyName_YIntercept = L"YIntercept";
|
||||
|
||||
DependencyProperty ^ Equation::s_parityProperty;
|
||||
static constexpr auto s_propertyName_Parity = L"Parity";
|
||||
|
||||
DependencyProperty ^ Equation::s_periodicityDirectionProperty;
|
||||
static constexpr auto s_propertyName_PeriodicityDirection = L"PeriodicityDirection";
|
||||
|
||||
DependencyProperty ^ Equation::s_periodicityExpressionProperty;
|
||||
static constexpr auto s_propertyName_PeriodicityExpression = L"PeriodicityExpression";
|
||||
|
||||
DependencyProperty ^ Equation::s_minimaProperty;
|
||||
static constexpr auto s_propertyName_Minima = L"Minima";
|
||||
|
||||
DependencyProperty ^ Equation::s_maximaProperty;
|
||||
static constexpr auto s_propertyName_Maxima = L"Maxima";
|
||||
|
||||
DependencyProperty ^ Equation::s_domainProperty;
|
||||
static constexpr auto s_propertyName_Domain = L"Domain";
|
||||
|
||||
DependencyProperty ^ Equation::s_rangeProperty;
|
||||
static constexpr auto s_propertyName_Range = L"Range";
|
||||
|
||||
DependencyProperty ^ Equation::s_inflectionPointsProperty;
|
||||
static constexpr auto s_propertyName_InflectionPoints = L"InflectionPoints";
|
||||
|
||||
DependencyProperty ^ Equation::s_monotonicityProperty;
|
||||
static constexpr auto s_propertyName_Monotonicity = L"Monotonicity";
|
||||
|
||||
DependencyProperty ^ Equation::s_verticalAsymptotesProperty;
|
||||
static constexpr auto s_propertyName_VerticalAsymptotes = L"VerticalAsymptotes";
|
||||
|
||||
DependencyProperty ^ Equation::s_horizontalAsymptotesProperty;
|
||||
static constexpr auto s_propertyName_HorizontalAsymptotes = L"HorizontalAsymptotes";
|
||||
|
||||
DependencyProperty ^ Equation::s_obliqueAsymptotesProperty;
|
||||
static constexpr auto s_propertyName_ObliqueAsymptotes = L"ObliqueAsymptotes";
|
||||
|
||||
DependencyProperty ^ Equation::s_tooComplexFeaturesProperty;
|
||||
static constexpr auto s_propertyName_TooComplexFeatures = L"TooComplexFeatures";
|
||||
|
||||
DependencyProperty ^ Equation::s_analysisErrorProperty;
|
||||
static constexpr auto s_propertyName_AnalysisError = L"AnalysisError";
|
||||
|
||||
namespace EquationProperties
|
||||
{
|
||||
String ^ Expression = StringReference(s_propertyName_Expression);
|
||||
String ^ LineColor = StringReference(s_propertyName_LineColor);
|
||||
String ^ IsLineEnabled = StringReference(s_propertyName_IsLineEnabled);
|
||||
String ^ HasGraphError = StringReference(s_propertyName_HasGraphError);
|
||||
String ^ IsValidated = StringReference(s_propertyName_IsValidated);
|
||||
String ^ XIntercept = StringReference(s_propertyName_XIntercept);
|
||||
String ^ YIntercept = StringReference(s_propertyName_YIntercept);
|
||||
String ^ Parity = StringReference(s_propertyName_Parity);
|
||||
String ^ PeriodicityDirection = StringReference(s_propertyName_PeriodicityDirection);
|
||||
String ^ PeriodicityExpression = StringReference(s_propertyName_PeriodicityExpression);
|
||||
String ^ Minima = StringReference(s_propertyName_Minima);
|
||||
String ^ Maxima = StringReference(s_propertyName_Maxima);
|
||||
String ^ Domain = StringReference(s_propertyName_Domain);
|
||||
String ^ Range = StringReference(s_propertyName_Range);
|
||||
String ^ InflectionPoints = StringReference(s_propertyName_InflectionPoints);
|
||||
String ^ Monotonicity = StringReference(s_propertyName_Monotonicity);
|
||||
String ^ VerticalAsymptotes = StringReference(s_propertyName_VerticalAsymptotes);
|
||||
String ^ HorizontalAsymptotes = StringReference(s_propertyName_HorizontalAsymptotes);
|
||||
String ^ ObliqueAsymptotes = StringReference(s_propertyName_ObliqueAsymptotes);
|
||||
String ^ TooComplexFeatures = StringReference(s_propertyName_TooComplexFeatures);
|
||||
String ^ AnalysisError = StringReference(s_propertyName_AnalysisError);
|
||||
}
|
||||
|
||||
void Equation::RegisterDependencyProperties()
|
||||
{
|
||||
if (!s_expressionProperty)
|
||||
{
|
||||
s_expressionProperty = DependencyProperty::Register(
|
||||
EquationProperties::Expression,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_lineColorProperty)
|
||||
{
|
||||
// Default line color should be the user's accent color
|
||||
auto uiSettings = ref new UISettings();
|
||||
|
||||
s_lineColorProperty = DependencyProperty::Register(
|
||||
EquationProperties::LineColor,
|
||||
SolidColorBrush::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_isLineEnabledProperty)
|
||||
{
|
||||
s_isLineEnabledProperty = DependencyProperty::Register(
|
||||
EquationProperties::IsLineEnabled,
|
||||
bool ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_hasGraphErrorProperty)
|
||||
{
|
||||
s_hasGraphErrorProperty = DependencyProperty::Register(
|
||||
EquationProperties::HasGraphError,
|
||||
bool ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(false, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_isValidatedProperty)
|
||||
{
|
||||
s_isValidatedProperty = DependencyProperty::Register(
|
||||
EquationProperties::IsValidated,
|
||||
bool ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(false, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_xInterceptProperty)
|
||||
{
|
||||
s_xInterceptProperty = DependencyProperty::Register(
|
||||
EquationProperties::XIntercept,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_yInterceptProperty)
|
||||
{
|
||||
s_yInterceptProperty = DependencyProperty::Register(
|
||||
EquationProperties::YIntercept,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_parityProperty)
|
||||
{
|
||||
s_parityProperty = DependencyProperty::Register(
|
||||
EquationProperties::Parity,
|
||||
int ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_periodicityDirectionProperty)
|
||||
{
|
||||
s_periodicityDirectionProperty = DependencyProperty::Register(
|
||||
EquationProperties::PeriodicityDirection,
|
||||
int ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_periodicityExpressionProperty)
|
||||
{
|
||||
s_periodicityExpressionProperty = DependencyProperty::Register(
|
||||
EquationProperties::PeriodicityExpression,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_minimaProperty)
|
||||
{
|
||||
s_minimaProperty = DependencyProperty::Register(
|
||||
EquationProperties::Minima,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_maximaProperty)
|
||||
{
|
||||
s_maximaProperty = DependencyProperty::Register(
|
||||
EquationProperties::Maxima,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_domainProperty)
|
||||
{
|
||||
s_domainProperty = DependencyProperty::Register(
|
||||
EquationProperties::Domain,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_rangeProperty)
|
||||
{
|
||||
s_rangeProperty = DependencyProperty::Register(
|
||||
EquationProperties::Range,
|
||||
String::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_inflectionPointsProperty)
|
||||
{
|
||||
s_inflectionPointsProperty = DependencyProperty::Register(
|
||||
EquationProperties::InflectionPoints,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_monotonicityProperty)
|
||||
{
|
||||
s_monotonicityProperty = DependencyProperty::Register(
|
||||
EquationProperties::Monotonicity,
|
||||
IObservableMap<String ^, String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_verticalAsymptotesProperty)
|
||||
{
|
||||
s_verticalAsymptotesProperty = DependencyProperty::Register(
|
||||
EquationProperties::VerticalAsymptotes,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_horizontalAsymptotesProperty)
|
||||
{
|
||||
s_horizontalAsymptotesProperty = DependencyProperty::Register(
|
||||
EquationProperties::HorizontalAsymptotes,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_obliqueAsymptotesProperty)
|
||||
{
|
||||
s_obliqueAsymptotesProperty = DependencyProperty::Register(
|
||||
EquationProperties::ObliqueAsymptotes,
|
||||
IObservableVector<String ^>::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
if (!s_tooComplexFeaturesProperty)
|
||||
{
|
||||
s_tooComplexFeaturesProperty = DependencyProperty::Register(
|
||||
EquationProperties::TooComplexFeatures,
|
||||
int ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_analysisErrorProperty)
|
||||
{
|
||||
s_analysisErrorProperty = DependencyProperty::Register(
|
||||
EquationProperties::AnalysisError,
|
||||
int ::typeid,
|
||||
Equation::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
void Equation::OnCustomDependencyPropertyChanged(DependencyObject ^ obj, DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
if (auto eq = static_cast<Equation ^>(obj))
|
||||
{
|
||||
String ^ propertyName = nullptr;
|
||||
if (args->Property == s_expressionProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Expression;
|
||||
}
|
||||
else if (args->Property == s_lineColorProperty)
|
||||
{
|
||||
propertyName = EquationProperties::LineColor;
|
||||
}
|
||||
else if (args->Property == s_isLineEnabledProperty)
|
||||
{
|
||||
propertyName = EquationProperties::IsLineEnabled;
|
||||
}
|
||||
else if (args->Property == s_xInterceptProperty)
|
||||
{
|
||||
propertyName = EquationProperties::XIntercept;
|
||||
}
|
||||
else if (args->Property == s_yInterceptProperty)
|
||||
{
|
||||
propertyName = EquationProperties::YIntercept;
|
||||
}
|
||||
else if (args->Property == s_parityProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Parity;
|
||||
}
|
||||
else if (args->Property == s_periodicityDirectionProperty)
|
||||
{
|
||||
propertyName = EquationProperties::PeriodicityDirection;
|
||||
}
|
||||
else if (args->Property == s_periodicityExpressionProperty)
|
||||
{
|
||||
propertyName = EquationProperties::PeriodicityExpression;
|
||||
}
|
||||
else if (args->Property == s_minimaProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Minima;
|
||||
}
|
||||
else if (args->Property == s_maximaProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Maxima;
|
||||
}
|
||||
else if (args->Property == s_domainProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Domain;
|
||||
}
|
||||
else if (args->Property == s_rangeProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Range;
|
||||
}
|
||||
else if (args->Property == s_inflectionPointsProperty)
|
||||
{
|
||||
propertyName = EquationProperties::InflectionPoints;
|
||||
}
|
||||
else if (args->Property == s_monotonicityProperty)
|
||||
{
|
||||
propertyName = EquationProperties::Monotonicity;
|
||||
}
|
||||
else if (args->Property == s_verticalAsymptotesProperty)
|
||||
{
|
||||
propertyName = EquationProperties::VerticalAsymptotes;
|
||||
}
|
||||
else if (args->Property == s_horizontalAsymptotesProperty)
|
||||
{
|
||||
propertyName = EquationProperties::HorizontalAsymptotes;
|
||||
}
|
||||
else if (args->Property == s_obliqueAsymptotesProperty)
|
||||
{
|
||||
propertyName = EquationProperties::ObliqueAsymptotes;
|
||||
}
|
||||
else if (args->Property == s_tooComplexFeaturesProperty)
|
||||
{
|
||||
propertyName = EquationProperties::TooComplexFeatures;
|
||||
}
|
||||
else if (args->Property == s_analysisErrorProperty)
|
||||
{
|
||||
propertyName = EquationProperties::AnalysisError;
|
||||
}
|
||||
else if (args->Property == s_hasGraphErrorProperty)
|
||||
{
|
||||
propertyName = EquationProperties::HasGraphError;
|
||||
}
|
||||
else if (args->Property == s_isValidatedProperty)
|
||||
{
|
||||
propertyName = EquationProperties::IsValidated;
|
||||
}
|
||||
|
||||
eq->PropertyChanged(eq, propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
wstring Equation::GetRequest()
|
||||
{
|
||||
wstringstream ss{};
|
||||
ss << GetRequestHeader() << GetExpression() << GetLineColor() << L"</mfenced></mrow>";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
wstring Equation::GetRequestHeader()
|
||||
{
|
||||
wstring expr{ Expression->Data() };
|
||||
|
||||
// Check for unicode characters of less than, less than or equal to, greater than and greater than or equal to.
|
||||
if (expr.find(L">><") != wstring::npos || expr.find(L"><<") != wstring::npos || expr.find(L">≥<") != wstring::npos
|
||||
|| expr.find(L">≤<") != wstring::npos)
|
||||
{
|
||||
return L"<mrow><mi>plotIneq2D</mi><mfenced separators=\"\">"s;
|
||||
}
|
||||
else if (expr.find(L">=<") != wstring::npos)
|
||||
{
|
||||
return L"<mrow><mi>plotEq2d</mi><mfenced separators=\"\">"s;
|
||||
}
|
||||
else
|
||||
{
|
||||
return L"<mrow><mi>plot2d</mi><mfenced separators=\"\">"s;
|
||||
}
|
||||
}
|
||||
|
||||
wstring Equation::GetExpression()
|
||||
{
|
||||
wstring mathML = Expression->Data();
|
||||
|
||||
size_t mathPrefix = 0;
|
||||
while ((mathPrefix = mathML.find(s_mathPrefix, mathPrefix)) != std::string::npos)
|
||||
{
|
||||
mathML.replace(mathPrefix, s_mathPrefix.length(), L"");
|
||||
mathPrefix += s_mathPrefix.length();
|
||||
}
|
||||
|
||||
return mathML;
|
||||
}
|
||||
|
||||
wstring Equation::GetLineColor()
|
||||
{
|
||||
return L""s;
|
||||
}
|
||||
|
||||
bool Equation::IsGraphableEquation()
|
||||
{
|
||||
return !Expression->IsEmpty() && IsLineEnabled && !HasGraphError;
|
||||
}
|
||||
}
|
@@ -1,507 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
namespace EquationProperties
|
||||
{
|
||||
extern Platform::String ^ Expression;
|
||||
extern Platform::String ^ LineColor;
|
||||
extern Platform::String ^ IsLineEnabled;
|
||||
}
|
||||
|
||||
ref class Equation;
|
||||
delegate void PropertyChangedEventHandler(Equation ^ sender, Platform::String ^ propertyName);
|
||||
|
||||
[Windows::UI::Xaml::Data::Bindable] public ref class Equation sealed : public Windows::UI::Xaml::DependencyObject
|
||||
{
|
||||
public:
|
||||
|
||||
Equation()
|
||||
{
|
||||
}
|
||||
|
||||
static void RegisterDependencyProperties();
|
||||
|
||||
#pragma region Platform::String ^ Expression DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ ExpressionProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_expressionProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String^ Expression
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return static_cast<Platform::String^>(GetValue(s_expressionProperty));
|
||||
}
|
||||
void set(Platform::String^ value)
|
||||
{
|
||||
SetValue(s_expressionProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::UI::Xaml::Media::SolidColorBrush ^ LineColor DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ LineColorProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_lineColorProperty;
|
||||
}
|
||||
}
|
||||
property Windows::UI::Xaml::Media::SolidColorBrush^ LineColor
|
||||
{
|
||||
Windows::UI::Xaml::Media::SolidColorBrush^ get()
|
||||
{
|
||||
return static_cast<Windows::UI::Xaml::Media::SolidColorBrush^>(GetValue(s_lineColorProperty));
|
||||
}
|
||||
void set(Windows::UI::Xaml::Media::SolidColorBrush^ value)
|
||||
{
|
||||
if (value == nullptr || LineColor == nullptr || (value->Color.A != LineColor->Color.A) || (value->Color.R != LineColor->Color.R)
|
||||
|| (value->Color.G != LineColor->Color.G) || (value->Color.B != LineColor->Color.B))
|
||||
SetValue(s_lineColorProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region bool IsLineEnabled DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty ^ IsLineEnabledProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty ^ get()
|
||||
{
|
||||
return s_isLineEnabledProperty;
|
||||
}
|
||||
}
|
||||
property bool IsLineEnabled
|
||||
{
|
||||
bool get()
|
||||
{
|
||||
return static_cast<bool>(GetValue(s_isLineEnabledProperty));
|
||||
}
|
||||
void set(bool value)
|
||||
{
|
||||
SetValue(s_isLineEnabledProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region bool HasGraphError DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty ^ HasGraphErrorProperty { Windows::UI::Xaml::DependencyProperty ^ get() { return s_hasGraphErrorProperty; } }
|
||||
|
||||
property bool HasGraphError
|
||||
{
|
||||
bool get()
|
||||
{
|
||||
return static_cast<bool>(GetValue(s_hasGraphErrorProperty));
|
||||
}
|
||||
|
||||
internal:
|
||||
void set(bool value)
|
||||
{
|
||||
SetValue(s_hasGraphErrorProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region bool IsValidated DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty ^ IsValidatedProperty { Windows::UI::Xaml::DependencyProperty ^ get() { return s_isValidatedProperty; } }
|
||||
|
||||
property bool IsValidated
|
||||
{
|
||||
bool get()
|
||||
{
|
||||
return static_cast<bool>(GetValue(s_isValidatedProperty));
|
||||
}
|
||||
|
||||
internal:
|
||||
void set(bool value)
|
||||
{
|
||||
SetValue(s_isValidatedProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Key Graph Features
|
||||
|
||||
|
||||
#pragma region Platform::String ^ XIntercept DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ XInterceptProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_xInterceptProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String^ XIntercept
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return static_cast<Platform::String^>(GetValue(s_xInterceptProperty));
|
||||
}
|
||||
internal: void set(Platform::String^ value)
|
||||
{
|
||||
SetValue(s_xInterceptProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Platform::String ^ YIntercept DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ YInterceptProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_yInterceptProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String^ YIntercept
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return static_cast<Platform::String^>(GetValue(s_yInterceptProperty));
|
||||
}
|
||||
internal: void set(Platform::String^ value)
|
||||
{
|
||||
SetValue(s_yInterceptProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region int Parity DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ ParityProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_parityProperty;
|
||||
}
|
||||
}
|
||||
property int Parity
|
||||
{
|
||||
int get()
|
||||
{
|
||||
return static_cast<int>(GetValue(s_parityProperty));
|
||||
}
|
||||
internal: void set(int value)
|
||||
{
|
||||
SetValue(s_parityProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region int Periodicity DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ PeriodicityDirectionProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_periodicityDirectionProperty;
|
||||
}
|
||||
}
|
||||
property int PeriodicityDirection
|
||||
{
|
||||
int get()
|
||||
{
|
||||
return static_cast<int>(GetValue(s_periodicityDirectionProperty));
|
||||
}
|
||||
internal: void set(int value)
|
||||
{
|
||||
SetValue(s_periodicityDirectionProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Platform::String ^ PeriodicityExpression DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ PeriodicityExpressionProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_periodicityExpressionProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String ^ PeriodicityExpression
|
||||
{
|
||||
Platform::String ^ get()
|
||||
{
|
||||
return static_cast<Platform::String ^>(GetValue(s_periodicityExpressionProperty));
|
||||
}
|
||||
internal: void set(Platform::String ^ value)
|
||||
{
|
||||
SetValue(s_periodicityExpressionProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ Minima DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ MinimaProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_minimaProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ Minima
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_minimaProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_minimaProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ Maxima DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ MaximaProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_maximaProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ Maxima
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_maximaProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_maximaProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Platform::String ^ Domain DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ DomainProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_domainProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String^ Domain
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return static_cast<Platform::String^>(GetValue(s_domainProperty));
|
||||
}
|
||||
internal: void set(Platform::String^ value)
|
||||
{
|
||||
SetValue(s_domainProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Platform::String ^ Range DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ RangeProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_rangeProperty;
|
||||
}
|
||||
}
|
||||
property Platform::String^ Range
|
||||
{
|
||||
Platform::String^ get()
|
||||
{
|
||||
return static_cast<Platform::String^>(GetValue(s_rangeProperty));
|
||||
}
|
||||
internal: void set(Platform::String^ value)
|
||||
{
|
||||
SetValue(s_rangeProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ InflectionPoints DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ InflectionPointsProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_inflectionPointsProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ InflectionPoints
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_inflectionPointsProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_inflectionPointsProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IObservableMap < Platform::String ^, Platform::String ^ > ^ Monotonicity DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ MonotonicityProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_monotonicityProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ Monotonicity
|
||||
{
|
||||
Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^>(GetValue(s_monotonicityProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ value)
|
||||
{
|
||||
SetValue(s_monotonicityProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ VerticalAsymptotes DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ VerticalAsymptotesProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_verticalAsymptotesProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ VerticalAsymptotes
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_verticalAsymptotesProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_verticalAsymptotesProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ HorizontalAsymptotes DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ HorizontalAsymptotesProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_horizontalAsymptotesProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ HorizontalAsymptotes
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_horizontalAsymptotesProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_horizontalAsymptotesProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ ObliqueAsymptotes DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ ObliqueAsymptotesProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_obliqueAsymptotesProperty;
|
||||
}
|
||||
}
|
||||
property Windows::Foundation::Collections::IVector<Platform::String^> ^ ObliqueAsymptotes
|
||||
{
|
||||
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_obliqueAsymptotesProperty));
|
||||
}
|
||||
internal: void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
|
||||
{
|
||||
SetValue(s_obliqueAsymptotesProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region int TooComplexFeatures DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ TooComplexFeaturesProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_tooComplexFeaturesProperty;
|
||||
}
|
||||
}
|
||||
property int TooComplexFeatures
|
||||
{
|
||||
int get()
|
||||
{
|
||||
return static_cast<int>(GetValue(s_tooComplexFeaturesProperty));
|
||||
}
|
||||
internal: void set(int value)
|
||||
{
|
||||
SetValue(s_tooComplexFeaturesProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region int AnalysisError DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty ^ AnalysisErrorProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty ^ get()
|
||||
{
|
||||
return s_analysisErrorProperty;
|
||||
}
|
||||
}
|
||||
property int AnalysisError
|
||||
{
|
||||
int get()
|
||||
{
|
||||
return static_cast<int>(GetValue(s_analysisErrorProperty));
|
||||
}
|
||||
internal: void set(int value)
|
||||
{
|
||||
SetValue(s_analysisErrorProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
internal : event PropertyChangedEventHandler ^ PropertyChanged;
|
||||
|
||||
std::wstring GetRequest();
|
||||
bool IsGraphableEquation();
|
||||
|
||||
private:
|
||||
static void OnCustomDependencyPropertyChanged(Windows::UI::Xaml::DependencyObject ^ obj, Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
|
||||
std::wstring GetRequestHeader();
|
||||
std::wstring GetExpression();
|
||||
std::wstring GetLineColor();
|
||||
|
||||
private:
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_expressionProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_lineColorProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_isLineEnabledProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_hasGraphErrorProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_isValidatedProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_xInterceptProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_yInterceptProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_parityProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_periodicityDirectionProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_periodicityExpressionProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_minimaProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_maximaProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_domainProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_rangeProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_inflectionPointsProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_monotonicityProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_verticalAsymptotesProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_horizontalAsymptotesProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_obliqueAsymptotesProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_tooComplexFeaturesProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_analysisErrorProperty;
|
||||
};
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Equation.h"
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
delegate void EquationChangedEventHandler(Equation ^ sender);
|
||||
delegate void VisibilityChangedEventHandler(Equation ^ sender);
|
||||
|
||||
public
|
||||
ref class EquationCollection sealed : public Windows::Foundation::Collections::IObservableVector<GraphControl::Equation ^>
|
||||
{
|
||||
public:
|
||||
virtual ~EquationCollection()
|
||||
{
|
||||
}
|
||||
|
||||
#pragma region IIterable
|
||||
virtual Windows::Foundation::Collections::IIterator< GraphControl::Equation^ >^ First()
|
||||
{
|
||||
return m_vector->First();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IVector
|
||||
virtual property unsigned int Size
|
||||
{
|
||||
unsigned int get()
|
||||
{
|
||||
return m_vector->Size;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Append(GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->Append(value);
|
||||
m_tokens.emplace_back(
|
||||
value->PropertyChanged += ref new GraphControl::PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged));
|
||||
}
|
||||
|
||||
virtual void Clear()
|
||||
{
|
||||
auto numEqs = m_vector->Size;
|
||||
for (auto i = 0u; i < numEqs; i++)
|
||||
{
|
||||
m_vector->GetAt(i)->PropertyChanged -= m_tokens[i];
|
||||
}
|
||||
|
||||
m_vector->Clear();
|
||||
m_tokens.clear();
|
||||
}
|
||||
|
||||
virtual GraphControl::Equation
|
||||
^ GetAt(unsigned int index) { return m_vector->GetAt(index); }
|
||||
|
||||
virtual unsigned int GetMany(unsigned int startIndex, Platform::WriteOnlyArray<GraphControl::Equation ^> ^ items)
|
||||
{
|
||||
return m_vector->GetMany(startIndex, items);
|
||||
}
|
||||
|
||||
virtual Windows::Foundation::Collections::IVectorView< GraphControl::Equation^ >^ GetView()
|
||||
{
|
||||
return m_vector->GetView();
|
||||
}
|
||||
|
||||
virtual Platform::Boolean IndexOf(GraphControl::Equation^ value, unsigned int *index)
|
||||
{
|
||||
return m_vector->IndexOf(value, index);
|
||||
}
|
||||
|
||||
virtual void InsertAt(unsigned int index, GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->InsertAt(index, value);
|
||||
m_tokens.insert(
|
||||
m_tokens.begin() + index, value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged));
|
||||
}
|
||||
|
||||
virtual void RemoveAt(unsigned int index)
|
||||
{
|
||||
m_vector->GetAt(index)->PropertyChanged -= m_tokens[index];
|
||||
|
||||
m_vector->RemoveAt(index);
|
||||
m_tokens.erase(m_tokens.begin() + index);
|
||||
}
|
||||
|
||||
virtual void RemoveAtEnd()
|
||||
{
|
||||
auto size = m_vector->Size;
|
||||
if (size > 0)
|
||||
{
|
||||
m_vector->GetAt(size - 1)->PropertyChanged -= *m_tokens.rbegin();
|
||||
m_tokens.erase(m_tokens.end() - 1);
|
||||
}
|
||||
|
||||
m_vector->RemoveAtEnd();
|
||||
}
|
||||
|
||||
virtual void ReplaceAll(const Platform::Array<GraphControl::Equation ^> ^ items)
|
||||
{
|
||||
auto size = m_vector->Size;
|
||||
for (auto i = 0u; i < size; i++)
|
||||
{
|
||||
m_vector->GetAt(i)->PropertyChanged -= m_tokens[i];
|
||||
}
|
||||
|
||||
size = items->Length;
|
||||
m_tokens.resize(size);
|
||||
for (auto i = 0u; i < size; i++)
|
||||
{
|
||||
m_tokens[i] = items[i]->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged);
|
||||
}
|
||||
|
||||
m_vector->ReplaceAll(items);
|
||||
}
|
||||
|
||||
virtual void SetAt(unsigned int index, GraphControl::Equation ^ value)
|
||||
{
|
||||
m_vector->GetAt(index)->PropertyChanged -= m_tokens[index];
|
||||
|
||||
m_vector->SetAt(index, value);
|
||||
m_tokens[index] = value->PropertyChanged += ref new PropertyChangedEventHandler(this, &EquationCollection::OnEquationPropertyChanged);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IObservableVector
|
||||
virtual event Windows::Foundation::Collections::VectorChangedEventHandler< GraphControl::Equation^ >^ VectorChanged
|
||||
{
|
||||
Windows::Foundation::EventRegistrationToken add(Windows::Foundation::Collections::VectorChangedEventHandler< GraphControl::Equation^ >^ handler)
|
||||
{
|
||||
return m_vector->VectorChanged += handler;
|
||||
}
|
||||
|
||||
void remove(Windows::Foundation::EventRegistrationToken token)
|
||||
{
|
||||
m_vector->VectorChanged -= token;
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
internal:
|
||||
EquationCollection() :
|
||||
m_vector(ref new Platform::Collections::Vector< GraphControl::Equation^ >())
|
||||
{
|
||||
}
|
||||
|
||||
event EquationChangedEventHandler ^ EquationChanged;
|
||||
event EquationChangedEventHandler ^ EquationStyleChanged;
|
||||
event EquationChangedEventHandler ^ EquationLineEnabledChanged;
|
||||
|
||||
private:
|
||||
void OnEquationPropertyChanged(GraphControl::Equation ^ sender, Platform::String ^ propertyName)
|
||||
{
|
||||
if (propertyName == EquationProperties::LineColor)
|
||||
{
|
||||
EquationStyleChanged(sender);
|
||||
}
|
||||
else if (propertyName == EquationProperties::Expression)
|
||||
{
|
||||
EquationChanged(sender);
|
||||
}
|
||||
else if (propertyName == EquationProperties::IsLineEnabled)
|
||||
{
|
||||
EquationLineEnabledChanged(sender);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Platform::Collections::Vector<GraphControl::Equation ^> ^ m_vector;
|
||||
std::vector<Windows::Foundation::EventRegistrationToken> m_tokens;
|
||||
};
|
||||
}
|
@@ -24,16 +24,17 @@ using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::UI::Xaml::Input;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
using namespace GraphControl;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, ForceProportionalAxes);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, Variables);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, Equations);
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto s_defaultStyleKey = L"GraphControl.Grapher";
|
||||
constexpr auto s_templateKey_SwapChainPanel = L"GraphSurface";
|
||||
|
||||
constexpr auto s_propertyName_Equations = L"Equations";
|
||||
constexpr auto s_propertyName_Variables = L"Variables";
|
||||
constexpr auto s_propertyName_ForceProportionalAxes = L"ForceProportionalAxes";
|
||||
|
||||
constexpr auto s_X = L"x";
|
||||
constexpr auto s_Y = L"y";
|
||||
constexpr auto s_defaultFormatType = FormatType::MathML;
|
||||
@@ -52,24 +53,19 @@ namespace
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
DependencyProperty ^ Grapher::s_equationsProperty;
|
||||
DependencyProperty ^ Grapher::s_variablesProperty;
|
||||
DependencyProperty ^ Grapher::s_forceProportionalAxesTemplateProperty;
|
||||
|
||||
Grapher::Grapher()
|
||||
: m_solver{ IMathSolver::CreateMathSolver() }
|
||||
, m_graph{ m_solver->CreateGrapher() }
|
||||
, m_Moving{ false }
|
||||
{
|
||||
Equations = ref new EquationCollection();
|
||||
|
||||
m_solver->ParsingOptions().SetFormatType(s_defaultFormatType);
|
||||
m_solver->FormatOptions().SetFormatType(s_defaultFormatType);
|
||||
m_solver->FormatOptions().SetMathMLPrefix(wstring(L"mml"));
|
||||
|
||||
DefaultStyleKey = StringReference(s_defaultStyleKey);
|
||||
|
||||
this->SetValue(EquationsProperty, ref new EquationCollection());
|
||||
this->SetValue(VariablesProperty, ref new Map<String ^, double>());
|
||||
|
||||
this->Loaded += ref new RoutedEventHandler(this, &Grapher::OnLoaded);
|
||||
this->Unloaded += ref new RoutedEventHandler(this, &Grapher::OnUnloaded);
|
||||
|
||||
@@ -147,52 +143,6 @@ namespace GraphControl
|
||||
TryUpdateGraph();
|
||||
}
|
||||
|
||||
void Grapher::RegisterDependencyProperties()
|
||||
{
|
||||
if (!s_equationsProperty)
|
||||
{
|
||||
s_equationsProperty = DependencyProperty::Register(
|
||||
StringReference(s_propertyName_Equations),
|
||||
EquationCollection::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_variablesProperty)
|
||||
{
|
||||
s_variablesProperty = DependencyProperty::Register(
|
||||
StringReference(s_propertyName_Variables),
|
||||
IObservableMap<String ^, double>::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
|
||||
if (!s_forceProportionalAxesTemplateProperty)
|
||||
{
|
||||
s_forceProportionalAxesTemplateProperty = DependencyProperty::Register(
|
||||
StringReference(s_propertyName_ForceProportionalAxes),
|
||||
bool ::typeid,
|
||||
Grapher::typeid,
|
||||
ref new PropertyMetadata(true, ref new PropertyChangedCallback(&Grapher::OnCustomDependencyPropertyChanged)));
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnCustomDependencyPropertyChanged(DependencyObject ^ obj, DependencyPropertyChangedEventArgs ^ args)
|
||||
{
|
||||
auto self = static_cast<Grapher ^>(obj);
|
||||
if (self)
|
||||
{
|
||||
if (args->Property == EquationsProperty)
|
||||
{
|
||||
self->OnEquationsChanged(args);
|
||||
}
|
||||
else if (args->Property == ForceProportionalAxesTemplateProperty)
|
||||
{
|
||||
self->OnForceProportionalAxesChanged(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnDependencyPropertyChanged(DependencyObject ^ obj, DependencyProperty ^ p)
|
||||
{
|
||||
if (p == SolidColorBrush::ColorProperty)
|
||||
@@ -202,30 +152,36 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnEquationsChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
void Grapher::OnEquationsPropertyChanged(EquationCollection ^ oldValue, EquationCollection ^ newValue)
|
||||
{
|
||||
if (auto older = static_cast<EquationCollection ^>(args->OldValue))
|
||||
if (oldValue != nullptr)
|
||||
{
|
||||
if (m_tokenEquationChanged.Value != 0)
|
||||
{
|
||||
older->EquationChanged -= m_tokenEquationChanged;
|
||||
oldValue->EquationChanged -= m_tokenEquationChanged;
|
||||
m_tokenEquationChanged.Value = 0;
|
||||
}
|
||||
|
||||
if (m_tokenEquationStyleChanged.Value != 0)
|
||||
{
|
||||
older->EquationStyleChanged -= m_tokenEquationStyleChanged;
|
||||
oldValue->EquationStyleChanged -= m_tokenEquationStyleChanged;
|
||||
m_tokenEquationStyleChanged.Value = 0;
|
||||
}
|
||||
|
||||
if (m_tokenEquationLineEnabledChanged.Value != 0)
|
||||
{
|
||||
oldValue->EquationLineEnabledChanged -= m_tokenEquationLineEnabledChanged;
|
||||
m_tokenEquationLineEnabledChanged.Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto newer = static_cast<EquationCollection ^>(args->NewValue))
|
||||
if (newValue != nullptr)
|
||||
{
|
||||
m_tokenEquationChanged = newer->EquationChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationChanged);
|
||||
m_tokenEquationChanged = newValue->EquationChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationChanged);
|
||||
|
||||
m_tokenEquationStyleChanged = newer->EquationStyleChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationStyleChanged);
|
||||
m_tokenEquationStyleChanged = newValue->EquationStyleChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationStyleChanged);
|
||||
|
||||
m_tokenEquationLineEnabledChanged = newer->EquationLineEnabledChanged +=
|
||||
m_tokenEquationLineEnabledChanged = newValue->EquationLineEnabledChanged +=
|
||||
ref new EquationChangedEventHandler(this, &Grapher::OnEquationLineEnabledChanged);
|
||||
}
|
||||
|
||||
@@ -268,8 +224,9 @@ namespace GraphControl
|
||||
PlotGraph();
|
||||
}
|
||||
|
||||
void Grapher::AnalyzeEquation(Equation ^ equation)
|
||||
KeyGraphFeaturesInfo ^ Grapher::AnalyzeEquation(Equation ^ equation)
|
||||
{
|
||||
auto result = ref new KeyGraphFeaturesInfo();
|
||||
if (auto graph = GetGraph(equation))
|
||||
{
|
||||
if (auto analyzer = graph->GetAnalyzer())
|
||||
@@ -281,38 +238,17 @@ namespace GraphControl
|
||||
(Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All))
|
||||
{
|
||||
Graphing::IGraphFunctionAnalysisData functionAnalysisData = m_solver->Analyze(analyzer.get());
|
||||
{
|
||||
equation->XIntercept = ref new String(functionAnalysisData.Zeros.c_str());
|
||||
equation->YIntercept = ref new String(functionAnalysisData.YIntercept.c_str());
|
||||
equation->Domain = ref new String(functionAnalysisData.Domain.c_str());
|
||||
equation->Range = ref new String(functionAnalysisData.Range.c_str());
|
||||
equation->Parity = functionAnalysisData.Parity;
|
||||
equation->PeriodicityDirection = functionAnalysisData.PeriodicityDirection;
|
||||
equation->PeriodicityExpression = ref new String(functionAnalysisData.PeriodicityExpression.c_str());
|
||||
equation->Minima = ConvertWStringVector(functionAnalysisData.Minima);
|
||||
equation->Maxima = ConvertWStringVector(functionAnalysisData.Maxima);
|
||||
equation->InflectionPoints = ConvertWStringVector(functionAnalysisData.InflectionPoints);
|
||||
equation->Monotonicity = ConvertWStringIntMap(functionAnalysisData.MonotoneIntervals);
|
||||
equation->VerticalAsymptotes = ConvertWStringVector(functionAnalysisData.VerticalAsymptotes);
|
||||
equation->HorizontalAsymptotes = ConvertWStringVector(functionAnalysisData.HorizontalAsymptotes);
|
||||
equation->ObliqueAsymptotes = ConvertWStringVector(functionAnalysisData.ObliqueAsymptotes);
|
||||
equation->TooComplexFeatures = functionAnalysisData.TooComplexFeatures;
|
||||
equation->AnalysisError = CalculatorApp::AnalysisErrorType::NoError;
|
||||
|
||||
return;
|
||||
}
|
||||
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
equation->AnalysisError = CalculatorApp::AnalysisErrorType::AnalysisNotSupported;
|
||||
|
||||
return;
|
||||
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
equation->AnalysisError = CalculatorApp::AnalysisErrorType::AnalysisCouldNotBePerformed;
|
||||
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisCouldNotBePerformed);
|
||||
}
|
||||
|
||||
void Grapher::PlotGraph()
|
||||
@@ -371,7 +307,7 @@ namespace GraphControl
|
||||
ss << L"<mo>,</mo>";
|
||||
}
|
||||
|
||||
ss << eq->GetRequest();
|
||||
ss << eq->GetRequest()->Data();
|
||||
}
|
||||
|
||||
ss << s_getGraphClosingTags;
|
||||
@@ -463,13 +399,13 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<IGraph> Grapher::GetGraph(GraphControl::Equation ^ equation)
|
||||
shared_ptr<IGraph> Grapher::GetGraph(Equation ^ equation)
|
||||
{
|
||||
std::shared_ptr<Graphing::IGraph> graph = m_solver->CreateGrapher();
|
||||
|
||||
wstringstream ss{};
|
||||
ss << s_getGraphOpeningTags;
|
||||
ss << equation->GetRequest();
|
||||
ss << equation->GetRequest()->Data();
|
||||
ss << s_getGraphClosingTags;
|
||||
|
||||
wstring request = ss.str();
|
||||
@@ -485,30 +421,6 @@ namespace GraphControl
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IObservableVector<String ^> ^ Grapher::ConvertWStringVector(vector<wstring> inVector)
|
||||
{
|
||||
Vector<String ^> ^ outVector = ref new Vector<String ^>();
|
||||
|
||||
for (auto v : inVector)
|
||||
{
|
||||
outVector->Append(ref new String(v.c_str()));
|
||||
}
|
||||
|
||||
return outVector;
|
||||
}
|
||||
|
||||
IObservableMap<String ^, String ^> ^ Grapher::ConvertWStringIntMap(map<wstring, int> inMap)
|
||||
{
|
||||
Map<String ^, String ^> ^ outMap = ref new Map<String ^, String ^>();
|
||||
;
|
||||
for (auto m : inMap)
|
||||
{
|
||||
outMap->Insert(ref new String(m.first.c_str()), m.second.ToString());
|
||||
}
|
||||
|
||||
return outMap;
|
||||
}
|
||||
|
||||
void Grapher::UpdateVariables()
|
||||
{
|
||||
auto updatedVariables = ref new Map<String ^, double>();
|
||||
@@ -573,7 +485,7 @@ namespace GraphControl
|
||||
graphColors.reserve(validEqs.size());
|
||||
for (Equation ^ eq : validEqs)
|
||||
{
|
||||
auto lineColor = eq->LineColor->Color;
|
||||
auto lineColor = eq->LineColor;
|
||||
graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A);
|
||||
}
|
||||
options.SetGraphColors(graphColors);
|
||||
@@ -595,7 +507,7 @@ namespace GraphControl
|
||||
return validEqs;
|
||||
}
|
||||
|
||||
void Grapher::OnForceProportionalAxesChanged(DependencyPropertyChangedEventArgs ^ args)
|
||||
void Grapher::OnForceProportionalAxesPropertyChanged(bool /*oldValue*/, bool /*newValue*/)
|
||||
{
|
||||
TryUpdateGraph();
|
||||
}
|
||||
|
@@ -4,11 +4,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "DirectX/RenderMain.h"
|
||||
#include "Equation.h"
|
||||
#include "EquationCollection.h"
|
||||
#include "../Models/Equation.h"
|
||||
#include "../Models/EquationCollection.h"
|
||||
#include "../Utils.h"
|
||||
#include "IGraphAnalyzer.h"
|
||||
#include "IMathSolver.h"
|
||||
#include "Common.h"
|
||||
#include "Models/KeyGraphFeaturesInfo.h"
|
||||
#include <ppltasks.h>
|
||||
|
||||
namespace GraphControl
|
||||
{
|
||||
@@ -28,71 +31,13 @@ public
|
||||
public:
|
||||
Grapher();
|
||||
|
||||
static void RegisterDependencyProperties();
|
||||
|
||||
#pragma region GraphControl::EquationCollection ^ Equations DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ EquationsProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_equationsProperty;
|
||||
}
|
||||
}
|
||||
|
||||
property GraphControl::EquationCollection^ Equations
|
||||
{
|
||||
GraphControl::EquationCollection^ get()
|
||||
{
|
||||
return static_cast< GraphControl::EquationCollection^ >(GetValue(s_equationsProperty));
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::Foundation::Collections::IObservableMap < Platform::String ^, double> ^ Variables DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ VariablesProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_variablesProperty;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::Foundation::Collections::IObservableMap<Platform::String^, double>^ Variables
|
||||
{
|
||||
Windows::Foundation::Collections::IObservableMap<Platform::String^, double>^ get()
|
||||
{
|
||||
return static_cast<Windows::Foundation::Collections::IObservableMap<Platform::String^, double>^>(GetValue(s_variablesProperty));
|
||||
}
|
||||
|
||||
void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, double>^ value)
|
||||
{
|
||||
SetValue(s_variablesProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Windows::UI::Xaml::DataTemplate ^ ForceProportionalAxes DependencyProperty
|
||||
static property Windows::UI::Xaml::DependencyProperty^ ForceProportionalAxesTemplateProperty
|
||||
{
|
||||
Windows::UI::Xaml::DependencyProperty^ get()
|
||||
{
|
||||
return s_forceProportionalAxesTemplateProperty;
|
||||
}
|
||||
}
|
||||
|
||||
property bool ForceProportionalAxes
|
||||
{
|
||||
bool get()
|
||||
{
|
||||
return static_cast<bool>(GetValue(s_forceProportionalAxesTemplateProperty));
|
||||
}
|
||||
void set(bool value)
|
||||
{
|
||||
SetValue(s_forceProportionalAxesTemplateProperty, value);
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(Grapher);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(bool, ForceProportionalAxes, true);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(
|
||||
SINGLE_ARG(Windows::Foundation::Collections::IObservableMap<Platform::String ^, double> ^),
|
||||
Variables,
|
||||
SINGLE_ARG(ref new Platform::Collections::Map<Platform::String ^, double>()));
|
||||
DEPENDENCY_PROPERTY_R_WITH_DEFAULT_AND_CALLBACK(GraphControl::EquationCollection ^, Equations, nullptr);
|
||||
// Pass active tracing turned on or off down to the renderer
|
||||
|
||||
property bool ActiveTracing
|
||||
@@ -153,7 +98,7 @@ public
|
||||
void SetVariable(Platform::String ^ variableName, double newValue);
|
||||
Platform::String ^ ConvertToLinear(Platform::String ^ mmlString);
|
||||
void PlotGraph();
|
||||
void AnalyzeEquation(GraphControl::Equation ^ equation);
|
||||
GraphControl::KeyGraphFeaturesInfo ^ AnalyzeEquation(GraphControl::Equation ^ equation);
|
||||
|
||||
protected:
|
||||
#pragma region Control Overrides
|
||||
@@ -173,13 +118,13 @@ public
|
||||
void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ args);
|
||||
void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ args);
|
||||
|
||||
static void OnCustomDependencyPropertyChanged(Windows::UI::Xaml::DependencyObject ^ obj, Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
void OnForceProportionalAxesPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnEquationsPropertyChanged(EquationCollection ^ oldValue, EquationCollection ^ newValue);
|
||||
void OnDependencyPropertyChanged(Windows::UI::Xaml::DependencyObject ^ obj, Windows::UI::Xaml::DependencyProperty ^ p);
|
||||
|
||||
void OnEquationsChanged(Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
void OnEquationChanged(GraphControl::Equation ^ equation);
|
||||
void OnEquationStyleChanged(GraphControl::Equation ^ equation);
|
||||
void OnEquationLineEnabledChanged(GraphControl::Equation ^ equation);
|
||||
void OnEquationChanged(Equation ^ equation);
|
||||
void OnEquationStyleChanged(Equation ^ equation);
|
||||
void OnEquationLineEnabledChanged(Equation ^ equation);
|
||||
bool TryUpdateGraph();
|
||||
void TryPlotGraph(bool shouldRetry);
|
||||
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation ^>& validEqs);
|
||||
@@ -188,8 +133,6 @@ public
|
||||
std::shared_ptr<Graphing::IGraph> GetGraph(GraphControl::Equation ^ equation);
|
||||
void UpdateVariables();
|
||||
|
||||
void OnForceProportionalAxesChanged(Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
|
||||
void OnBackgroundColorChanged(const Windows::UI::Color& color);
|
||||
|
||||
void ScaleRange(double centerX, double centerY, double scale);
|
||||
@@ -222,8 +165,6 @@ public
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationLineEnabledChanged;
|
||||
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_forceProportionalAxesTemplateProperty;
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_tokenBackgroundColorChanged;
|
||||
|
||||
const std::unique_ptr<Graphing::IMathSolver> m_solver;
|
||||
|
Reference in New Issue
Block a user