Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
530f2bc
Added IGraphAnalyzer
sanderl Jul 17, 2019
e23796a
Merged with feature/GraphingCalculator
sanderl Aug 5, 2019
39809f8
Key Graph Features called and getting returned to the client. To do p…
sanderl Aug 9, 2019
e571935
Updated UpdateKeyGraphFeatures to add function analysis data to all p…
sanderl Sep 5, 2019
2c9dfef
Update KGF when variables are updated
sanderl Sep 9, 2019
900b9e8
Key graph features ui started
sanderl Sep 10, 2019
85fedd9
Merge with feature/GraphingCalculator
sanderl Sep 10, 2019
9670254
Added MathRichEditBox and started hooking up key graph features to th…
sanderl Sep 11, 2019
21948ce
Updated EquationViewModel to include parity and periodicity
sanderl Sep 12, 2019
16060bd
Updated key graph features to update the EquationViewModel
sanderl Sep 23, 2019
93dc298
merged with feature graphing calculator and updated rich edit box to …
sanderl Sep 23, 2019
024702c
updated key graph features to display more values
sanderl Sep 27, 2019
d147d0f
Key graph features populating uing MathRichEdit mode
sanderl Oct 4, 2019
25bd16b
merged with feature/GraphingCalculator
sanderl Oct 4, 2019
0f5f013
moved KeyGraphFeatures control to GraphingCalculator.xaml
sanderl Oct 4, 2019
6d42c67
Use MathML formatting instead of MathRichEdit for strings passed back…
sanderl Oct 7, 2019
b7bc9c1
cleaned up project targeting and equation.h comments
sanderl Oct 7, 2019
4cd7878
Updated equation edit box to populate for KeyGraphFeatures
sanderl Oct 9, 2019
3e7693d
Fixed vcxproj files to have the correct targeting and certificates. K…
sanderl Oct 9, 2019
ebcb14a
Updated per PR feedback
sanderl Oct 9, 2019
a0c27d5
Update MathRichEditBox to detect if the string is a mathml string and…
sanderl Oct 10, 2019
14d470b
fixed the issue where parity, periodicity and monotonicity could be s…
sanderl Oct 10, 2019
0523a7a
updated key graph features edit box to populate with the correct expr…
sanderl Oct 10, 2019
27f8a55
KGF control UI adjustments and error handling
sanderl Oct 11, 2019
b027291
Error control updates
sanderl Oct 11, 2019
cd3d63f
Error handling added when analysis fails
sanderl Oct 16, 2019
cc2b687
fixed alignment on rich edit boxes
sanderl Oct 16, 2019
243a696
Add monotonicity direction into the mathml string and only have 1 ric…
sanderl Oct 16, 2019
5cd8bd5
Set hover state on KGF EquationEditBox to change button opacity and f…
sanderl Oct 17, 2019
e7daa84
remove sideload package certificate info VS added
sanderl Oct 17, 2019
35f1ff2
updated logic for setting error strings to be in the viewmodel
sanderl Oct 18, 2019
0608945
Updated KeyGraphFeatures to populate dynamically using a ListView and…
sanderl Oct 28, 2019
9cd5d20
Update periodicity to not show if it isn't supported
sanderl Oct 29, 2019
23375b4
Fixed issue where y-intercept was using the x-intercept value
sanderl Oct 30, 2019
1dde387
Remove ItemsControl ItemsContainerStyle
sanderl Oct 30, 2019
3d60ace
Updated per pr feedback. Fixed bug where analysis error would not reset
sanderl Nov 5, 2019
49a069b
Update MathRichEdit box to remove selection when focus is lost
sanderl Nov 6, 2019
01d23a3
Updated mathrichedit to get LAF access for Dev, Release and Graphing …
sanderl Nov 7, 2019
a6c074b
Remove OnLostFocus in MathRichEdit, Change KGF ItemsControl back to L…
sanderl Nov 7, 2019
d9f02a9
Clean up styles for KGF and ensure the match the comps
sanderl Nov 8, 2019
dbb70a9
Moved formatoptions logic to the Grapher constructor and reverted Lin…
sanderl Nov 8, 2019
6cbf3f6
Add copyright header to KGF Files
sanderl Nov 11, 2019
95c37b4
fixed issue where asymptote values were not populating
sanderl Nov 12, 2019
00231a7
Disable KGF button when there is no equation. Fixed issue where equat…
sanderl Nov 12, 2019
f785e6e
Removed formatoptions testing lines used for debugging
sanderl Nov 12, 2019
55f6b1c
Merge branch 'feature/GraphingCalculator' into key-graph-features
sanderl Nov 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CalcManager/CalcManager.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0.18970.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0.19019.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down
3 changes: 2 additions & 1 deletion src/CalcViewModel/CalcViewModel.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.18970.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.19019.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
</PropertyGroup>
Expand Down Expand Up @@ -351,6 +351,7 @@
<ClInclude Include="DataLoaders\UnitConverterDataConstants.h" />
<ClInclude Include="DataLoaders\UnitConverterDataLoader.h" />
<ClInclude Include="DateCalculatorViewModel.h" />
<ClInclude Include="GraphingCalculatorEnums.h" />
<ClInclude Include="GraphingCalculator\EquationViewModel.h" />
<ClInclude Include="GraphingCalculator\GraphingCalculatorViewModel.h" />
<ClInclude Include="HistoryItemViewModel.h" />
Expand Down
3 changes: 3 additions & 0 deletions src/CalcViewModel/CalcViewModel.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
<ClInclude Include="DataLoaders\CurrencyDataLoader.h">
<Filter>DataLoaders</Filter>
</ClInclude>
<ClInclude Include="GraphingCalculatorEnums.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
312 changes: 311 additions & 1 deletion src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,324 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#include "pch.h"
#include "EquationViewModel.h"
#include "CalcViewModel\Common\LocalizationSettings.h"
#include "CalcViewModel\GraphingCalculatorEnums.h"

using namespace CalculatorApp::Common;
using namespace Graphing;
using namespace Platform;
using namespace Platform::Collections;
using namespace std;
using namespace Windows::UI;
using namespace Windows::UI::Xaml;
using namespace Windows::Foundation::Collections;

namespace CalculatorApp::ViewModel
{
GridDisplayItems::GridDisplayItems()
: m_Expression{ "" }
, m_Direction{ "" }
{
}

KeyGraphFeaturesItem::KeyGraphFeaturesItem()
: m_Title{ "" }
, m_DisplayItems{ ref new Vector<String ^>() }
, m_GridItems{ ref new Vector<GridDisplayItems ^>() }
, m_IsText{ false }
{
}

EquationViewModel::EquationViewModel()
: m_LineColor{ nullptr }, m_KeyGraphFeaturesVisibility{ ::Visibility::Collapsed }
: m_LineColor{ nullptr }
, m_Expression{ "" }
, m_IsAnalysisUpdated{ false }
, m_Domain{ "" }
, m_Range{ "" }
, m_XIntercept{ "" }
, m_YIntercept{ "" }
, m_Parity{ -1 }
, m_PeriodicityDirection{ -1 }
, m_PeriodicityExpression{ "" }
, m_Minima{ ref new Vector<String ^>() }
, m_Maxima{ ref new Vector<String ^>() }
, m_InflectionPoints{ ref new Vector<String ^>() }
, m_Monotonicity{ ref new Map<String ^, String ^>() }
, m_VerticalAsymptotes{ ref new Vector<String ^>() }
, m_HorizontalAsymptotes{ ref new Vector<String ^>() }
, m_ObliqueAsymptotes{ ref new Vector<String ^>() }
, m_TooComplexFeatures{ -1 }
, m_AnalysisError{ 0 }
, m_AnalysisErrorVisible{ false }
, m_KeyGraphFeaturesItems{ ref new Vector<KeyGraphFeaturesItem ^>() }
, m_resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() }
{
}

void EquationViewModel::OnPropertyChanged(String ^ propertyName)
{
if (propertyName == L"IsAnalysisUpdated")
{
OnIsAnalysisUpdatedChanged();
}
}

