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

[BUG] GetImageStream wrong when lines populated from code #649

Closed
1 task done
cornem opened this issue Sep 22, 2022 · 4 comments · Fixed by #653
Closed
1 task done

[BUG] GetImageStream wrong when lines populated from code #649

cornem opened this issue Sep 22, 2022 · 4 comments · Fixed by #653
Assignees
Labels
bug Something isn't working

Comments

@cornem
Copy link

cornem commented Sep 22, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When the DrawingView.Lines is bound to a view model property and initalized with some lines, the DrawingView displays the lines correctly, but GetImageStream returns a bitmap of only a portion of the view. After the user has interacted with the DrawingView, a proper bitmap will be returned.

Expected Behavior

When the view is initialized with a binding on Lines already containing some lines, GetImageStream should return a bitmap of the same size as if the lines were drawn on the view by the user.

Steps To Reproduce

  1. Create a view model with a property ObservableCollection<IDrawingLine>
  2. Initialize the property with some DrawingLine instances
  3. Create a view with a DrawingView and bind the Lines to the view model property
  4. Show bitmap using DrawingView.GetImageStream
  5. Observe the difference after interacting with the DrawingView

Link to public reproduction project repository

https://github.com/cornem/maui-drawingview-repro

Environment

- .NET MAUI CommunityToolkit: 1.3.0
- OS: Windows 11
- .NET MAUI: 6.0.486

Anything else?

Confirmed not working on Windows and Android. Other targets were not tested.

@cornem cornem added bug Something isn't working unverified labels Sep 22, 2022
@VladislavAntonyuk VladislavAntonyuk self-assigned this Sep 22, 2022
@cornem
Copy link
Author

cornem commented Sep 23, 2022

Looking at this more, what actually appears to happen is that somehow all lines except the last DrawingLine are removed from the Lines collection.

So at the time the Loaded event fires, drawingView.Lines only contains one line, though seven lines were added when MainViewModel initialized.

@bijington
Copy link
Contributor

@cornem It looks like you haven't set ClearOnFinish to false as per the docs here: https://learn.microsoft.com/en-gb/dotnet/communitytoolkit/maui/views/drawingview#multiline-usage

@VladislavAntonyuk I do wonder if we should either automatically set ClearOnFinish if IsMultiLineModeEnabled is set to true, or ignore the flag?

@cornem
Copy link
Author

cornem commented Sep 23, 2022

@bijington Setting that property actually makes no difference; Lines.Count is still 1 instead of 7.

@VladislavAntonyuk
Copy link
Collaborator

@cornem It looks like you haven't set ClearOnFinish to false as per the docs here: https://learn.microsoft.com/en-gb/dotnet/communitytoolkit/maui/views/drawingview#multiline-usage

@VladislavAntonyuk I do wonder if we should either automatically set ClearOnFinish if IsMultiLineModeEnabled is set to true, or ignore the flag?

no, they are independent. I may have 5 lines (IsMultiLineModeEnabled = true). I want to clean on drawing 6th line. I set ClearOnFinish = true.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants