Equation button updates: Enable/Disable on click, button content f1, f2, f3..., visibility icon on hover (#804)
* Added enable/disable line functionality * Update EquationTextBox to change the opacity of functions have are not visible. Update the function label for the EquationTextBox to increment the label to show f1, f2, f3, etc * rebase key-graph-features and fix issue where removing an equation box and adding a new one repopulates the previous equation * Added visibility icon for the equation button hover * updated EquationButton to be a toggle button to better handle the LineHidden state and other PR comment fixes. * Updated EquationButton style to use a toggle button and to have placeholder icons for the show/hide states * Updated equation button after pulling the refactor work into the branch. Fixed the Equation Button in KGF UI * Fixed Pepe's bugs * Uncomment temporary.pfx in calculator.vcxproj
This commit is contained in:
@@ -23,7 +23,10 @@ namespace GraphControl
|
||||
DependencyProperty ^ Equation::s_lineColorProperty;
|
||||
static constexpr auto s_propertyName_LineColor = L"LineColor";
|
||||
|
||||
DependencyProperty ^ Equation::s_xInterceptProperty;
|
||||
DependencyProperty ^ Equation::s_isLineEnabledProperty;
|
||||
static constexpr auto s_propertyName_IsLineEnabled = L"IsLineEnabled";
|
||||
|
||||
DependencyProperty ^ Equation::s_xInterceptProperty;
|
||||
static constexpr auto s_propertyName_XIntercept = L"XIntercept";
|
||||
|
||||
DependencyProperty ^ Equation::s_yInterceptProperty;
|
||||
@@ -75,6 +78,7 @@ namespace GraphControl
|
||||
{
|
||||
String ^ Expression = StringReference(s_propertyName_Expression);
|
||||
String ^ LineColor = StringReference(s_propertyName_LineColor);
|
||||
String ^ IsLineEnabled = StringReference(s_propertyName_IsLineEnabled);
|
||||
String ^ XIntercept = StringReference(s_propertyName_XIntercept);
|
||||
String ^ YIntercept = StringReference(s_propertyName_YIntercept);
|
||||
String ^ Parity = StringReference(s_propertyName_Parity);
|
||||
@@ -116,6 +120,15 @@ namespace GraphControl
|
||||
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_xInterceptProperty)
|
||||
{
|
||||
s_xInterceptProperty = DependencyProperty::Register(
|
||||
@@ -273,6 +286,10 @@ namespace GraphControl
|
||||
{
|
||||
propertyName = EquationProperties::LineColor;
|
||||
}
|
||||
else if (args->Property == s_isLineEnabledProperty)
|
||||
{
|
||||
propertyName = EquationProperties::IsLineEnabled;
|
||||
}
|
||||
else if (args->Property == s_xInterceptProperty)
|
||||
{
|
||||
propertyName = EquationProperties::XIntercept;
|
||||
|
@@ -9,6 +9,7 @@ namespace GraphControl
|
||||
{
|
||||
extern Platform::String ^ Expression;
|
||||
extern Platform::String ^ LineColor;
|
||||
extern Platform::String ^ IsLineEnabled;
|
||||
}
|
||||
|
||||
ref class Equation;
|
||||
@@ -68,6 +69,28 @@ namespace GraphControl
|
||||
}
|
||||
#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 Key Graph Features
|
||||
|
||||
|
||||
@@ -422,6 +445,7 @@ namespace GraphControl
|
||||
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_xInterceptProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_yInterceptProperty;
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_parityProperty;
|
||||
|
@@ -148,6 +148,7 @@ public
|
||||
|
||||
event EquationChangedEventHandler ^ EquationChanged;
|
||||
event EquationChangedEventHandler ^ EquationStyleChanged;
|
||||
event EquationChangedEventHandler ^ EquationLineEnabledChanged;
|
||||
|
||||
private:
|
||||
void OnEquationPropertyChanged(GraphControl::Equation ^, Platform::String ^ propertyName)
|
||||
@@ -160,8 +161,12 @@ public
|
||||
{
|
||||
EquationChanged();
|
||||
}
|
||||
else if (propertyName == EquationProperties::IsLineEnabled)
|
||||
{
|
||||
EquationLineEnabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Platform::Collections::Vector<GraphControl::Equation ^> ^ m_vector;
|
||||
std::vector<Windows::Foundation::EventRegistrationToken> m_tokens;
|
||||
|
@@ -79,6 +79,8 @@ namespace GraphControl
|
||||
auto cw = CoreWindow::GetForCurrentThread();
|
||||
cw->KeyDown += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &Grapher::OnCoreKeyDown);
|
||||
cw->KeyUp += ref new TypedEventHandler<CoreWindow ^, KeyEventArgs ^>(this, &Grapher::OnCoreKeyUp);
|
||||
|
||||
auto& formatOptions = m_solver->FormatOptions();
|
||||
}
|
||||
|
||||
void Grapher::OnLoaded(Object ^ sender, RoutedEventArgs ^ args)
|
||||
@@ -222,6 +224,9 @@ namespace GraphControl
|
||||
m_tokenEquationChanged = newer->EquationChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationChanged);
|
||||
|
||||
m_tokenEquationStyleChanged = newer->EquationStyleChanged += ref new EquationChangedEventHandler(this, &Grapher::OnEquationStyleChanged);
|
||||
|
||||
m_tokenEquationLineEnabledChanged = newer->EquationLineEnabledChanged +=
|
||||
ref new EquationChangedEventHandler(this, &Grapher::OnEquationLineEnabledChanged);
|
||||
}
|
||||
|
||||
UpdateGraph();
|
||||
@@ -245,6 +250,11 @@ namespace GraphControl
|
||||
}
|
||||
}
|
||||
|
||||
void Grapher::OnEquationLineEnabledChanged()
|
||||
{
|
||||
UpdateGraph();
|
||||
}
|
||||
|
||||
void Grapher::PlotGraph()
|
||||
{
|
||||
UpdateGraph();
|
||||
@@ -258,7 +268,9 @@ namespace GraphControl
|
||||
{
|
||||
if (analyzer->CanFunctionAnalysisBePerformed())
|
||||
{
|
||||
if (S_OK == analyzer->PerformFunctionAnalysis((Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All))
|
||||
if (S_OK
|
||||
== analyzer->PerformFunctionAnalysis(
|
||||
(Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All))
|
||||
{
|
||||
Graphing::IGraphFunctionAnalysisData functionAnalysisData = m_solver->Analyze(analyzer.get());
|
||||
{
|
||||
@@ -297,6 +309,8 @@ namespace GraphControl
|
||||
|
||||
void Grapher::UpdateGraph()
|
||||
{
|
||||
optional<vector<shared_ptr<IEquation>>> initResult = nullopt;
|
||||
|
||||
if (m_renderMain && m_graph != nullptr)
|
||||
{
|
||||
auto validEqs = GetValidEquations();
|
||||
@@ -323,28 +337,22 @@ namespace GraphControl
|
||||
unique_ptr<IExpression> graphExpression;
|
||||
if (graphExpression = m_solver->ParseInput(request))
|
||||
{
|
||||
if (m_graph->TryInitialize(graphExpression.get()))
|
||||
{
|
||||
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
||||
SetGraphArgs();
|
||||
|
||||
m_renderMain->Graph = m_graph;
|
||||
|
||||
UpdateVariables();
|
||||
}
|
||||
initResult = m_graph->TryInitialize(graphExpression.get());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (initResult == nullopt)
|
||||
{
|
||||
if (m_graph->TryInitialize())
|
||||
{
|
||||
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
||||
SetGraphArgs();
|
||||
initResult = m_graph->TryInitialize();
|
||||
}
|
||||
|
||||
m_renderMain->Graph = m_graph;
|
||||
if (initResult != nullopt)
|
||||
{
|
||||
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
||||
SetGraphArgs();
|
||||
|
||||
UpdateVariables();
|
||||
}
|
||||
UpdateVariables();
|
||||
m_renderMain->Graph = m_graph;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,7 +393,7 @@ namespace GraphControl
|
||||
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()));
|
||||
@@ -482,7 +490,7 @@ namespace GraphControl
|
||||
|
||||
for (Equation ^ eq : Equations)
|
||||
{
|
||||
if (!eq->Expression->IsEmpty())
|
||||
if (!eq->Expression->IsEmpty() && eq->IsLineEnabled)
|
||||
{
|
||||
validEqs.push_back(eq);
|
||||
}
|
||||
|
@@ -173,7 +173,7 @@ public
|
||||
void OnEquationsChanged(Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
|
||||
void OnEquationChanged();
|
||||
void OnEquationStyleChanged();
|
||||
|
||||
void OnEquationLineEnabledChanged();
|
||||
void UpdateGraph();
|
||||
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation ^>& validEqs);
|
||||
std::vector<Equation ^> GetValidEquations();
|
||||
@@ -210,6 +210,7 @@ public
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationsChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationStyleChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationChanged;
|
||||
Windows::Foundation::EventRegistrationToken m_tokenEquationLineEnabledChanged;
|
||||
|
||||
static Windows::UI::Xaml::DependencyProperty ^ s_forceProportionalAxesTemplateProperty;
|
||||
|
||||
|
Reference in New Issue
Block a user