-
Notifications
You must be signed in to change notification settings - Fork 457
Feature/add drawingcompleted event to drawingview #1473
Feature/add drawingcompleted event to drawingview #1473
Conversation
I have clearly screwed something up. I tried rebasing on |
@bijington we just target |
- Centralize the on complete invocation. - Add event to invoke when complete.
70daf60
to
a425206
Compare
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CanExecute(Points)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be removed?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should be removed?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
…ithub.com:bijington/XamarinCommunityToolkit into feature/add-drawingcompleted-event-to-drawingview
Sorry for the conflicts :( let me know if you want to update or abandon this |
It is already implemented in the MultiLine PR |
I don't think this PR adds any real value now so I'm happy to close it |
maybe if we have a minor release before 1.3, it can be included |
It's entirely up to you. If it was released then I guess this would be better targeting main instead? |
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 ! |
Description of Change
Bugs Fixed
DrawingCompleted
Event toDrawingView
#1466API Changes
Added:
DrawingView.DrawingCompleted
eventDrawingCompletedEventArgs
with the points that are in the drawingBehavioral Changes
DrawingCompletedCommand
to be within theDrawingView
which simplifies the raising of the new event also.Points
collection being initialised to a share instance.PR Checklist
approved