Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passive & Active tracing #638

Merged
merged 44 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b4a9347
Plumebd with data transfer
DavidShoe Jul 12, 2019
7e01206
Getting mainpage to talk to getbitmap. moving share callbacks from m…
DavidShoe Jul 15, 2019
74695d1
Trying to get bitmap from renderer.
DavidShoe Jul 16, 2019
68f6bdd
work
DavidShoe Jul 18, 2019
39ddc13
Share worked
DavidShoe Jul 18, 2019
c37d937
cleanups
DavidShoe Jul 18, 2019
427beb1
Cleanups progressing
DavidShoe Jul 19, 2019
46a0ae0
Share working, need loc for title string and user notification incase…
DavidShoe Jul 19, 2019
ee28b7a
More cleanup, now using share icon image and resources for strings. …
DavidShoe Jul 19, 2019
bc490ec
Change share to html based start.
DavidShoe Jul 24, 2019
95871e1
Key working, with UL but going to try changing to table.
DavidShoe Jul 24, 2019
3eb0552
Fix a html formating error, generating a new UL for each equation.
DavidShoe Jul 24, 2019
c80375e
Switched over to a table for equation key and have color block formating
DavidShoe Jul 24, 2019
82bc868
Merge pull request #1 from microsoft/feature/GraphingCalculator
DavidShoe Jul 25, 2019
b14f487
Merge branch 'feature/GraphingCalculator' into working
DavidShoe Jul 26, 2019
0a059df
Merge pull request #2 from DavidShoe/working
DavidShoe Jul 26, 2019
5e53af5
Updates from PR feedback, using Graphing::IBitmap abstraction.
DavidShoe Jul 30, 2019
1dc2608
Merge branch 'working' into feature/GraphingCalculator
DavidShoe Jul 30, 2019
8037671
Update src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.h
DavidShoe Jul 30, 2019
59bef86
PR Updates.
DavidShoe Jul 30, 2019
fc1c0e1
Merge commit
DavidShoe Jul 30, 2019
1aadd66
Add variables to the graph key.
DavidShoe Jul 30, 2019
c0ba6b7
Merge branch 'AddVariables' into feature/GraphingCalculator
DavidShoe Jul 30, 2019
6b3b08f
eod
DavidShoe Jul 30, 2019
b30396f
Passive graph value tracing working.
DavidShoe Aug 2, 2019
7a99613
Basic active tracing cursor working.
DavidShoe Aug 2, 2019
2b8bd15
Move active tracing from graphingcalculator to grapher to save some h…
DavidShoe Aug 5, 2019
29e5ce2
Active tracing working, need to put button on screen for activation.
DavidShoe Aug 5, 2019
96a7e20
Added active tracing control button (placeholder image)
DavidShoe Aug 5, 2019
ce123ff
Merge of passive (popup display) and active tracing.
DavidShoe Aug 5, 2019
980155e
Eod
DavidShoe Aug 6, 2019
523c5e2
Popup trace value now tracks the highlighted point.
DavidShoe Aug 6, 2019
76d2d1d
Popup skined
DavidShoe Aug 7, 2019
c27afd4
PR Updates.
DavidShoe Aug 8, 2019
be45fce
Merge pull request #3 from DavidShoe/PRUpdates
DavidShoe Aug 8, 2019
50b5267
Merge remote-tracking branch 'myfork/feature/GraphingCalculator' into…
DavidShoe Aug 27, 2019
24d0de7
merge with mainline so we can get the pull request in.
DavidShoe Aug 27, 2019
4b9d668
Update certificate thumbnail so VS2019 doesn't have a build error.
DavidShoe Aug 27, 2019
ddaaa0f
PR comments in process.
DavidShoe Sep 23, 2019
6eeb447
PR Updates
DavidShoe Sep 25, 2019
691c62f
Merge with upstream
DavidShoe Sep 27, 2019
da9565e
PR Updates, change tracing value to use tooltip static resource so we…
DavidShoe Sep 30, 2019
acff033
PR updates, changed how we detect who has focus so we don't eat keys …
DavidShoe Oct 1, 2019
6c775ce
Additional filtering for the Key Up/Down in the grapher.
DavidShoe Oct 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 39 additions & 17 deletions src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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/>
Expand All @@ -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">
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
<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="&#xE73F;"/>
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
</Button>
<Button x:Name="Share" Click="OnShareClick" MinWidth="40" MinHeight="40">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72D;"/>
</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="White" BorderBrush="SlateBlue" BorderThickness="3,3,3,3">
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
<TextBlock x:Name="TraceValue" Text="x=0,y=0" Margin="5,5,5,5"/>
</Grid>
</Popup>

</Grid>


<!-- Temporary button until the final UI is created -->
<Button Margin="12,0,0,12"
Expand Down Expand Up @@ -369,9 +394,6 @@
</Grid.RowDefinitions>

<StackPanel>
<Button x:Name="Share" Click="OnShareClick">
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72D;"/>
</Button>
<local:EquationInputArea Grid.Row="0" Equations="{x:Bind ViewModel.Equations}"/>
</StackPanel>

Expand Down
94 changes: 71 additions & 23 deletions src/Calculator/Views/GraphingCalculator/GraphingCalculator.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,35 +31,58 @@ 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);
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 = "x=" + newPoint.X.ToString() + ", y=" + newPoint.Y.ToString();
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
}

GraphingCalculatorViewModel ^ GraphingCalculator::ViewModel::get()
{
return m_viewModel;
}

void GraphingCalculator::ViewModel::set(GraphingCalculatorViewModel^ vm)
void GraphingCalculator::ViewModel::set(GraphingCalculatorViewModel ^ vm)
{
if (m_viewModel != vm)
{
Expand All @@ -67,15 +91,15 @@ 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();
}

// 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
Expand Down Expand Up @@ -142,11 +166,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");
Expand All @@ -164,7 +187,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(__FUNCTIONW__, ex);

Expand All @@ -179,20 +202,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")
{
Expand All @@ -212,21 +234,20 @@ 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)
{
SubmitTextbox(sender);
}
}

double GraphingCalculator::validateDouble(String^ value, double defaultValue)
double GraphingCalculator::validateDouble(String ^ value, double defaultValue)
{
try
{
Expand All @@ -238,7 +259,7 @@ double GraphingCalculator::validateDouble(String^ value, double defaultValue)
}
}

void GraphingCalculator::TextBoxGotFocus(TextBox^ sender, RoutedEventArgs^ e)
void GraphingCalculator::TextBoxGotFocus(TextBox ^ sender, RoutedEventArgs ^ e)
{
sender->SelectAll();
}
Expand All @@ -257,3 +278,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;
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

}
2 changes: 1 addition & 1 deletion src/CalculatorUnitTests/CalculatorUnitTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros">
<PackageCertificateKeyFile>CalculatorUnitTests_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>3F0C32266A4D995CC08C9AEC3960CFF3EF0D1853</PackageCertificateThumbprint>
<PackageCertificateThumbprint>BE776C83699DBCE4969DE9EE730AEAF66C5D5182</PackageCertificateThumbprint>
DavidShoe marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
Expand Down