/// <summary> /// Triggers special UI to select a date (day/month/year) /// </summary> public void selectDate(string options) { try { try { this.dateTimePickerOptions = String.IsNullOrEmpty(options) ? new DateTimePickerOptions() : WP7GapClassLib.PhoneGap.JSON.JsonHelper.Deserialize <DateTimePickerOptions>(options); } catch (Exception ex) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message)); return; } this.dateTimePickerTask = new DateTimePickerTask(); dateTimePickerTask.Value = dateTimePickerOptions.Value; dateTimePickerTask.Completed += this.dateTimePickerTask_Completed; dateTimePickerTask.Show(DateTimePickerTask.DateTimePickerType.Date); } catch (Exception e) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message)); } }
/// <summary> /// Handles datetime picker result /// </summary> /// <param name="sender"></param> /// <param name="e">stores information about current captured image</param> private void dateTimePickerTask_Completed(object sender, DateTimePickerTask.DateTimeResult e) { if (e.Error != null) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR)); return; } switch (e.TaskResult) { case TaskResult.OK: try { DispatchCommandResult(new PluginResult(PluginResult.Status.OK, e.Value.Value.ToString())); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Datetime picker error. " + ex.Message)); } break; case TaskResult.Cancel: DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled.")); break; } this.dateTimePickerTask = null; }