Allow line style to be changed (#1097)

* add line style

* start line style

* More fixes

* undo key

* more tweaks

* address comments

* Fix merge
This commit is contained in:
Pepe Rivera 2020-03-27 09:56:11 -07:00 committed by GitHub
parent 7dcfe0439c
commit fec7c907f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 383 additions and 92 deletions

View File

@ -45,7 +45,8 @@ namespace CalculatorApp
public enum class LineStyleType public enum class LineStyleType
{ {
Color Color,
Pattern
}; };
public ref class TraceLogger sealed public ref class TraceLogger sealed

View File

@ -5,87 +5,118 @@
xmlns:local="using:CalculatorApp" xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> mc:Ignorable="d">
<StackPanel>
<GridView x:Name="ColorChooser"
ItemsSource="{x:Bind AvailableColors}"
Loaded="ColorChooserLoaded"
SelectionChanged="SelectionChanged"
SingleSelectionFollowsFocus="False">
<GridView.Resources>
<Style TargetType="GridViewItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="MinHeight" Value="52"/>
<Setter Property="MinWidth" Value="52"/>
<Setter Property="Height" Value="52"/>
<Setter Property="Width" Value="52"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridViewItem">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/>
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/>
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderPressedThemeBrush}"/>
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="ItemContent.Margin" Value="2,2,2,2"/>
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderSelectedThemeBrush}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ItemBorder"
Margin="6,6,6,6"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="Transparent"
Stroke="Transparent"
StrokeThickness="2"
UseLayoutRounding="false"/>
<ContentPresenter x:Name="ItemContent" UseLayoutRounding="false"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GridView.Resources>
<GridView.Header>
<TextBlock x:Uid="LineColorText" Margin="8,0,8,8"/>
</GridView.Header>
<GridView.ItemTemplate>
<DataTemplate x:DataType="Brush">
<Ellipse Margin="8,8,8,8"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="{x:Bind}"
StrokeThickness="0"
AutomationProperties.Name="{x:Bind local:EquationStylePanelControl.GetColorAutomationName((Brush))}"
UseLayoutRounding="false"/>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="7" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
<GridView x:Name="ColorChooser" <ComboBox x:Name="StyleChooserBox"
ItemsSource="{x:Bind AvailableColors}" x:Uid="StyleChooserBox"
Loaded="ColorChooserLoaded" MinWidth="200"
SelectionChanged="SelectionChanged" Margin="8,0"
SingleSelectionFollowsFocus="False"> Loaded="StyleChooserBox_Loaded"
<GridView.ItemContainerStyle> SelectedItem="{x:Bind SelectedStyle}"
<Style TargetType="GridViewItem"> SelectionChanged="StyleChooserBox_SelectionChanged"
<Setter Property="Margin" Value="0"/> Visibility="Visible"
<Setter Property="Padding" Value="0"/> IsEnabled="{x:Bind EnableLineStylePicker}">
<Setter Property="MinHeight" Value="52"/> <ComboBox.ItemTemplate>
<Setter Property="MinWidth" Value="52"/> <!-- Set x:DataType to be Platform::Object so that we can pass it to the x:Bind function directly since we cannot pass an enum in c++/cx -->
<Setter Property="Height" Value="52"/> <DataTemplate x:DataType="x:Object">
<Setter Property="Width" Value="52"/> <Grid x:Name="LineGrid"
<Setter Property="HorizontalContentAlignment" Value="Center"/> Height="20"
<Setter Property="VerticalContentAlignment" Value="Center"/> MaxWidth="200"
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}"/> AutomationProperties.Name="{x:Bind local:EquationStylePanelControl.GetLineAutomationName((x:Object))}">
<Setter Property="Template"> <Line VerticalAlignment="Center"
<Setter.Value> Stroke="{ThemeResource AppControlPageTextBaseHighColorBrush}"
<ControlTemplate TargetType="GridViewItem"> StrokeThickness="2.5"
<Grid> StrokeDashArray="{x:Bind local:EquationStylePanelControl.GetLinePattern((x:Object))}"
<VisualStateManager.VisualStateGroups> X1="0"
<VisualStateGroup x:Name="CommonStates"> X2="200"
<VisualState x:Name="Normal"/> Y1="4"
<VisualState x:Name="PointerOver"> Y2="4"/>
<VisualState.Setters> </Grid>
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/> </DataTemplate>
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/> </ComboBox.ItemTemplate>
</VisualState.Setters> </ComboBox>
</VisualState> </StackPanel>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="ItemContent.Margin" Value="-2,-2,-2,-2"/>
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderPressedThemeBrush}"/>
<Setter Target="ItemBorder.Margin" Value="2,2,2,2"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="ItemContent.Margin" Value="2,2,2,2"/>
<Setter Target="ItemBorder.Stroke" Value="{ThemeResource InkToolbarFlyoutItemBorderSelectedThemeBrush}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ItemBorder"
Margin="6,6,6,6"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="Transparent"
Stroke="Transparent"
StrokeThickness="2"
UseLayoutRounding="false"/>
<ContentPresenter x:Name="ItemContent" UseLayoutRounding="false"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GridView.ItemContainerStyle>
<GridView.Header>
<TextBlock x:Uid="LineColorText" Margin="8,0,8,8"/>
</GridView.Header>
<GridView.ItemTemplate>
<DataTemplate x:DataType="Brush">
<Ellipse Margin="8,8,8,8"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Fill="{x:Bind}"
StrokeThickness="0"
UseLayoutRounding="false"/>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="7" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</UserControl> </UserControl>

