Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Feature/add drawingcompleted event to drawingview #1473

Conversation

bijington
Copy link
Contributor

@bijington bijington commented Jul 5, 2021

Description of Change

Bugs Fixed

API Changes

Added:

  • DrawingView.DrawingCompleted event
  • DrawingCompletedEventArgs with the points that are in the drawing

Behavioral Changes

  • Refactored the raising of DrawingCompletedCommand to be within the DrawingView which simplifies the raising of the new event also.
  • Fixed a potentially serious issue with the Points collection being initialised to a share instance.

PR Checklist

  • Has a linked Issue, and the Issue has been approved
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

@bijington bijington changed the base branch from main to develop July 5, 2021 22:31
@bijington
Copy link
Contributor Author

I have clearly screwed something up. I tried rebasing on develop since I had originally branched from main. I suspect if this is still needed I will need to start with a clean branch off develop

@pictos
Copy link
Contributor

pictos commented Jul 5, 2021

@bijington we just target main for bug fixes

bijington added 3 commits July 9, 2021 06:07
- Centralize the on complete invocation.
- Add event to invoke when complete.
@bijington bijington force-pushed the feature/add-drawingcompleted-event-to-drawingview branch from 70daf60 to a425206 Compare July 9, 2021 05:13
@bijington bijington marked this pull request as ready for review July 9, 2021 05:17
@VladislavAntonyuk
Copy link
Contributor

also moved it to #1475

@@ -94,5 +97,19 @@ static object CoerceValue(BindableObject bindable, object value)
Color strokeColor,
Color backgroundColor) =>
DrawingViewService.GetImageStream(points.ToList(), imageSize, lineWidth, strokeColor, backgroundColor);

public void OnDrawingCompleted()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be internal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did originally make it internal but the DrawingViewRenderer.wpf.cs class is external to this project.

Copy link
Contributor

Choose a reason for hiding this comment

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

DrawingViewRenderer.wpf.cs is a sample. and not a part of the plugin, so let's make this method internal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I completely missed that! I can revert the renderer code to use the Command implementation then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should now be addressed

if (!Points.Any())
return;

if (DrawingCompletedCommand?.CanExecute(null) ?? false)
Copy link
Contributor

Choose a reason for hiding this comment

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

CanExecute(Points)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it would get fixed in a separate PR for this: #1474 but I guess it is a limited change. I thought additional unit tests would have been good though which then increases the size of that change.

Copy link
Contributor

Choose a reason for hiding this comment

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

you are adding a new code, where actually the bug exists. even if it's just a copy from another part. I think it would be nice to fix it as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK Happy to fix. I will add some unit tests covering the bug fix also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should now be addressed

if (Element.DrawingCompletedCommand?.CanExecute(null) ?? false)
Element.DrawingCompletedCommand.Execute(Element.Points);
}
Element.OnDrawingCompleted();

if (Element.ClearOnFinish)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Clear function does some tidy up logic in the renderer so I think it needs to stay.

Copy link
Contributor

Choose a reason for hiding this comment

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

for example on Android, you removed this method, while it stays here.
I understand that you wanted to removed duplicated code and move it to the shared OnDrawingCompleted, but because of such additional logic in Clear method, I think it's better to keep it in all renderers.
I implemented the same in DrawingView MultiLine PR.

if (Element.DrawingCompletedCommand?.CanExecute(null) ?? false)
Element.DrawingCompletedCommand.Execute(elementPoints);
}
Element.OnDrawingCompleted();

if (Element.ClearOnFinish)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should be removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

If Element.ClearOnFinish is executed in DrawingView.shared.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Clear function does some tidy up logic in the renderer so I think it needs to stay.

@jfversluis
Copy link
Member

Sorry for the conflicts :( let me know if you want to update or abandon this

@VladislavAntonyuk
Copy link
Contributor

It is already implemented in the MultiLine PR

@bijington
Copy link
Contributor Author

I don't think this PR adds any real value now so I'm happy to close it

@VladislavAntonyuk
Copy link
Contributor

maybe if we have a minor release before 1.3, it can be included

@bijington
Copy link
Contributor Author

It's entirely up to you. If it was released then I guess this would be better targeting main instead?

@jfversluis
Copy link
Member

Ah right, this is included in the other one. OK, then we can close this one. There probably won't be a service release for 1.2 :)

Thanks for your efforts though @bijington !

@jfversluis jfversluis closed this Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Add DrawingCompleted Event to DrawingView
4 participants