void EquationViewModel::OnIsAnalysisUpdatedChanged()
{
if (IsAnalysisUpdated)
{
if (AnalysisError != 0)
{
AnalysisErrorVisible = true;
if (AnalysisError == static_cast<int>(AnalysisErrorType::AnalysisCouldNotBePerformed))
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisCouldNotBePerformed");
}
else if (AnalysisError == static_cast<int>(AnalysisErrorType::AnalysisNotSupported))
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
}
return;
}
KeyGraphFeaturesItems->Clear();
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Domain"), Domain, m_resourceLoader->GetString(L"KGFDomainNone"));
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Range"), Range, m_resourceLoader->GetString(L"KGFRangeNone"));
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"XIntercept"), XIntercept, m_resourceLoader->GetString(L"KGFXInterceptNone"));
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"YIntercept"), YIntercept, m_resourceLoader->GetString(L"KGFYInterceptNone"));
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Minima"), Minima, m_resourceLoader->GetString(L"KGFMinimaNone"));
SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Maxima"), Maxima, m_resourceLoader->GetString(L"KGFMaximaNone"));
SetKeyGraphFeaturesItems(
m_resourceLoader->GetString(L"InflectionPoints"), InflectionPoints, m_resourceLoader->GetString(L"KGFInflectionPointsNone"));
SetKeyGraphFeaturesItems(
m_resourceLoader->GetString(L"VerticalAsymptotes"), VerticalAsymptotes, m_resourceLoader->GetString(L"KGFVerticalAsymptotesNone"));
SetKeyGraphFeaturesItems(
m_resourceLoader->GetString(L"HorizontalAsymptotes"), HorizontalAsymptotes, m_resourceLoader->GetString(L"KGFHorizontalAsymptotesNone"));
SetKeyGraphFeaturesItems(
m_resourceLoader->GetString(L"ObliqueAsymptotes"), ObliqueAsymptotes, m_resourceLoader->GetString(L"KGFObliqueAsymptotesNone"));
SetParityStringProperty();
SetPeriodicityStringProperty();
SetMonotoncityStringProperty();
SetTooComplexFeaturesErrorProperty();

AnalysisErrorVisible = false;
IsAnalysisUpdated = false;
}
}

void EquationViewModel::SetKeyGraphFeaturesItems(String ^ title, String ^ expression, String ^ errorString)
{
KeyGraphFeaturesItem ^ item = ref new KeyGraphFeaturesItem();
item->Title = title;
if (expression != L"")
{
item->DisplayItems->Append(expression);
item->IsText = false;
}
else
{
item->DisplayItems->Append(errorString);
item->IsText = true;
}
KeyGraphFeaturesItems->Append(item);
}

void EquationViewModel::SetKeyGraphFeaturesItems(String ^ title, IObservableVector<String ^> ^ expressionVector, String ^ errorString)
{
KeyGraphFeaturesItem ^ item = ref new KeyGraphFeaturesItem();
item->Title = title;
if (expressionVector->Size != 0)
{
for (auto expression : expressionVector)
{
item->DisplayItems->Append(expression);
}
item->IsText = false;
}
else
{
item->DisplayItems->Append(errorString);
item->IsText = true;
}
KeyGraphFeaturesItems->Append(item);
}

void EquationViewModel::SetParityStringProperty()
{
KeyGraphFeaturesItem ^ parityItem = ref new KeyGraphFeaturesItem();
parityItem->Title = m_resourceLoader->GetString(L"Parity");
switch (Parity)
{
case 0:
parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityUnknown"));
break;
case 1:
parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityOdd"));
break;
case 2:
parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityEven"));
break;
case 3:
parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityNeither"));
break;
default:
parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityUnknown"));

}
parityItem->IsText = true;

KeyGraphFeaturesItems->Append(parityItem);
}

void EquationViewModel::SetPeriodicityStringProperty()
{
KeyGraphFeaturesItem ^ periodicityItem = ref new KeyGraphFeaturesItem();
periodicityItem->Title = m_resourceLoader->GetString(L"Periodicity");
switch (PeriodicityDirection)
{
case 0:
// Periodicity is not supported or is too complex to calculate.
// Return out of this function without adding periodicity to KeyGraphFeatureItems.
// SetTooComplexFeaturesErrorProperty will set the too complex error when periodicity is supported and unknown
return;
case 1:
if (PeriodicityExpression == L"")
{
periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityUnknown"));
periodicityItem->IsText = true;
}
else
{
periodicityItem->DisplayItems->Append(PeriodicityExpression);
periodicityItem->IsText = false;
}
break;
case 2:
periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityNotPeriodic"));
periodicityItem->IsText = false;
break;
default:
periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityError"));
periodicityItem->IsText = true;
}

KeyGraphFeaturesItems->Append(periodicityItem);
}