View File

@ -3,6 +3,7 @@
#include "pch.h" #include "pch.h"
#include "EquationStylePanelControl.xaml.h" #include "EquationStylePanelControl.xaml.h"
#include "CalcViewModel/Common/AppResourceProvider.h"
using namespace CalculatorApp; using namespace CalculatorApp;
@ -19,13 +20,23 @@ using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation; using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::Xaml::Shapes; using namespace Windows::UI::Xaml::Shapes;
using namespace GraphControl;
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedColor); DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedColor);
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, SelectedStyle);
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, EnableLineStylePicker);
DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, AvailableColors); DEPENDENCY_PROPERTY_INITIALIZATION(EquationStylePanelControl, AvailableColors);
EquationStylePanelControl::EquationStylePanelControl() EquationStylePanelControl::EquationStylePanelControl()
{ {
InitializeComponent(); InitializeComponent();
auto allStyles = ref new Vector<EquationLineStyle>();
allStyles->Append(::EquationLineStyle::Solid);
allStyles->Append(::EquationLineStyle::Dash);
allStyles->Append(::EquationLineStyle::Dot);
StyleChooserBox->ItemsSource = allStyles;
} }
void EquationStylePanelControl::SelectionChanged(Object ^ /*sender */, SelectionChangedEventArgs ^ e) 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<EquationLineStyle>(item);
auto comboBoxItem = dynamic_cast<ComboBoxItem ^>(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<EquationLineStyle>(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<SolidColorBrush ^>(brush);
if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush1")))
{
return resourceLoader->GetResourceString("equationColor1AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush2")))
{
return resourceLoader->GetResourceString("equationColor2AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush3")))
{
return resourceLoader->GetResourceString("equationColor3AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush4")))
{
return resourceLoader->GetResourceString("equationColor4AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush5")))
{
return resourceLoader->GetResourceString("equationColor5AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush6")))
{
return resourceLoader->GetResourceString("equationColor6AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush7")))
{
return resourceLoader->GetResourceString("equationColor7AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush8")))
{
return resourceLoader->GetResourceString("equationColor8AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush9")))
{
return resourceLoader->GetResourceString("equationColor9AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush10")))
{
return resourceLoader->GetResourceString("equationColor10AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush11")))
{
return resourceLoader->GetResourceString("equationColor11AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup(L"EquationBrush12")))
{
return resourceLoader->GetResourceString("equationColor12AutomationName");
}
else if (color == safe_cast<SolidColorBrush ^>(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<Box<EquationLineStyle> ^>(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<Box<EquationLineStyle> ^>(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;
}

View File

@ -16,7 +16,13 @@ namespace CalculatorApp
DEPENDENCY_PROPERTY_OWNER(EquationStylePanelControl); DEPENDENCY_PROPERTY_OWNER(EquationStylePanelControl);
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, SelectedColor, Windows::UI::Colors::Black); 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<Windows::UI::Xaml::Media::SolidColorBrush ^> ^, AvailableColors, nullptr); DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Media::SolidColorBrush ^> ^, 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: private:
void SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e); void SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
@ -25,5 +31,9 @@ namespace CalculatorApp
Platform::Object ^ sender, Platform::Object ^ sender,
Windows::UI::Xaml::RoutedEventArgs ^ e); Windows::UI::Xaml::RoutedEventArgs ^ e);
void SelectColor(Windows::UI::Color selectedColor); 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);
}; };
} }

