From 93bb820eff547f8de304f05249f572da861256fb Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 19 Jul 2022 15:15:31 -0500 Subject: Improve DTF samples. --- src/test/dtf/EmbeddedUI/AssemblyInfo.cs | 3 -- src/test/dtf/EmbeddedUI/EmbeddedUI.config | 10 ++++++ src/test/dtf/EmbeddedUI/EmbeddedUI.csproj | 43 ++++++-------------------- src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs | 19 +++++++++--- src/test/dtf/EmbeddedUI/SetupWizard.xaml | 2 ++ src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs | 47 ++++++++++++++++++++++++++++- src/test/dtf/SampleCA/CustomAction.config | 10 ++++++ src/test/dtf/SampleCA/SampleCA.csproj | 8 ++++- src/test/dtf/SampleCA/testsub/testfile.txt | 1 + 9 files changed, 100 insertions(+), 43 deletions(-) delete mode 100644 src/test/dtf/EmbeddedUI/AssemblyInfo.cs create mode 100644 src/test/dtf/EmbeddedUI/EmbeddedUI.config create mode 100644 src/test/dtf/SampleCA/CustomAction.config create mode 100644 src/test/dtf/SampleCA/testsub/testfile.txt (limited to 'src/test') diff --git a/src/test/dtf/EmbeddedUI/AssemblyInfo.cs b/src/test/dtf/EmbeddedUI/AssemblyInfo.cs deleted file mode 100644 index 27aeb535..00000000 --- a/src/test/dtf/EmbeddedUI/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyDescription("Sample managed embedded external UI")] diff --git a/src/test/dtf/EmbeddedUI/EmbeddedUI.config b/src/test/dtf/EmbeddedUI/EmbeddedUI.config new file mode 100644 index 00000000..700aff6f --- /dev/null +++ b/src/test/dtf/EmbeddedUI/EmbeddedUI.config @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj b/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj index 9f745a19..a6339220 100644 --- a/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj +++ b/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj @@ -1,49 +1,24 @@ - + - {864B8C50-7895-4485-AC89-900D86FD8C0D} - Library - WixToolset.Samples.EmbeddedUI - WixToolset.Samples.EmbeddedUI - v3.5 - 512 + net35 + Sample managed embedded external UI + true - - - - - SetupWizard.xaml - + - - MSBuild:Compile - Designer - - - - - - 3.0 - - - 3.0 - + + - - 3.5 - + - - 3.0 - + - - diff --git a/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs b/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs index b9cd213a..ae86dc97 100644 --- a/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs +++ b/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs @@ -11,6 +11,7 @@ namespace WixToolset.Samples.EmbeddedUI public class SampleEmbeddedUI : IEmbeddedUI { + private bool isMaintenance; private Thread appThread; private Application app; private SetupWizard setupWizard; @@ -46,11 +47,11 @@ namespace WixToolset.Samples.EmbeddedUI if (String.Equals(session["REMOVE"], "All", StringComparison.OrdinalIgnoreCase)) { - // Don't show custom UI when uninstalling. + // Don't show custom UI when uninstall was specified on the command line. return false; - - // An embedded UI could display an uninstall wizard, it's just not imlemented here. } + + this.isMaintenance = session.EvaluateCondition("Installed"); } // Start the setup wizard on a separate thread. @@ -69,6 +70,16 @@ namespace WixToolset.Samples.EmbeddedUI } else { + switch (this.setupWizard.Operation) + { + case SetupOperationType.Repair: + session["REINSTALL"] = "ALL"; + break; + case SetupOperationType.Uninstall: + session["REMOVE"] = "ALL"; + break; + } + // Start the installation with a silenced internal UI. // This "embedded external UI" will handle message types except for source resolution. internalUILevel = InstallUIOptions.NoChange | InstallUIOptions.SourceResolutionOnly; @@ -121,7 +132,7 @@ namespace WixToolset.Samples.EmbeddedUI private void Run() { this.app = new Application(); - this.setupWizard = new SetupWizard(this.installStartEvent); + this.setupWizard = new SetupWizard(this.installStartEvent, this.isMaintenance); this.setupWizard.InitializeComponent(); this.app.Run(this.setupWizard); this.installExitEvent.Set(); diff --git a/src/test/dtf/EmbeddedUI/SetupWizard.xaml b/src/test/dtf/EmbeddedUI/SetupWizard.xaml index 9fd493a7..97e406c2 100644 --- a/src/test/dtf/EmbeddedUI/SetupWizard.xaml +++ b/src/test/dtf/EmbeddedUI/SetupWizard.xaml @@ -8,6 +8,8 @@ Title="Sample Embedded UI" Height="400" Width="540" Visibility="Visible"> + + diff --git a/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs b/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs index b846d61f..a4345481 100644 --- a/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs +++ b/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs @@ -16,19 +16,44 @@ namespace WixToolset.Samples.EmbeddedUI using System.Windows.Shapes; using WixToolset.Dtf.WindowsInstaller; + public enum SetupOperationType + { + Install, + Repair, + Uninstall + } + /// /// Interaction logic for SetupWizard.xaml /// public partial class SetupWizard : Window { + private bool isMaintenance; private ManualResetEvent installStartEvent; private InstallProgressCounter progressCounter; private bool canceled; - public SetupWizard(ManualResetEvent installStartEvent) + public SetupOperationType Operation { get; private set; } + + public SetupWizard(ManualResetEvent installStartEvent, bool isMaintenance) { this.installStartEvent = installStartEvent; this.progressCounter = new InstallProgressCounter(0.5); + this.isMaintenance = isMaintenance; + + this.Loaded += this.SetupWizard_Loaded; + } + + private void SetupWizard_Loaded(object sender, RoutedEventArgs e) + { + this.Loaded -= this.SetupWizard_Loaded; + + if (this.isMaintenance) + { + this.installButton.Visibility = Visibility.Hidden; + this.repairButton.Visibility = Visibility.Visible; + this.uninstallButton.Visibility = Visibility.Visible; + } } public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, @@ -81,8 +106,28 @@ namespace WixToolset.Samples.EmbeddedUI } private void installButton_Click(object sender, RoutedEventArgs e) + { + this.Operation = SetupOperationType.Install; + this.StartInstall(); + } + + private void repairButton_Click(object sender, RoutedEventArgs e) + { + this.Operation = SetupOperationType.Repair; + this.StartInstall(); + } + + private void uninstallButton_Click(object sender, RoutedEventArgs e) + { + this.Operation = SetupOperationType.Uninstall; + this.StartInstall(); + } + + private void StartInstall() { this.installButton.Visibility = Visibility.Hidden; + this.repairButton.Visibility = Visibility.Hidden; + this.uninstallButton.Visibility = Visibility.Hidden; this.progressBar.Visibility = Visibility.Visible; this.progressLabel.Visibility = Visibility.Visible; this.installStartEvent.Set(); diff --git a/src/test/dtf/SampleCA/CustomAction.config b/src/test/dtf/SampleCA/CustomAction.config new file mode 100644 index 00000000..700aff6f --- /dev/null +++ b/src/test/dtf/SampleCA/CustomAction.config @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/test/dtf/SampleCA/SampleCA.csproj b/src/test/dtf/SampleCA/SampleCA.csproj index fb6d8dca..866b7575 100644 --- a/src/test/dtf/SampleCA/SampleCA.csproj +++ b/src/test/dtf/SampleCA/SampleCA.csproj @@ -1,9 +1,15 @@ - net472 + net20 Sample managed custom actions + + + + + + diff --git a/src/test/dtf/SampleCA/testsub/testfile.txt b/src/test/dtf/SampleCA/testsub/testfile.txt new file mode 100644 index 00000000..8056aefd --- /dev/null +++ b/src/test/dtf/SampleCA/testsub/testfile.txt @@ -0,0 +1 @@ +test file for testing subdirectory support and binary stream reading -- cgit v1.2.3-55-g6feb