/// <summary>
        /// Triggers  special UI to select a date (day/month/year)
        /// </summary>
        public void selectDate(string options)
        {
            try {
                try
                {
                    string value = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize <string[]>(options)[0];
                    dateTimePickerOptions = new DateTimePickerOptions();
                    if (!String.IsNullOrEmpty(value))
                    {
                        dateTimePickerOptions.Value = FromUnixTime(long.Parse(value));
                    }

                    //this.dateTimePickerOptions = String.IsNullOrEmpty(options["value"]) ? new DateTimePickerOptions() :
                    //    WPCordovaClassLib.Cordova.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));
            }
        }
Exemple #2
0
        /// <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
                {
                    long result = (long)e.Value.Value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
                    if (!ResultHandlers.ContainsKey(CurrentCommandCallbackId))
                    {
                        ResultHandlers.Add(CurrentCommandCallbackId, mySavedHandler);
                    }
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result.ToString()), _callbackId);
                }
                catch (Exception ex)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Datetime picker error. " + ex.Message), _callbackId);
                }
                break;

            case TaskResult.Cancel:
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."), _callbackId);
                break;
            }

            this.dateTimePickerTask = null;
        }
        /// <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
                {
                    long result = (long)e.Value.Value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result + ""));
                }
                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;
        }
        /// <summary>
        /// Triggers  special UI to select a date (day/month/year)
        /// </summary>
        public void selectDate(string options)
        {
            try {

                try
                {

                    string value = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize<string[]>(options)[0];
                    dateTimePickerOptions = new DateTimePickerOptions();
                    if(!String.IsNullOrEmpty(value)) {
                        dateTimePickerOptions.Value = FromUnixTime(long.Parse(value));
                    }

                    //this.dateTimePickerOptions = String.IsNullOrEmpty(options["value"]) ? new DateTimePickerOptions() :
                    //    WPCordovaClassLib.Cordova.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));
            }
        }
        public void selectDate(string options)
        {
            try 
            {
                if (!GetDefaults(options)) return;

                _dateTimePickerTask = new DateTimePickerTask { Value = _dateTimePickerOptions.Value };

                _dateTimePickerTask.Completed += dateTimePickerTask_Completed;
                _dateTimePickerTask.Show(DateTimePickerTask.DateTimePickerType.Date);
            }
            catch (Exception e)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
            }
        }
Exemple #6
0
        public void selectDate(string options)
        {
            try
            {
                if (!GetDefaults(options))
                {
                    return;
                }

                _dateTimePickerTask = new DateTimePickerTask {
                    Value = _dateTimePickerOptions.Value
                };

                _dateTimePickerTask.Completed += dateTimePickerTask_Completed;
                _dateTimePickerTask.Show(DateTimePickerTask.DateTimePickerType.Date);
            }
            catch (Exception e)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
            }
        }
Exemple #7
0
        /// <summary>
        /// Triggers  special UI to select a date (day/month/year)
        /// </summary>
        public void selectDate(string options)
        {
            try {
                try
                {
                    var args = JSON.JsonHelper.Deserialize <string[]>(options);
                    _callbackId = args[args.Length - 1];
                    if (ResultHandlers.ContainsKey(CurrentCommandCallbackId))
                    {
                        mySavedHandler = ResultHandlers[CurrentCommandCallbackId];
                    }
                    string value = WPCordovaClassLib.Cordova.JSON.JsonHelper.Deserialize <string[]>(options)[0];
                    dateTimePickerOptions = new DateTimePickerOptions();
                    if (!String.IsNullOrEmpty(value))
                    {
                        dateTimePickerOptions.Value = FromUnixTime(long.Parse(value));
                    }

                    //this.dateTimePickerOptions = String.IsNullOrEmpty(options["value"]) ? new DateTimePickerOptions() :
                    //    WPCordovaClassLib.Cordova.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));
            }
        }
        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
                    {
                        var result = (long) e.Value.Value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result + ""));
                    }
                    catch (Exception ex)
                    {
                        DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Datetime picker error. " + ex.Message));
                    }
                    break;

                case TaskResult.Cancel:
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Cancelled."));
                    break;               
            }

            _dateTimePickerTask = null;
        }