コード例 #1
0
        /// <summary>
        /// Evaluates the specified result and shows a dialog depending on the status.
        /// </summary>
        /// <param name="result">The result to be evaluated.</param>
        /// <returns>True on successful evaluation, false otherwise.</returns>
        internal MessageDialog CreateResultDialog(Result result)
        {
            MessageDialog dialog;

            switch (result.StatusCode)
            {
            case Result.Status.Success:
            {
                var durationText = BuildDurationText(result.ElapsedTime);
                dialog = DialogFactory.CreateInformationDialog(
                    I18N.Resources.GetString("Success/Text"), durationText);
                break;
            }

            case Result.Status.Fail:
            {
                var message = !string.IsNullOrEmpty(result.Message)
                            ? result.Message : I18N.Resources.GetString("SomethingWentWrong/Text");
                dialog = DialogFactory.CreateErrorDialog(message);
                break;
            }

            case Result.Status.Interrupt:
            {
                dialog = DialogFactory.CreateInformationDialog(
                    I18N.Resources.GetString("Interrupted/Text"),
                    I18N.Resources.GetString("OperationCancelled/Text"));
                break;
            }

            case Result.Status.PartialFail:
            {
                dialog = DialogFactory.CreateErrorDialog(
                    I18N.Resources.GetString("NotAllExtracted/Text"));
                break;
            }

            default: throw new ArgumentOutOfRangeException(nameof(result.StatusCode));
            }
            return(dialog);
        }