void EquationViewModel::SetMonotoncityStringProperty()
{
KeyGraphFeaturesItem ^ monotonicityItem = ref new KeyGraphFeaturesItem();
monotonicityItem->Title = m_resourceLoader->GetString(L"Monotonicity");
if (Monotonicity->Size != 0)
{
for (auto item : Monotonicity)
{
GridDisplayItems ^ gridItem = ref new GridDisplayItems();
gridItem->Expression = item->Key;

auto monotonicityType = item->Value->Data();
switch (*monotonicityType)
{
case '0':
gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityUnknown");
break;
case '1':
gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityIncreasing");
break;
case '2':
gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityDecreasing");
break;
case '3':
gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityConstant");
break;
default:
gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityError");
break;
}

monotonicityItem->GridItems->Append(gridItem);
}
monotonicityItem->IsText = false;
}
else
{
monotonicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFMonotonicityError"));
monotonicityItem->IsText = true;
}

KeyGraphFeaturesItems->Append(monotonicityItem);
}

void EquationViewModel::SetTooComplexFeaturesErrorProperty()
{
if (TooComplexFeatures <= 0)
{
return;
}

Platform::String ^ separator = ref new String(LocalizationSettings::GetInstance().GetListSeparator().c_str());

wstring error;
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Domain) == KeyGraphFeaturesFlag::Domain)
{
error.append((m_resourceLoader->GetString(L"Domain") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Range) == KeyGraphFeaturesFlag::Range)
{
error.append((m_resourceLoader->GetString(L"Range") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Zeros) == KeyGraphFeaturesFlag::Zeros)
{
error.append((m_resourceLoader->GetString(L"XIntercept") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::YIntercept) == KeyGraphFeaturesFlag::YIntercept)
{
error.append((m_resourceLoader->GetString(L"YIntercept") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Parity) == KeyGraphFeaturesFlag::Parity)
{
error.append((m_resourceLoader->GetString(L"Parity") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Periodicity) == KeyGraphFeaturesFlag::Periodicity)
{
error.append((m_resourceLoader->GetString(L"Periodicity") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Minima) == KeyGraphFeaturesFlag::Minima)
{
error.append((m_resourceLoader->GetString(L"Minima") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::Maxima) == KeyGraphFeaturesFlag::Maxima)
{
error.append((m_resourceLoader->GetString(L"Maxima") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::InflectionPoints) == KeyGraphFeaturesFlag::InflectionPoints)
{
error.append((m_resourceLoader->GetString(L"InflectionPoints") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::VerticalAsymptotes) == KeyGraphFeaturesFlag::VerticalAsymptotes)
{
error.append((m_resourceLoader->GetString(L"VerticalAsymptotes") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::HorizontalAsymptotes) == KeyGraphFeaturesFlag::HorizontalAsymptotes)
{
error.append((m_resourceLoader->GetString(L"HorizontalAsymptotes") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::ObliqueAsymptotes) == KeyGraphFeaturesFlag::ObliqueAsymptotes)
{
error.append((m_resourceLoader->GetString(L"ObliqueAsymptotes") + separator + L" ")->Data());
}
if ((TooComplexFeatures & KeyGraphFeaturesFlag::MonotoneIntervals) == KeyGraphFeaturesFlag::MonotoneIntervals)
{
error.append((m_resourceLoader->GetString(L"Monotonicity") + separator + L" ")->Data());
}

KeyGraphFeaturesItem ^ tooComplexItem = ref new KeyGraphFeaturesItem();
tooComplexItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFTooComplexFeaturesError"));
tooComplexItem->DisplayItems->Append(ref new String(error.substr(0, (error.length() - (separator->Length() + 1))).c_str()));
tooComplexItem->IsText = true;

KeyGraphFeaturesItems->Append(tooComplexItem);
}

}
Loading