View File

@ -3944,9 +3944,13 @@
<comment>Label text for the max text box</comment> <comment>Label text for the max text box</comment>
</data> </data>
<data name="LineColorText.Text" xml:space="preserve"> <data name="LineColorText.Text" xml:space="preserve">
<value>Line Color</value> <value>Color</value>
<comment>Label for the Line Color section of the style picker</comment> <comment>Label for the Line Color section of the style picker</comment>
</data> </data>
<data name="StyleChooserBox.Header" xml:space="preserve">
<value>Style</value>
<comment>Label for the Line Style section of the style picker</comment>
</data>
<data name="KeyGraphFeaturesLabel.Text" xml:space="preserve"> <data name="KeyGraphFeaturesLabel.Text" xml:space="preserve">
<value>Function analysis</value> <value>Function analysis</value>
<comment>Title for KeyGraphFeatures Control</comment> <comment>Title for KeyGraphFeatures Control</comment>
@ -4462,4 +4466,72 @@
<value>Select All</value> <value>Select All</value>
<comment>Select all menu item from the Equation TextBox</comment> <comment>Select all menu item from the Equation TextBox</comment>
</data> </data>
<data name="solidLineStyleAutomationName" xml:space="preserve">
<value>Solid line style</value>
<comment>Name of the solid line style for a graphed equation</comment>
</data>
<data name="dotLineStyleAutomationName" xml:space="preserve">
<value>Dot line style</value>
<comment>Name of the dotted line style for a graphed equation</comment>
</data>
<data name="dashLineStyleAutomationName" xml:space="preserve">
<value>Dash line style</value>
<comment>Name of the dashed line style for a graphed equation</comment>
</data>
<data name="equationColor1AutomationName" xml:space="preserve">
<value>Navy Blue</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor2AutomationName" xml:space="preserve">
<value>Seafoam</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor3AutomationName" xml:space="preserve">
<value>Violet</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor4AutomationName" xml:space="preserve">
<value>Green</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor5AutomationName" xml:space="preserve">
<value>Mint Green</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor6AutomationName" xml:space="preserve">
<value>Dark Green</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor7AutomationName" xml:space="preserve">
<value>Charcoal</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor8AutomationName" xml:space="preserve">
<value>Red</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor9AutomationName" xml:space="preserve">
<value>Plum Light</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor10AutomationName" xml:space="preserve">
<value>Magenta</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor11AutomationName" xml:space="preserve">
<value>Yellow Gold</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor12AutomationName" xml:space="preserve">
<value>Orange Bright</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor13AutomationName" xml:space="preserve">
<value>Brown</value>
<comment>Name of color in the color picker</comment>
</data>
<data name="equationColor14AutomationName" xml:space="preserve">
<value>Black</value>
<comment>Name of color in the color picker</comment>
</data>
</root> </root>

View File

@ -848,7 +848,9 @@
RemoveButtonClicked="EquationTextBox_RemoveButtonClicked"> RemoveButtonClicked="EquationTextBox_RemoveButtonClicked">
<controls:EquationTextBox.ColorChooserFlyout> <controls:EquationTextBox.ColorChooserFlyout>
<Flyout x:Uid="ColorChooserFlyout" Placement="Bottom"> <Flyout x:Uid="ColorChooserFlyout" Placement="Bottom">
<local:EquationStylePanelControl SelectedColor="{x:Bind LineColor, Mode=TwoWay}"/> <local:EquationStylePanelControl EnableLineStylePicker="{x:Bind GraphEquation.IsInequality, Converter={StaticResource BooleanNegationConverter}, Mode=OneWay}"
SelectedColor="{x:Bind LineColor, Mode=TwoWay}"
SelectedStyle="{x:Bind GraphEquation.EquationStyle, Mode=TwoWay}"/>
</Flyout> </Flyout>
</controls:EquationTextBox.ColorChooserFlyout> </controls:EquationTextBox.ColorChooserFlyout>
</controls:EquationTextBox> </controls:EquationTextBox>

View File

