本文整理汇总了C#中Windows.OpenReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.OpenReadAsync方法的具体用法?C# Windows.OpenReadAsync怎么用?C# Windows.OpenReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.OpenReadAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScanBarcodeAsync
public async Task ScanBarcodeAsync(Windows.Storage.StorageFile file)
{
WriteableBitmap bitmap;
BitmapDecoder decoder;
using (IRandomAccessStream str = await file.OpenReadAsync())
{
decoder = await BitmapDecoder.CreateAsync(str);
bitmap = new WriteableBitmap(Convert.ToInt32(decoder.PixelWidth), Convert.ToInt32(decoder.PixelHeight));
await bitmap.SetSourceAsync(str);
}
lock (locker)
{
ZXing.BarcodeReader reader = new ZXing.BarcodeReader();
reader.Options.PossibleFormats = new ZXing.BarcodeFormat[] { ZXing.BarcodeFormat.CODE_128, ZXing.BarcodeFormat.QR_CODE, ZXing.BarcodeFormat.CODE_39 };
reader.Options.TryHarder = true;
reader.AutoRotate = true;
var results = reader.Decode(bitmap);
if (results == null)
{
this.OnBarcodeScannCompleted(new BarcodeScanCompletedEventArgs(false, string.Empty));
}
else
{
this.OnBarcodeScannCompleted(new BarcodeScanCompletedEventArgs(true, results.Text));
}
}
}
示例2: GetBookFromFile
public async static Task<IBook> GetBookFromFile(Windows.Storage.IStorageFile file)
{
if (file == null) { return null; }
else if (Path.GetExtension(file.Path).ToLower() == ".pdf")
{
var book = new Books.Pdf.PdfBook();
await book.Load(file);
return book;
}
else if (new string[] { ".zip", ".cbz" }.Contains(Path.GetExtension(file.Path).ToLower()))
{
var book = new Books.Cbz.CbzBook();
await book.LoadAsync(WindowsRuntimeStreamExtensions.AsStream(await file.OpenReadAsync()));
return book;
}
else if (new string[] { ".rar", ".cbr" }.Contains(Path.GetExtension(file.Path).ToLower()))
{
var book = new Books.Compressed.CompressedBook();
await book.LoadAsync(WindowsRuntimeStreamExtensions.AsStream(await file.OpenReadAsync()));
return book;
}
return null;
}