Update Icons Implement the Graph View Button (#1149)
* Update icon file * function analysis and negate button icons updated * Replace zoom reset button with graph view button * Fixed issue where the window settings did not update after panning/zooming * Updated icon styling and added logic for updating the graph view button state when user manipulates the graph and when all equations are removed * updated LogGraphButton clicked to have an enum for the button value instead of a string * Updated the logic for how to set the IsManualAdjustment, ensured graphsettings now update IsManualAdjustment when changed
This commit is contained in:
@@ -37,6 +37,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, AxesColor);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GraphBackground);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, GridLinesColor);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, LineWidth);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Grapher, IsKeepCurrentView);
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -87,7 +88,7 @@ namespace GraphControl
|
||||
void Grapher::ZoomFromCenter(double scale)
|
||||
{
|
||||
ScaleRange(0, 0, scale);
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
|
||||
}
|
||||
|
||||
void Grapher::ScaleRange(double centerX, double centerY, double scale)
|
||||
@@ -103,7 +104,7 @@ namespace GraphControl
|
||||
m_renderMain->GetCriticalSection().unlock();
|
||||
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -122,7 +123,7 @@ namespace GraphControl
|
||||
if (SUCCEEDED(renderer->ResetRange()))
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +208,6 @@ namespace GraphControl
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool keepCurrentView = true;
|
||||
|
||||
// If the equation has changed, the IsLineEnabled state is reset.
|
||||
@@ -254,7 +254,7 @@ namespace GraphControl
|
||||
|
||||
void Grapher::PlotGraph(bool keepCurrentView)
|
||||
{
|
||||
TryPlotGraph(keepCurrentView, false);
|
||||
TryPlotGraph(keepCurrentView,false);
|
||||
}
|
||||
|
||||
task<void> Grapher::TryPlotGraph(bool keepCurrentView, bool shouldRetry)
|
||||
@@ -405,7 +405,7 @@ namespace GraphControl
|
||||
// Do not re-initialize the graph to empty if there are still valid equations graphed
|
||||
if (!shouldKeepPreviousGraph)
|
||||
{
|
||||
initResult = m_graph->TryInitialize();
|
||||
initResult = TryInitializeGraph(false, nullptr);
|
||||
if (initResult != nullopt)
|
||||
{
|
||||
UpdateGraphOptions(m_graph->GetOptions(), vector<Equation ^>());
|
||||
@@ -711,7 +711,7 @@ namespace GraphControl
|
||||
const auto [centerX, centerY] = PointerPositionToGraphPosition(pos.X, pos.Y, ActualWidth, ActualHeight);
|
||||
|
||||
ScaleRange(centerX, centerY, scale);
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
|
||||
|
||||
e->Handled = true;
|
||||
}
|
||||
@@ -793,7 +793,7 @@ namespace GraphControl
|
||||
if (needsRenderPass)
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, ref new RoutedEventArgs());
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1086,7 +1086,7 @@ void Grapher::OnLineWidthPropertyChanged(double oldValue, double newValue)
|
||||
|
||||
optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bool keepCurrentView, const IExpression* graphingExp)
|
||||
{
|
||||
if (keepCurrentView)
|
||||
if (keepCurrentView || IsKeepCurrentView)
|
||||
{
|
||||
double xMin, xMax, yMin, yMax;
|
||||
m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
|
@@ -25,6 +25,12 @@ public
|
||||
public
|
||||
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);
|
||||
|
||||
public enum class GraphViewChangedReason
|
||||
{
|
||||
Manipulation,
|
||||
Reset
|
||||
};
|
||||
|
||||
[Windows::UI::Xaml::Markup::ContentPropertyAttribute(Name = L"Equations")] public ref class Grapher sealed
|
||||
: public Windows::UI::Xaml::Controls::Control,
|
||||
public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
@@ -33,7 +39,7 @@ public
|
||||
event TracingValueChangedEventHandler ^ TracingValueChangedEvent;
|
||||
event PointerValueChangedEventHandler ^ PointerValueChangedEvent;
|
||||
event TracingChangedEventHandler ^ TracingChangedEvent;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ GraphViewChangedEvent;
|
||||
event Windows::Foundation::EventHandler<GraphViewChangedReason> ^ GraphViewChangedEvent;
|
||||
event Windows::UI::Xaml::RoutedEventHandler ^ GraphPlottedEvent;
|
||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
||||
|
||||
@@ -51,8 +57,9 @@ public
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, AxesColor, Windows::UI::Colors::Transparent);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GraphBackground, Windows::UI::Colors::Transparent);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(Windows::UI::Color, GridLinesColor, Windows::UI::Colors::Transparent);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(double, LineWidth, 2.0);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsKeepCurrentView, false);
|
||||
|
||||
// Pass active tracing turned on or off down to the renderer
|
||||
property bool ActiveTracing
|
||||
{
|
||||
@@ -249,6 +256,7 @@ public
|
||||
if (m_renderMain)
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Manipulation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,6 +312,7 @@ public
|
||||
void SetEquationErrors();
|
||||
std::optional<std::vector<std::shared_ptr<Graphing::IEquation>>> TryInitializeGraph(bool keepCurrentView, _In_ const Graphing::IExpression* graphingExp = nullptr);
|
||||
|
||||
|
||||
private:
|
||||
DX::RenderMain ^ m_renderMain = nullptr;
|
||||
|
||||
|
Reference in New Issue
Block a user