Пример #1
0
        // Overloaded versions...
        public static int ShowCommandBox(string title,
                                         string mainInstruction,
                                         string content,
                                         string expandedInfo,
                                         string footer,
                                         string verificationText,
                                         string commandButtons,
                                         bool showCancelButton,
                                         CommonIcon mainIcon,
                                         CommonIcon footerIcon,
                                         ProgressBarStyle progressBarStyle)
        {
            DialogResult res = ShowTaskDialogBox(IntPtr.Zero, title, mainInstruction, content, expandedInfo, footer,
                                                 verificationText,
                                                 string.Empty, commandButtons,
                                                 (showCancelButton ? CommonButtons.Cancel : CommonButtons.None),
                                                 mainIcon, footerIcon, progressBarStyle);

            if (res == DialogResult.OK)
            {
                return(CommandButtonResult);
            }

            return(-1);
        }
Пример #2
0
 public static DialogResult MessageBox(string title,
                                       string mainInstruction,
                                       string content,
                                       CommonButtons buttons,
                                       CommonIcon mainIcon,
                                       ProgressBarStyle progressBarStyle)
 {
     return(MessageBox(IntPtr.Zero, title, mainInstruction, content, string.Empty, string.Empty, string.Empty, buttons, mainIcon, CommonIcon.Information, progressBarStyle));
 }
Пример #3
0
        /// <summary>
        /// Initializes a new Task Dialog instance with an instruction, a title, some
        /// content text, a specific button and an icon.</summary>
        /// <param name="instruction">The main instruction to display.</param>
        /// <param name="title">The title of the Task Dialog.</param>
        /// <param name="content">The content text that will be shown below the main instruction.</param>
        /// <param name="commonButtons">Specifies one or more buttons to be displayed on the bottom of the dialog, instead of the default OK button.</param>
        /// <param name="icon">The icon to display.</param>
        public TaskDialog(string instruction, string title, string content, CommonButton commonButtons, CommonIcon icon)
        {
            Init();

            Title         = title;
            Instruction   = instruction;
            Content       = content;
            CommonButtons = commonButtons;
            CommonIcon    = icon;
        }
Пример #4
0
 public static int ShowRadioBox(IntPtr owner,
                                string title,
                                string mainInstruction,
                                string content,
                                string expandedInfo,
                                string footer,
                                string verificationText,
                                string radioButtons,
                                CommonIcon mainIcon,
                                CommonIcon footerIcon)
 {
     return(ShowRadioBox(owner, title, mainInstruction, content, expandedInfo, footer, verificationText, radioButtons,
                         CommonIcon.None, CommonIcon.Information, 0));
 }
Пример #5
0
 // Overloaded versions...
 public static DialogResult MessageBox(string title,
                                       string mainInstruction,
                                       string content,
                                       string expandedInfo,
                                       string footer,
                                       string verificationText,
                                       CommonButtons buttons,
                                       CommonIcon mainIcon,
                                       CommonIcon footerIcon,
                                       ProgressBarStyle progressBarStyle)
 {
     return(ShowTaskDialogBox(IntPtr.Zero, title, mainInstruction, content, expandedInfo, footer, verificationText, string.Empty, string.Empty,
                              buttons, mainIcon, footerIcon, progressBarStyle));
 }
Пример #6
0
 // Overloaded versions...
 public static DialogResult ShowTaskDialogBox(IntPtr owner,
                                              string title,
                                              string mainInstruction,
                                              string content,
                                              string expandedInfo,
                                              string footer,
                                              string verificationText,
                                              string radioButtons,
                                              string commandButtons,
                                              CommonButtons buttons,
                                              CommonIcon mainIcon,
                                              CommonIcon footerIcon,
                                              ProgressBarStyle progressBarStyle)
 {
     return(ShowTaskDialogBox(owner, title, mainInstruction, content, expandedInfo, footer, verificationText,
                              radioButtons, commandButtons, buttons, mainIcon, footerIcon, 0, progressBarStyle));
 }
Пример #7
0
        // Overloaded versions...
        public static int ShowRadioBox(string title,
                                       string mainInstruction,
                                       string content,
                                       string expandedInfo,
                                       string footer,
                                       string verificationText,
                                       string radioButtons,
                                       CommonIcon mainIcon,
                                       CommonIcon footerIcon,
                                       int defaultIndex)
        {
            DialogResult res = ShowTaskDialogBox(IntPtr.Zero, title, mainInstruction, content, expandedInfo, footer,
                                                 verificationText,
                                                 radioButtons, string.Empty, CommonButtons.Ok | CommonButtons.Cancel, mainIcon, footerIcon,
                                                 defaultIndex, ProgressBarStyle.None);

            if (res == DialogResult.OK)
            {
                return(RadioButtonResult);
            }

            return(-1);
        }
