/// <summary>
 /// Displays a message box with the specified text and parameters.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="title">The title.</param>
 /// <param name="helpFile">The help file.</param>
 /// <param name="helpTopic">The help topic.</param>
 /// <param name="initialization">The initialization.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="customIcon">The custom icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <param name="customButtons">The custom buttons.</param>
 /// <param name="buttonsLayout">The buttons layout.</param>
 /// <param name="autoSizeMode">The auto size mode.</param>
 /// <param name="position">The position.</param>
 /// <param name="showHelpButton">if set to <c>true</c> shows help button.</param>
 /// <param name="helpNavigator">The help navigator.</param>
 /// <param name="showDoNotShowAgainCheckBox">if set to <c>true</c> shows the do not show again check box.</param>
 /// <param name="style">The style.</param>
 /// <param name="autoClose">The auto close configuration.</param>
 /// <param name="design">The design.</param>
 /// <param name="titleStyle">The title style.</param>
 /// <param name="titleIcon">The title icon.</param>
 /// <param name="legacyButtons">The legacy buttons.</param>
 /// <param name="legacyIcon">The legacy icon.</param>
 /// <param name="legacyDefaultButton">The legacy default button.</param>
 /// <param name="behavior">The behavior.</param>
 /// <param name="callback">The callback.</param>
 /// <param name="opacity">The opacity.</param>
 /// <param name="parent">The parent form.</param>
 /// <param name="order">The z-order</param>
 /// <param name="sound">The sound configuration</param>
 /// <returns>One of the <see cref="InformationBoxResult"/> values.</returns>
 public static InformationBoxResult Show(string text,
                                         string title     = "",
                                         string helpFile  = "",
                                         string helpTopic = "",
                                         InformationBoxInitialization initialization = InformationBoxInitialization.FromScopeAndParameters,
                                         InformationBoxButtons buttons = InformationBoxButtons.OK,
                                         InformationBoxIcon icon       = InformationBoxIcon.None,
                                         Icon customIcon = null,
                                         InformationBoxDefaultButton defaultButton = InformationBoxDefaultButton.Button1,
                                         string[] customButtons = null,
                                         InformationBoxButtonsLayout buttonsLayout = InformationBoxButtonsLayout.GroupMiddle,
                                         InformationBoxAutoSizeMode autoSizeMode   = InformationBoxAutoSizeMode.None,
                                         InformationBoxPosition position           = InformationBoxPosition.CenterOnParent,
                                         bool showHelpButton         = false,
                                         HelpNavigator helpNavigator = HelpNavigator.TableOfContents,
                                         InformationBoxCheckBox showDoNotShowAgainCheckBox = 0,
                                         InformationBoxStyle style                   = InformationBoxStyle.Standard,
                                         AutoCloseParameters autoClose               = null,
                                         DesignParameters design                     = null,
                                         InformationBoxTitleIconStyle titleStyle     = InformationBoxTitleIconStyle.None,
                                         InformationBoxTitleIcon titleIcon           = null,
                                         MessageBoxButtons?legacyButtons             = null,
                                         MessageBoxIcon?legacyIcon                   = null,
                                         MessageBoxDefaultButton?legacyDefaultButton = null,
                                         InformationBoxBehavior behavior             = InformationBoxBehavior.Modal,
                                         AsyncResultCallback callback                = null,
                                         InformationBoxOpacity opacity               = InformationBoxOpacity.NoFade,
                                         Form parent = null,
                                         InformationBoxOrder order = InformationBoxOrder.Default,
                                         InformationBoxSound sound = InformationBoxSound.Default)
 {
     return(new InformationBoxForm(text, title, helpFile, helpTopic, initialization, buttons, icon, customIcon, defaultButton,
                                   customButtons, buttonsLayout, autoSizeMode, position, showHelpButton, helpNavigator, showDoNotShowAgainCheckBox,
                                   style, autoClose, design, titleStyle, titleIcon, legacyButtons, legacyIcon, legacyDefaultButton, behavior, callback, opacity, parent, order, sound).Show());
 }
        /// <summary>
        /// Generates the code.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        private void GenerateCode(InformationBoxBehavior behavior, Language language)
        {
            InformationBoxButtons buttons             = this.GetButtons();
            InformationBoxIcon    icon                = this.GetIcon();
            string iconFileName                       = this.txbIcon.Text;
            InformationBoxDefaultButton defaultButton = this.GetDefaultButton();
            InformationBoxButtonsLayout buttonsLayout = this.GetButtonsLayout();
            InformationBoxAutoSizeMode  autoSize      = this.GetAutoSize();
            InformationBoxPosition      position      = this.GetPosition();
            HelpNavigator                navigator    = this.GetHelpNavigator();
            InformationBoxCheckBox       checkState   = this.GetCheckBoxState();
            InformationBoxStyle          style        = this.GetStyle();
            AutoCloseParameters          autoClose    = this.GetAutoClose();
            DesignParameters             design       = this.GetDesign();
            InformationBoxTitleIconStyle titleStyle   = this.GetTitleStyle();
            InformationBoxOpacity        opacity      = this.GetOpacity();
            InformationBoxOrder          order        = this.GetOrder();

            ICodeGeneratorFactory factory = new CodeGeneratorFactory();
            ICodeGenerator        codeGen = factory.CreateGenerator(language);

            String generatedCode = codeGen.GenerateSingleCall(
                behavior, this.txbText.Text, this.txbTitle.Text, buttons, this.txbUser1.Text, this.txbUser2.Text,
                icon, iconFileName, defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked,
                this.txbHelpFile.Text, this.txbHelpTopic.Text, navigator, checkState, style, this.chbActivateAutoClose.Checked,
                autoClose, design, titleStyle, this.txbTitleIconFile.Text, opacity, order);

            this.txbCode.Text = generatedCode;
        }
示例#3
0
        /// <summary>
        /// Shows the box.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        private void ShowBox(InformationBoxBehavior behavior)
        {
            InformationBoxButtons buttons             = this.GetButtons();
            InformationBoxIcon    icon                = this.GetIcon();
            string iconFileName                       = this.txbIcon.Text;
            InformationBoxDefaultButton defaultButton = this.GetDefaultButton();
            InformationBoxButtonsLayout buttonsLayout = this.GetButtonsLayout();
            InformationBoxAutoSizeMode  autoSize      = this.GetAutoSize();
            InformationBoxPosition      position      = this.GetPosition();
            HelpNavigator                navigator    = this.GetHelpNavigator();
            InformationBoxCheckBox       checkState   = this.GetCheckBoxState();
            CheckState                   state        = 0;
            InformationBoxStyle          style        = this.GetStyle();
            AutoCloseParameters          autoClose    = this.GetAutoClose();
            DesignParameters             design       = this.GetDesign();
            InformationBoxTitleIconStyle titleStyle   = this.GetTitleStyle();
            InformationBoxOpacity        opacity      = this.GetOpacity();
            InformationBoxOrder          order        = this.GetOrder();
            InformationBoxSound          sound        = this.GetSound();

            InformationBoxTitleIcon titleIcon = null;

            if (titleStyle == InformationBoxTitleIconStyle.Custom)
            {
                titleIcon = new InformationBoxTitleIcon(this.txbTitleIconFile.Text);
            }

            if (String.IsNullOrEmpty(iconFileName))
            {
                InformationBox.Show(this.txbText.Text, out state, this.txbTitle.Text, buttons, new string[] { this.txbUser1.Text, this.txbUser2.Text, this.txbUser3.Text }, icon, defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked, this.txbHelpFile.Text, navigator, this.txbHelpTopic.Text, checkState, style, autoClose, design, titleStyle, titleIcon, behavior, new AsyncResultCallback(BoxClosed), opacity, order, sound);
            }
            else
            {
                InformationBox.Show(this.txbText.Text, out state, this.txbTitle.Text, buttons, new string[] { this.txbUser1.Text, this.txbUser2.Text, this.txbUser3.Text }, new Icon(iconFileName), defaultButton, buttonsLayout, autoSize, position, this.chbHelpButton.Checked, this.txbHelpFile.Text, navigator, this.txbHelpTopic.Text, checkState, style, autoClose, design, titleStyle, titleIcon, behavior, new AsyncResultCallback(BoxClosed), opacity, order, sound);
            }

            if (checkState != 0)
            {
                InformationBox.Show(
                    String.Format(CultureInfo.InvariantCulture, "The state of the checkbox was {0}", state),
                    InformationBoxIcon.Information);
            }
        }
