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

Add new Sample Scenario - InkStroke - Resize and Move selected InkStroke #1189

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hjharvey-MSFT
Copy link

@hjharvey-MSFT hjharvey-MSFT commented Apr 2, 2020

We recently came across a question in the forums regarding an issue with someone selecting an inkstroke then trying to move and resize it. After digging through the samples I noticed that we didn't provide any guidance on how this could be done.

The team and I thought it would be a good idea to provide this sample, so I wrote an additional scenario that shows an approach that could be taken to accomplish this.

Essentially what happens is you highlight and select the Inkstoke. This creates a "selection" box around the item which you can mouse over. When you mouse over your mouse pointer changes to indicate the action that can be preformed, Either move or resize. Then you click and hold the mouse to preform your action.

added comments, removed redundant code, changed order of methods. etc.
@msftclas
Copy link

msftclas commented Apr 2, 2020

CLA assistant check
All CLA requirements met.

Windows::Foundation::EventRegistrationToken pointerExitedRectangleToken;
Windows::Foundation::EventRegistrationToken pointerMovedRectangleToken;
Windows::Foundation::EventRegistrationToken pointerPressedRectangleToken;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete extra blank lines

Scenario13::Scenario13()
{
InitializeComponent();
LassoSelect = (Symbol)0xEF20;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use static_cast

if (currentManipulationType != ManipulationTypes::None)
return;

Windows::UI::Core::CoreWindow^ window = Windows::UI::Core::CoreWindow::GetForCurrentThread();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto window = ...

/// <param name="e"></param>
void Scenario13::SelectionRectangle_ManipulationDelta(Object^ sender, Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs^ e)
{
CompositeTransform^ transform = (CompositeTransform^)selectionRectangle->RenderTransform;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto transform = ..., use safe_cast

break;

case ManipulationTypes::Size:
//Example Scaling factor used to determine the speed at which the box will grow/shrink.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after //, here and below

//Example Scaling factor used to determine the speed at which the box will grow/shrink.
auto scale = std::abs(1 + (float)e->Delta.Translation.X / 100);

//Restrict scaling to a Minimum value. this well prevent negative With amounts and app crashing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment needs editing, This will prevent...


auto allStrokes = inkCanvas->InkPresenter->StrokeContainer->GetStrokes();

if (allStrokes == nullptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

winrt containers should never be null, so this test is unnecessary, instead empty (Size() == 0). Is there an API bug where it returns null?


float3x2 matrixSacale = make_float3x2_scale(scale, topLeft);

for (auto stroke : allStrokes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto& stroke : ...

{
float3x2 matrix = make_float3x2_translation((float)position.X, (float)position.Y);

auto allStrokes = inkCanvas->InkPresenter->StrokeContainer->GetStrokes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indent

if (allStrokes == nullptr)
return;

for (auto stroke : allStrokes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto const&

void Scenario13::ClearSelection()
{
auto strokes = inkCanvas->InkPresenter->StrokeContainer->GetStrokes();
for (auto stroke : strokes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants