Defines System.Windows.Forms.T:System.Windows.Forms.Form, which is to be used as the for custom MSI dialog.

As opposite to the WixSharp.T:WixSharp.WixForm based custom dialogs WixCLRDialog is instantiated not at compile but at run time. Thus it is possible to implement comprehensive deployment algorithms in any of the available Form event handlers.

The usual usability scenario is the injection of the managed Custom Action (for displaying the WixCLRDialog) into the sequence of the standard dialogs (WixSharp.T:WixSharp.CustomUI).

While it is possible to construct T:WixSharp.CustomUI instance manually it is preferred to use Factory methods of T:WixSharp.CustomUIBuilder (e.g. InjectPostLicenseClrDialog) for this.

static public void Main() { ManagedAction showDialog; var project = new Project("CustomDialogTest", showDialog = new ShowClrDialogAction("ShowProductActivationDialog")); project.UI = WUI.WixUI_Common; project.CustomUI = CustomUIBuilder.InjectPostLicenseClrDialog(showDialog.Id, " LicenseAccepted = \"1\""); Compiler.BuildMsi(project); } ... public class CustomActions { [CustomAction] public static ActionResult ShowProductActivationDialog(Session session) { return WixCLRDialog.ShowAsMsiDialog(new CustomDialog(session)); } } ... public partial class CustomDialog : WixCLRDialog { private GroupBox groupBox1; private Button cancelBtn; ...

The all communications with the installation in progress are to be done by modifying the MSI properties or executing MSI actions via Session object.

When closing the dialog make sure you set the DeialogResul properly. WixCLRDialog offers three predefined routines for setting the DialogResult:

- MSINext

- MSIBack

- MSICancel

By invoking these routines from the corresponding event handlers you can control your MSI UI sequence: void cancelBtn_Click(object sender, EventArgs e) { MSICancel(); } void nextBtn_Click(object sender, EventArgs e) { MSINext(); } void backBtn_Click(object sender, EventArgs e) { MSIBack(); }

Inheritance: System.Windows.Forms.Form
Beispiel #1
0
        /// <summary>
        /// Shows as specified managed dialog.
        /// <para>It uses WIN32 API to hide the parent native MSI dialog and place managed form dialog
        /// at the same desktop location and with the same size as the parent.</para>
        /// <para>It also ensures that after the managed dialog is closed the proper ActionResult is returned.</para>
        /// </summary>
        /// <param name="dialog">The dialog.</param>
        /// <returns>ActionResult value</returns>
        public static ActionResult ShowAsMsiDialog(WixCLRDialog dialog)
        {
            ActionResult retval = ActionResult.Success;

            try
            {
                using (dialog)
                {
                    DialogResult result = dialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        dialog.session["Custom_UI_Command"] = "next";
                        retval = ActionResult.Success;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        dialog.session["Custom_UI_Command"] = "abort";
                        retval = ActionResult.UserExit;
                    }
                    if (result == DialogResult.Retry)
                    {
                        dialog.session["Custom_UI_Command"] = "back";
                        retval = ActionResult.Success;
                    }
                }
            }
            catch (Exception e)
            {
                dialog.session.Log("Error: " + e.ToString());
                retval = ActionResult.Failure;
            }

#if DEBUG
            //System.Diagnostics.Debugger.Launch();
#endif

            return(retval);
        }
Beispiel #2
0
        /// <summary>
        /// Shows as specified managed dialog.
        /// <para>It uses WIN32 API to hide the parent native MSI dialog and place managed form dialog
        /// at the same desktop location and with the same size as the parent.</para>
        /// <para>It also ensures that after the managed dialog is closed the proper ActionResult is returned.</para>
        /// </summary>
        /// <param name="dialog">The dialog.</param>
        /// <returns>ActionResult value</returns>
        public static ActionResult ShowAsMsiDialog(WixCLRDialog dialog)
        {
            ActionResult retval = ActionResult.Success;

            try
            {
                using (dialog)
                {
                    DialogResult result = dialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        dialog.session["Custom_UI_Command"] = "next";
                        retval = ActionResult.Success;
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        dialog.session["Custom_UI_Command"] = "abort";
                        retval = ActionResult.UserExit;
                    }
                    if (result == DialogResult.Retry)
                    {
                        dialog.session["Custom_UI_Command"] = "back";
                        retval = ActionResult.Success;
                    }
                }
            }
            catch (Exception e)
            {
                dialog.session.Log("Error: " + e.ToString());
                retval = ActionResult.Failure;
            }

            #if DEBUG

            //System.Diagnostics.Debugger.Launch();
            #endif

            return retval;
        }