Пример #8
0
 /// <summary>
 /// CommonIconに対する追加処理
 /// </summary>
 public virtual void SetCommonIcon(CommonIcon icon)
 {
 }
 /// <summary>
 /// Updates the footer icon. Note the type (standard via enum or
 /// custom via Icon type) must be used when upating the icon.
 /// </summary>
 /// <param name="icon">Task Dialog standard icon.</param>
 /// <exception cref="NotImplementedException"><c>NotImplementedException</c>.</exception>
 public void UpdateFooterIcon(CommonIcon icon)
 {
     throw new NotImplementedException();
 }
Пример #10
0
        private static CommonButtonResult InternalShow(IntPtr parent, string title, string instruction, string content, CommonButton commonButtons, CommonIcon icon)
        {
            int dlgValue;

            try {
                //Get handle for parent window if none specified (behave like MessageBox)
                if (parent == IntPtr.Zero)
                {
                    parent = Native.Methods.GetActiveWindow();
                }

                if (NativeMethods.TaskDialog(parent, IntPtr.Zero, title, instruction, content, (int)commonButtons, new IntPtr((long)icon), out dlgValue) != 0)
                {
                    throw new Exception(string.Format(Resources.ExceptionMessages.NativeCallFailure, "TaskDialog"));
                }
            }
            catch (EntryPointNotFoundException ex) {
                throw new Exception(Resources.ExceptionMessages.CommonControlEntryPointNotFound, ex);
            }
            catch (Exception ex) {
                throw new Exception(Resources.ExceptionMessages.TaskDialogFailure, ex);
            }

            //Convert int value to common dialog result
            if (dlgValue > 0 && dlgValue <= 8)
            {
                return((CommonButtonResult)dlgValue);
            }
            else
            {
                return(CommonButtonResult.None);
            }
        }
Пример #11
0
 /// <summary>Displays a task dialog that has a message, a title, an instruction, one or more buttons, and an icon.</summary>
 /// <param name="text">The text to display.</param>
 /// <param name="title">The title bar caption of the dialog.</param>
 /// <param name="instruction">The instruction shown below the main text.</param>
 /// <param name="buttons">Value that specifies which button or buttons to display.</param>
 /// <param name="icon">The icon to display.</param>
 public static CommonButtonResult Show(string instruction, string title, string content, CommonButton buttons, CommonIcon icon)
 {
     return(InternalShow(IntPtr.Zero, title, instruction, content, buttons, icon));
 }
