예제 #1
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;
        }