示例#4
0
        /// <summary>
        /// Generates a single method call to display an InfoBox.
        /// </summary>
        /// <param name="behavior">The behavior.</param>
        /// <param name="text">The text.</param>
        /// <param name="title">The title.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="button1Text">The button1 text.</param>
        /// <param name="button2Text">The button2 text.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="iconFileName">Name of the icon file.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <param name="buttonsLayout">The buttons layout.</param>
        /// <param name="autoSize">The autosize parameters</param>
        /// <param name="position">The position.</param>
        /// <param name="showHelp">if set to <c>true</c> [show help].</param>
        /// <param name="helpFile">The help file.</param>
        /// <param name="helpTopic">The help topic.</param>
        /// <param name="navigator">The navigator.</param>
        /// <param name="checkState">The state of the checkbox.</param>
        /// <param name="style">The style.</param>
        /// <param name="useAutoClose">if set to <c>true</c> [use auto close].</param>
        /// <param name="autoClose">The auto-close parameters.</param>
        /// <param name="design">The design.</param>
        /// <param name="titleStyle">The title style.</param>
        /// <param name="titleIconFileName">Filename of the title icon .</param>
        /// <param name="opacity">The opacity.</param>
        /// <param name="order">The order.</param>
        /// <returns></returns>
        public string GenerateSingleCall(InformationBoxBehavior behavior, string text, string title, InformationBoxButtons buttons, string button1Text, string button2Text, InformationBoxIcon icon, string iconFileName, InformationBoxDefaultButton defaultButton, InformationBoxButtonsLayout buttonsLayout, InformationBoxAutoSizeMode autoSize, InformationBoxPosition position, bool showHelp, string helpFile, string helpTopic, System.Windows.Forms.HelpNavigator navigator, InformationBoxCheckBox checkState, InformationBoxStyle style, bool useAutoClose, AutoCloseParameters autoClose, DesignParameters design, InformationBoxTitleIconStyle titleStyle, string titleIconFileName, InformationBoxOpacity opacity, InformationBoxOrder order)
        {
            StringBuilder codeBuilder = new StringBuilder();

            if (checkState == 0)
            {
                codeBuilder.AppendFormat("InformationBox.Show(\"{0}\", ", text.Replace(Environment.NewLine, "\\n"));
            }
            else
            {
                codeBuilder.Append("Dim doNotShowState as CheckState = CheckState.Indeterminate");
                codeBuilder.Append(Environment.NewLine);
                codeBuilder.AppendFormat("InformationBox.Show(\"{0}\", doNotShowState, ", text.Replace(Environment.NewLine, "\\n"));
            }

            if (!String.IsNullOrEmpty(helpFile) || !String.IsNullOrEmpty(title))
            {
                codeBuilder.AppendFormat("\"{0}\", ", title);
            }

            if (buttons != InformationBoxButtons.OK)
            {
                codeBuilder.AppendFormat("InformationBoxButtons.{0}, ", buttons);
            }

            if (buttons == InformationBoxButtons.OKCancelUser1 ||
                buttons == InformationBoxButtons.User1User2 ||
                buttons == InformationBoxButtons.YesNoUser1)
            {
                codeBuilder.AppendFormat("New String() {{ \"{0}\", \"{1}\" }}, ", button1Text, button2Text);
            }

            if (icon != InformationBoxIcon.None)
            {
                codeBuilder.AppendFormat("InformationBoxIcon.{0}, ", icon);
            }

            if (!String.IsNullOrEmpty(iconFileName))
            {
                codeBuilder.AppendFormat("New System.Drawing.Icon(@\"{0}\"), ", iconFileName);
            }

            if (defaultButton != InformationBoxDefaultButton.Button1)
            {
                codeBuilder.AppendFormat("InformationBoxDefaultButton.{0}, ", defaultButton);
            }

            if (buttonsLayout != InformationBoxButtonsLayout.GroupMiddle)
            {
                codeBuilder.AppendFormat("InformationBoxButtonsLayout.{0}, ", buttonsLayout);
            }

            if (autoSize != InformationBoxAutoSizeMode.None)
            {
                codeBuilder.AppendFormat("InformationBoxAutoSizeMode.{0}, ", autoSize);
            }

            if (position != InformationBoxPosition.CenterOnParent)
            {
                codeBuilder.AppendFormat("InformationBoxPosition.{0}, ", position);
            }

            if (showHelp)
            {
                codeBuilder.Append("True, ");
            }

            if (!String.IsNullOrEmpty(helpFile))
            {
                codeBuilder.AppendFormat("\"{0}\", ", helpFile);
            }

            if (navigator != 0)
            {
                codeBuilder.AppendFormat("HelpNavigator.{0}, ", navigator);
            }

            if (!String.IsNullOrEmpty(helpTopic))
            {
                codeBuilder.AppendFormat("\"{0}\", ", helpTopic);
            }

            if (checkState != 0)
            {
                codeBuilder.Append("InformationBoxCheckBox.Show");
                if ((checkState & InformationBoxCheckBox.Checked) == InformationBoxCheckBox.Checked)
                {
                    codeBuilder.Append(" Or InformationBoxCheckBox.Checked");
                }

                if ((checkState & InformationBoxCheckBox.RightAligned) == InformationBoxCheckBox.RightAligned)
                {
                    codeBuilder.Append(" Or InformationBoxCheckBox.RightAligned");
                }

                codeBuilder.Append(", ");
            }

            if (style != InformationBoxStyle.Standard)
            {
                codeBuilder.AppendFormat("InformationBoxStyle.{0}, ", style);
            }

            if (order != InformationBoxOrder.Default)
            {
                codeBuilder.AppendFormat("InformationBoxOrder.{0}, ", order);
            }

            if (useAutoClose)
            {
                if (autoClose.Seconds == AutoCloseParameters.Default.Seconds &&
                    autoClose.DefaultButton == InformationBoxDefaultButton.Button1 &&
                    autoClose.Result == InformationBoxResult.None)
                {
                    codeBuilder.Append("AutoCloseParameters.Default, ");
                }
                else
                {
                    if (autoClose.Mode == AutoCloseDefinedParameters.Button)
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}, InformationBoxDefaultButton.{1}), ", autoClose.Seconds, autoClose.DefaultButton);
                    }
                    else if (autoClose.Mode == AutoCloseDefinedParameters.Result)
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}, InformationBoxResult.{1}), ", autoClose.Seconds, autoClose.Result);
                    }
                    else
                    {
                        codeBuilder.AppendFormat("New AutoCloseParameters({0}), ", autoClose.Seconds);
                    }
                }
            }

            if (null != design)
            {
                codeBuilder.AppendFormat(CultureInfo.InvariantCulture, "New DesignParameters(Color.FromArgb({0},{1},{2}), Color.FromArgb({3},{4},{5})), ", design.FormBackColor.R, design.FormBackColor.G, design.FormBackColor.B, design.BarsBackColor.R, design.BarsBackColor.G, design.BarsBackColor.B);
            }

            if (titleStyle == InformationBoxTitleIconStyle.Custom)
            {
                codeBuilder.AppendFormat(CultureInfo.InvariantCulture, "New InformationBoxTitleIcon(@\"{0}\"), ", titleIconFileName);
            }
            else if (titleStyle == InformationBoxTitleIconStyle.SameAsBox)
            {
                codeBuilder.Append("InformationBoxTitleIconStyle.SameAsBox, ");
            }

            if (behavior == InformationBoxBehavior.Modeless)
            {
                codeBuilder.Append("InformationBoxBehavior.Modeless, ");
            }

            if (opacity != InformationBoxOpacity.NoFade)
            {
                codeBuilder.AppendFormat("InformationBoxOpacity.{0}, ", opacity);
            }

            codeBuilder[codeBuilder.Length - 2] = ')';

            return(codeBuilder.ToString().Replace("\"\"", "String.Empty"));
        }