Example #1
0
        public DialogResult CommandBox(string title, string mainInstruction, string content,
                                       string expandedInfo,
                                       string help,
                                       string verificationText, string commandButtons, bool showCancelButton,
                                       SysIcons mainIcon,
                                       SysIcons footerIcon, DialogResponseHandler handler)
        {
            //BringToFront();
            TaskDialog dialog = new TaskDialog();

            dialog.HelpDelegate = delegate(string url) { Utils.StartProcess(url); };
            DialogResult result = dialog.ShowCommandBox(this, title,
                                                        mainInstruction,
                                                        content,
                                                        expandedInfo,
                                                        FormatHelp(help),
                                                        verificationText,
                                                        commandButtons,
                                                        showCancelButton,
                                                        mainIcon,
                                                        footerIcon);

            handler(dialog.CommandButtonResult, dialog.VerificationChecked);
            return(result);
        }
Example #2
0
        //--------------------------------------------------------------------------------
        // Overloaded versions...
        //--------------------------------------------------------------------------------
        public int ShowRadioBox(string Title,
                                string MainInstruction,
                                string Content,
                                string ExpandedInfo,
                                string Footer,
                                string VerificationText,
                                string RadioButtons,
                                SysIcons MainIcon,
                                SysIcons FooterIcon,
                                int DefaultIndex)
        {
            DialogResult res = ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer,
                                                 VerificationText,
                                                 RadioButtons, "", TaskDialogButtons.OKCancel, MainIcon, FooterIcon,
                                                 DefaultIndex);

            if (res == DialogResult.OK)
            {
                return(_radioButtonResult);
            }
            else
            {
                return(-1);
            }
        }
Example #3
0
 public DialogResult CommandBox(string title, string mainInstruction, string content, string expandedInfo,
                                string help, string verificationText, string commandButtons,
                                bool showCancelButton, SysIcons mainIcon, SysIcons footerIcon,
                                DialogResponseHandler handler)
 {
     return(DialogResult.None);
 }
Example #4
0
 /// <summary>
 /// Messages the box.
 /// </summary>
 /// <param name="Title">The title.</param>
 /// <param name="MainInstruction">The main instruction.</param>
 /// <param name="Content">The content.</param>
 /// <param name="Buttons">The buttons.</param>
 /// <param name="MainIcon">The main icon.</param>
 /// <returns></returns>
 static public DialogResult MessageBox(string Title,
                                       string MainInstruction,
                                       string Content,
                                       TaskDialogButtons Buttons,
                                       SysIcons MainIcon)
 {
     return(MessageBox(Title, MainInstruction, Content, "", "", "", Buttons, MainIcon, SysIcons.Information));
 }
Example #5
0
 /// <summary>
 /// Messages the 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="Buttons">The buttons.</param>
 /// <param name="MainIcon">The main icon.</param>
 /// <param name="FooterIcon">The footer icon.</param>
 /// <returns></returns>
 static public DialogResult MessageBox(string Title,
                                       string MainInstruction,
                                       string Content,
                                       string ExpandedInfo,
                                       string Footer,
                                       string VerificationText,
                                       TaskDialogButtons Buttons,
                                       SysIcons MainIcon,
                                       SysIcons FooterIcon)
 {
     return(ShowTaskDialogBox(Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                              "", "", Buttons, MainIcon, FooterIcon));
 }
Example #6
0
 public DialogResult ShowRadioBox(IWin32Window Owner,
                                  string Title,
                                  string MainInstruction,
                                  string Content,
                                  string ExpandedInfo,
                                  string Footer,
                                  string VerificationText,
                                  string RadioButtons,
                                  SysIcons MainIcon,
                                  SysIcons FooterIcon)
 {
     return(ShowRadioBox(Owner, Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                         RadioButtons, SysIcons.Question, SysIcons.Information, 0));
 }
Example #7
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));
 }
Example #8
0
 //--------------------------------------------------------------------------------
 // Overloaded versions...
 //--------------------------------------------------------------------------------
 public DialogResult ShowCommandBox(string Title,
                                    string MainInstruction,
                                    string Content,
                                    string ExpandedInfo,
                                    string Footer,
                                    string VerificationText,
                                    string CommandButtons,
                                    bool ShowCancelButton,
                                    SysIcons MainIcon,
                                    SysIcons FooterIcon)
 {
     return(ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer,
                              VerificationText,
                              "", CommandButtons,
                              (ShowCancelButton ? TaskDialogButtons.Cancel : TaskDialogButtons.None),
                              MainIcon, FooterIcon));
 }
Example #9
0
        //--------------------------------------------------------------------------------

        #endregion

        //--------------------------------------------------------------------------------

        #region ShowRadioBox

        //--------------------------------------------------------------------------------
        public DialogResult ShowRadioBox(IWin32Window Owner,
                                         string Title,
                                         string MainInstruction,
                                         string Content,
                                         string ExpandedInfo,
                                         string Footer,
                                         string VerificationText,
                                         string RadioButtons,
                                         SysIcons MainIcon,
                                         SysIcons FooterIcon,
                                         int DefaultIndex)
        {
            return(ShowTaskDialogBox(Owner, Title, MainInstruction, Content, ExpandedInfo, Footer,
                                     VerificationText,
                                     RadioButtons, "", TaskDialogButtons.OKCancel, MainIcon, FooterIcon,
                                     DefaultIndex));
        }
Example #10
0
        /// <summary>
        /// Shows the command 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="CommandButtons">The command buttons.</param>
        /// <param name="ShowCancelButton">if set to <c>true</c> [show cancel button].</param>
        /// <param name="MainIcon">The main icon.</param>
        /// <param name="FooterIcon">The footer icon.</param>
        /// <returns></returns>
        static public int ShowCommandBox(string Title,
                                         string MainInstruction,
                                         string Content,
                                         string ExpandedInfo,
                                         string Footer,
                                         string VerificationText,
                                         string CommandButtons,
                                         bool ShowCancelButton,
                                         SysIcons MainIcon,
                                         SysIcons FooterIcon)
        {
            DialogResult res = ShowTaskDialogBox(Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                                                 "", CommandButtons, (ShowCancelButton ? TaskDialogButtons.Cancel : TaskDialogButtons.None),
                                                 MainIcon, FooterIcon);

            if (res == DialogResult.OK)
            {
                return(CommandButtonResult);
            }
            else
            {
                return(-1);
            }
        }
Example #11
0
 //--------------------------------------------------------------------------------
 public DialogResult ShowRadioBox(IWin32Window Owner,
     string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     string RadioButtons,
     SysIcons MainIcon,
     SysIcons FooterIcon,
     int DefaultIndex)
 {
     return ShowTaskDialogBox(Owner, Title, MainInstruction, Content, ExpandedInfo, Footer,
                              VerificationText,
                              RadioButtons, "", TaskDialogButtons.OKCancel, MainIcon, FooterIcon,
                              DefaultIndex);
 }
Example #12
0
 public DialogResult ShowCommandBox(string Title, string MainInstruction, string Content, string CommandButtons,
     bool ShowCancelButton, SysIcons MainIcon)
 {
     return ShowCommandBox(null, Title, MainInstruction, Content, CommandButtons, ShowCancelButton, MainIcon);
 }
Example #13
0
 public DialogResult ShowCommandBox(IWin32Window Owner, string Title, string MainInstruction, string Content,
     string CommandButtons, bool ShowCancelButton, SysIcons MainIcon)
 {
     return ShowCommandBox(Owner, Title, MainInstruction, Content, "", "", "", CommandButtons, ShowCancelButton,
                           MainIcon, SysIcons.Information);
 }
Example #14
0
 public DialogResult MessageBox(string Title,
     string MainInstruction,
     string Content,
     TaskDialogButtons Buttons,
     SysIcons MainIcon)
 {
     return MessageBox(null, Title, MainInstruction, Content, "", "", "", Buttons, MainIcon, SysIcons.Information);
 }
Example #15
0
 //--------------------------------------------------------------------------------
 // Overloaded versions...
 //--------------------------------------------------------------------------------
 public DialogResult ShowCommandBox(string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     string CommandButtons,
     bool ShowCancelButton,
     SysIcons MainIcon,
     SysIcons FooterIcon)
 {
     return ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer,
                              VerificationText,
                              "", CommandButtons,
                              (ShowCancelButton ? TaskDialogButtons.Cancel : TaskDialogButtons.None),
                              MainIcon, FooterIcon);
 }
Example #16
0
 public DialogResult CommandBox(string title, string mainInstruction, string content, string expandedInfo,
                                string help, string verificationText, string commandButtons,
                                bool showCancelButton, SysIcons mainIcon, SysIcons footerIcon,
                                DialogResponseHandler handler)
 {
     return DialogResult.None;
 }
Example #17
0
 public DialogResult ShowCommandBox(string Title, string MainInstruction, string Content, string CommandButtons,
                                    bool ShowCancelButton, SysIcons MainIcon)
 {
     return(ShowCommandBox(null, Title, MainInstruction, Content, CommandButtons, ShowCancelButton, MainIcon));
 }
Example #18
0
 /// <summary>
 /// Shows the command 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="CommandButtons">The command buttons.</param>
 /// <param name="ShowCancelButton">if set to <c>true</c> [show cancel button].</param>
 /// <param name="MainIcon">The main icon.</param>
 /// <param name="FooterIcon">The footer icon.</param>
 /// <returns></returns>
 public static int ShowCommandBox( string Title,
                              string MainInstruction,
                              string Content,
                              string ExpandedInfo,
                              string Footer,
                              string VerificationText,
                              string CommandButtons,
                              bool ShowCancelButton,
                              SysIcons MainIcon,
                              SysIcons FooterIcon )
 {
     DialogResult res = ShowTaskDialogBox ( Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                                    "", CommandButtons, ( ShowCancelButton ? TaskDialogButtons.Cancel : TaskDialogButtons.None ),
                                    MainIcon, FooterIcon );
       if ( res == DialogResult.OK )
     return CommandButtonResult;
       else
     return -1;
 }
Example #19
0
        //--------------------------------------------------------------------------------
        /// <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>
        public static 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;
              }
        }
Example #20
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, "",
                              "", Buttons, MainIcon, FooterIcon);
 }
Example #21
0
 public DialogResult CommandBox(string title, string mainInstruction, string content,
     string expandedInfo,
     string help,
     string verificationText, string commandButtons, bool showCancelButton,
     SysIcons mainIcon,
     SysIcons footerIcon, DialogResponseHandler handler)
 {
     //BringToFront();
     TaskDialog dialog = new TaskDialog();
     dialog.HelpDelegate = delegate(string url) { Utils.StartProcess(url); };
     DialogResult result = dialog.ShowCommandBox(this, title,
                                                 mainInstruction,
                                                 content,
                                                 expandedInfo,
                                                 FormatHelp(help),
                                                 verificationText,
                                                 commandButtons,
                                                 showCancelButton,
                                                 mainIcon,
                                                 footerIcon);
     handler(dialog.CommandButtonResult, dialog.VerificationChecked);
     return result;
 }
Example #22
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;
        }
Example #23
0
 //--------------------------------------------------------------------------------
 // Overloaded versions...
 //--------------------------------------------------------------------------------
 public int ShowRadioBox(string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     string RadioButtons,
     SysIcons MainIcon,
     SysIcons FooterIcon,
     int DefaultIndex)
 {
     DialogResult res = ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer,
                                          VerificationText,
                                          RadioButtons, "", TaskDialogButtons.OKCancel, MainIcon, FooterIcon,
                                          DefaultIndex);
     if (res == DialogResult.OK)
         return _radioButtonResult;
     else
         return -1;
 }
Example #24
0
 public DialogResult ShowCommandBox(IWin32Window Owner, string Title, string MainInstruction, string Content,
                                    string CommandButtons, bool ShowCancelButton, SysIcons MainIcon)
 {
     return(ShowCommandBox(Owner, Title, MainInstruction, Content, "", "", "", CommandButtons, ShowCancelButton,
                           MainIcon, SysIcons.Information));
 }
Example #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);
        }
Example #26
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);
            }
        }
Example #27
0
 public DialogResult ShowRadioBox(IWin32Window Owner,
     string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     string RadioButtons,
     SysIcons MainIcon,
     SysIcons FooterIcon)
 {
     return ShowRadioBox(Owner, Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText,
                         RadioButtons, SysIcons.Question, SysIcons.Information, 0);
 }
Example #28
0
 public DialogResult MessageBox(string title, string message, string content, TaskDialogButtons buttons,
                                SysIcons icons)
 {
     return DialogResult.None;
 }
Example #29
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);
 }
Example #30
0
 //--------------------------------------------------------------------------------
 // Overloaded versions...
 //--------------------------------------------------------------------------------
 public DialogResult MessageBox(string Title,
     string MainInstruction,
     string Content,
     string ExpandedInfo,
     string Footer,
     string VerificationText,
     TaskDialogButtons Buttons,
     SysIcons MainIcon,
     SysIcons FooterIcon)
 {
     return ShowTaskDialogBox(null, Title, MainInstruction, Content, ExpandedInfo, Footer, VerificationText, String.Empty,
                              String.Empty, Buttons, MainIcon, FooterIcon);
 }
Example #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);
 }
Example #32
0
 public DialogResult MessageBox(string title, string message, string content,
     TaskDialogButtons buttons,
     SysIcons icons)
 {
     //BringToFront();
     TaskDialog dialog = new TaskDialog();
     return dialog.MessageBox(this,
                              title,
                              message,
                              content,
                              buttons, icons);
 }