签名板Xamarin.Forms将签名另存为文件 [英] Signature Pad Xamarin.Forms Saving signature as a file
本文介绍了签名板Xamarin.Forms将签名另存为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Xamarin的初学者. 我试图编写一个简单的应用程序来借助Signature Pad保存签名. 来自MainPage.xaml的一段代码
I am a beginner in Xamarin. I tried to write a simple app to save the signature with the help of Signature Pad. A piece of code from MainPage.xaml
<controls:SignaturePadView x:Name="SignaturePAD"
Grid.Row="1"
StrokeColor="Black"
StrokeWidth="3"
BackgroundColor="Gray"
CaptionTextColor="Black"
PromptTextColor="Black"
SignatureLineColor="Black"
CaptionText="Podpis odbiorcy">
</controls:SignaturePadView>
<Button Grid.Row="2"
x:Name="SaveButton"
Text="Potwierdź"
Clicked="SaveSignature"/>
和MainPage.xaml.cs中的一个片段
and a fragment from MainPage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
public async void SaveSignature(object sender, EventArgs e)
{
Stream image = await SignaturePAD.GetImageStreamAsync(SignatureImageFormat.Png);
}
}
我的问题是如何将其保存到手机库中? 我将不胜感激
And my question is how can I save it into the my phone gallery? I will be grateful for any help
推荐答案
SignaturePad
返回流-因此您可以使用普通的C#I/O将其写入文件,例如FileStream
the SignaturePad
returns a stream - so you can write it to a file using normal C# I/O, like FileStream
Stream image = await SignaturePAD.GetImageStreamAsync(SignatureImageFormat.Png);
using (FileStream file = new FileStream(file_path, FileMode.Create, System.IO.FileAccess.Write))
{
image.CopyTo(file);
}
这篇关于签名板Xamarin.Forms将签名另存为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文