From 3e48517abd78411db9d6feca06382fcec4c23366 Mon Sep 17 00:00:00 2001 From: Gillardo Date: Tue, 28 Apr 2015 13:46:32 +0100 Subject: [PATCH] Added support for WP8 --- plugin.xml | 9 +++++++++ src/wp8/FileOpener2.cs | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/wp8/FileOpener2.cs diff --git a/plugin.xml b/plugin.xml index d74dbc6..a7008e7 100644 --- a/plugin.xml +++ b/plugin.xml @@ -37,4 +37,13 @@ + + + + + + + + + diff --git a/src/wp8/FileOpener2.cs b/src/wp8/FileOpener2.cs new file mode 100644 index 0000000..9c389e7 --- /dev/null +++ b/src/wp8/FileOpener2.cs @@ -0,0 +1,46 @@ +using System; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Microsoft.Phone.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Media; +using Windows.Storage; +using System.Diagnostics; +using System.IO; + +namespace WPCordovaClassLib.Cordova.Commands +{ + public class FileOpener2 : BaseCommand + { + + public async void open(string options) + { + string[] args = JSON.JsonHelper.Deserialize(options); + var fileName = System.IO.Path.GetFileName(args[0]); + string aliasCurrentCommandCallbackId = args[2]; + + try + { + // Access isolated storage. + StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; + + // Access the file. + StorageFile file = await local.GetFileAsync(fileName); + + // Launch the bug query file. + await Windows.System.Launcher.LaunchFileAsync(file); + + DispatchCommandResult(new PluginResult(PluginResult.Status.OK), aliasCurrentCommandCallbackId); + } + catch (FileNotFoundException) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), aliasCurrentCommandCallbackId); + } + catch (Exception) + { + DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR), aliasCurrentCommandCallbackId); + } + } + } +} \ No newline at end of file