From 49a9c54b318ae922e1d3565954f54bdf699b4c2c Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 16 Jul 2012 18:15:31 -0700 Subject: [PATCH] Camera + Notification --- .../standalone/cordovalib/Commands/Camera.cs | 19 +++++++++++++++++-- .../cordovalib/Commands/Notification.cs | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/templates/standalone/cordovalib/Commands/Camera.cs b/templates/standalone/cordovalib/Commands/Camera.cs index 9e10a7d..8fbf317 100644 --- a/templates/standalone/cordovalib/Commands/Camera.cs +++ b/templates/standalone/cordovalib/Commands/Camera.cs @@ -195,8 +195,23 @@ public void takePicture(string options) { try { - this.cameraOptions = String.IsNullOrEmpty(options) ? - new CameraOptions() : JSON.JsonHelper.Deserialize(options); + string[] args = JSON.JsonHelper.Deserialize(options); + // ["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType", + // "mediaType", "allowEdit", "correctOrientation", "saveToPhotoAlbum" ] + this.cameraOptions = new CameraOptions(); + this.cameraOptions.Quality = int.Parse(args[0]); + this.cameraOptions.DestinationType = int.Parse(args[1]); + this.cameraOptions.PictureSourceType = int.Parse(args[2]); + this.cameraOptions.TargetWidth = int.Parse(args[3]); + this.cameraOptions.TargetHeight = int.Parse(args[4]); + this.cameraOptions.EncodingType = int.Parse(args[5]); + this.cameraOptions.MediaType = int.Parse(args[6]); + this.cameraOptions.AllowEdit = bool.Parse(args[7]); + this.cameraOptions.CorrectOrientation = bool.Parse(args[8]); + this.cameraOptions.SaveToPhotoAlbum = bool.Parse(args[9]); + + //this.cameraOptions = String.IsNullOrEmpty(options) ? + // new CameraOptions() : JSON.JsonHelper.Deserialize(options); } catch (Exception ex) { diff --git a/templates/standalone/cordovalib/Commands/Notification.cs b/templates/standalone/cordovalib/Commands/Notification.cs index f91cc71..896342e 100644 --- a/templates/standalone/cordovalib/Commands/Notification.cs +++ b/templates/standalone/cordovalib/Commands/Notification.cs @@ -89,7 +89,11 @@ public void alert(string options) { Deployment.Current.Dispatcher.BeginInvoke(() => { - AlertOptions alertOpts = JSON.JsonHelper.Deserialize(options); + string[] args = JSON.JsonHelper.Deserialize(options); + AlertOptions alertOpts = new AlertOptions();// JSON.JsonHelper.Deserialize(options); + alertOpts.message = args[0]; + alertOpts.title = args[1]; + alertOpts.buttonLabel = args[2]; PhoneApplicationPage page = Page; if (page != null) @@ -120,7 +124,12 @@ public void confirm(string options) { Deployment.Current.Dispatcher.BeginInvoke(() => { - AlertOptions alertOpts = JSON.JsonHelper.Deserialize(options); + //AlertOptions alertOpts = JSON.JsonHelper.Deserialize(options); + string[] args = JSON.JsonHelper.Deserialize(options); + AlertOptions alertOpts = new AlertOptions();// JSON.JsonHelper.Deserialize(options); + alertOpts.message = args[0]; + alertOpts.title = args[1]; + alertOpts.buttonLabel = args[2]; PhoneApplicationPage page = Page; if (page != null) @@ -197,9 +206,10 @@ void btnOK_Click(object sender, RoutedEventArgs e) - public void beep(string count) + public void beep(string options) { - int times = int.Parse(count); + string[] args = JSON.JsonHelper.Deserialize(options); + int times = int.Parse(args[0]); StreamResourceInfo sri = Application.GetResourceStream(new Uri("/WP7CordovaClassLib;component/resources/notification-beep.wav", UriKind.Relative)); if (sri != null)