Passive & Active tracing (#638)
* Plumebd with data transfer * Getting mainpage to talk to getbitmap. moving share callbacks from mainpage to graphingcalculator * Trying to get bitmap from renderer. * work * Share worked * cleanups * Cleanups progressing * Share working, need loc for title string and user notification incase of a failure. Then add the equations key. * More cleanup, now using share icon image and resources for strings. Still need to do the graph equation key. * Change share to html based start. * Key working, with UL but going to try changing to table. * Fix a html formating error, generating a new UL for each equation. * Switched over to a table for equation key and have color block formating * Updates from PR feedback, using Graphing::IBitmap abstraction. * Update src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h Fixed Co-Authored-By: Pepe Rivera <joseartrivera@gmail.com> * PR Updates. * Add variables to the graph key. * eod * Passive graph value tracing working. * Basic active tracing cursor working. * Move active tracing from graphingcalculator to grapher to save some hops. Also block tracking of the active tracing key's when in the EquationTextBox. * Active tracing working, need to put button on screen for activation. * Added active tracing control button (placeholder image) * Eod * Popup trace value now tracks the highlighted point. * Popup skined * PR Updates. * Update certificate thumbnail so VS2019 doesn't have a build error. * PR comments in process. * PR Updates * PR Updates, change tracing value to use tooltip static resource so we automatically change depending on system values. And changed text formatting of the value to be generic (x,y) value. * PR updates, changed how we detect who has focus so we don't eat keys when not in active tracing. * Additional filtering for the Key Up/Down in the grapher.
This commit is contained in:
committed by
Stephanie Anderl
parent
7864fe6413
commit
18f80a89db
@@ -9,7 +9,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:CalculatorApp.ViewModel"
|
||||
DataContextChanged="GraphingCalculator_DataContextChanged"
|
||||
mc:Ignorable="d">
|
||||
mc:Ignorable="d"
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="ZoomRepeatButtonStyle" TargetType="RepeatButton">
|
||||
@@ -32,7 +33,7 @@
|
||||
<converters:BooleanToVisibilityNegationConverter x:Name="BooleanToVisibilityNegationConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<Grid x:Name="RootGrid" >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowHamburger" Height="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<RowDefinition/>
|
||||
@@ -46,21 +47,45 @@
|
||||
<Grid x:Name="LeftGrid"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0">
|
||||
<graphControl:Grapher Name="GraphingControl"
|
||||
Margin="4,7,4,4"
|
||||
<Grid Grid.Row="0" Margin="4,7,4,4">
|
||||
<graphControl:Grapher Name="GraphingControl"
|
||||
EquationsSource="{x:Bind ViewModel.Equations, Mode=OneWay}"
|
||||
ForceProportionalAxes="True"
|
||||
UseSystemFocusVisuals="True"
|
||||
VariablesUpdated="GraphVariablesUpdated">
|
||||
<graphControl:Grapher.Background>
|
||||
<SolidColorBrush Color="White"/>
|
||||
</graphControl:Grapher.Background>
|
||||
<graphControl:Grapher.EquationTemplate>
|
||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||
<graphControl:Equation Expression="{x:Bind Expression, Mode=OneWay}" LineColor="{x:Bind LineColor, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
</graphControl:Grapher.EquationTemplate>
|
||||
</graphControl:Grapher>
|
||||
VariablesUpdated="GraphVariablesUpdated"
|
||||
LostFocus="OnGraphLostFocus"
|
||||
LosingFocus="OnLoosingFocus">
|
||||
<graphControl:Grapher.Background>
|
||||
<SolidColorBrush Color="White"/>
|
||||
</graphControl:Grapher.Background>
|
||||
<graphControl:Grapher.EquationTemplate>
|
||||
<DataTemplate x:DataType="vm:EquationViewModel">
|
||||
<graphControl:Equation Expression="{x:Bind Expression, Mode=OneWay}" LineColor="{x:Bind LineColor, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
</graphControl:Grapher.EquationTemplate>
|
||||
|
||||
</graphControl:Grapher>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,10,10">
|
||||
<Button x:Name="ActiveTracing" Click="OnActiveTracingClick" MinWidth="40" MinHeight="40" Margin="0,0,10,0">
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph=""/>
|
||||
</Button>
|
||||
<Button x:Name="Share" Click="OnShareClick" MinWidth="40" MinHeight="40">
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph=""/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<Popup x:Name="TraceValuePopup" Grid.Row="0" RenderTransformOrigin="0,1">
|
||||
<Popup.RenderTransform>
|
||||
<TranslateTransform x:Name="TraceValuePopupTransform" X="50" Y="150"/>
|
||||
</Popup.RenderTransform>
|
||||
<Grid Background="{StaticResource ToolTipBackground}" BorderBrush="{StaticResource ToolTipBorderBrush}" BorderThickness="3,3,3,3">
|
||||
<TextBlock x:Name="TraceValue" Text="x=0,y=0" Margin="5,5,5,5" Foreground="{StaticResource ToolTipForeground}"/>
|
||||
</Grid>
|
||||
</Popup>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
<!-- Temporary button until the final UI is created -->
|
||||
<Button Margin="12,0,0,12"
|
||||
@@ -372,9 +397,6 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button x:Name="Share" Click="OnShareClick">
|
||||
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph=""/>
|
||||
</Button>
|
||||
<local:EquationInputArea Grid.Row="1"
|
||||
Margin="0,8,0,0"
|
||||
Equations="{x:Bind ViewModel.Equations}"/>
|
||||
|
@@ -22,6 +22,7 @@ using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Windows::System;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::UI::Input;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Data;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
@@ -30,35 +31,61 @@ using namespace Windows::UI::Xaml::Media;
|
||||
using namespace Windows::UI::Xaml::Media::Imaging;
|
||||
using namespace Windows::UI::Popups;
|
||||
|
||||
|
||||
constexpr auto sc_ViewModelPropertyName = L"ViewModel";
|
||||
|
||||
|
||||
GraphingCalculator::GraphingCalculator()
|
||||
{
|
||||
Equation::RegisterDependencyProperties();
|
||||
Grapher::RegisterDependencyProperties();
|
||||
InitializeComponent();
|
||||
|
||||
DataTransferManager^ dataTransferManager = DataTransferManager::GetForCurrentView();
|
||||
DataTransferManager ^ dataTransferManager = DataTransferManager::GetForCurrentView();
|
||||
|
||||
// Register the current control as a share source.
|
||||
m_dataRequestedToken = dataTransferManager->DataRequested += ref new TypedEventHandler<DataTransferManager^, DataRequestedEventArgs^>(this, &GraphingCalculator::OnDataRequested);
|
||||
m_dataRequestedToken = dataTransferManager->DataRequested +=
|
||||
ref new TypedEventHandler<DataTransferManager ^, DataRequestedEventArgs ^>(this, &GraphingCalculator::OnDataRequested);
|
||||
|
||||
// Request notifications when we should be showing the trace values
|
||||
GraphingControl->TracingChangedEvent += ref new TracingChangedEventHandler(this, &GraphingCalculator::OnShowTracePopupChanged);
|
||||
|
||||
// And when the actual trace value changes
|
||||
GraphingControl->TracingValueChangedEvent += ref new TracingValueChangedEventHandler(this, &GraphingCalculator::OnTracePointChanged);
|
||||
}
|
||||
|
||||
void GraphingCalculator::GraphingCalculator_DataContextChanged(FrameworkElement^ sender, DataContextChangedEventArgs^ args)
|
||||
void GraphingCalculator::OnShowTracePopupChanged(bool newValue)
|
||||
{
|
||||
ViewModel = dynamic_cast<GraphingCalculatorViewModel^>(args->NewValue);
|
||||
if (TraceValuePopup->IsOpen != newValue)
|
||||
{
|
||||
TraceValuePopup->IsOpen = newValue;
|
||||
if (TraceValuePopup->IsOpen)
|
||||
{
|
||||
// Set the keyboard focus to the graph control so we can use the arrow keys safely.
|
||||
GraphingControl->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingCalculator::GraphingCalculator_DataContextChanged(FrameworkElement ^ sender, DataContextChangedEventArgs ^ args)
|
||||
{
|
||||
ViewModel = dynamic_cast<GraphingCalculatorViewModel ^>(args->NewValue);
|
||||
|
||||
ViewModel->VariableUpdated += ref new EventHandler<VariableChangedEventArgs>(this, &CalculatorApp::GraphingCalculator::OnVariableChanged);
|
||||
}
|
||||
|
||||
GraphingCalculatorViewModel^ GraphingCalculator::ViewModel::get()
|
||||
void GraphingCalculator::OnTracePointChanged(Windows::Foundation::Point newPoint)
|
||||
{
|
||||
TraceValuePopupTransform->X = (int)GraphingControl->TraceLocation.X + 15;
|
||||
TraceValuePopupTransform->Y = (int)GraphingControl->TraceLocation.Y - 30;
|
||||
|
||||
TraceValue->Text = "(" + newPoint.X.ToString() + ", " + newPoint.Y.ToString() + ")";
|
||||
}
|
||||
|
||||
GraphingCalculatorViewModel ^ GraphingCalculator::ViewModel::get()
|
||||
{
|
||||
return m_viewModel;
|
||||
}
|
||||
|
||||
void GraphingCalculator::ViewModel::set(GraphingCalculatorViewModel^ vm)
|
||||
void GraphingCalculator::ViewModel::set(GraphingCalculatorViewModel ^ vm)
|
||||
{
|
||||
if (m_viewModel != vm)
|
||||
{
|
||||
@@ -67,7 +94,7 @@ void GraphingCalculator::ViewModel::set(GraphingCalculatorViewModel^ vm)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
// Ask the OS to start a share action.
|
||||
DataTransferManager::ShowShareUI();
|
||||
@@ -75,7 +102,7 @@ void CalculatorApp::GraphingCalculator::OnShareClick(Platform::Object^ sender, W
|
||||
|
||||
// When share is invoked (by the user or programmatically) the event handler we registered will be called to populate the data package with the
|
||||
// data to be shared. We will request the current graph image from the grapher as a stream that will pass to the share request.
|
||||
void GraphingCalculator::OnDataRequested(DataTransferManager^ sender, DataRequestedEventArgs^ args)
|
||||
void GraphingCalculator::OnDataRequested(DataTransferManager ^ sender, DataRequestedEventArgs ^ args)
|
||||
{
|
||||
auto resourceLoader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
|
||||
try
|
||||
@@ -142,11 +169,10 @@ void GraphingCalculator::OnDataRequested(DataTransferManager^ sender, DataReques
|
||||
}
|
||||
rawHtml += L"</table></p>";
|
||||
|
||||
|
||||
// Shortcut to the request data
|
||||
auto requestData = args->Request->Data;
|
||||
|
||||
DataPackage^ dataPackage = ref new DataPackage();
|
||||
DataPackage ^ dataPackage = ref new DataPackage();
|
||||
auto html = HtmlFormatHelper::CreateHtmlFormat(ref new String(rawHtml.c_str()));
|
||||
|
||||
auto titleString = resourceLoader->GetString(L"ShareActionTitle");
|
||||
@@ -164,7 +190,7 @@ void GraphingCalculator::OnDataRequested(DataTransferManager^ sender, DataReques
|
||||
// And the bitmap (in case the share target can't handle HTML)
|
||||
requestData->SetBitmap(bitmapStream);
|
||||
}
|
||||
catch(Exception ^ ex)
|
||||
catch (Exception ^ ex)
|
||||
{
|
||||
TraceLogger::GetInstance().LogPlatformException(ViewMode::Graphing, __FUNCTIONW__, ex);
|
||||
|
||||
@@ -179,20 +205,19 @@ void GraphingCalculator::OnDataRequested(DataTransferManager^ sender, DataReques
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingCalculator::GraphVariablesUpdated(Object^, Object^)
|
||||
void GraphingCalculator::GraphVariablesUpdated(Object ^, Object ^)
|
||||
{
|
||||
m_viewModel->UpdateVariables(GraphingControl->Variables);
|
||||
}
|
||||
|
||||
void GraphingCalculator::OnVariableChanged(Platform::Object^ sender, VariableChangedEventArgs args)
|
||||
void GraphingCalculator::OnVariableChanged(Platform::Object ^ sender, VariableChangedEventArgs args)
|
||||
{
|
||||
GraphingControl->SetVariable(args.variableName, args.newValue);
|
||||
}
|
||||
|
||||
|
||||
void GraphingCalculator::SubmitTextbox(TextBox^ sender)
|
||||
void GraphingCalculator::SubmitTextbox(TextBox ^ sender)
|
||||
{
|
||||
auto variableViewModel = static_cast<VariableViewModel^>(sender->DataContext);
|
||||
auto variableViewModel = static_cast<VariableViewModel ^>(sender->DataContext);
|
||||
|
||||
if (sender->Name == "ValueTextBox")
|
||||
{
|
||||
@@ -212,13 +237,12 @@ void GraphingCalculator::SubmitTextbox(TextBox^ sender)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingCalculator::TextBoxLosingFocus(TextBox^ sender, LosingFocusEventArgs^)
|
||||
void GraphingCalculator::TextBoxLosingFocus(TextBox ^ sender, LosingFocusEventArgs ^)
|
||||
{
|
||||
SubmitTextbox(sender);
|
||||
}
|
||||
|
||||
|
||||
void GraphingCalculator::TextBoxKeyDown(TextBox^ sender, KeyRoutedEventArgs^ e)
|
||||
void GraphingCalculator::TextBoxKeyDown(TextBox ^ sender, KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
if (e->Key == ::VirtualKey::Enter)
|
||||
{
|
||||
@@ -226,7 +250,7 @@ void GraphingCalculator::TextBoxKeyDown(TextBox^ sender, KeyRoutedEventArgs^ e)
|
||||
}
|
||||
}
|
||||
|
||||
double GraphingCalculator::validateDouble(String^ value, double defaultValue)
|
||||
double GraphingCalculator::validateDouble(String ^ value, double defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -238,7 +262,7 @@ double GraphingCalculator::validateDouble(String^ value, double defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingCalculator::TextBoxGotFocus(TextBox^ sender, RoutedEventArgs^ e)
|
||||
void GraphingCalculator::TextBoxGotFocus(TextBox ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
sender->SelectAll();
|
||||
}
|
||||
@@ -257,3 +281,30 @@ void GraphingCalculator::OnZoomResetCommand(Object ^ /* parameter */)
|
||||
{
|
||||
GraphingControl->ResetGrid();
|
||||
}
|
||||
|
||||
void GraphingCalculator::OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
GraphingControl->ActiveTracing = !GraphingControl->ActiveTracing;
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::OnGraphLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
// If the graph is losing focus while we are in active tracing we need to turn it off so we don't try to eat keys in other controls.
|
||||
if (GraphingControl->ActiveTracing)
|
||||
{
|
||||
GraphingControl->ActiveTracing = false;
|
||||
OnShowTracePopupChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorApp::GraphingCalculator::OnLoosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args)
|
||||
{
|
||||
FrameworkElement ^ newFocusElement = (FrameworkElement ^) args->NewFocusedElement;
|
||||
if (newFocusElement == nullptr || newFocusElement->Name == nullptr)
|
||||
{
|
||||
// Because clicking on the swap chain panel will try to move focus to a control that can't actually take focus
|
||||
// we will get a null destination. So we are going to try and cancel that request.
|
||||
// If the destination is not in our application we will also get a null destination but the cancel will fail so it doesn't hurt to try.
|
||||
args->TryCancel();
|
||||
}
|
||||
}
|
||||
|
@@ -45,13 +45,18 @@ namespace CalculatorApp
|
||||
|
||||
void OnShareClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
void OnShowTracePopupChanged(bool newValue);
|
||||
void OnTracePointChanged(Windows::Foundation::Point newPoint);
|
||||
|
||||
|
||||
private:
|
||||
Windows::Foundation::EventRegistrationToken m_dataRequestedToken;
|
||||
|
||||
void OnDataRequested(Windows::ApplicationModel::DataTransfer::DataTransferManager^ sender, Windows::ApplicationModel::DataTransfer::DataRequestedEventArgs^ e);
|
||||
void CommandInvokedHandler(Windows::UI::Popups::IUICommand^ command);
|
||||
|
||||
void TextBoxGotFocus(Windows::UI::Xaml::Controls::TextBox^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnActiveTracingClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnGraphLostFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnLoosingFocus(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::LosingFocusEventArgs ^ args);
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user