Exemple #1
0
        /// <summary>
        /// メッセージボックスを表示する。
        /// </summary>
        /// <param name="owner">オーナーウィンドウ。</param>
        /// <param name="text">表示テキスト。</param>
        /// <param name="caption">キャプション。</param>
        /// <param name="button">表示ボタン。</param>
        /// <param name="icon">表示アイコン。</param>
        /// <returns>表示結果値。</returns>
        public static Result Show(
            Window owner,
            string text,
            string caption = "",
            Button button = Button.Ok,
            Icon icon = Icon.None)
        {
            Result result = Result.None;

            if (TaskDialog.IsPlatformSupported)
            {
                using (var dialog = new TaskDialog())
                {
                    if (owner != null)
                    {
                        dialog.OwnerWindowHandle =
                            (new WindowInteropHelper(owner)).Handle;
                    }

                    dialog.Text = text;
                    dialog.Caption = caption;
                    dialog.Icon = icon.ToTaskDialogStandardIcon();
                    dialog.StandardButtons = button.ToTaskDialogStandardButtons();
                    dialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
                    dialog.Opened += OnTaskDialogOpened;

                    result = Convert(dialog.Show());
                }
            }
            else
            {
                result =
                    Convert(
                        System.Windows.MessageBox.Show(
                            owner,
                            text,
                            caption,
                            button.ToMessageBoxButton(),
                            icon.ToMessageBoxImage()));
            }

            return result;
        }