Graphing Calculator Diagnostics Instrumentation (#1041)
* Add telemetry for keyboard button usage in graphing mode * Added the diagnostics for EquationAdded and FunctionAnalysis * Added remaining diagnostics events for graphing calculator * Fix proj files to include the IsStoreBuild condition. Move the Delayer class to the Calculator/Utils folder * Ensure the variable textbox has focus before logging diagnostics * Move maxVariableCount check into the tracelogger class * Created enums and updated the slider value changed method to remove the variable from the map after the log method is called * Re-enable hidden lines when the expression is updated * Fixed extra line in grapher.h and removed the conditional logging for variable count * Updated logging per PR feedback * Updated variable logging and fixed issues in the IsEquationLineDisabled binding the EditTextBox control. * Update per PR feedback * Added TraceLogging project to contain shared logging logic. * Updated TraceLogging project and updated tracelogger classes to use the TraceLogging project methods * Updated VariableLogging to log variable name. And updated per PR comments * Updated Variables logging to log count changed instead of variable added and fixed issue with variableSliders not being initialized * Remove outdated tracelogging call caused by rebase * Updated Delayer class to DispatcherTimerDelayer and fixed some small formatting issues * Fixed missing Dalyer class name updates * Removed extra line in traceloger.h
This commit is contained in:
@@ -150,7 +150,6 @@ void Calculator::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
|
||||
|
||||
Platform::String ^ Calculator::GetCurrentLayoutState()
|
||||
{
|
||||
|
||||
if (IsProgrammer)
|
||||
{
|
||||
return L"Programmer";
|
||||
@@ -195,7 +194,7 @@ void Calculator::UpdateViewState()
|
||||
|
||||
void Calculator::AnimateCalculator(bool resultAnimate)
|
||||
{
|
||||
static auto uiSettings = ref new UISettings();
|
||||
static auto uiSettings = ref new UISettings();
|
||||
if (uiSettings->AnimationsEnabled)
|
||||
{
|
||||
m_doAnimate = true;
|
||||
@@ -703,6 +702,11 @@ void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKe
|
||||
|
||||
void CalculatorApp::Calculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
|
||||
{
|
||||
if (!IsStandard && !IsScientific && !IsProgrammer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer;
|
||||
TraceLogger::GetInstance()->LogVisualStateChanged(mode, e->NewState->Name, IsAlwaysOnTop);
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/>
|
||||
<converters:BooleanNegationConverter x:Name="BooleanNegationConverter"/>
|
||||
|
||||
<DataTemplate x:Key="VariableDataTemplate" x:DataType="vm:VariableViewModel">
|
||||
<Grid DataContext="{x:Bind}" Tapped="VariableAreaTapped">
|
||||
@@ -130,9 +131,11 @@
|
||||
<Slider Grid.Column="1"
|
||||
Margin="8,0,8,-6"
|
||||
VerticalAlignment="Center"
|
||||
DataContext="{x:Bind}"
|
||||
Maximum="{x:Bind Max, Mode=TwoWay}"
|
||||
Minimum="{x:Bind Min, Mode=TwoWay}"
|
||||
StepFrequency="{x:Bind Step, Mode=TwoWay}"
|
||||
ValueChanged="Slider_ValueChanged"
|
||||
Value="{x:Bind Value, Mode=TwoWay}"/>
|
||||
|
||||
<Grid Grid.Row="1"
|
||||
@@ -391,7 +394,8 @@
|
||||
Grid.Column="1"
|
||||
MinWidth="44"
|
||||
MinHeight="44"
|
||||
VerticalAlignment="Stretch">
|
||||
VerticalAlignment="Stretch"
|
||||
IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsEquationLineDisabled, Mode=TwoWay}">
|
||||
<ToggleButton.Content>
|
||||
<StackPanel HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
|
@@ -129,6 +129,7 @@ void EquationInputArea::EquationTextBox_Submitted(Object ^ sender, MathRichEditB
|
||||
|| (submission->Source == EquationSubmissionSource::FOCUS_LOST && submission->HasTextChanged && eq->Expression != nullptr
|
||||
&& eq->Expression->Length() > 0))
|
||||
{
|
||||
eq->IsLineEnabled = true;
|
||||
unsigned int index = 0;
|
||||
if (Equations->IndexOf(eq, &index))
|
||||
{
|
||||
@@ -219,6 +220,8 @@ void EquationInputArea::EquationTextBox_EquationButtonClicked(Object ^ sender, R
|
||||
{
|
||||
auto eq = GetViewModelFromEquationTextBox(sender);
|
||||
eq->IsLineEnabled = !eq->IsLineEnabled;
|
||||
|
||||
TraceLogger::GetInstance()->LogShowHideButtonClicked(eq->IsLineEnabled ? false : true);
|
||||
}
|
||||
|
||||
void EquationInputArea::EquationTextBox_Loaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
@@ -333,21 +336,25 @@ void EquationInputArea::SubmitTextbox(TextBox ^ sender)
|
||||
{
|
||||
val = validateDouble(sender->Text, variableViewModel->Value);
|
||||
variableViewModel->Value = val;
|
||||
TraceLogger::GetInstance()->LogVariableChanged(L"ValueTextBox", variableViewModel->Name);
|
||||
}
|
||||
else if (sender->Name == "MinTextBox")
|
||||
{
|
||||
val = validateDouble(sender->Text, variableViewModel->Min);
|
||||
variableViewModel->Min = val;
|
||||
TraceLogger::GetInstance()->LogVariableSettingsChanged(L"MinTextBox");
|
||||
}
|
||||
else if (sender->Name == "MaxTextBox")
|
||||
{
|
||||
val = validateDouble(sender->Text, variableViewModel->Max);
|
||||
variableViewModel->Max = val;
|
||||
TraceLogger::GetInstance()->LogVariableSettingsChanged(L"MaxTextBox");
|
||||
}
|
||||
else if (sender->Name == "StepTextBox")
|
||||
{
|
||||
val = validateDouble(sender->Text, variableViewModel->Step);
|
||||
variableViewModel->Step = val;
|
||||
TraceLogger::GetInstance()->LogVariableSettingsChanged(L"StepTextBox");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -419,6 +426,50 @@ void EquationInputArea::EquationTextBox_EquationFormatRequested(Object ^ sender,
|
||||
EquationFormatRequested(sender, e);
|
||||
}
|
||||
|
||||
void EquationInputArea::Slider_ValueChanged(Object ^ sender, RangeBaseValueChangedEventArgs ^ e)
|
||||
{
|
||||
if (variableSliders == nullptr)
|
||||
{
|
||||
variableSliders = ref new Map<String ^, DispatcherTimerDelayer ^>();
|
||||
}
|
||||
|
||||
auto slider = static_cast<Slider ^>(sender);
|
||||
|
||||
// The slider value updates when the user uses the TextBox to change the variable value.
|
||||
// Check the focus state so that we don't trigger the event when the user used the textbox to change the variable value.
|
||||
if (slider->FocusState == Windows::UI::Xaml::FocusState::Unfocused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto variableVM = static_cast<VariableViewModel ^>(slider->DataContext);
|
||||
if (variableVM == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto name = variableVM->Name;
|
||||
|
||||
if (!variableSliders->HasKey(name))
|
||||
{
|
||||
TimeSpan timeSpan;
|
||||
timeSpan.Duration = 10000000; // The duration is 1 second. TimeSpan durations are expressed in 100 nanosecond units.
|
||||
DispatcherTimerDelayer ^ delayer = ref new DispatcherTimerDelayer(timeSpan);
|
||||
delayer->Action += ref new EventHandler<Platform::Object ^>([this, name](Platform::Object ^ sender, Platform::Object ^ e) {
|
||||
TraceLogger::GetInstance()->LogVariableChanged("Slider", name);
|
||||
variableSliders->Remove(name);
|
||||
});
|
||||
delayer->Start();
|
||||
variableSliders->Insert(name, delayer);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
auto delayer = variableSliders->Lookup(name);
|
||||
delayer->ResetAndStart();
|
||||
}
|
||||
}
|
||||
|
||||
EquationViewModel ^ EquationInputArea::GetViewModelFromEquationTextBox(Object ^ sender)
|
||||
{
|
||||
auto tb = static_cast<EquationTextBox ^>(sender);
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "Controls/EquationTextBox.h"
|
||||
#include "Converters/BooleanNegationConverter.h"
|
||||
#include "Controls/MathRichEditBox.h"
|
||||
#include "CalcViewModel/Common/TraceLogger.h"
|
||||
#include "Utils/DispatcherTimerDelayer.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
@@ -36,7 +38,6 @@ public
|
||||
|
||||
static Windows::UI::Xaml::Media::SolidColorBrush
|
||||
^ ToSolidColorBrush(Windows::UI::Color color) { return ref new Windows::UI::Xaml::Media::SolidColorBrush(color); }
|
||||
|
||||
private:
|
||||
void OnPropertyChanged(Platform::String ^ propertyName);
|
||||
void OnEquationsPropertyChanged();
|
||||
@@ -65,6 +66,7 @@ public
|
||||
void SubmitTextbox(Windows::UI::Xaml::Controls::TextBox ^ textbox);
|
||||
void VariableAreaTapped(Platform::Object ^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
void EquationTextBox_EquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
|
||||
void Slider_ValueChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs ^ e);
|
||||
|
||||
CalculatorApp::ViewModel::EquationViewModel ^ GetViewModelFromEquationTextBox(Platform::Object ^ sender);
|
||||
|
||||
@@ -72,5 +74,6 @@ public
|
||||
int m_lastLineColorIndex;
|
||||
int m_lastFunctionLabelIndex;
|
||||
ViewModel::EquationViewModel ^ m_equationToFocus;
|
||||
Platform::Collections::Map<Platform::String ^, CalculatorApp::DispatcherTimerDelayer ^> ^ variableSliders;
|
||||
};
|
||||
}
|
||||
|
@@ -390,7 +390,7 @@
|
||||
MaxWidth="420"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
<VisualStateGroup CurrentStateChanged="OnVisualStateChanged">
|
||||
<VisualState x:Name="ColumnsState">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="800"/>
|
||||
|
@@ -217,6 +217,7 @@ void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object ^ sender,
|
||||
{
|
||||
// Ask the OS to start a share action.
|
||||
DataTransferManager::ShowShareUI();
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::Share);
|
||||
}
|
||||
|
||||
// When share is invoked (by the user or programmatically) the event handler we registered will be called to populate the data package with the
|
||||
@@ -348,16 +349,19 @@ void GraphingCalculator::OnVariableChanged(Platform::Object ^ sender, VariableCh
|
||||
void GraphingCalculator::OnZoomInCommand(Object ^ /* parameter */)
|
||||
{
|
||||
GraphingControl->ZoomFromCenter(zoomInScale);
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomIn);
|
||||
}
|
||||
|
||||
void GraphingCalculator::OnZoomOutCommand(Object ^ /* parameter */)
|
||||
{
|
||||
GraphingControl->ZoomFromCenter(zoomOutScale);
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomOut);
|
||||
}
|
||||
|
||||
void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
|
||||
{
|
||||
GraphingControl->ResetGrid();
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ZoomReset);
|
||||
}
|
||||
|
||||
String ^ GraphingCalculator::GetTracingLegend(Platform::IBox<bool> ^ isTracing)
|
||||
@@ -525,6 +529,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Checked(Platform::Object ^
|
||||
KeyboardShortcutManager::IgnoreEscape(false);
|
||||
|
||||
TracePointer->Visibility = ::Visibility::Visible;
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingChecked);
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
@@ -543,6 +548,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_Unchecked(Platform::Object
|
||||
KeyboardShortcutManager::HonorEscape();
|
||||
|
||||
TracePointer->Visibility = ::Visibility::Collapsed;
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::ActiveTracingUnchecked);
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args)
|
||||
@@ -557,6 +563,7 @@ void CalculatorApp::GraphingCalculator::ActiveTracing_KeyUp(Windows::UI::Core::C
|
||||
void GraphingCalculator::GraphSettingsButton_Click(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
DisplayGraphSettings();
|
||||
TraceLogger::GetInstance()->LogGraphButtonClicked(GraphButton::GraphSettings);
|
||||
}
|
||||
|
||||
void GraphingCalculator::DisplayGraphSettings()
|
||||
@@ -676,3 +683,8 @@ void GraphingCalculator::GraphMenuFlyoutItem_Click(Object ^ sender, RoutedEventA
|
||||
dataPackage->SetBitmap(bitmapStream);
|
||||
::Clipboard::SetContent(dataPackage);
|
||||
}
|
||||
|
||||
void GraphingCalculator::OnVisualStateChanged(Object ^ sender, VisualStateChangedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance()->LogVisualStateChanged(ViewMode::Graphing, e->NewState->Name, false);
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include "Views\GraphingCalculator\KeyGraphFeaturesPanel.xaml.h"
|
||||
#include "Views\GraphingCalculator\GraphingNumPad.xaml.h"
|
||||
#include "Views\GraphingCalculator\GraphingSettings.xaml.h"
|
||||
#include "CalcViewModel/Common/TraceLogger.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
@@ -97,6 +98,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
|
||||
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -203,6 +203,7 @@ void GraphingNumPad::Button_Clicked(Platform::Object ^ sender, DependencyPropert
|
||||
if (mathRichEdit != nullptr && sender != nullptr)
|
||||
{
|
||||
auto id = button->ButtonId;
|
||||
TraceLogger::GetInstance()->UpdateButtonUsage(id, CalculatorApp::Common::ViewMode::Graphing);
|
||||
auto output = buttonOutput.find(id);
|
||||
mathRichEdit->InsertText(std::get<0>(output->second), std::get<1>(output->second), std::get<2>(output->second));
|
||||
}
|
||||
@@ -214,6 +215,7 @@ void GraphingNumPad::SubmitButton_Clicked(Platform::Object ^ /*sender*/, RoutedE
|
||||
if (mathRichEdit != nullptr)
|
||||
{
|
||||
mathRichEdit->SubmitEquation(CalculatorApp::Controls::EquationSubmissionSource::ENTER_KEY);
|
||||
TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Submit, CalculatorApp::Common::ViewMode::Graphing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +226,7 @@ void GraphingNumPad::ClearButton_Clicked(Platform::Object ^ /*sender*/, RoutedEv
|
||||
{
|
||||
mathRichEdit->MathText = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"></math>";
|
||||
mathRichEdit->SubmitEquation(CalculatorApp::Controls::EquationSubmissionSource::PROGRAMMATIC);
|
||||
TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Clear, CalculatorApp::Common::ViewMode::Graphing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +236,7 @@ void GraphingNumPad::BackSpaceButton_Clicked(Platform::Object ^ /*sender*/, Rout
|
||||
if (mathRichEdit != nullptr)
|
||||
{
|
||||
mathRichEdit->BackSpace();
|
||||
TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Backspace, CalculatorApp::Common::ViewMode::Graphing);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "CalcViewModel/GraphingCalculator/GraphingCalculatorViewModel.h"
|
||||
#include "Views/GraphingCalculator/EquationInputArea.xaml.h"
|
||||
#include "CalcViewModel/Common/CalculatorButtonUser.h"
|
||||
#include "CalcViewModel/Common/TraceLogger.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
Reference in New Issue
Block a user