question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Proposal] DrawingView

See original GitHub issue

DrawingView

  • Proposed
  • Prototype
  • Implementation
    • iOS Support
    • Android Support
    • macOS Support
    • Windows Support
  • Unit Tests
  • Sample
  • Documentation

Summary

Allows you to draw one or multiple lines on a canvas

Detailed Design

DrawingView.shared.cs

public class DrawingView : View
{
  public static readonly BindableProperty ClearOnFinishProperty;
  public static readonly BindableProperty MultiLineModeProperty;
  public static readonly BindableProperty LinesProperty;
  public static readonly BindableProperty DrawingLineCompletedCommandProperty;
  public static readonly BindableProperty DefaultLineColorProperty;
  public static readonly BindableProperty DefaultLineWidthProperty;
  
  public event EventHandler<DrawingLineCompletedEventArgs>? DrawingLineCompleted;
  
  public Color DefaultLineColor { get; set; }
  public float DefaultLineWidth { get; set; }
  public ICommand? DrawingLineCompletedCommand { get; set; }
  public ObservableCollection<Line> Lines { get; set; }
  public bool MultiLineMode { get; set; }
  public bool ClearOnFinish { get; set; }
  
  public Stream GetImageStream(double imageSizeWidth, double imageSizeHeight);
  public static Stream GetImageStream(IEnumerable<Line> lines, Size imageSize, Color backgroundColor);
}

Usage Syntax

XAML Usage

<views:DrawingView x:Name="DrawingViewControl" 
   BackgroundColor="LightGray" 
   HeightRequest="200"
   DefaultLineColor="Red"
   DefaultLineWidth="3"
   Lines="{Binding Lines, Mode=TwoWay}"
   ClearOnFinish="{Binding Source={x:Reference ClearOnFinish}, Path=IsToggled}"
   MultiLineMode="{Binding Source={x:Reference MultiLineMode}, Path=IsToggled}"/>

C# Usage

new DrawingView
{
   BackgroundColor = Colors.LightGray,
   HeightRequest = 200,
   DefaultLineColor = Colors.Red,
   DefaultLineWidth = 3
}.Bind(DrawingView.Lines, nameof(ViewModel.Lines))
 .Bind(DrawingView.ClearOnFinish, nameof(ViewModel.ShouldClear))
 .Bind(DrawingView.MultiLineMode, nameof(ViewModel.ShouldAllowMultiLine));

Alternatives

Might be a duplicate of Microsoft.Maui.Graphics?

Unresolved Questions

Is DrawingView still necessary? Or has it been superseded by Microsoft.Maui.Graphics?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jsuarezruizcommented, Oct 7, 2021

I think could be part of the Toolkit or maybe also of .NET MAUI Graphics. What does make sense to me is directly use Maui Graphics in GraphicsView. Could simplified the code and at the end benefits also Graphics.

0reactions
msftbot[bot]commented, Apr 27, 2022

Reopening Proposal.

Only Proposals moved to the Closed Project Column and Completed Project Column can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CommunityToolkit/docs/maui/views/DrawingView.md at main
The DrawingView provides a surface that allows for the drawing of lines through the use of touch or mouse interaction.
Read more >
Save an Image from .NET MAUI Community Toolkit ... - YouTube
With the .NET MAUI Community Toolkit DrawingView you can let your creativity go free! Or, just capture boring signatures.
Read more >
How to use CommunityToolkit.Maui DrawingView inside of ...
In .NET MAUI Blazor , I tried to use the Drawing View in .razor page . ... I would suggest that you can...
Read more >
Saving and loading ink content from DrawView
Hello. I am writing an app on C# using MAUI, after some years without seriously touching C#, so I am a ittle rusty....
Read more >
Island on the Fence: drawing: view of proposal model ...
Island on the Fence: drawing: view of proposal model: floating island with border fence in background. Isla en la muralla.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found