C# Class WixSharp.WixCLRDialog

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
ファイルを表示 Open project: Eun/WixSharp Class Usage Examples

Public Properties

Property Type Description
session Microsoft.Deployment.WindowsInstaller.Session

Protected Properties

Property Type Description
delta int
hostWindow System.IntPtr

Public Methods

Method Description
GetMSIBinaryStream ( string binaryId ) : Stream

Gets the embedded MSI binary stream.

InitializeComponent ( ) : void
MSIBack ( ) : void

Closes the dialog and sets the this.DialogResult to the 'DialogResult.Retry' value ensuring the setup is resumed with the previous UI sequence dialog is displayed.

MSICancel ( ) : void

Closes the dialog and sets the this.DialogResult to the 'DialogResult.Cancel' value ensuring the setup is cancelled.

MSINext ( ) : void

Closes the dialog and sets the this.DialogResult to the 'DialogResult.OK' value ensuring the setup is resumed and the UI sequence advanced to the next step.

ShowAsMsiDialog ( WixCLRDialog dialog ) : ActionResult

Shows as specified managed dialog.

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.

It also ensures that after the managed dialog is closed the proper ActionResult is returned.

WixCLRDialog ( ) : System

Initializes a new instance of the WixCLRDialog class. This constructor is to be used by the Visual Studio Form designer only. You should always use WixCLRDialog(Session session) constructor instead.

WixCLRDialog ( Microsoft.Deployment.WindowsInstaller.Session session ) : System

Initializes a new instance of the WixCLRDialog class.

WixDialog_Load ( object sender, EventArgs e ) : void

Protected Methods

Method Description
Init ( ) : void

Inits this instance.

ReplaceHost ( ) : void

'Replaces' the current step dialog with the "itself".

It uses WIN32 API to hide the parent native MSI dialog and place managed form dialog (itself) at the same desktop location and with the same size as the parent.

RestoreHost ( ) : void

Restores parent native MSI dialog after the previous ReplaceHost call.

Private Methods

Method Description
GetMsiForegroundWindow ( ) : IntPtr
WixPanel_FormClosed ( object sender, System.Windows.Forms.FormClosedEventArgs e ) : void
form_VisibleChanged ( object sender, EventArgs e ) : void

Method Details

GetMSIBinaryStream() public method

Gets the embedded MSI binary stream.
public GetMSIBinaryStream ( string binaryId ) : Stream
binaryId string The binary id.
return Stream

Init() protected method

Inits this instance.
protected Init ( ) : void
return void

InitializeComponent() public method

public InitializeComponent ( ) : void
return void

MSIBack() public method

Closes the dialog and sets the this.DialogResult to the 'DialogResult.Retry' value ensuring the setup is resumed with the previous UI sequence dialog is displayed.
public MSIBack ( ) : void
return void

MSICancel() public method

Closes the dialog and sets the this.DialogResult to the 'DialogResult.Cancel' value ensuring the setup is cancelled.
public MSICancel ( ) : void
return void

MSINext() public method

Closes the dialog and sets the this.DialogResult to the 'DialogResult.OK' value ensuring the setup is resumed and the UI sequence advanced to the next step.
public MSINext ( ) : void
return void

ReplaceHost() protected method

'Replaces' the current step dialog with the "itself".

It uses WIN32 API to hide the parent native MSI dialog and place managed form dialog (itself) at the same desktop location and with the same size as the parent.

protected ReplaceHost ( ) : void
return void

RestoreHost() protected method

Restores parent native MSI dialog after the previous ReplaceHost call.
protected RestoreHost ( ) : void
return void

ShowAsMsiDialog() public static method

Shows as specified managed dialog.

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.

It also ensures that after the managed dialog is closed the proper ActionResult is returned.

public static ShowAsMsiDialog ( WixCLRDialog dialog ) : ActionResult
dialog WixCLRDialog The dialog.
return ActionResult

WixCLRDialog() public method

Initializes a new instance of the WixCLRDialog class. This constructor is to be used by the Visual Studio Form designer only. You should always use WixCLRDialog(Session session) constructor instead.
public WixCLRDialog ( ) : System
return System

WixCLRDialog() public method

Initializes a new instance of the WixCLRDialog class.
public WixCLRDialog ( Microsoft.Deployment.WindowsInstaller.Session session ) : System
session Microsoft.Deployment.WindowsInstaller.Session The session.
return System

WixDialog_Load() public method

public WixDialog_Load ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void

Property Details

delta protected_oe property

There is some strange resizing artefact (at least on Win7) when MoveWindow does not resize the window accurately. Thus special adjustment ('delta') is needed to fix the problem.

The delta value is used in the ReplaceHost method.

protected int delta
return int

hostWindow protected_oe property

The WIN32 handle to the host window (parent MSI dialog).
protected IntPtr,System hostWindow
return System.IntPtr

session public_oe property

The MSI session
public Session,Microsoft.Deployment.WindowsInstaller session
return Microsoft.Deployment.WindowsInstaller.Session