@ -558,13 +558,14 @@ namespace GraphControl
auto lineColor = eq->LineColor; auto lineColor = eq->LineColor;
graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A); graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A);
if (eq->GraphedEquation) if (eq->GraphedEquation)
{ {
if (!eq->HasGraphError && eq->IsSelected) if (!eq->HasGraphError && eq->IsSelected)
{ {
eq->GraphedEquation->TrySelectEquation(); eq->GraphedEquation->TrySelectEquation();
} }
eq->GraphedEquation->GetGraphEquationOptions()->SetLineStyle(static_cast<::Graphing::Renderer::LineStyle>(eq->EquationStyle));
eq->GraphedEquation->GetGraphEquationOptions()->SetLineWidth(LineWidth); eq->GraphedEquation->GetGraphEquationOptions()->SetLineWidth(LineWidth);
eq->GraphedEquation->GetGraphEquationOptions()->SetSelectedEquationLineWidth(LineWidth + ((LineWidth <= 2) ? 1 : 2)); eq->GraphedEquation->GetGraphEquationOptions()->SetSelectedEquationLineWidth(LineWidth + ((LineWidth <= 2) ? 1 : 2));
} }

View File

@ -26,6 +26,7 @@ namespace GraphControl
{ {
wstring request; wstring request;
wstring_view expr{ Expression->Data() }; 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. // Check for unicode characters of less than, less than or equal to, greater than and greater than or equal to.
if (expr.find(L">&#x3E;<") != wstring_view::npos || expr.find(L">&#x3C;<") != wstring_view::npos || expr.find(L">&#x2265;<") != wstring_view::npos if (expr.find(L">&#x3E;<") != wstring_view::npos || expr.find(L">&#x3C;<") != wstring_view::npos || expr.find(L">&#x2265;<") != wstring_view::npos
@ -33,6 +34,8 @@ namespace GraphControl
|| expr.find(L">&lt;<") != wstring_view::npos || expr.find(L">&gt;<") != wstring_view::npos) || expr.find(L">&lt;<") != wstring_view::npos || expr.find(L">&gt;<") != wstring_view::npos)
{ {
request = L"<mrow><mi>plotIneq2D</mi><mfenced separators=\"\">"; request = L"<mrow><mi>plotIneq2D</mi><mfenced separators=\"\">";
IsInequality = true;
EquationStyle = EquationLineStyle::Dash;
} }
else if (expr.find(L">=<") != wstring_view::npos) else if (expr.find(L">=<") != wstring_view::npos)
{ {

View File

@ -7,6 +7,16 @@
namespace GraphControl namespace GraphControl
{ {
public
enum class EquationLineStyle : int
{
Solid,
Dot,
Dash,
DashDot,
DashDotDot
};
public enum class ErrorType public enum class ErrorType
{ {
Evaluation, Evaluation,
@ -211,7 +221,9 @@ namespace GraphControl
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsLineEnabled); OBSERVABLE_NAMED_PROPERTY_RW(bool, IsLineEnabled);
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsValidated); OBSERVABLE_NAMED_PROPERTY_RW(bool, IsValidated);
OBSERVABLE_NAMED_PROPERTY_RW(bool, HasGraphError); OBSERVABLE_NAMED_PROPERTY_RW(bool, HasGraphError);
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsInequality);
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsSelected); OBSERVABLE_NAMED_PROPERTY_RW(bool, IsSelected);
OBSERVABLE_NAMED_PROPERTY_RW(EquationLineStyle, EquationStyle);
OBSERVABLE_NAMED_PROPERTY_RW(ErrorType, GraphErrorType); OBSERVABLE_NAMED_PROPERTY_RW(ErrorType, GraphErrorType);
OBSERVABLE_NAMED_PROPERTY_RW(int, GraphErrorCode); OBSERVABLE_NAMED_PROPERTY_RW(int, GraphErrorCode);
@ -221,12 +233,10 @@ namespace GraphControl
void set(Windows::UI::Color value); void set(Windows::UI::Color value);
} }
static property Platform::String static property Platform::String ^ LineColorPropertyName { Platform::String ^ get(); }
^ LineColorPropertyName { Platform::String ^ get(); }
public : Platform::String
^ GetRequest();
public:
Platform::String ^ GetRequest();
bool IsGraphableEquation(); bool IsGraphableEquation();
internal: internal:

View File

@ -158,7 +158,7 @@ public
{ {
auto equation = static_cast<Equation ^>(sender); auto equation = static_cast<Equation ^>(sender);
auto propertyName = args->PropertyName; 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); EquationStyleChanged(equation);
} }