Skip to content

Commit

Permalink
wix3: updated skip dialog example
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-shilo committed Oct 31, 2024
1 parent 8825bc8 commit ff1ad85
Showing 1 changed file with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ static public void Main()

//removing all entry dialogs and installdir
project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
// .Add(Dialogs.Licence) // decide if to show (or not) this dialog at runtime
// .Add(Dialogs.Features)
// .Add(Dialogs.SetupType)
// .Add(Dialogs.InstallDir)
.Add(Dialogs.Licence) // decide if to show (or not) this dialog at runtime
.Add(Dialogs.Features)
.Add(Dialogs.SetupType)
.Add(Dialogs.InstallDir)
.Add(Dialogs.Progress)
.Add(Dialogs.Exit);

Expand All @@ -81,10 +81,10 @@ static public void Main()
project.PreserveTempFiles = true;
project.SourceBaseDir = @"..\..\";

// Set the whole UI to French.
// Set the whole UI to French - example.
// Replace the text of "Next" button (exta_fr-fr.wxl).
project.Language = "fr-FR";
project.LocalizationFile = "exta_fr-fr.wxl";
// project.Language = "fr-FR";
// project.LocalizationFile = "exta_fr-fr.wxl";

project.BuildMsi();
}
Expand All @@ -100,30 +100,27 @@ static void Project_UILoaded(SetupEventArgs e)
var msiFile = e.Session.Database.FilePath;

// Simulate analyzing the runtime conditions with the message box.
// Make a decision to show (or not) Licence dialog by injecting it in the Dialogs collection
// if (MessageBox.Show("Do you want to inject 'Licence Dialog'?", "Wix#", MessageBoxButtons.YesNo) == DialogResult.Yes)
// e.ManagedUIShell.CurrentDialog.Shell.Dialogs.Insert(1, Dialogs.Licence);
// Make a decision to show (or not) Licence dialog.

// There are two options for skipping dialogs:
// - by modifying dialog sequence (next two commented lines)

// if (MessageBox.Show("Do you want to remove 'Licence Dialog'?", "Wix#", MessageBoxButtons.YesNo) == DialogResult.Yes)
// e.ManagedUI.CurrentDialog.Shell.Dialogs.Remove(Dialogs.Licence);

// - by handling OnCurrentDialogChanged event
e.ManagedUI.OnCurrentDialogChanged += ManagedUIShell_OnCurrentDialogChanged;
}

static Type LastDialog;

static void ManagedUIShell_OnCurrentDialogChanged(IManagedDialog obj)
{
var prevDialog = LastDialog;
LastDialog = obj.GetType();

if (obj.GetType() == Dialogs.Licence)
{
// Simulate analyzing the runtime conditions with the message box.
// Make a decision to jump over the dialog in the sequence
if (MessageBox.Show("Do you want to skip 'Licence Dialog'?", "Wix#", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (prevDialog == Dialogs.Welcome)
obj.Shell.GoNext();
else
obj.Shell.GoPrev();
obj.Shell.GoNext();
}
}
}
Expand Down

0 comments on commit ff1ad85

Please sign in to comment.