diff --git a/src/CalcViewModel/Common/TraceLogger.h b/src/CalcViewModel/Common/TraceLogger.h
index 37e4b2b..4a32ebe 100644
--- a/src/CalcViewModel/Common/TraceLogger.h
+++ b/src/CalcViewModel/Common/TraceLogger.h
@@ -45,7 +45,8 @@ namespace CalculatorApp
public enum class LineStyleType
{
- Color
+ Color,
+ Pattern
};
public ref class TraceLogger sealed
diff --git a/src/Calculator/EquationStylePanelControl.xaml b/src/Calculator/EquationStylePanelControl.xaml
index 8eaf5b0..c9112cf 100644
--- a/src/Calculator/EquationStylePanelControl.xaml
+++ b/src/Calculator/EquationStylePanelControl.xaml
@@ -5,87 +5,118 @@
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Calculator/EquationStylePanelControl.xaml.cpp b/src/Calculator/EquationStylePanelControl.xaml.cpp
index f35861b..bea8698 100644
--- a/src/Calculator/EquationStylePanelControl.xaml.cpp
+++ b/src/Calculator/EquationStylePanelControl.xaml.cpp
@@ -3,6 +3,7 @@
#include "pch.h"
#include "EquationStylePanelControl.xaml.h"
+#include "CalcViewModel/Common/AppResourceProvider.h"
using namespace CalculatorApp;
@@ -19,13 +20,23 @@ using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Shapes;
+using namespace GraphControl;
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedColor);
+DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedStyle);
+DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, EnableLineStylePicker);
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, AvailableColors);
EquationStylePanelControl::EquationStylePanelControl()
{
InitializeComponent();
+
+ auto allStyles = ref new Vector();
+ allStyles->Append(::EquationLineStyle::Solid);
+ allStyles->Append(::EquationLineStyle::Dash);
+ allStyles->Append(::EquationLineStyle::Dot);
+
+ StyleChooserBox->ItemsSource = allStyles;
}
void EquationStylePanelControl::SelectionChanged(Object ^ /*sender */, SelectionChangedEventArgs ^ e)
@@ -79,3 +90,153 @@ void EquationStylePanelControl::SelectColor(Color selectedColor)
}
}
}
+
+void EquationStylePanelControl::OnSelectedStylePropertyChanged(EquationLineStyle oldStyle, EquationLineStyle newStyle)
+{
+ if (oldStyle != newStyle)
+ {
+ SelectStyle(newStyle);
+ TraceLogger::GetInstance()->LogGraphLineStyleChanged(LineStyleType::Pattern);
+ }
+}
+
+void EquationStylePanelControl::SelectStyle(EquationLineStyle selectedStyle)
+{
+ for (auto item : StyleChooserBox->Items->GetView())
+ {
+ auto style = static_cast(item);
+ auto comboBoxItem = dynamic_cast(StyleChooserBox->ContainerFromItem(style));
+
+ if (!comboBoxItem)
+ {
+ continue;
+ }
+
+ if (style == selectedStyle)
+ {
+ comboBoxItem->IsSelected = true;
+ return;
+ }
+ else
+ {
+ comboBoxItem->IsSelected = false;
+ }
+ }
+}
+
+void EquationStylePanelControl::StyleChooserBox_SelectionChanged(Object ^ sender, SelectionChangedEventArgs ^ e)
+{
+ if (e->AddedItems->Size > 0)
+ {
+ SelectedStyle = static_cast(e->AddedItems->GetAt(0));
+ }
+}
+
+void EquationStylePanelControl::StyleChooserBox_Loaded(Object ^ sender, RoutedEventArgs ^ e)
+{
+ SelectStyle(SelectedStyle);
+}
+
+String ^ EquationStylePanelControl::GetColorAutomationName(Brush ^ brush)
+{
+ auto resourceLoader = AppResourceProvider::GetInstance();
+ auto color = static_cast(brush);
+
+ if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush1")))
+ {
+ return resourceLoader->GetResourceString("equationColor1AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush2")))
+ {
+ return resourceLoader->GetResourceString("equationColor2AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush3")))
+ {
+ return resourceLoader->GetResourceString("equationColor3AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush4")))
+ {
+ return resourceLoader->GetResourceString("equationColor4AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush5")))
+ {
+ return resourceLoader->GetResourceString("equationColor5AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush6")))
+ {
+ return resourceLoader->GetResourceString("equationColor6AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush7")))
+ {
+ return resourceLoader->GetResourceString("equationColor7AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush8")))
+ {
+ return resourceLoader->GetResourceString("equationColor8AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush9")))
+ {
+ return resourceLoader->GetResourceString("equationColor9AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush10")))
+ {
+ return resourceLoader->GetResourceString("equationColor10AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush11")))
+ {
+ return resourceLoader->GetResourceString("equationColor11AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush12")))
+ {
+ return resourceLoader->GetResourceString("equationColor12AutomationName");
+ }
+ else if (color == safe_cast(Application::Current->Resources->Lookup(L"EquationBrush13")))
+ {
+ return resourceLoader->GetResourceString("equationColor13AutomationName");
+ }
+ else
+ {
+ return resourceLoader->GetResourceString("equationColor14AutomationName");
+ }
+}
+
+String ^ EquationStylePanelControl::GetLineAutomationName(Object ^ line)
+{
+ auto resourceLoader = AppResourceProvider::GetInstance();
+ auto lineStyle = static_cast ^>(line)->Value;
+
+ switch (lineStyle)
+ {
+ case ::EquationLineStyle::Dot:
+ return resourceLoader->GetResourceString("dotLineStyleAutomationName");
+ break;
+ case ::EquationLineStyle::Dash:
+ return resourceLoader->GetResourceString("dashLineStyleAutomationName");
+ break;
+ case ::EquationLineStyle::Solid:
+ default:
+ return resourceLoader->GetResourceString("solidLineStyleAutomationName");
+ break;
+ }
+}
+
+DoubleCollection ^ EquationStylePanelControl::GetLinePattern(Object ^ line)
+{
+ auto lineStyle = static_cast ^>(line)->Value;
+
+ auto linePattern = ref new DoubleCollection();
+ switch (lineStyle)
+ {
+ case ::EquationLineStyle::Dot:
+ linePattern->Append(1);
+ break;
+ case ::EquationLineStyle::Dash:
+ linePattern->Append(2);
+ linePattern->Append(1);
+ break;
+ default:
+ break;
+ }
+
+ return linePattern;
+}
diff --git a/src/Calculator/EquationStylePanelControl.xaml.h b/src/Calculator/EquationStylePanelControl.xaml.h
index 4876e7b..3753ac3 100644
--- a/src/Calculator/EquationStylePanelControl.xaml.h
+++ b/src/Calculator/EquationStylePanelControl.xaml.h
@@ -16,7 +16,13 @@ namespace CalculatorApp
DEPENDENCY_PROPERTY_OWNER(EquationStylePanelControl);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, SelectedColor, Windows::UI::Colors::Black);
+ DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(GraphControl::EquationLineStyle, SelectedStyle, GraphControl::EquationLineStyle::Solid);
DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IVector ^, AvailableColors, nullptr);
+ DEPENDENCY_PROPERTY(bool, EnableLineStylePicker);
+
+ static Windows::UI::Xaml::Media::DoubleCollection ^ GetLinePattern(Platform::Object ^ line);
+ static Platform::String ^ GetLineAutomationName(Platform::Object ^ line);
+ static Platform::String ^ GetColorAutomationName(Windows::UI::Xaml::Media::Brush ^ color);
private:
void SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
@@ -25,5 +31,9 @@ namespace CalculatorApp
Platform::Object ^ sender,
Windows::UI::Xaml::RoutedEventArgs ^ e);
void SelectColor(Windows::UI::Color selectedColor);
+ void OnSelectedStylePropertyChanged(GraphControl::EquationLineStyle oldStyle, GraphControl::EquationLineStyle newStyle);
+ void SelectStyle(GraphControl::EquationLineStyle selectedStyle);
+ void StyleChooserBox_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
+ void StyleChooserBox_Loaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
};
}
diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw
index c7e8d92..0b0795c 100644
--- a/src/Calculator/Resources/en-US/Resources.resw
+++ b/src/Calculator/Resources/en-US/Resources.resw
@@ -3944,9 +3944,13 @@
Label text for the max text box
- Line Color
+ Color
Label for the Line Color section of the style picker
+
+ Style
+ Label for the Line Style section of the style picker
+
Function analysis
Title for KeyGraphFeatures Control
@@ -4462,4 +4466,72 @@
Select All
Select all menu item from the Equation TextBox
+
+ Solid line style
+ Name of the solid line style for a graphed equation
+
+
+ Dot line style
+ Name of the dotted line style for a graphed equation
+
+
+ Dash line style
+ Name of the dashed line style for a graphed equation
+
+
+ Navy Blue
+ Name of color in the color picker
+
+
+ Seafoam
+ Name of color in the color picker
+
+
+ Violet
+ Name of color in the color picker
+
+
+ Green
+ Name of color in the color picker
+
+
+ Mint Green
+ Name of color in the color picker
+
+
+ Dark Green
+ Name of color in the color picker
+
+
+ Charcoal
+ Name of color in the color picker
+
+
+ Red
+ Name of color in the color picker
+
+
+ Plum Light
+ Name of color in the color picker
+
+
+ Magenta
+ Name of color in the color picker
+
+
+ Yellow Gold
+ Name of color in the color picker
+
+
+ Orange Bright
+ Name of color in the color picker
+
+
+ Brown
+ Name of color in the color picker
+
+
+ Black
+ Name of color in the color picker
+
diff --git a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml
index c3a0cc3..ec7274f 100644
--- a/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml
+++ b/src/Calculator/Views/GraphingCalculator/EquationInputArea.xaml
@@ -848,7 +848,9 @@
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
-
+
diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp
index a0e3823..562fc63 100644
--- a/src/GraphControl/Control/Grapher.cpp
+++ b/src/GraphControl/Control/Grapher.cpp
@@ -558,13 +558,14 @@ namespace GraphControl
auto lineColor = eq->LineColor;
graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A);
- if (eq->GraphedEquation)
+ if (eq->GraphedEquation)
{
if (!eq->HasGraphError && eq->IsSelected)
{
eq->GraphedEquation->TrySelectEquation();
}
+ eq->GraphedEquation->GetGraphEquationOptions()->SetLineStyle(static_cast<::Graphing::Renderer::LineStyle>(eq->EquationStyle));
eq->GraphedEquation->GetGraphEquationOptions()->SetLineWidth(LineWidth);
eq->GraphedEquation->GetGraphEquationOptions()->SetSelectedEquationLineWidth(LineWidth + ((LineWidth <= 2) ? 1 : 2));
}
diff --git a/src/GraphControl/Models/Equation.cpp b/src/GraphControl/Models/Equation.cpp
index 5446876..32ae6db 100644
--- a/src/GraphControl/Models/Equation.cpp
+++ b/src/GraphControl/Models/Equation.cpp
@@ -26,6 +26,7 @@ namespace GraphControl
{
wstring request;
wstring_view expr{ Expression->Data() };
+ IsInequality = false;
// 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_view::npos || expr.find(L"><<") != wstring_view::npos || expr.find(L">≥<") != wstring_view::npos
@@ -33,6 +34,8 @@ namespace GraphControl
|| expr.find(L"><<") != wstring_view::npos || expr.find(L">><") != wstring_view::npos)
{
request = L"plotIneq2D";
+ IsInequality = true;
+ EquationStyle = EquationLineStyle::Dash;
}
else if (expr.find(L">=<") != wstring_view::npos)
{
diff --git a/src/GraphControl/Models/Equation.h b/src/GraphControl/Models/Equation.h
index 03b847b..da5c50c 100644
--- a/src/GraphControl/Models/Equation.h
+++ b/src/GraphControl/Models/Equation.h
@@ -7,6 +7,16 @@
namespace GraphControl
{
+public
+ enum class EquationLineStyle : int
+ {
+ Solid,
+ Dot,
+ Dash,
+ DashDot,
+ DashDotDot
+ };
+
public enum class ErrorType
{
Evaluation,
@@ -211,7 +221,9 @@ namespace GraphControl
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsLineEnabled);
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsValidated);
OBSERVABLE_NAMED_PROPERTY_RW(bool, HasGraphError);
+ OBSERVABLE_NAMED_PROPERTY_RW(bool, IsInequality);
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsSelected);
+ OBSERVABLE_NAMED_PROPERTY_RW(EquationLineStyle, EquationStyle);
OBSERVABLE_NAMED_PROPERTY_RW(ErrorType, GraphErrorType);
OBSERVABLE_NAMED_PROPERTY_RW(int, GraphErrorCode);
@@ -221,12 +233,10 @@ namespace GraphControl
void set(Windows::UI::Color value);
}
- static property Platform::String
- ^ LineColorPropertyName { Platform::String ^ get(); }
-
- public : Platform::String
- ^ GetRequest();
+ static property Platform::String ^ LineColorPropertyName { Platform::String ^ get(); }
+ public:
+ Platform::String ^ GetRequest();
bool IsGraphableEquation();
internal:
diff --git a/src/GraphControl/Models/EquationCollection.h b/src/GraphControl/Models/EquationCollection.h
index ad5c9c8..59b9cdb 100644
--- a/src/GraphControl/Models/EquationCollection.h
+++ b/src/GraphControl/Models/EquationCollection.h
@@ -158,7 +158,7 @@ public
{
auto equation = static_cast(sender);
auto propertyName = args->PropertyName;
- if (propertyName == GraphControl::Equation::LineColorPropertyName || propertyName == GraphControl::Equation::IsSelectedPropertyName)
+ if (propertyName == GraphControl::Equation::LineColorPropertyName || propertyName == GraphControl::Equation::IsSelectedPropertyName || propertyName == GraphControl::Equation::EquationStylePropertyName)
{
EquationStyleChanged(equation);
}