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(); }