Repository navigation
Labels
approvedThis Proposal has been approved and is ready to be added to the ToolkitThis Proposal has been approved and is ready to be added to the ToolkitchampionA member of the .NET MAUI Toolkit core team has chosen to champion this featureA member of the .NET MAUI Toolkit core team has chosen to champion this featuredocumentation approvedproposalA fully fleshed out proposal describing a new feature in syntactic and semantic detailA fully fleshed out proposal describing a new feature in syntactic and semantic detail
Milestone
Description
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?
Metadata
Metadata
Assignees
Labels
approvedThis Proposal has been approved and is ready to be added to the ToolkitThis Proposal has been approved and is ready to be added to the ToolkitchampionA member of the .NET MAUI Toolkit core team has chosen to champion this featureA member of the .NET MAUI Toolkit core team has chosen to champion this featuredocumentation approvedproposalA fully fleshed out proposal describing a new feature in syntactic and semantic detailA fully fleshed out proposal describing a new feature in syntactic and semantic detail
Activity
VladislavAntonyuk commentedon Sep 28, 2021
Duplicate #4
VladislavAntonyuk commentedon Sep 28, 2021
DrawingView allows to draw any shape (draw the line by finger), while Maui Graphics has predefined shapes: lines, rectangles.
TheCodeTraveler commentedon Sep 28, 2021
@jsuarezruiz Could you confirm whether or not
Microsoft.Maui.Graphicswill make DrawingView obsolete?VladislavAntonyuk commentedon Oct 6, 2021
@jsuarezruiz maybe DrawingView can be a part of Maui Graphics? Or is it not enough stable yet?
jsuarezruiz commentedon 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.
TheCodeTraveler commentedon Jan 6, 2022
May be duplicate of GraphicsView: dotnet/maui#923
VladislavAntonyuk commentedon Jan 6, 2022
@brminnick I don't think it is a duplicate.
Maui.Graphics provides control to draw - GraphicsView (consider it to be a paper), But DrawingView actually draws on it (like a pencil).
We can use controls from Maui.Graphics (https://github.com/dotnet/Microsoft.Maui.Graphics/blob/main/src/Microsoft.Maui.Graphics/Android/NativeGraphicsView.cs) instead of implementing our own (https://github.com/VladislavAntonyuk/Maui/commit/23503b47026f1e99416f8a38f5d3a717dbfc2fa1#diff-ba611d8a56be8ce1566b9bd46df26cd055b8fbc3fb05df9560d7ecb8cb48ecbcR24)