Ejemplo n.º 1
0
    static public void Main()
    {
        //Support for building native MSI UI is an experimental feature and no longer supported.
        //It has been superseded by the "Managed UI" feature available in v1.0.22.0 and higher.

        Dialog productActivationDialog = new ProductActivationForm().ToWDialog();

        var project = new Project("CustomDialogTest",

                                  new Dir(@"%ProgramFiles%\My Company\My Product",
                                          new File(@"..\..\AppFiles\CommunityLicence.txt")
        {
            Condition = "LICENCING_MODEL = \"COMMUNITY\"".ToCondition()
        },
                                          new File(@"..\..\AppFiles\ProLicence.txt")
        {
            Condition = "LICENCING_MODEL = \"PRO\"".ToCondition()
        },
                                          new File(@"..\..\AppFiles\DemoLicence.txt")
        {
            Condition = "LICENCING_MODEL = \"DEMO\"".ToCondition()
        },
                                          new File(@"..\..\AppFiles\TrialLicence.txt")
        {
            Condition = "LICENCING_MODEL = \"TRIAL\"".ToCondition()
        }),

                                  new Property("SERIALNUMBER", "123-456-DEMO"),
                                  new Property("UseActivation", "1"),
                                  new Property("LICENCING_MODEL", "DEMO"),
                                  new Property("SERIALNUMBER_VALIDATED", "FALSE"),

                                  new ManagedAction("ValidateLicenceKey")
        {
            Id = "ValidateLicenceKey", Sequence = Sequence.NotInSequence
        },
                                  new ManagedAction("ClaimLicenceKey")
        {
            Id = "ClaimLicenceKey", Sequence = Sequence.NotInSequence
        });

        project.UI       = WUI.WixUI_Common;
        project.CustomUI = CustomUIBuilder.BuildPostLicenseDialogUI(customDialog: productActivationDialog,
                                                                    onNextActions: new DialogAction[]
        {
            new ExecuteCustomAction("ValidateLicenceKey"),
            new ShowDialog(NativeDialogs.InstallDirDlg, "SERIALNUMBER_VALIDATED = \"TRUE\"")
        });

        //In this sample we are using built-in BuildPostLicenseDialogUI but if it is not suitable for
        //you can define you own routine for building UI definition.
        //CustomUIHelper.cs is an example of such an alternative. In this case it does the same job
        //as built-in BuildPostLicenseDialogUI but you can modify it to suite your needs better.
        //
        //alternatively you can call CustoUIHelper with the local implementation of the CustomUI sequence
        //project.CustomUI = CustoUIHelper.BuildCustomUI();

        Compiler.PreserveTempFiles = true;
        Compiler.BuildMsi(project);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Builds the custom UI.
    /// This is the equivalent of the CustomUIBuilder.BuildPostLicenseDialogUI implementation
    /// </summary>
    /// <returns></returns>
    public static CustomUI BuildCustomUI()
    {
        Dialog activationDialog = new ProductActivationForm().ToWDialog();

        XElement xml = activationDialog.ToXElement();

        var customUI = new CustomUI();

        customUI.CustomDialogs.Add(activationDialog);

        customUI.On(NativeDialogs.ExitDialog, Buttons.Finish, new CloseDialog()
        {
            Order = 9999
        });

        customUI.On(NativeDialogs.WelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.LicenseAgreementDlg));

        customUI.On(NativeDialogs.LicenseAgreementDlg, Buttons.Back, new ShowDialog(NativeDialogs.WelcomeDlg));
        customUI.On(NativeDialogs.LicenseAgreementDlg, Buttons.Next, new ShowDialog(activationDialog, "LicenseAccepted = \"1\""));

        customUI.On(activationDialog, Buttons.Back, new ShowDialog(NativeDialogs.LicenseAgreementDlg));

        customUI.On(activationDialog, Buttons.Next, new DialogAction {
            Name = "DoAction", Value = "ValidateLicenceKey"
        },
                    new ShowDialog(NativeDialogs.InstallDirDlg, "SERIALNUMBER_VALIDATED = \"TRUE\""));

        customUI.On(activationDialog, Buttons.Cancel, new CloseDialog("Exit"));

        customUI.On(NativeDialogs.InstallDirDlg, Buttons.Back, new ShowDialog(activationDialog));
        customUI.On(NativeDialogs.InstallDirDlg, Buttons.Next, new SetTargetPath(),
                    new ShowDialog(NativeDialogs.VerifyReadyDlg));

        customUI.On(NativeDialogs.InstallDirDlg, Buttons.ChangeFolder,
                    new SetProperty("_BrowseProperty", "[WIXUI_INSTALLDIR]"),
                    new ShowDialog(CommonDialogs.BrowseDlg));

        customUI.On(NativeDialogs.VerifyReadyDlg, Buttons.Back, new ShowDialog(NativeDialogs.InstallDirDlg, Condition.NOT_Installed),
                    new ShowDialog(NativeDialogs.MaintenanceTypeDlg, Condition.Installed));

        customUI.On(NativeDialogs.MaintenanceWelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.MaintenanceTypeDlg));

        customUI.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Back, new ShowDialog(NativeDialogs.MaintenanceWelcomeDlg));
        customUI.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Repair, new ShowDialog(NativeDialogs.VerifyReadyDlg));
        customUI.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Remove, new ShowDialog(NativeDialogs.VerifyReadyDlg));

        return(customUI);
    }