Пример #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="TaskDialogButtonData" /> class.
        /// </summary>
        /// <param name="button">The button.</param>
        /// <param name="isDefault">if set to <c>true</c>, the button is defaulted.</param>
        public TaskDialogButtonData(TaskDialogButtons button, bool isDefault)
            : this((int) button, null, null, isDefault)
        {
            if (!IsSingleButton(button))
            {
                throw new ArgumentOutOfRangeException("button", SR.TaskDialogButtonData_ButtonSingleValue);
            }

            _button = button;
            _header = TypeDescriptor.GetConverter(button).ConvertToString(button);
        }
Пример #2
0
        private static int maxHeightExpandedInfo = 700; //ToDo: Use Screen Height

        #endregion Fields

        #region Methods

        //--------------------------------------------------------------------------------
        public static DialogResult MessageBox(string Title,
                                              string MainInstruction,
                                              string Content,
                                              string ExpandedInfo,
                                              string Footer,
                                              string VerificationText,
                                              TaskDialogButtons Buttons,
                                              TaskDialogIcons MainIcon,
                                              TaskDialogIcons FooterIcon)
        {
            return ShowTaskDialogBox(Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                                     "", "", Buttons, MainIcon, FooterIcon);
        }
Пример #3
0
        public static TaskDialogResult ShowTaskDialog(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;
            if (NativeMethods.TaskDialog(IntPtr.Zero, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
                throw new InvalidOperationException("Error occurred calling TaskDialog.");

            switch (p)
            {
                case 1: return TaskDialogResult.Ok;
                case 2: return TaskDialogResult.Cancel;
                case 4: return TaskDialogResult.Retry;
                case 6: return TaskDialogResult.Yes;
                case 7: return TaskDialogResult.No;
                case 8: return TaskDialogResult.Close;
                default: return TaskDialogResult.None;
            }
        }
Пример #4
0
        /// <summary>
        /// Show a task dialog using the specified values as content.
        /// </summary>
        /// <param name="windowTitle">Caption of the window.</param>
        /// <param name="mainInstruction">Principal text.</param>
        /// <param name="content">Extra text.</param>
        /// <param name="icon">Predefined icon.</param>
        /// <param name="commonButtons">Common buttons.</param>
        /// <returns>One of the DialogResult values.</returns>
        public static DialogResult Show(string windowTitle,
                                        string mainInstruction,
                                        string content,
                                        MessageBoxIcon icon,
                                        TaskDialogButtons commonButtons)
        {
            // Create a temporary task dialog for storing definition whilst showing
            using (KryptonTaskDialog taskDialog = new KryptonTaskDialog())
            {
                // Store incoming values
                taskDialog.WindowTitle     = windowTitle;
                taskDialog.MainInstruction = mainInstruction;
                taskDialog.Content         = content;
                taskDialog.Icon            = icon;
                taskDialog.CommonButtons   = commonButtons;

                // Show as a modal dialog
                return(taskDialog.ShowDialog());
            }
        }
Пример #5
0
        /// <summary>
        /// Initialize a new instance of the VisualTaskDialog class.
        /// </summary>
        /// <param name="taskDialog">Reference to component with definition of content.</param>
        public VisualTaskDialog(KryptonTaskDialog taskDialog)
        {
            // Must provide a valid reference
            if (taskDialog == null)
                throw new ArgumentNullException("taskDialog");

            _taskDialog = taskDialog;

            // Initialize with task dialog values
            _windowTitle = taskDialog.WindowTitle;
            _mainInstruction = taskDialog.MainInstruction;
            _content = taskDialog.Content;
            _mainIcon = taskDialog.Icon;
            _customMainIcon = taskDialog.CustomIcon;
            _radioButtons = taskDialog.RadioButtons;
            _commandButtons = taskDialog.CommandButtons;
            _commonButtons = taskDialog.CommonButtons;
            _defaultRadioButton = taskDialog.DefaultRadioButton;
            _defaultButton = taskDialog.DefaultButton;
            _footerIcon = taskDialog.FooterIcon;
            _customFooterIcon = taskDialog.CustomFooterIcon;
            _footerText = taskDialog.FooterText;
            _footerHyperlink = taskDialog.FooterHyperlink;
            _checkboxText = taskDialog.CheckboxText;
            _checkboxState = taskDialog.CheckboxState;
            _allowDialogClose = taskDialog.AllowDialogClose;

            InitializeComponent();
            UpdateContents();
        }
Пример #6
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/>.
        /// </summary>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult Show(String instruction, String content, String title,
			                                TaskDialogButtons buttons)
        {
            return Show(instruction, content, title, buttons, TaskDialogIcon.None);
        }
Пример #7
0
 /// <summary>
 /// Displays a <see cref="TaskDialog"/> using an <see cref="InlineModalDialog" />.
 /// </summary>
 /// <param name="owner">The owner.</param>
 /// <param name="header">The header.</param>
 /// <param name="content">The content.</param>
 /// <param name="title">The title.</param>
 /// <param name="standardButtons">The standard buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <returns></returns>
 public static TaskDialogResult ShowInline(DependencyObject owner, string header, string content, string title, TaskDialogButtons standardButtons, TaskDialogIcon icon)
 {
     return(ShowInlineCore(owner, header, content, title, standardButtons, icon, false));
 }
Пример #8
0
        private static TaskDialogResult ShowInlineCore(DependencyObject owner, string header, string content, string title, TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks, params TaskDialogButtonData[] buttons)
        {
            if (title == null)
            {
                title = string.Empty;
            }

            if (content == string.Empty)
            {
                content = null;
            }

            var taskDialog = new TaskDialog
            {
                Title    = title,
                Header   = header,
                Content  = content,
                MainIcon = TaskDialogIconConverter.ConvertFrom(icon)
            };

            foreach (TaskDialogButtonData buttonData in TaskDialogButtonData.FromStandardButtons(standardButtons))
            {
                taskDialog.Buttons.Add(buttonData);
            }

            if (useCommandLinks)
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.CommandLinks.Add(buttonData);
                }
            }
            else
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.Buttons.Add(buttonData);
                }
            }

            if (owner == null && Application.Current != null)
            {
                owner = Application.Current.MainWindow;
            }

            taskDialog.Background = SystemColors.WindowBrush;

            taskDialog.ShowInline(owner);

            return(taskDialog.Result);
        }
Пример #9
0
        static TaskDialogResult ShowInternal(Window window, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            IntPtr windowHandle = IntPtr.Zero;

            if (window != null)
            {
                WindowInteropHelper win = new WindowInteropHelper(window);
                windowHandle = win.Handle;
            }

            return TaskDialog(windowHandle, IntPtr.Zero, caption, instruction, text, buttons, icon);
        }
Пример #10
0
 /// <summary>
 ///     Converts a flag-valued <see cref="TaskDialogButtons" /> to <see cref="TaskDialogButtonData" /> objects.
 /// </summary>
 /// <param name="buttons">The buttons.</param>
 /// <returns></returns>
 public static IEnumerable <TaskDialogButtonData> FromStandardButtons(TaskDialogButtons buttons)
 {
     return
         (((IEnumerable <object>) new EnumFlagsConverter().Convert(buttons)).Cast <TaskDialogButtons>()
          .Select(b => new TaskDialogButtonData(b)));
 }
Пример #11
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons)
 {
     return(Show(text, instruction, caption, buttons, 0));
 }
Пример #12
0
        //--------------------------------------------------------------------------------
        public DialogResult ShowTaskDialogBox(IWin32Window Owner,
            string Title,
            string MainInstruction,
            string Content,
            string ExpandedInfo,
            string Footer,
            string VerificationText,
            string RadioButtons,
            string CommandButtons,
            TaskDialogButtons Buttons,
            SysIcons MainIcon,
            SysIcons FooterIcon,
            int DefaultIndex)
        {
            DialogResult result;
            if (OnTaskDialogShown != null)
                OnTaskDialogShown(null, EventArgs.Empty);

            if (VistaTaskDialog.IsAvailableOnThisOS)
            {
                // [OPTION 1] Show Vista TaskDialog
                VistaTaskDialog vtd = new VistaTaskDialog();

                vtd.WindowTitle = Title;
                vtd.MainInstruction = MainInstruction;
                vtd.Content = Content;
                vtd.ExpandedInformation = ExpandedInfo;
                vtd.Footer = Footer;

                // Radio Buttons
                if (RadioButtons != "")
                {
                    List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
                    string[] arr = RadioButtons.Split(new char[] {'|'});
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId = 1000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.RadioButtons = lst.ToArray();
                    vtd.NoDefaultRadioButton = (DefaultIndex == -1);
                    if (DefaultIndex >= 0)
                        vtd.DefaultRadioButton = DefaultIndex;
                }

                // Custom Buttons
                if (CommandButtons != "")
                {
                    List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
                    string[] arr = CommandButtons.Split(new char[] {'|'});
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId = 2000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.Buttons = lst.ToArray();
                    if (DefaultIndex >= 0)
                        vtd.DefaultButton = DefaultIndex;
                }

                switch (Buttons)
                {
                    case TaskDialogButtons.YesNo:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No;
                        break;
                    case TaskDialogButtons.YesNoCancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No |
                                            VistaTaskDialogCommonButtons.Cancel;
                        break;
                    case TaskDialogButtons.OKCancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok | VistaTaskDialogCommonButtons.Cancel;
                        break;
                    case TaskDialogButtons.OK:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok;
                        break;
                    case TaskDialogButtons.Close:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Close;
                        break;
                    case TaskDialogButtons.Cancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Cancel;
                        break;
                    default:
                        vtd.CommonButtons = 0;
                        break;
                }

                switch (MainIcon)
                {
                    case SysIcons.Information:
                        vtd.MainIcon = VistaTaskDialogIcon.Information;
                        break;
                    case SysIcons.Question:
                        vtd.MainIcon = VistaTaskDialogIcon.Question;
                        break;
                    case SysIcons.Warning:
                        vtd.MainIcon = VistaTaskDialogIcon.Warning;
                        break;
                    case SysIcons.Error:
                        vtd.MainIcon = VistaTaskDialogIcon.Error;
                        break;
                }

                switch (FooterIcon)
                {
                    case SysIcons.Information:
                        vtd.FooterIcon = VistaTaskDialogIcon.Information;
                        break;
                    case SysIcons.Question:
                        vtd.FooterIcon = VistaTaskDialogIcon.Question;
                        break;
                    case SysIcons.Warning:
                        vtd.FooterIcon = VistaTaskDialogIcon.Warning;
                        break;
                    case SysIcons.Error:
                        vtd.FooterIcon = VistaTaskDialogIcon.Error;
                        break;
                }

                vtd.EnableHyperlinks = true;
                vtd.ShowProgressBar = false;
                vtd.AllowDialogCancellation = (Buttons == TaskDialogButtons.Cancel ||
                                               Buttons == TaskDialogButtons.Close ||
                                               Buttons == TaskDialogButtons.OKCancel ||
                                               Buttons == TaskDialogButtons.YesNoCancel);
                vtd.CallbackTimer = false;
                vtd.ExpandedByDefault = false;
                vtd.ExpandFooterArea = false;
                vtd.PositionRelativeToWindow = true;
                vtd.RightToLeftLayout = false;
                vtd.NoDefaultRadioButton = false;
                vtd.CanBeMinimized = false;
                vtd.ShowMarqueeProgressBar = false;
                vtd.UseCommandLinks = (CommandButtons != "");
                vtd.UseCommandLinksNoIcon = false;
                vtd.VerificationText = VerificationText;
                vtd.VerificationFlagChecked = false;
                vtd.ExpandedControlText = Locale.localizedString("More Options", "Bookmark");
                vtd.CollapsedControlText = Locale.localizedString("More Options", "Bookmark");
                vtd.Callback =
                    delegate(VistaActiveTaskDialog taskDialog, VistaTaskDialogNotificationArgs args, object callbackData)
                        {
                            if (!String.IsNullOrEmpty(args.Hyperlink))
                            {
                                HelpDelegate(args.Hyperlink);
                            }
                            return false;
                        };

                // Show the Dialog
                result =
                    (DialogResult)
                    vtd.Show((vtd.CanBeMinimized ? null : Owner), out _verificationChecked, out _radioButtonResult);

                // if a command button was clicked, then change return result
                // to "DialogResult.OK" and set the CommandButtonResult
                if ((int) result >= 2000)
                {
                    CommandButtonResult = ((int) result - 2000);
                    result = DialogResult.OK;
                }
                if (RadioButtonResult >= 1000)
                    RadioButtonResult -= 1000; // deduct the ButtonID start value for radio buttons
            }
            else
            {
                // [OPTION 2] Show Emulated Form
                using (TaskDialogForm td = new TaskDialogForm())
                {
                    td.Title = Title;
                    td.MainInstruction = MainInstruction;
                    td.Content = Content;
                    td.ExpandedInfo = ExpandedInfo;
                    td.Footer = Footer;
                    td.RadioButtons = RadioButtons;
                    td.CommandButtons = CommandButtons;
                    td.PlaySystemSounds = PlaySystemSounds;
                    td.Buttons = Buttons;
                    td.MainIcon = MainIcon;
                    td.FooterIcon = FooterIcon;
                    td.VerificationText = VerificationText;
                    td.Width = EmulatedFormWidth;
                    td.DefaultButtonIndex = DefaultIndex;
                    td.BuildForm();
                    result = td.ShowDialog(Owner);

                    RadioButtonResult = td.RadioButtonIndex;
                    CommandButtonResult = td.CommandButtonClickedIndex;
                    VerificationChecked = td.VerificationCheckBoxChecked;
                }
            }
            if (OnTaskDialogClosed != null)
                OnTaskDialogClosed(null, EventArgs.Empty);
            return result;
        }
Пример #13
0
 /// <summary>
 ///  Initialize a new instance of the KryptonTaskDialog class.
 /// </summary>
 public KryptonTaskDialog()
 {
     _radioButtons   = new KryptonTaskDialogCommandCollection();
     _commandButtons = new KryptonTaskDialogCommandCollection();
     _commonButtons  = TaskDialogButtons.OK;
 }
Пример #14
0
 /// <summary>
 ///     Added to support the deprecated <see cref="P:StandardButtons" /> property.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">
 ///     The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs" /> instance containing
 ///     the event data.
 /// </param>
 private void OnButtonsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     _standardButtons = Buttons.OfType<TaskDialogButtonData>().Where(b => b.Button != TaskDialogButtons.None)
         .Aggregate(TaskDialogButtons.None, (b, bd) => b | bd.Button);
 }
Пример #15
0
        private static TaskDialogResult ShowCore(DependencyObject owner, string header, string content, string title,
            TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks,
            params TaskDialogButtonData[] buttons)
        {
            var taskDialog = new TaskDialog
            {
                Owner = owner,
                Title = title,
                Header = header,
                Content = content,
                MainIcon = TaskDialogIconConverter.ConvertFrom(icon)
            };

            foreach (TaskDialogButtonData buttonData in TaskDialogButtonData.FromStandardButtons(standardButtons))
            {
                taskDialog.Buttons.Add(buttonData);
            }

            if (useCommandLinks)
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.CommandLinks.Add(buttonData);
                }
            }
            else
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.Buttons.Add(buttonData);
                }
            }

            taskDialog.Show();

            return taskDialog.Result;
        }
Пример #16
0
 public static TaskDialogResult Show(DependencyObject owner, string header, string content, string title,
     TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks,
     params TaskDialogButtonData[] buttons)
 {
     return ShowCore(owner, header, content, title, standardButtons, icon, useCommandLinks, buttons);
 }
Пример #17
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TaskDialogButtonData" /> class.
 /// </summary>
 /// <param name="button">The button.</param>
 public TaskDialogButtonData(TaskDialogButtons button)
     : this(button, false)
 {
 }
Пример #18
0
 public static TaskDialogResult Show(IWin32Window owner, string text, string instruction, string caption, TaskDialogButtons buttons)
 {
     return(Show(owner, text, instruction, caption, buttons, 0));
 }
Пример #19
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/>.
        /// </summary>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <param name="icon">A <see cref="TaskDialogIcon"/> value that specifies the icon to
        /// display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult Show(String instruction, String content, String title,
			                                TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            // Initialize task dialog instance
            TaskDialog taskDialog = new TaskDialog();
            taskDialog.Title = title;
            taskDialog.Instruction = instruction;
            taskDialog.Content = content;
            taskDialog.CommonButtons = buttons;
            taskDialog.DefaultIcon = icon;

            // Show instance and return result
            return taskDialog.Show();
        }
Пример #20
0
        /// <summary>
        /// Method to actually show the task dialog.
        /// </summary>
        /// <param name="text">The text to display.</param>
        /// <param name="instruction">The instructions to display.</param>
        /// <param name="caption">The caption for the task dialog.</param>
        /// <param name="buttons">Any <see cref="TaskDialogButtons"/> to display.</param>
        /// <param name="icon">The <see cref="TaskDialogIcon"/> to display.</param>
        /// <returns>The <see cref="TaskDialogResult"/> from the task dialog.</returns>
        private TaskDialogResult ShowInternal(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int result;

            if (externalTaskDialog(_owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out result) != 0)
                throw new InvalidOperationException("ShowInternal");

            switch (result)
            {
                case 1: return TaskDialogResult.OK;
                case 2: return TaskDialogResult.Cancel;
                case 4: return TaskDialogResult.Retry;
                case 6: return TaskDialogResult.Yes;
                case 7: return TaskDialogResult.No;
                case 8: return TaskDialogResult.Close;
                default: return TaskDialogResult.None;
            }
        }
Пример #21
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/> in front of the specified window.
        /// </summary>
        /// <param name="owner">A <see cref="Window"/> that represents the owner window of the
        /// task dialog.</param>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult ShowModal(Window owner, String instruction, String content,
			                                     String title, TaskDialogButtons buttons)
        {
            return ShowModal(owner, instruction, content, title, buttons, TaskDialogIcon.None);
        }
Пример #22
0
 public static extern TaskDialogResult TaskDialog(IntPtr hwndParent, IntPtr hInstance,
                                                  string title, string mainInstruction, string content,
                                                  TaskDialogButtons buttons, TaskDialogIcon icon);
Пример #23
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/> in front of the specified window.
        /// </summary>
        /// <param name="owner">A <see cref="Window"/> that represents the owner window of the
        /// task dialog.</param>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <param name="icon">A <see cref="TaskDialogIcon"/> value that specifies the icon to
        /// display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult ShowModal(Window owner, String instruction, String content,
			                                     String title, TaskDialogButtons buttons,
			                                     TaskDialogIcon icon)
        {
            // Validate arguments
            if (owner == null) {
                throw new ArgumentNullException("owner");
            }

            // Initialize task dialog instance
            TaskDialog taskDialog = new TaskDialog();
            taskDialog.Title = title;
            taskDialog.Instruction = instruction;
            taskDialog.Content = content;
            taskDialog.CommonButtons = buttons;
            taskDialog.DefaultIcon = icon;

            // Show instance and return result
            return taskDialog.ShowModal(owner);
        }
Пример #24
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons)
 {
     return Show(text, instruction, caption, buttons, 0);
 }
Пример #25
0
        //--------------------------------------------------------------------------------

        #region ShowTaskDialogBox

        //--------------------------------------------------------------------------------
        public DialogResult ShowTaskDialogBox(IWin32Window Owner,
                                              string Title,
                                              string MainInstruction,
                                              string Content,
                                              string ExpandedInfo,
                                              string Footer,
                                              string VerificationText,
                                              string RadioButtons,
                                              string CommandButtons,
                                              TaskDialogButtons Buttons,
                                              SysIcons MainIcon,
                                              SysIcons FooterIcon,
                                              int DefaultIndex)

        {
            DialogResult result;

            if (OnTaskDialogShown != null)
            {
                OnTaskDialogShown(null, EventArgs.Empty);
            }

            if (VistaTaskDialog.IsAvailableOnThisOS)
            {
                // [OPTION 1] Show Vista TaskDialog
                VistaTaskDialog vtd = new VistaTaskDialog();

                vtd.WindowTitle         = Title;
                vtd.MainInstruction     = MainInstruction;
                vtd.Content             = Content;
                vtd.ExpandedInformation = ExpandedInfo;
                vtd.Footer = Footer;

                // Radio Buttons
                if (RadioButtons != "")
                {
                    List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton>();
                    string[] arr = RadioButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId   = 1000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.RadioButtons         = lst.ToArray();
                    vtd.NoDefaultRadioButton = (DefaultIndex == -1);
                    if (DefaultIndex >= 0)
                    {
                        vtd.DefaultRadioButton = DefaultIndex;
                    }
                }

                // Custom Buttons
                if (CommandButtons != "")
                {
                    List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton>();
                    string[] arr = CommandButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId   = 2000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.Buttons = lst.ToArray();
                    if (DefaultIndex >= 0)
                    {
                        vtd.DefaultButton = DefaultIndex;
                    }
                }

                switch (Buttons)
                {
                case TaskDialogButtons.YesNo:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No;
                    break;

                case TaskDialogButtons.YesNoCancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No |
                                        VistaTaskDialogCommonButtons.Cancel;
                    break;

                case TaskDialogButtons.OKCancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok | VistaTaskDialogCommonButtons.Cancel;
                    break;

                case TaskDialogButtons.OK:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok;
                    break;

                case TaskDialogButtons.Close:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Close;
                    break;

                case TaskDialogButtons.Cancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Cancel;
                    break;

                default:
                    vtd.CommonButtons = 0;
                    break;
                }

                switch (MainIcon)
                {
                case SysIcons.Information:
                    vtd.MainIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Question:
                    vtd.MainIcon = VistaTaskDialogIcon.Question;
                    break;

                case SysIcons.Warning:
                    vtd.MainIcon = VistaTaskDialogIcon.Warning;
                    break;

                case SysIcons.Error:
                    vtd.MainIcon = VistaTaskDialogIcon.Error;
                    break;
                }

                switch (FooterIcon)
                {
                case SysIcons.Information:
                    vtd.FooterIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Question:
                    vtd.FooterIcon = VistaTaskDialogIcon.Question;
                    break;

                case SysIcons.Warning:
                    vtd.FooterIcon = VistaTaskDialogIcon.Warning;
                    break;

                case SysIcons.Error:
                    vtd.FooterIcon = VistaTaskDialogIcon.Error;
                    break;
                }

                vtd.EnableHyperlinks        = true;
                vtd.ShowProgressBar         = false;
                vtd.AllowDialogCancellation = (Buttons == TaskDialogButtons.Cancel ||
                                               Buttons == TaskDialogButtons.Close ||
                                               Buttons == TaskDialogButtons.OKCancel ||
                                               Buttons == TaskDialogButtons.YesNoCancel);
                vtd.CallbackTimer            = false;
                vtd.ExpandedByDefault        = false;
                vtd.ExpandFooterArea         = false;
                vtd.PositionRelativeToWindow = true;
                vtd.RightToLeftLayout        = false;
                vtd.NoDefaultRadioButton     = false;
                vtd.CanBeMinimized           = false;
                vtd.ShowMarqueeProgressBar   = false;
                vtd.UseCommandLinks          = (CommandButtons != "");
                vtd.UseCommandLinksNoIcon    = false;
                vtd.VerificationText         = VerificationText;
                vtd.VerificationFlagChecked  = false;
                vtd.ExpandedControlText      = Locale.localizedString("More Options", "Bookmark");
                vtd.CollapsedControlText     = Locale.localizedString("More Options", "Bookmark");
                vtd.Callback =
                    delegate(VistaActiveTaskDialog taskDialog, VistaTaskDialogNotificationArgs args, object callbackData)
                {
                    if (!String.IsNullOrEmpty(args.Hyperlink))
                    {
                        HelpDelegate(args.Hyperlink);
                    }
                    return(false);
                };

                // Show the Dialog
                result =
                    (DialogResult)
                    vtd.Show((vtd.CanBeMinimized ? null : Owner), out _verificationChecked, out _radioButtonResult);

                // if a command button was clicked, then change return result
                // to "DialogResult.OK" and set the CommandButtonResult
                if ((int)result >= 2000)
                {
                    CommandButtonResult = ((int)result - 2000);
                    result = DialogResult.OK;
                }
                if (RadioButtonResult >= 1000)
                {
                    RadioButtonResult -= 1000; // deduct the ButtonID start value for radio buttons
                }
            }
            else
            {
                // [OPTION 2] Show Emulated Form
                using (TaskDialogForm td = new TaskDialogForm())
                {
                    td.Title              = Title;
                    td.MainInstruction    = MainInstruction;
                    td.Content            = Content;
                    td.ExpandedInfo       = ExpandedInfo;
                    td.Footer             = Footer;
                    td.RadioButtons       = RadioButtons;
                    td.CommandButtons     = CommandButtons;
                    td.PlaySystemSounds   = PlaySystemSounds;
                    td.Buttons            = Buttons;
                    td.MainIcon           = MainIcon;
                    td.FooterIcon         = FooterIcon;
                    td.VerificationText   = VerificationText;
                    td.Width              = EmulatedFormWidth;
                    td.DefaultButtonIndex = DefaultIndex;
                    td.BuildForm();
                    result = td.ShowDialog(Owner);

                    RadioButtonResult   = td.RadioButtonIndex;
                    CommandButtonResult = td.CommandButtonClickedIndex;
                    VerificationChecked = td.VerificationCheckBoxChecked;
                }
            }
            if (OnTaskDialogClosed != null)
            {
                OnTaskDialogClosed(null, EventArgs.Empty);
            }
            return(result);
        }
Пример #26
0
 public static TaskDialogResult Show(Window owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return ShowInternal(new WindowInteropHelper(owner).Handle, text, instruction, caption, buttons, icon);
 }
Пример #27
0
        //--------------------------------------------------------------------------------
        #region ShowTaskDialogBox
        //--------------------------------------------------------------------------------
        /// <summary>
        /// Shows the task dialog box.
        /// </summary>
        /// <param name="Title">The title.</param>
        /// <param name="MainInstruction">The main instruction.</param>
        /// <param name="Content">The content.</param>
        /// <param name="ExpandedInfo">The expanded info.</param>
        /// <param name="Footer">The footer.</param>
        /// <param name="VerificationText">The verification text.</param>
        /// <param name="RadioButtons">The radio buttons.</param>
        /// <param name="CommandButtons">The command buttons.</param>
        /// <param name="Buttons">The buttons.</param>
        /// <param name="MainIcon">The main icon.</param>
        /// <param name="FooterIcon">The footer icon.</param>
        /// <returns></returns>
        static public DialogResult ShowTaskDialogBox(string Title,
                                                     string MainInstruction,
                                                     string Content,
                                                     string ExpandedInfo,
                                                     string Footer,
                                                     string VerificationText,
                                                     string RadioButtons,
                                                     string CommandButtons,
                                                     TaskDialogButtons Buttons,
                                                     SysIcons MainIcon,
                                                     SysIcons FooterIcon)
        {
            if (VistaTaskDialog.IsAvailableOnThisOS && !ForceEmulationMode)
            {
                // [OPTION 1] Show Vista TaskDialog
                VistaTaskDialog vtd = new VistaTaskDialog( );

                vtd.WindowTitle         = Title;
                vtd.MainInstruction     = MainInstruction;
                vtd.Content             = Content;
                vtd.ExpandedInformation = ExpandedInfo;
                vtd.Footer = Footer;

                // Radio Buttons
                if (RadioButtons != "")
                {
                    List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton> ( );
                    string[] arr = RadioButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try {
                            VistaTaskDialogButton button = new VistaTaskDialogButton( );
                            button.ButtonId   = 1000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        } catch (FormatException) {
                        }
                    }
                    vtd.RadioButtons = lst.ToArray( );
                }

                // Custom Buttons
                if (CommandButtons != "")
                {
                    List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton> ( );
                    string[] arr = CommandButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try {
                            VistaTaskDialogButton button = new VistaTaskDialogButton( );
                            button.ButtonId   = 2000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        } catch (FormatException) {
                        }
                    }
                    vtd.Buttons = lst.ToArray( );
                }

                switch (Buttons)
                {
                case TaskDialogButtons.YesNo:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No;
                    break;

                case TaskDialogButtons.YesNoCancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No | VistaTaskDialogCommonButtons.Cancel;
                    break;

                case TaskDialogButtons.OKCancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok | VistaTaskDialogCommonButtons.Cancel;
                    break;

                case TaskDialogButtons.OK:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok;
                    break;

                case TaskDialogButtons.Close:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Close;
                    break;

                case TaskDialogButtons.Cancel:
                    vtd.CommonButtons = VistaTaskDialogCommonButtons.Cancel;
                    break;

                default:
                    vtd.CommonButtons = 0;
                    break;
                }

                switch (MainIcon)
                {
                case SysIcons.Information:
                    vtd.MainIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Question:
                    vtd.MainIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Warning:
                    vtd.MainIcon = VistaTaskDialogIcon.Warning;
                    break;

                case SysIcons.Error:
                    vtd.MainIcon = VistaTaskDialogIcon.Error;
                    break;
                }

                switch (FooterIcon)
                {
                case SysIcons.Information:
                    vtd.FooterIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Question:
                    vtd.FooterIcon = VistaTaskDialogIcon.Information;
                    break;

                case SysIcons.Warning:
                    vtd.FooterIcon = VistaTaskDialogIcon.Warning;
                    break;

                case SysIcons.Error:
                    vtd.FooterIcon = VistaTaskDialogIcon.Error;
                    break;
                }

                vtd.EnableHyperlinks        = false;
                vtd.ShowProgressBar         = false;
                vtd.AllowDialogCancellation = (Buttons == TaskDialogButtons.Cancel ||
                                               Buttons == TaskDialogButtons.Close ||
                                               Buttons == TaskDialogButtons.OKCancel ||
                                               Buttons == TaskDialogButtons.YesNoCancel);
                vtd.CallbackTimer            = false;
                vtd.ExpandedByDefault        = false;
                vtd.ExpandFooterArea         = false;
                vtd.PositionRelativeToWindow = true;
                vtd.RightToLeftLayout        = false;
                vtd.NoDefaultRadioButton     = false;
                vtd.CanBeMinimized           = false;
                vtd.ShowMarqueeProgressBar   = false;
                vtd.UseCommandLinks          = (CommandButtons != "");
                vtd.UseCommandLinksNoIcon    = false;
                vtd.VerificationText         = VerificationText;
                vtd.VerificationFlagChecked  = false;
                vtd.ExpandedControlText      = "Hide details";
                vtd.CollapsedControlText     = "Show details";
                vtd.Callback = null;

                // Show the Dialog
                DialogResult result = ( DialogResult )vtd.Show((vtd.CanBeMinimized ? null : Form.ActiveForm), out VerificationChecked, out RadioButtonResult);

                // if a command button was clicked, then change return result
                // to "DialogResult.OK" and set the CommandButtonResult
                if (( int )result >= 2000)
                {
                    CommandButtonResult = (( int )result - 2000);
                    result = DialogResult.OK;
                }
                if (RadioButtonResult >= 1000)
                {
                    RadioButtonResult -= 1000; // deduct the ButtonID start value for radio buttons
                }
                return(result);
            }
            else
            {
                // [OPTION 2] Show Emulated Form
                TaskDialogForm td = new TaskDialogForm( );
                td.Title            = Title;
                td.MainInstruction  = MainInstruction;
                td.Content          = Content;
                td.ExpandedInfo     = ExpandedInfo;
                td.Footer           = Footer;
                td.RadioButtons     = RadioButtons;
                td.CommandButtons   = CommandButtons;
                td.Buttons          = Buttons;
                td.MainIcon         = MainIcon;
                td.FooterIcon       = FooterIcon;
                td.VerificationText = VerificationText;
                td.Width            = EmulatedFormWidth;
                td.BuildForm( );
                DialogResult result = td.ShowDialog( );

                RadioButtonResult   = td.RadioButtonIndex;
                CommandButtonResult = td.CommandButtonClickedIndex;
                VerificationChecked = td.VerificationCheckBoxChecked;
                return(result);
            }
        }
Пример #28
0
 /// <summary>
 /// Displays a <see cref="TaskDialog"/> using an <see cref="InlineModalDialog" />.
 /// </summary>
 /// <param name="owner">The owner.</param>
 /// <param name="header">The header.</param>
 /// <param name="content">The content.</param>
 /// <param name="title">The title.</param>
 /// <param name="standardButtons">The standard buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="useCommandLinks">if set to <c>true</c>, use <see cref="CommandLink"/>s instead of <see cref="Button"/>s.</param>
 /// <param name="buttons">The buttons.</param>
 /// <returns></returns>
 public static TaskDialogResult ShowInline(DependencyObject owner, string header, string content, string title, TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks, params TaskDialogButtonData[] buttons)
 {
     return(ShowInlineCore(owner, header, content, title, standardButtons, icon, useCommandLinks, buttons));
 }
Пример #29
0
 public DialogResult MessageBox(string title, string message, string content, TaskDialogButtons buttons,
                                SysIcons icons)
 {
     return DialogResult.None;
 }
Пример #30
0
 /// <summary>
 /// Displays a <see cref="TaskDialog"/> using an <see cref="InlineModalDialog" />.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="content">The content.</param>
 /// <param name="title">The title.</param>
 /// <param name="standardButtons">The standard buttons.</param>
 /// <returns></returns>
 public static TaskDialogResult ShowInline(string header, string content, string title, TaskDialogButtons standardButtons)
 {
     return(ShowInlineCore(null, header, content, title, standardButtons, TaskDialogIcon.None, false));
 }
Пример #31
0
 public DialogResult MessageBox(IWin32Window Owner,
     string Title,
     string MainInstruction,
     string Content,
     TaskDialogButtons Buttons,
     SysIcons MainIcon)
 {
     return MessageBox(Owner, Title, MainInstruction, Content, String.Empty, String.Empty, String.Empty, Buttons, MainIcon,
                       SysIcons.Information);
 }
Пример #32
0
        //--------------------------------------------------------------------------------
        public static DialogResult ShowTaskDialogBox(string Title,
                                                     string MainInstruction,
                                                     string Content,
                                                     string ExpandedInfo,
                                                     string Footer,
                                                     string VerificationText,
                                                     string RadioButtons,
                                                     string CommandButtons,
                                                     TaskDialogButtons Buttons,
                                                     TaskDialogIcons MainIcon,
                                                     TaskDialogIcons FooterIcon)
        {
            if (VistaTaskDialog.IsAvailableOnThisOS && !ForceEmulationMode)
            {
                // [OPTION 1] Show Vista TaskDialog
                VistaTaskDialog vtd = new VistaTaskDialog();

                vtd.WindowTitle = Title;
                vtd.MainInstruction = MainInstruction;
                vtd.Content = Content;
                vtd.ExpandedInformation = ExpandedInfo;
                vtd.Footer = Footer;

                // Radio Buttons
                if (RadioButtons != "")
                {
                    List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
                    string[] arr = RadioButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId = 1000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.RadioButtons = lst.ToArray();
                }

                // Custom Buttons
                if (CommandButtons != "")
                {
                    List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
                    string[] arr = CommandButtons.Split(new char[] { '|' });
                    for (int i = 0; i < arr.Length; i++)
                    {
                        try
                        {
                            VistaTaskDialogButton button = new VistaTaskDialogButton();
                            button.ButtonId = 2000 + i;
                            button.ButtonText = arr[i];
                            lst.Add(button);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                    vtd.Buttons = lst.ToArray();
                }

                switch (Buttons)
                {
                    case TaskDialogButtons.YesNo:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No;
                        break;
                    case TaskDialogButtons.YesNoCancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Yes | VistaTaskDialogCommonButtons.No | VistaTaskDialogCommonButtons.Cancel;
                        break;
                    case TaskDialogButtons.OKCancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok | VistaTaskDialogCommonButtons.Cancel;
                        break;
                    case TaskDialogButtons.OK:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Ok;
                        break;
                    case TaskDialogButtons.Close:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Close;
                        break;
                    case TaskDialogButtons.Cancel:
                        vtd.CommonButtons = VistaTaskDialogCommonButtons.Cancel;
                        break;
                    default:
                        vtd.CommonButtons = 0;
                        break;
                }

                switch (MainIcon)
                {
                    case TaskDialogIcons.Information: vtd.MainIcon = VistaTaskDialogIcon.Information; break;
                    case TaskDialogIcons.Question: vtd.MainIcon = VistaTaskDialogIcon.Information; break;
                    case TaskDialogIcons.Warning: vtd.MainIcon = VistaTaskDialogIcon.Warning; break;
                    case TaskDialogIcons.Error: vtd.MainIcon = VistaTaskDialogIcon.Error; break;
                }

                switch (FooterIcon)
                {
                    case TaskDialogIcons.Information: vtd.FooterIcon = VistaTaskDialogIcon.Information; break;
                    case TaskDialogIcons.Question: vtd.FooterIcon = VistaTaskDialogIcon.Information; break;
                    case TaskDialogIcons.Warning: vtd.FooterIcon = VistaTaskDialogIcon.Warning; break;
                    case TaskDialogIcons.Error: vtd.FooterIcon = VistaTaskDialogIcon.Error; break;
                }

                vtd.EnableHyperlinks = false;
                vtd.ShowProgressBar = false;
                vtd.AllowDialogCancellation = (Buttons == TaskDialogButtons.Cancel ||
                                               Buttons == TaskDialogButtons.Close ||
                                               Buttons == TaskDialogButtons.OKCancel ||
                                               Buttons == TaskDialogButtons.YesNoCancel);
                vtd.CallbackTimer = false;
                vtd.ExpandedByDefault = false;
                vtd.ExpandFooterArea = false;
                vtd.PositionRelativeToWindow = true;
                vtd.RightToLeftLayout = false;
                vtd.NoDefaultRadioButton = false;
                vtd.CanBeMinimized = false;
                vtd.ShowMarqueeProgressBar = false;
                vtd.UseCommandLinks = (CommandButtons != "");
                vtd.UseCommandLinksNoIcon = false;
                vtd.VerificationText = VerificationText;
                vtd.VerificationFlagChecked = false;
                vtd.ExpandedControlText = Properties.Resources.TASKDIALOG_HIDEDETAILS;
                vtd.CollapsedControlText = Properties.Resources.TASKDIALOG_SHOWDETAILS;
                vtd.Callback = null;

                // Show the Dialog
                DialogResult result = (DialogResult)vtd.Show((vtd.CanBeMinimized ? null : Form.ActiveForm), out VerificationChecked, out RadioButtonResult);

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

                return result;
            }
            else
            {
                // [OPTION 2] Show Emulated Form
                EmulatedTaskDialog td = new EmulatedTaskDialog();

                //ML-2422: Can't confirm error message, with a lot of detailed information.
                td.ExpandedInfo = ExpandedInfo;
                try
                {
                    int expandedInfoHeight = td.GetExpandedInfoLabelHeight;
                    if (expandedInfoHeight > maxHeightExpandedInfo)
                        td.ExpandedInfo = td.ExpandedInfo.Substring(0, (int)(td.ExpandedInfo.Length * ((int)(maxHeightExpandedInfo / expandedInfoHeight))));
                }
                catch (Exception e) { Trace.WriteLine("Can't cut text in EmulatedTaskDialog: " + e.ToString()); }

                td.TopMost = true;
                td.Title = Title;
                td.MainInstruction = MainInstruction;
                td.Content = Content;
                td.Footer = Footer;
                td.RadioButtons = RadioButtons;
                td.CommandButtons = CommandButtons;
                td.Buttons = Buttons;
                td.MainIcon = MainIcon;
                td.FooterIcon = FooterIcon;
                td.VerificationText = VerificationText;
                td.Width = EmulatedFormWidth;
                td.BuildForm();
                DialogResult result = td.ShowDialog();

                RadioButtonResult = td.RadioButtonIndex;
                CommandButtonResult = td.CommandButtonClickedIndex;
                VerificationChecked = td.VerificationCheckBoxChecked;
                return result;
            }
        }
Пример #33
0
 //--------------------------------------------------------------------------------
 public DialogResult MessageBox(IWin32Window Owner,
     string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     TaskDialogButtons Buttons,
     SysIcons MainIcon,
     SysIcons FooterIcon)
 {
     return ShowTaskDialogBox(Owner, Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText, String.Empty,
                              String.Empty, Buttons, MainIcon, FooterIcon);
 }
Пример #34
0
        /// <summary>
        /// Display a standard message box.
        /// </summary>
        /// <param name="handle">The handle of the owning window.</param>
        /// <param name="title">The title of the dialog box.</param>
        /// <param name="instruction">The main instruction text.</param>
        /// <param name="content">Text content text displayed uner the main instruction.</param>
        /// <param name="buttons">The buttons to display in the dialog.</param>
        /// <param name="icon"></param>
        /// <returns></returns>
        public static TaskDialogResults ShowMessage(IntPtr handle, string title, string instruction, string content, TaskDialogButtons buttons, TaskDialogIcons icon)
        {
            int iconID = (int)icon;
            int result;
            int hresult = TaskDlog(handle, IntPtr.Zero, title, instruction, content, (int)buttons, (ushort)iconID, out result);

            if (hresult != 0)
            {
                throw new Win32Exception(hresult);
            }

            return((TaskDialogResults)result);
        }
Пример #35
0
        /// <summary>
        /// Method to actually show the task dialog.
        /// </summary>
        /// <param name="text">The text to display.</param>
        /// <param name="instruction">The instructions to display.</param>
        /// <param name="caption">The caption for the task dialog.</param>
        /// <param name="buttons">Any <see cref="TaskDialogButtons"/> to display.</param>
        /// <param name="icon">The <see cref="TaskDialogIcon"/> to display.</param>
        /// <returns>The <see cref="TaskDialogResult"/> from the task dialog.</returns>
        private TaskDialogResult ShowInternal(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int result;

            if (externalTaskDialog(_owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out result) != 0)
            {
                throw new InvalidOperationException("ShowInternal");
            }

            switch (result)
            {
            case 1: return(TaskDialogResult.OK);

            case 2: return(TaskDialogResult.Cancel);

            case 4: return(TaskDialogResult.Retry);

            case 6: return(TaskDialogResult.Yes);

            case 7: return(TaskDialogResult.No);

            case 8: return(TaskDialogResult.Close);

            default: return(TaskDialogResult.None);
            }
        }
Пример #36
0
        private static TaskDialogResult ShowInternal(IntPtr owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;

            if (_TaskDialog(owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
            {
                throw new InvalidOperationException("Something weird has happened.");
            }

            switch (p)
            {
            case 1:
                return(TaskDialogResult.OK);

            case 2:
                return(TaskDialogResult.Cancel);

            case 4:
                return(TaskDialogResult.Retry);

            case 6:
                return(TaskDialogResult.Yes);

            case 7:
                return(TaskDialogResult.No);

            case 8:
                return(TaskDialogResult.Close);

            default:
                return(TaskDialogResult.None);
            }
        }
Пример #37
0
        /// <summary>
        /// Show a task dialog using the specified values as content.
        /// </summary>
        /// <param name="windowTitle">Caption of the window.</param>
        /// <param name="mainInstruction">Principal text.</param>
        /// <param name="content">Extra text.</param>
        /// <param name="icon">Predefined icon.</param>
        /// <param name="commonButtons">Common buttons.</param>
        /// <returns>One of the DialogResult values.</returns>
        public static DialogResult Show(string windowTitle,
                                        string mainInstruction,
                                        string content,
                                        MessageBoxIcon icon,
                                        TaskDialogButtons commonButtons)
        {
            // Create a temporary task dialog for storing definition whilst showing
            using (KryptonTaskDialog taskDialog = new KryptonTaskDialog())
            {
                // Store incoming values
                taskDialog.WindowTitle = windowTitle;
                taskDialog.MainInstruction = mainInstruction;
                taskDialog.Content = content;
                taskDialog.Icon = icon;
                taskDialog.CommonButtons = commonButtons;

                // Show as a modal dialog
                return taskDialog.ShowDialog();
            }
        }
Пример #38
0
 public static TaskDialogResult Show(IWin32Window owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return(ShowInternal(owner.Handle, text, instruction, caption, buttons, icon));
 }
Пример #39
0
 /// <summary>
 ///  Initialize a new instance of the KryptonTaskDialog class.
 /// </summary>
 public KryptonTaskDialog()
 {
     _radioButtons = new KryptonTaskDialogCommandCollection();
     _commandButtons = new KryptonTaskDialogCommandCollection();
     _commonButtons = TaskDialogButtons.OK;
 }
Пример #40
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return(ShowInternal(IntPtr.Zero, text, instruction, caption, buttons, icon));
 }
Пример #41
0
        public static TaskDialogResult ShowTaskDialog(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;

            if (NativeMethods.TaskDialog(IntPtr.Zero, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
            {
                throw new InvalidOperationException("Error occurred calling TaskDialog.");
            }

            switch (p)
            {
            case 1: return(TaskDialogResult.Ok);

            case 2: return(TaskDialogResult.Cancel);

            case 4: return(TaskDialogResult.Retry);

            case 6: return(TaskDialogResult.Yes);

            case 7: return(TaskDialogResult.No);

            case 8: return(TaskDialogResult.Close);

            default: return(TaskDialogResult.None);
            }
        }
Пример #42
0
 public DialogResult MessageBox(string Title,
     string MainInstruction,
     string Content,
     TaskDialogButtons Buttons,
     SysIcons MainIcon)
 {
     return MessageBox(null, Title, MainInstruction, Content, "", "", "", Buttons, MainIcon, SysIcons.Information);
 }
Пример #43
0
 public static TaskDialogResult Show(string content, string instruction = null, string caption = null,
     TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
      => Show(IntPtr.Zero, content, instruction, caption, buttons, icon);
Пример #44
0
 public DialogResult ShowTaskDialogBox(string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     string RadioButtons,
     string CommandButtons,
     TaskDialogButtons Buttons,
     SysIcons MainIcon,
     SysIcons FooterIcon)
 {
     return ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                              RadioButtons, CommandButtons, Buttons, MainIcon, FooterIcon, 0);
 }
Пример #45
0
 public static TaskDialogResult Show(TaskDialog owner, string content, string instruction = null, string caption = null,
     TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
     => Show(GetWindowHandle((IWin32Window)owner), content, instruction, caption, buttons, icon);
Пример #46
0
        private void ShowTaskDialog_Click(object sender, RoutedEventArgs e)
        {
            TaskDialog taskDialog = new TaskDialog();

            taskDialog.Background = Brushes.White;
            taskDialog.Title      = TitleText.Text;
            taskDialog.Header     = HeaderText.Text;
            taskDialog.Content    = ContentText.Text;
            taskDialog.AllowDialogCancellation = AllowCancellation.IsChecked == true;
            if (FooterText.Text.Length > 0)
            {
                taskDialog.ShowFooter = true;
                taskDialog.Footer     = FooterText.Text;
            }
            if (VerificationText.Text.Length > 0)
            {
                taskDialog.ShowVerification = true;
                taskDialog.Verification     = VerificationText.Text;
            }
            taskDialog.ShowProgressBar         = ShowProgresBar.IsChecked == true;
            taskDialog.IsProgressIndeterminate = ProgresBarIndeterminate.IsChecked == true;
            if (ExpansionText.Text.Length > 0)
            {
                taskDialog.ExpansionPosition = (ExpandFooter.IsChecked == true)
                    ? TaskDialogExpansionPosition.Footer
                    : TaskDialogExpansionPosition.Header;
                taskDialog.ExpansionContent       = ExpansionText.Text;
                taskDialog.ExpansionButtonContent = ExpansionButtonText.Text;
            }
            TaskDialogButtons standardButtons = TaskDialogButtons.None;

            if (OKButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.OK;
            }
            if (CancelButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.Cancel;
            }
            if (RetryButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.Retry;
            }
            if (YesButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.Yes;
            }
            if (NoButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.No;
            }
            if (CloseButton.IsChecked == true)
            {
                standardButtons |= TaskDialogButtons.Close;
            }

            foreach (object item in Radios.Items.Cast <RadioData>().Select(r => r.Value))
            {
                taskDialog.RadioButtons.Add(item);
            }

            foreach (object item in TaskDialogButtonData.FromStandardButtons(standardButtons))
            {
                taskDialog.Buttons.Add(item);
            }

            if (UseCommandLinks.IsChecked == true)
            {
                foreach (object item in _buttons)
                {
                    taskDialog.CommandLinks.Add(item);
                }
            }
            else
            {
                foreach (object item in _buttons)
                {
                    taskDialog.Buttons.Add(item);
                }
            }

            taskDialog.MainIcon   = TaskDialogIconConverter.ConvertFrom((TaskDialogIcon)MainIcon.SelectedItem);
            taskDialog.FooterIcon = TaskDialogIconConverter.ConvertFrom((TaskDialogIcon)FooterIcon.SelectedItem);


            ShowDialog(taskDialog);
        }
Пример #47
0
        public static TaskDialogResult Show(IntPtr hwndOwner, string content, string instruction = null, string caption = null,
            TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
        {
            TaskDialog dialog = new TaskDialog()
            {
                Content = content,
                MainInstruction = instruction,
                Title = caption,
                CommonButtons = buttons,
                MainIcon = icon
            };
            dialog.Show(hwndOwner);

            return dialog.ResultCommonButtonID;
        }
Пример #48
0
 static extern TaskDialogResult TaskDialog(IntPtr hWndParent, IntPtr hInstance, String title, String mainInstruction, String content, TaskDialogButtons buttons, TaskDialogIcon icon);
Пример #49
0
        private static TaskDialogResult ShowInternal(IntPtr owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;

            if (_TaskDialog(owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
                throw new InvalidOperationException("Something weird has happened.");

            switch (p)
            {
                case 1:
                    return TaskDialogResult.OK;
                case 2:
                    return TaskDialogResult.Cancel;
                case 4:
                    return TaskDialogResult.Retry;
                case 6:
                    return TaskDialogResult.Yes;
                case 7:
                    return TaskDialogResult.No;
                case 8:
                    return TaskDialogResult.Close;
                default:
                    return TaskDialogResult.None;
            }
        }
Пример #50
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return ShowInternal(null, text, instruction, caption, buttons, icon);
 }
Пример #51
0
        public static DialogResult ShowKryptonMessageBox(string title, string mainIntrustion, string content, TaskDialogButtons commonButton, MessageBoxIcon icon, IWin32Window owner = null)
        {
            KryptonTaskDialog kUserDialog = new KryptonTaskDialog();

            kUserDialog.WindowTitle     = title;
            kUserDialog.MainInstruction = mainIntrustion;
            kUserDialog.Content         = content;
            kUserDialog.CommonButtons   = commonButton;
            kUserDialog.Icon            = icon;
            return(kUserDialog.ShowDialog(owner));
        }