├── .gitattributes
├── .gitignore
├── Acr.XamForms.SignaturePad.Droid
├── Acr.XamForms.SignaturePad.Droid.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Resources
│ ├── Layout
│ │ └── SignaturePad.axml
│ ├── Resource.Designer.cs
│ └── Values
│ │ └── Strings.xml
├── SignaturePadRenderer.cs
├── SignatureService.cs
├── SignatureServiceActivity.cs
└── packages.config
├── Acr.XamForms.SignaturePad.WindowsPhone
├── Acr.XamForms.SignaturePad.WindowsPhone.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SignaturePad.xaml
├── SignaturePad.xaml.cs
├── SignaturePadRenderer.cs
└── packages.config
├── Acr.XamForms.SignaturePad.iOS
├── Acr.XamForms.SignaturePad.iOS.csproj
├── Properties
│ └── AssemblyInfo.cs
├── SignaturePadRenderer.cs
├── SignatureService.cs
├── SignatureServiceController.cs
├── SignatureServiceView.cs
├── SignatureView.designer.cs
├── SignatureView.xib
└── packages.config
├── Acr.XamForms.SignaturePad
├── Acr.XamForms.SignaturePad.csproj
├── DrawPoint.cs
├── ISignatureService.cs
├── Properties
│ └── AssemblyInfo.cs
├── SignaturePadConfiguration.cs
├── SignaturePadView.cs
└── SignatureResult.cs
├── Acr.XamForms.sln
├── CommonAssemblyInfo.cs
├── Components
├── signature-pad-1.3.7.info
├── signature-pad-1.3.7.png
└── signature-pad-1.3.7
│ ├── component
│ ├── Details.md
│ ├── GettingStarted.md
│ ├── License.md
│ ├── Manifest.xml
│ ├── icons
│ │ ├── signature-pad_128x128.png
│ │ └── signature-pad_256x256.png
│ └── screenshots
│ │ └── signature-ios.jpg
│ ├── lib
│ ├── android
│ │ └── SignaturePad.Android.dll
│ ├── ios-unified
│ │ └── SignaturePad.iOS.dll
│ └── ios
│ │ └── SignaturePad.iOS.dll
│ └── samples
│ ├── Sample.Android
│ ├── Activity1.cs
│ ├── Assets
│ │ └── AboutAssets.txt
│ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── AboutResources.txt
│ │ ├── Resource.designer.cs
│ │ ├── drawable
│ │ │ ├── Icon.png
│ │ │ └── logo_galaxy_black_64.png
│ │ ├── layout
│ │ │ └── Main.axml
│ │ └── values
│ │ │ └── Strings.xml
│ ├── Sample.Android.csproj
│ └── Sample.Android.sln
│ ├── Sample.iOS-Classic
│ ├── AppDelegate.cs
│ ├── Controllers
│ │ └── SampleController.cs
│ ├── Default-568h@2x.png
│ ├── Entitlements.plist
│ ├── Info.plist
│ ├── Main.cs
│ ├── Resources
│ │ ├── Default-586h@2x-568h@2x.png
│ │ ├── Default-586h@2x-Landscape.png
│ │ ├── Default-586h@2x-Landscape@2x.png
│ │ ├── Default-586h@2x-Portrait.png
│ │ ├── Default-586h@2x-Portrait@2x.png
│ │ ├── Default-586h@2x.png
│ │ ├── Default-586h@2x@2x.png
│ │ ├── Icon-60@2x.png
│ │ ├── Icon-72.png
│ │ ├── Icon-72@2x.png
│ │ ├── Icon-76.png
│ │ ├── Icon-76@2x.png
│ │ ├── Icon-Small-40.png
│ │ ├── Icon-Small-40@2x.png
│ │ ├── Icon-Small-50.png
│ │ ├── Icon-Small-50@2x.png
│ │ ├── Icon-Small.png
│ │ ├── Icon-Small@2x.png
│ │ ├── Icon.png
│ │ ├── Icon@2x.png
│ │ └── logo-galaxy-black-64.png
│ ├── Sample-Classic.csproj
│ ├── Sample.iOS-Classic.sln
│ ├── Sample.iOS.csproj
│ ├── Views
│ │ └── SampleView.cs
│ ├── iTunesArtwork.png
│ └── iTunesArtwork@2x.png
│ └── Sample.iOS
│ ├── AppDelegate.cs
│ ├── Controllers
│ └── SampleController.cs
│ ├── Default-568h@2x.png
│ ├── Entitlements.plist
│ ├── Info.plist
│ ├── Main.cs
│ ├── Resources
│ ├── Default-586h@2x-568h@2x.png
│ ├── Default-586h@2x-Landscape.png
│ ├── Default-586h@2x-Landscape@2x.png
│ ├── Default-586h@2x-Portrait.png
│ ├── Default-586h@2x-Portrait@2x.png
│ ├── Default-586h@2x.png
│ ├── Default-586h@2x@2x.png
│ ├── Icon-60@2x.png
│ ├── Icon-72.png
│ ├── Icon-72@2x.png
│ ├── Icon-76.png
│ ├── Icon-76@2x.png
│ ├── Icon-Small-40.png
│ ├── Icon-Small-40@2x.png
│ ├── Icon-Small-50.png
│ ├── Icon-Small-50@2x.png
│ ├── Icon-Small.png
│ ├── Icon-Small@2x.png
│ ├── Icon.png
│ ├── Icon@2x.png
│ └── logo-galaxy-black-64.png
│ ├── Sample-Classic.csproj
│ ├── Sample.iOS.csproj
│ ├── Sample.iOS.sln
│ ├── Views
│ └── SampleView.cs
│ ├── iTunesArtwork.png
│ └── iTunesArtwork@2x.png
├── Samples
├── Samples.Android
│ ├── MainActivity.cs
│ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── Drawable
│ │ │ └── Icon.png
│ │ └── Resource.Designer.cs
│ ├── Samples.Android.csproj
│ └── packages.config
├── Samples.WinPhone
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Assets
│ │ ├── AlignmentGrid.png
│ │ ├── ApplicationIcon.png
│ │ └── Tiles
│ │ │ ├── FlipCycleTileLarge.png
│ │ │ ├── FlipCycleTileMedium.png
│ │ │ ├── FlipCycleTileSmall.png
│ │ │ ├── IconicTileMediumLarge.png
│ │ │ └── IconicTileSmall.png
│ ├── LocalizedStrings.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ ├── AssemblyInfo.cs
│ │ └── WMAppManifest.xml
│ ├── Resources
│ │ ├── AppResources.Designer.cs
│ │ └── AppResources.resx
│ ├── Samples.WinPhone.csproj
│ ├── Toolkit.Content
│ │ ├── ApplicationBar.Add.png
│ │ ├── ApplicationBar.Cancel.png
│ │ ├── ApplicationBar.Check.png
│ │ ├── ApplicationBar.Delete.png
│ │ └── ApplicationBar.Select.png
│ └── packages.config
├── Samples.iOS
│ ├── AppDelegate.cs
│ ├── Bootstrap
│ │ ├── BarCodeServiceBootstrap.cs
│ │ ├── MobileBootstrap.cs
│ │ ├── SignaturePadBootstrap.cs
│ │ └── UserDialogsBootstrap.cs
│ ├── Info.plist
│ ├── Main.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Samples.iOS.csproj
│ └── packages.config
└── Samples
│ ├── App.cs
│ ├── Models
│ ├── MenuItem.cs
│ └── Signature.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Samples.csproj
│ ├── ViewModels
│ ├── SignatureListViewModel.cs
│ └── SignaturePadConfigViewModel.cs
│ ├── Views
│ ├── HomeView.cs
│ ├── SignatureListView.xaml
│ ├── SignatureListView.xaml.cs
│ ├── SignaturePadConfigView.xaml
│ ├── SignaturePadConfigView.xaml.cs
│ ├── SignatureXamlView.xaml
│ └── SignatureXamlView.xaml.cs
│ └── packages.config
├── license.txt
├── nuspec
├── Acr.XamForms.SignaturePad.nuspec
├── Bootstrap
│ └── SignaturePadBootstrap.cs.pp
├── nuget.exe
└── pack.cmd
└── readme.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 | packages/
18 |
19 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
20 | !packages/*/build/
21 |
22 | # MSTest test Results
23 | [Tt]est[Rr]esult*/
24 | [Bb]uild[Ll]og.*
25 |
26 | *_i.c
27 | *_p.c
28 | *.ilk
29 | *.meta
30 | *.obj
31 | *.pch
32 | *.pdb
33 | *.pgc
34 | *.pgd
35 | *.rsp
36 | *.sbr
37 | *.tlb
38 | *.tli
39 | *.tlh
40 | *.tmp
41 | *.tmp_proj
42 | *.log
43 | *.vspscc
44 | *.vssscc
45 | .builds
46 | *.pidb
47 | *.log
48 | *.scc
49 |
50 | # Visual C++ cache files
51 | ipch/
52 | *.aps
53 | *.ncb
54 | *.opensdf
55 | *.sdf
56 | *.cachefile
57 |
58 | # Visual Studio profiler
59 | *.psess
60 | *.vsp
61 | *.vspx
62 |
63 | # Guidance Automation Toolkit
64 | *.gpState
65 |
66 | # ReSharper is a .NET coding add-in
67 | _ReSharper*/
68 | *.[Rr]e[Ss]harper
69 |
70 | # TeamCity is a build add-in
71 | _TeamCity*
72 |
73 | # DotCover is a Code Coverage Tool
74 | *.dotCover
75 |
76 | # NCrunch
77 | *.ncrunch*
78 | .*crunch*.local.xml
79 |
80 | # Installshield output folder
81 | [Ee]xpress/
82 |
83 | # DocProject is a documentation generator add-in
84 | DocProject/buildhelp/
85 | DocProject/Help/*.HxT
86 | DocProject/Help/*.HxC
87 | DocProject/Help/*.hhc
88 | DocProject/Help/*.hhk
89 | DocProject/Help/*.hhp
90 | DocProject/Help/Html2
91 | DocProject/Help/html
92 |
93 | # Click-Once directory
94 | publish/
95 |
96 | # Publish Web Output
97 | *.Publish.xml
98 |
99 | # NuGet Packages Directory
100 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
101 | #packages/
102 |
103 | # Windows Azure Build Output
104 | csx
105 | *.build.csdef
106 |
107 | # Windows Store app package directory
108 | AppPackages/
109 |
110 | # Others
111 | sql/
112 | ClientBin/
113 | [Ss]tyle[Cc]op.*
114 | ~$*
115 | *~
116 | *.dbmdl
117 | *.[Pp]ublish.xml
118 | *.pfx
119 | *.publishsettings
120 |
121 | # RIA/Silverlight projects
122 | Generated_Code/
123 |
124 | # Backup & report files from converting an old project file to a newer
125 | # Visual Studio version. Backup files are not needed, because we have git ;-)
126 | _UpgradeReport_Files/
127 | Backup*/
128 | UpgradeLog*.XML
129 | UpgradeLog*.htm
130 |
131 | # SQL Server files
132 | App_Data/*.mdf
133 | App_Data/*.ldf
134 |
135 |
136 | #LightSwitch generated files
137 | GeneratedArtifacts/
138 | _Pvt_Extensions/
139 | ModelManifest.xml
140 |
141 | # =========================
142 | # Windows detritus
143 | # =========================
144 |
145 | # Windows image file caches
146 | Thumbs.db
147 | ehthumbs.db
148 |
149 | # Folder config file
150 | Desktop.ini
151 |
152 | # Recycle Bin used on file shares
153 | $RECYCLE.BIN/
154 |
155 | # Mac desktop service store files
156 | .DS_Store
157 | *.DotSettings
158 |
159 | *.userprefs
160 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/Acr.XamForms.SignaturePad.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {1D5482F6-AA89-422C-9E34-88A8A1AD8AB6}
7 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
8 | Library
9 | Properties
10 | Acr.XamForms.SignaturePad.Droid
11 | Acr.XamForms.SignaturePad.Droid
12 | 512
13 | Resources\Resource.Designer.cs
14 | Off
15 | v4.4
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | 0509c31c
24 | False
25 |
26 |
27 | true
28 | full
29 | false
30 | ..\bin\Debug\MonoAndroid\
31 | DEBUG;TRACE
32 | prompt
33 | 4
34 | None
35 |
36 |
37 | pdbonly
38 | true
39 | ..\bin\Release\MonoAndroid\
40 | TRACE
41 | prompt
42 | 4
43 | false
44 |
45 |
46 |
47 | ..\packages\Xamarin.Forms.1.4.2.6359\lib\MonoAndroid10\FormsViewGroup.dll
48 | True
49 |
50 |
51 |
52 |
53 | ..\Components\signature-pad-1.3.7\lib\android\SignaturePad.Android.dll
54 |
55 |
56 |
57 |
58 |
59 | ..\packages\Xamarin.Android.Support.v4.22.1.1.1\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll
60 | True
61 |
62 |
63 | ..\packages\Xamarin.Forms.1.4.2.6359\lib\MonoAndroid10\Xamarin.Forms.Core.dll
64 | True
65 |
66 |
67 | ..\packages\Xamarin.Forms.1.4.2.6359\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
68 | True
69 |
70 |
71 | ..\packages\Xamarin.Forms.1.4.2.6359\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
72 | True
73 |
74 |
75 | ..\packages\Xamarin.Forms.1.4.2.6359\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
76 | True
77 |
78 |
79 |
80 |
81 | CommonAssemblyInfo.cs
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
100 |
101 |
102 | {B2AF970D-D640-451C-95AF-92AF531B8C1E}
103 | Acr.XamForms.SignaturePad
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | False
113 | 1.3.7
114 |
115 |
116 |
117 |
118 |
119 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Acr.XamForms.SignaturePad.Droid")]
4 | [assembly: AssemblyDescription("")]
5 |
6 | [assembly: AssemblyVersion("1.0.0.0")]
7 | [assembly: AssemblyFileVersion("1.0.0.0")]
8 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/Resources/Layout/SignaturePad.axml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
18 |
28 |
38 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/Resources/Resource.Designer.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable 1591
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.0
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | [assembly: global::Android.Runtime.ResourceDesignerAttribute("Acr.XamForms.SignaturePad.Droid.Resource", IsApplication=false)]
13 |
14 | namespace Acr.XamForms.SignaturePad.Droid
15 | {
16 |
17 |
18 | [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
19 | public partial class Resource
20 | {
21 |
22 | static Resource()
23 | {
24 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
25 | }
26 |
27 | public partial class Attribute
28 | {
29 |
30 | static Attribute()
31 | {
32 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
33 | }
34 |
35 | private Attribute()
36 | {
37 | }
38 | }
39 |
40 | public partial class Id
41 | {
42 |
43 | // aapt resource value: 0x7f040002
44 | public static int btnCancel = 2130968578;
45 |
46 | // aapt resource value: 0x7f040003
47 | public static int btnSave = 2130968579;
48 |
49 | // aapt resource value: 0x7f040000
50 | public static int rootView = 2130968576;
51 |
52 | // aapt resource value: 0x7f040001
53 | public static int signatureView = 2130968577;
54 |
55 | static Id()
56 | {
57 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
58 | }
59 |
60 | private Id()
61 | {
62 | }
63 | }
64 |
65 | public partial class Layout
66 | {
67 |
68 | // aapt resource value: 0x7f020000
69 | public static int SignaturePad = 2130837504;
70 |
71 | static Layout()
72 | {
73 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
74 | }
75 |
76 | private Layout()
77 | {
78 | }
79 | }
80 |
81 | public partial class String
82 | {
83 |
84 | // aapt resource value: 0x7f030001
85 | public static int ApplicationName = 2130903041;
86 |
87 | // aapt resource value: 0x7f030000
88 | public static int Hello = 2130903040;
89 |
90 | static String()
91 | {
92 | global::Android.Runtime.ResourceIdManager.UpdateIdValues();
93 | }
94 |
95 | private String()
96 | {
97 | }
98 | }
99 | }
100 | }
101 | #pragma warning restore 1591
102 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/Resources/Values/Strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World, Click Me!
4 | $projectname$
5 |
6 |
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/SignaturePadRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Drawing;
4 | using System.IO;
5 | using System.Linq;
6 | using Acr.XamForms.SignaturePad;
7 | using Acr.XamForms.SignaturePad.Droid;
8 | using Xamarin.Forms;
9 | using Xamarin.Forms.Platform.Android;
10 | using Color = Xamarin.Forms.Color;
11 | using NativeView = SignaturePad.SignaturePadView;
12 |
13 | [assembly: ExportRenderer(typeof(SignaturePadView), typeof(SignaturePadRenderer))]
14 |
15 |
16 | namespace Acr.XamForms.SignaturePad.Droid {
17 |
18 | public class SignaturePadRenderer : ViewRenderer {
19 |
20 | protected override void OnElementChanged(ElementChangedEventArgs e) {
21 | base.OnElementChanged(e);
22 |
23 | if (e.OldElement != null || this.Element == null)
24 | return;
25 |
26 | var view = new NativeView(Forms.Context);
27 | var el = e.NewElement;
28 |
29 | if (el.BackgroundColor != Color.Default)
30 | view.BackgroundColor = el.BackgroundColor.ToAndroid();
31 |
32 | if (!String.IsNullOrWhiteSpace(el.CaptionText))
33 | view.Caption.Text = el.CaptionText;
34 |
35 | if (el.CaptionTextColor != Color.Default)
36 | view.Caption.SetTextColor(el.CaptionTextColor.ToAndroid());
37 |
38 | if (!String.IsNullOrWhiteSpace(el.ClearText))
39 | view.ClearLabel.Text = el.ClearText;
40 |
41 | if (el.ClearTextColor != Color.Default)
42 | view.ClearLabel.SetTextColor(el.ClearTextColor.ToAndroid());
43 |
44 | if (!String.IsNullOrWhiteSpace(el.PromptText))
45 | view.SignaturePrompt.Text = el.PromptText;
46 |
47 | if (el.PromptTextColor != Color.Default)
48 | view.SignaturePrompt.SetTextColor(el.PromptTextColor.ToAndroid());
49 |
50 | if (el.SignatureLineColor != Color.Default)
51 | view.SignatureLineColor = el.SignatureLineColor.ToAndroid();
52 |
53 | if (el.StrokeColor != Color.Default)
54 | view.StrokeColor = el.StrokeColor.ToAndroid();
55 |
56 | if (el.StrokeWidth > 0)
57 | view.StrokeWidth = el.StrokeWidth;
58 |
59 | this.Element.SetInternals(
60 | this.GetImageStream,
61 | () => view.Points.Select(x => new DrawPoint(x.X, x.Y)),
62 | x => view.LoadPoints(x.Select(y => new PointF(y.X, y.Y)).ToArray()),
63 | () => view.IsBlank
64 | );
65 |
66 | this.SetNativeControl(view);
67 | }
68 |
69 |
70 | protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) {
71 | base.OnElementPropertyChanged(sender, e);
72 |
73 | if (this.Element == null || this.Control == null)
74 | return;
75 |
76 | var el = this.Element;
77 | if (e.PropertyName == SignaturePadView.BackgroundColorProperty.PropertyName)
78 | this.Control.BackgroundColor = el.BackgroundColor.ToAndroid();
79 |
80 | else if (e.PropertyName == SignaturePadView.CaptionTextProperty.PropertyName)
81 | this.Control.Caption.Text = el.CaptionText;
82 |
83 | else if (e.PropertyName == SignaturePadView.CaptionTextColorProperty.PropertyName)
84 | this.Control.Caption.SetTextColor(el.CaptionTextColor.ToAndroid());
85 |
86 | else if (e.PropertyName == SignaturePadView.ClearTextProperty.PropertyName)
87 | this.Control.ClearLabel.Text = el.ClearText;
88 |
89 | else if (e.PropertyName == SignaturePadView.ClearTextColorProperty.PropertyName)
90 | this.Control.ClearLabel.SetTextColor(el.ClearTextColor.ToAndroid());
91 |
92 | else if (e.PropertyName == SignaturePadView.PromptTextProperty.PropertyName)
93 | this.Control.SignaturePrompt.Text = el.PromptText;
94 |
95 | else if (e.PropertyName == SignaturePadView.PromptTextColorProperty.PropertyName)
96 | this.Control.SignaturePrompt.SetTextColor(el.PromptTextColor.ToAndroid());
97 |
98 | else if (e.PropertyName == SignaturePadView.SignatureLineColorProperty.PropertyName)
99 | this.Control.SignatureLineColor = el.SignatureLineColor.ToAndroid();
100 |
101 | else if (e.PropertyName == SignaturePadView.StrokeColorProperty.PropertyName)
102 | this.Control.StrokeColor = el.StrokeColor.ToAndroid();
103 |
104 | else if (e.PropertyName == SignaturePadView.StrokeWidthProperty.PropertyName)
105 | this.Control.StrokeWidth = el.StrokeWidth;
106 | }
107 |
108 |
109 | private Stream GetImageStream(ImageFormatType imgFormat) {
110 | using (var image = this.Control.GetImage()) {
111 | var stream = new MemoryStream();
112 | var format = imgFormat == ImageFormatType.Png
113 | ? Android.Graphics.Bitmap.CompressFormat.Png
114 | : Android.Graphics.Bitmap.CompressFormat.Jpeg;
115 | image.Compress(format, 100, stream); // TODO: quality control
116 | return stream; // TODO: careful
117 | }
118 | }
119 | }
120 | }
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/SignatureService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Acr.XamForms.SignaturePad.Droid;
5 | using Xamarin.Forms;
6 |
7 | [assembly: Dependency(typeof(SignatureService))]
8 |
9 |
10 | namespace Acr.XamForms.SignaturePad.Droid {
11 |
12 | public class SignatureService : ISignatureService {
13 |
14 | internal SignaturePadConfiguration CurrentConfig { get; private set; }
15 | private TaskCompletionSource tcs;
16 |
17 |
18 | internal void Complete(SignatureResult result) {
19 | this.tcs.TrySetResult(result);
20 | }
21 |
22 |
23 | internal void Cancel() {
24 | this.tcs.TrySetResult(new SignatureResult(true, null, null));
25 | }
26 |
27 |
28 | public virtual Task Request(SignaturePadConfiguration config, CancellationToken cancelToken) {
29 | CurrentConfig = config ?? SignaturePadConfiguration.Default;
30 |
31 | this.tcs = new TaskCompletionSource();
32 | cancelToken.Register(this.Cancel);
33 | Forms.Context.StartActivity(typeof(SignaturePadActivity));
34 |
35 | return this.tcs.Task;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Acr.XamForms.SignaturePad.Droid/SignatureServiceActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using Android.App;
5 | using Android.OS;
6 | using Xamarin.Forms;
7 | using Xamarin.Forms.Platform.Android;
8 | using Button = Android.Widget.Button;
9 | using NativeView = global::SignaturePad.SignaturePadView;
10 | using RelativeLayout = Android.Widget.RelativeLayout;
11 |
12 |
13 | namespace Acr.XamForms.SignaturePad.Droid {
14 |
15 | [Activity]
16 | public class SignaturePadActivity : Activity {
17 | private static readonly string fileStore;
18 | private NativeView signatureView;
19 | private Button btnSave;
20 | private Button btnCancel;
21 |
22 |
23 | static SignaturePadActivity() {
24 | var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
25 | fileStore = Path.Combine(path, "signature.tmp");
26 | }
27 |
28 |
29 | protected override void OnCreate(Bundle bundle) {
30 | base.OnCreate(bundle);
31 | this.SetContentView(Resource.Layout.SignaturePad);
32 |
33 | var rootView = this.FindViewById(Resource.Id.rootView);
34 | this.signatureView = this.FindViewById(Resource.Id.signatureView);
35 | this.btnSave = this.FindViewById