Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Add some documentation #152

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SignaturePad.Android/SignaturePadCanvasView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public float StrokeWidth
{
stroke.Width = value;
}

inkPresenter.Invalidate ();
}
}

/// <summary>
/// Clear the canvas and invoke <see cref="Cleared"/> event
/// </summary>
public void Clear ()
{
inkPresenter.Clear ();
Expand Down
10 changes: 8 additions & 2 deletions src/SignaturePad.Android/SignaturePadView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,19 @@ private void Initialize (IAttributeSet attrs)
}

public SignaturePadCanvasView SignaturePadCanvas { get; private set; }

public View SignatureLine { get; private set; }

/// <summary>
/// TextView which write text below the separator line
/// </summary>
public TextView Caption { get; private set; }

/// <summary>
/// TextView which write text aboce the separator line
/// </summary>
public TextView SignaturePrompt { get; private set; }

public TextView ClearLabel { get; private set; }

[Obsolete ("Set the background instead.")]
Expand Down
20 changes: 20 additions & 0 deletions src/SignaturePad.Shared/SignaturePadCanvasView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ partial class SignaturePadCanvasView

public event EventHandler Cleared;

/// <summary>
/// Check if there is any stoke.
/// </summary>
public bool IsBlank => inkPresenter == null ? true : inkPresenter.GetStrokes ().Count == 0;

/// <summary>
/// Get currents points. A new line of points start with coordinate (0,0)
/// </summary>
public NativePoint[] Points
{
get
Expand All @@ -63,6 +69,9 @@ public NativePoint[] Points
}
}

/// <summary>
/// Get currents strokes represented by an array of array of points.
/// </summary>
public NativePoint[][] Strokes
{
get
Expand All @@ -77,6 +86,12 @@ public NativePoint[][] Strokes
}
}

/// <summary>
/// Get a rect containing the signature.
/// Some padding can be add to a max from bounds of canvas.
/// </summary>
/// <param name="padding">Padding added to the signature.</param>
/// <returns>The rect containing the signature with some padding.</returns>
public NativeRect GetSignatureBounds (float padding = 5f)
{
if (IsBlank)
Expand Down Expand Up @@ -436,6 +451,11 @@ private bool GetImageConstructionArguments (ImageConstructionSettings settings,
return true;
}

/// <summary>
/// Allow the user to import strokes represented by an array of an array of points.
/// Strokes are used to draw a signature in the view after clearing it.
/// </summary>
/// <param name="loadedStrokes">Array of array of points. Each array of points represent a line.</param>
public void LoadStrokes (NativePoint[][] loadedStrokes)
{
// clear any existing paths or points.
Expand Down
19 changes: 19 additions & 0 deletions src/SignaturePad.Shared/SignaturePadView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ partial class SignaturePadView
private static readonly NativeColor SignaturePadLightColor = Windows.UI.Colors.White;
#endif


/// <summary>
/// Get currents strokes from the canvas. Strokes are represented by an array of array of points.
/// </summary>
public NativePoint[][] Strokes => SignaturePadCanvas.Strokes;

/// <summary>
/// Get currents points from the canvas. A new line of points start with coordinate (0,0)
/// </summary>
public NativePoint[] Points => SignaturePadCanvas.Points;

public bool IsBlank => SignaturePadCanvas?.IsBlank ?? true;
Expand All @@ -61,20 +68,32 @@ partial class SignaturePadView

public event EventHandler Cleared;

/// <summary>
/// Clear the canvas and invoke <see cref="Cleared"/> event
/// </summary>
public void Clear ()
{
SignaturePadCanvas.Clear ();

UpdateUi ();
}

/// <summary>
/// Allow the user to import an array of points to be used to draw a signature in the view, with new
/// lines indicated by a { 0, 0 } point in the array.
/// <param name="loadedPoints"></param>
public void LoadPoints (NativePoint[] points)
{
SignaturePadCanvas.LoadPoints (points);

UpdateUi ();
}

/// <summary>
/// Allow the user to import strokes represented by an array of an array of points.
/// Strokes are used to draw a signature in the view after clearing it.
/// </summary>
/// <param name="loadedStrokes">Array of array of points. Each array of points represent a line.</param>
public void LoadStrokes (NativePoint[][] strokes)
{
SignaturePadCanvas.LoadStrokes (strokes);
Expand Down