Пример #12
0
        /// <exception cref="ArgumentException">Not supported yet.</exception>
        public static DialogResult ShowTaskDialogBox(IntPtr owner,
                                                     string title,
                                                     string mainInstruction,
                                                     string content,
                                                     string expandedInfo,
                                                     string footer,
                                                     string verificationText,
                                                     string radioButtons,
                                                     string commandButtons,
                                                     CommonButtons buttons,
                                                     CommonIcon mainIcon,
                                                     CommonIcon footerIcon,
                                                     int defaultIndex,
                                                     ProgressBarStyle progressBarStyle)
        {
            ITaskDialog taskDialog;

            if (NativeTaskDialog.IsAvailableOnThisOs && !ForceEmulationMode)
            {
                taskDialog = new NativeTaskDialog();
            }
            else
            {
                taskDialog = new EmulatedTaskDialog(false);
            }

            TaskConfig = new TaskDialogConfig();

            TaskConfig.Parent              = owner;
            TaskConfig.WindowTitle         = title;
            TaskConfig.MainInstruction     = mainInstruction;
            TaskConfig.Content             = content;
            TaskConfig.ExpandedInformation = expandedInfo;
            TaskConfig.Footer              = footer;

            // Radio Buttons
            if (!string.IsNullOrEmpty(radioButtons))
            {
                List <TaskDialogButton> lst = new List <TaskDialogButton>();
                string[] arr = radioButtons.Split(new[] { '|' });
                for (int i = 0; i < arr.Length; i++)
                {
                    try {
                        TaskDialogButton button = new TaskDialogButton {
                            ButtonId = 1000 + i, ButtonText = arr[i]
                        };
                        lst.Add(button);
                    } catch (FormatException) {}
                }
                TaskConfig.RadioButtons.AddRange(lst);
                TaskConfig.Flags.NoDefaultRadioButton = (defaultIndex == -1);
                if (defaultIndex >= 0)
                {
                    TaskConfig.DefaultRadioButton = defaultIndex + 1000;
                }
                else
                {
                    TaskConfig.DefaultRadioButton = 1000;
                }
            }

            // Custom Buttons
            if (!string.IsNullOrEmpty(commandButtons))
            {
                List <TaskDialogButton> lst = new List <TaskDialogButton>();
                string[] arr = commandButtons.Split(new[] { '|' });
                for (int i = 0; i < arr.Length; i++)
                {
                    try {
                        TaskDialogButton button = new TaskDialogButton {
                            ButtonId = 2000 + i, ButtonText = arr[i]
                        };
                        lst.Add(button);
                    } catch (FormatException) {}
                }
                TaskConfig.Buttons.AddRange(lst);
                if (defaultIndex >= 0)
                {
                    TaskConfig.DefaultButton = defaultIndex;
                }
            }

            TaskConfig.CommonButtons = buttons;
            TaskConfig.MainIcon      = mainIcon;
            if (TaskConfig.MainIcon == CommonIcon.Custom)
            {
                throw new ArgumentException("Not supported yet.", "mainIcon");
            }
            TaskConfig.FooterIcon = footerIcon;
            if (TaskConfig.FooterIcon == CommonIcon.Custom)
            {
                throw new ArgumentException("Not supported yet.", "footerIcon");
            }

            TaskConfig.Flags.EnableHyperLinks        = true;
            TaskConfig.Flags.ShowProgressBar         = (progressBarStyle == ProgressBarStyle.Continous) ? true : false;
            TaskConfig.Flags.ShowMarqueeProgressBar  = (progressBarStyle == ProgressBarStyle.Marquee) ? true : false;
            TaskConfig.Flags.AllowDialogCancellation = ((buttons & CommonButtons.Cancel) >= 0 ||
                                                        (buttons & CommonButtons.Close) >= 0);

            TaskConfig.Flags.CallbackTimer            = true;
            TaskConfig.Flags.ExpandedByDefault        = false;
            TaskConfig.Flags.ExpandFooterArea         = false;
            TaskConfig.Flags.PositionRelativeToWindow = true;
            TaskConfig.Flags.RtlLayout               = false;
            TaskConfig.Flags.CanBeMinimized          = false;
            TaskConfig.Flags.UseCommandLinks         = (TaskConfig.Buttons.Count > 0);
            TaskConfig.Flags.UseCommandLinksNoIcon   = false;
            TaskConfig.VerificationText              = verificationText;
            TaskConfig.Flags.VerificationFlagChecked = false;
            TaskConfig.ExpandedControlText           = "Hide details";
            TaskConfig.CollapsedControlText          = "Show details";

            taskDialog.Created             += TaskDialogCreated;
            taskDialog.ButtonClicked       += TaskDialogButtonClicked;
            taskDialog.HyperlinkClicked    += TaskDialogHyperlinkClicked;
            taskDialog.Timer               += TaskDialogTimer;
            taskDialog.Destroyed           += TaskDialogDestroyed;
            taskDialog.RadioButtonClicked  += TaskDialogRadioButtonClicked;
            taskDialog.DialogConstructed   += TaskDialogDialogConstructed;
            taskDialog.VerificationClicked += TaskDialogVerificationClicked;
            taskDialog.Help += TaskDialogHelp;
            taskDialog.ExpandoButtonClicked += TaskDialogExpandoButtonClicked;
            taskDialog.Navigated            += TaskDialogNavigated;

            DialogResult dialogResult = DialogResult.None;
            int          result       = taskDialog.TaskDialogIndirect(TaskConfig, out ButtonResult, out RadioButtonResult, out VerificationChecked);

            // Try to interpret the ButtonResult as a DialogResult
            try {
                if (ButtonResult < 1000)
                {
                    dialogResult = (DialogResult)ButtonResult;
                }
// ReSharper disable EmptyGeneralCatchClause
            } catch {}
// ReSharper restore EmptyGeneralCatchClause

            // if a command button was clicked, then change return result
            // to "DialogResult.OK" and set the CommandButtonResult)
            if (result >= 2000)
            {
                CommandButtonResult = result - 2000;
                dialogResult        = DialogResult.OK;
            }
            if (RadioButtonResult >= 1000)
            {
                // deduct the ButtonID start value for radio buttons
                RadioButtonResult -= 1000;
            }

            return(dialogResult);
        }
Пример #13
0
    /// <summary>
    /// CommonIconに対する追加処理
    /// </summary>
    public override void SetCommonIcon(CommonIcon icon)
    {
        var sprite = SharedUI.Instance.commonAtlas.GetSprite(this.master.key);

        icon.SetIconSprite(sprite);
    }