diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-07-19 15:17:10 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-07-20 08:53:56 -0500 |
| commit | 913b6238417dceeb8440315e4669990756d17655 (patch) | |
| tree | a9e3552ea124d2025e30436afc8629f071c01ed4 /src/test/dtf/EmbeddedUI | |
| parent | 93bb820eff547f8de304f05249f572da861256fb (diff) | |
| download | wix-913b6238417dceeb8440315e4669990756d17655.tar.gz wix-913b6238417dceeb8440315e4669990756d17655.tar.bz2 wix-913b6238417dceeb8440315e4669990756d17655.zip | |
Add WixInternalUIBootstrapperApplication as a new built-in BA.
Implements 6835
Diffstat (limited to 'src/test/dtf/EmbeddedUI')
| -rw-r--r-- | src/test/dtf/EmbeddedUI/EmbeddedUI.config | 10 | ||||
| -rw-r--r-- | src/test/dtf/EmbeddedUI/EmbeddedUI.csproj | 24 | ||||
| -rw-r--r-- | src/test/dtf/EmbeddedUI/InstallProgressCounter.cs | 174 | ||||
| -rw-r--r-- | src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs | 141 | ||||
| -rw-r--r-- | src/test/dtf/EmbeddedUI/SetupWizard.xaml | 19 | ||||
| -rw-r--r-- | src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs | 154 |
6 files changed, 0 insertions, 522 deletions
diff --git a/src/test/dtf/EmbeddedUI/EmbeddedUI.config b/src/test/dtf/EmbeddedUI/EmbeddedUI.config deleted file mode 100644 index 700aff6f..00000000 --- a/src/test/dtf/EmbeddedUI/EmbeddedUI.config +++ /dev/null | |||
| @@ -1,10 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8" ?> | ||
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 3 | |||
| 4 | |||
| 5 | <configuration> | ||
| 6 | <startup useLegacyV2RuntimeActivationPolicy="true"> | ||
| 7 | <supportedRuntime version="v4.0" /> | ||
| 8 | <supportedRuntime version="v2.0.50727" /> | ||
| 9 | </startup> | ||
| 10 | </configuration> | ||
diff --git a/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj b/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj deleted file mode 100644 index a6339220..00000000 --- a/src/test/dtf/EmbeddedUI/EmbeddedUI.csproj +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 2 | <PropertyGroup> | ||
| 3 | <TargetFramework>net35</TargetFramework> | ||
| 4 | <Description>Sample managed embedded external UI</Description> | ||
| 5 | <UseWPF>true</UseWPF> | ||
| 6 | </PropertyGroup> | ||
| 7 | |||
| 8 | <ItemGroup> | ||
| 9 | <Content Include="EmbeddedUI.config" CopyToOutputDirectory="PreserveNewest" /> | ||
| 10 | </ItemGroup> | ||
| 11 | |||
| 12 | <ItemGroup> | ||
| 13 | <Reference Include="PresentationCore" /> | ||
| 14 | <Reference Include="PresentationFramework" /> | ||
| 15 | <Reference Include="System" /> | ||
| 16 | <Reference Include="System.Core" /> | ||
| 17 | <Reference Include="System.Xml" /> | ||
| 18 | <Reference Include="WindowsBase" /> | ||
| 19 | </ItemGroup> | ||
| 20 | |||
| 21 | <ItemGroup> | ||
| 22 | <PackageReference Include="WixToolset.Dtf.CustomAction" /> | ||
| 23 | </ItemGroup> | ||
| 24 | </Project> | ||
diff --git a/src/test/dtf/EmbeddedUI/InstallProgressCounter.cs b/src/test/dtf/EmbeddedUI/InstallProgressCounter.cs deleted file mode 100644 index 3d75081c..00000000 --- a/src/test/dtf/EmbeddedUI/InstallProgressCounter.cs +++ /dev/null | |||
| @@ -1,174 +0,0 @@ | |||
| 1 | namespace WixToolset.Samples.EmbeddedUI | ||
| 2 | { | ||
| 3 | using System; | ||
| 4 | using WixToolset.Dtf.WindowsInstaller; | ||
| 5 | |||
| 6 | /// <summary> | ||
| 7 | /// Tracks MSI progress messages and converts them to usable progress. | ||
| 8 | /// </summary> | ||
| 9 | public class InstallProgressCounter | ||
| 10 | { | ||
| 11 | private int total; | ||
| 12 | private int completed; | ||
| 13 | private int step; | ||
| 14 | private bool moveForward; | ||
| 15 | private bool enableActionData; | ||
| 16 | private int progressPhase; | ||
| 17 | private double scriptPhaseWeight; | ||
| 18 | |||
| 19 | public InstallProgressCounter() : this(0.3) | ||
| 20 | { | ||
| 21 | } | ||
| 22 | |||
| 23 | public InstallProgressCounter(double scriptPhaseWeight) | ||
| 24 | { | ||
| 25 | if (!(0 <= scriptPhaseWeight && scriptPhaseWeight <= 1)) | ||
| 26 | { | ||
| 27 | throw new ArgumentOutOfRangeException("scriptPhaseWeight"); | ||
| 28 | } | ||
| 29 | |||
| 30 | this.scriptPhaseWeight = scriptPhaseWeight; | ||
| 31 | } | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// Gets a number between 0 and 1 that indicates the overall installation progress. | ||
| 35 | /// </summary> | ||
| 36 | public double Progress { get; private set; } | ||
| 37 | |||
| 38 | public void ProcessMessage(InstallMessage messageType, Record messageRecord) | ||
| 39 | { | ||
| 40 | // This MSI progress-handling code was mostly borrowed from burn and translated from C++ to C#. | ||
| 41 | |||
| 42 | switch (messageType) | ||
| 43 | { | ||
| 44 | case InstallMessage.ActionStart: | ||
| 45 | if (this.enableActionData) | ||
| 46 | { | ||
| 47 | this.enableActionData = false; | ||
| 48 | } | ||
| 49 | break; | ||
| 50 | |||
| 51 | case InstallMessage.ActionData: | ||
| 52 | if (this.enableActionData) | ||
| 53 | { | ||
| 54 | if (this.moveForward) | ||
| 55 | { | ||
| 56 | this.completed += this.step; | ||
| 57 | } | ||
| 58 | else | ||
| 59 | { | ||
| 60 | this.completed -= this.step; | ||
| 61 | } | ||
| 62 | |||
| 63 | this.UpdateProgress(); | ||
| 64 | } | ||
| 65 | break; | ||
| 66 | |||
| 67 | case InstallMessage.Progress: | ||
| 68 | this.ProcessProgressMessage(messageRecord); | ||
| 69 | break; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | private void ProcessProgressMessage(Record progressRecord) | ||
| 74 | { | ||
| 75 | // This MSI progress-handling code was mostly borrowed from burn and translated from C++ to C#. | ||
| 76 | |||
| 77 | if (progressRecord == null || progressRecord.FieldCount == 0) | ||
| 78 | { | ||
| 79 | return; | ||
| 80 | } | ||
| 81 | |||
| 82 | int fieldCount = progressRecord.FieldCount; | ||
| 83 | int progressType = progressRecord.GetInteger(1); | ||
| 84 | string progressTypeString = String.Empty; | ||
| 85 | switch (progressType) | ||
| 86 | { | ||
| 87 | case 0: // Master progress reset | ||
| 88 | if (fieldCount < 4) | ||
| 89 | { | ||
| 90 | return; | ||
| 91 | } | ||
| 92 | |||
| 93 | this.progressPhase++; | ||
| 94 | |||
| 95 | this.total = progressRecord.GetInteger(2); | ||
| 96 | if (this.progressPhase == 1) | ||
| 97 | { | ||
| 98 | // HACK!!! this is a hack courtesy of the Windows Installer team. It seems the script planning phase | ||
| 99 | // is always off by "about 50". So we'll toss an extra 50 ticks on so that the standard progress | ||
| 100 | // doesn't go over 100%. If there are any custom actions, they may blow the total so we'll call this | ||
| 101 | // "close" and deal with the rest. | ||
| 102 | this.total += 50; | ||
| 103 | } | ||
| 104 | |||
| 105 | this.moveForward = (progressRecord.GetInteger(3) == 0); | ||
| 106 | this.completed = (this.moveForward ? 0 : this.total); // if forward start at 0, if backwards start at max | ||
| 107 | this.enableActionData = false; | ||
| 108 | |||
| 109 | this.UpdateProgress(); | ||
| 110 | break; | ||
| 111 | |||
| 112 | case 1: // Action info | ||
| 113 | if (fieldCount < 3) | ||
| 114 | { | ||
| 115 | return; | ||
| 116 | } | ||
| 117 | |||
| 118 | if (progressRecord.GetInteger(3) == 0) | ||
| 119 | { | ||
| 120 | this.enableActionData = false; | ||
| 121 | } | ||
| 122 | else | ||
| 123 | { | ||
| 124 | this.enableActionData = true; | ||
| 125 | this.step = progressRecord.GetInteger(2); | ||
| 126 | } | ||
| 127 | break; | ||
| 128 | |||
| 129 | case 2: // Progress report | ||
| 130 | if (fieldCount < 2 || this.total == 0 || this.progressPhase == 0) | ||
| 131 | { | ||
| 132 | return; | ||
| 133 | } | ||
| 134 | |||
| 135 | if (this.moveForward) | ||
| 136 | { | ||
| 137 | this.completed += progressRecord.GetInteger(2); | ||
| 138 | } | ||
| 139 | else | ||
| 140 | { | ||
| 141 | this.completed -= progressRecord.GetInteger(2); | ||
| 142 | } | ||
| 143 | |||
| 144 | this.UpdateProgress(); | ||
| 145 | break; | ||
| 146 | |||
| 147 | case 3: // Progress total addition | ||
| 148 | this.total += progressRecord.GetInteger(2); | ||
| 149 | break; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | private void UpdateProgress() | ||
| 154 | { | ||
| 155 | if (this.progressPhase < 1 || this.total == 0) | ||
| 156 | { | ||
| 157 | this.Progress = 0; | ||
| 158 | } | ||
| 159 | else if (this.progressPhase == 1) | ||
| 160 | { | ||
| 161 | this.Progress = this.scriptPhaseWeight * Math.Min(this.completed, this.total) / this.total; | ||
| 162 | } | ||
| 163 | else if (this.progressPhase == 2) | ||
| 164 | { | ||
| 165 | this.Progress = this.scriptPhaseWeight + | ||
| 166 | (1 - this.scriptPhaseWeight) * Math.Min(this.completed, this.total) / this.total; | ||
| 167 | } | ||
| 168 | else | ||
| 169 | { | ||
| 170 | this.Progress = 1; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | } | ||
| 174 | } | ||
diff --git a/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs b/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs deleted file mode 100644 index ae86dc97..00000000 --- a/src/test/dtf/EmbeddedUI/SampleEmbeddedUI.cs +++ /dev/null | |||
| @@ -1,141 +0,0 @@ | |||
| 1 | namespace WixToolset.Samples.EmbeddedUI | ||
| 2 | { | ||
| 3 | using System; | ||
| 4 | using System.Collections.Generic; | ||
| 5 | using System.Configuration; | ||
| 6 | using System.Threading; | ||
| 7 | using System.Windows; | ||
| 8 | using System.Windows.Threading; | ||
| 9 | using WixToolset.Dtf.WindowsInstaller; | ||
| 10 | using Application = System.Windows.Application; | ||
| 11 | |||
| 12 | public class SampleEmbeddedUI : IEmbeddedUI | ||
| 13 | { | ||
| 14 | private bool isMaintenance; | ||
| 15 | private Thread appThread; | ||
| 16 | private Application app; | ||
| 17 | private SetupWizard setupWizard; | ||
| 18 | private ManualResetEvent installStartEvent; | ||
| 19 | private ManualResetEvent installExitEvent; | ||
| 20 | |||
| 21 | /// <summary> | ||
| 22 | /// Initializes the embedded UI. | ||
| 23 | /// </summary> | ||
| 24 | /// <param name="session">Handle to the installer which can be used to get and set properties. | ||
| 25 | /// The handle is only valid for the duration of this method call.</param> | ||
| 26 | /// <param name="resourcePath">Path to the directory that contains all the files from the MsiEmbeddedUI table.</param> | ||
| 27 | /// <param name="internalUILevel">On entry, contains the current UI level for the installation. After this | ||
| 28 | /// method returns, the installer resets the UI level to the returned value of this parameter.</param> | ||
| 29 | /// <returns>True if the embedded UI was successfully initialized; false if the installation | ||
| 30 | /// should continue without the embedded UI.</returns> | ||
| 31 | /// <exception cref="InstallCanceledException">The installation was canceled by the user.</exception> | ||
| 32 | /// <exception cref="InstallerException">The embedded UI failed to initialize and | ||
| 33 | /// causes the installation to fail.</exception> | ||
| 34 | public bool Initialize(Session session, string resourcePath, ref InstallUIOptions internalUILevel) | ||
| 35 | { | ||
| 36 | if (session != null) | ||
| 37 | { | ||
| 38 | if ((internalUILevel & InstallUIOptions.Full) != InstallUIOptions.Full) | ||
| 39 | { | ||
| 40 | // Don't show custom UI when the UI level is set to basic. | ||
| 41 | return false; | ||
| 42 | |||
| 43 | // An embedded UI could display an alternate dialog sequence for reduced or | ||
| 44 | // basic modes, but it's not implemented here. We'll just fall back to the | ||
| 45 | // built-in MSI basic UI. | ||
| 46 | } | ||
| 47 | |||
| 48 | if (String.Equals(session["REMOVE"], "All", StringComparison.OrdinalIgnoreCase)) | ||
| 49 | { | ||
| 50 | // Don't show custom UI when uninstall was specified on the command line. | ||
| 51 | return false; | ||
| 52 | } | ||
| 53 | |||
| 54 | this.isMaintenance = session.EvaluateCondition("Installed"); | ||
| 55 | } | ||
| 56 | |||
| 57 | // Start the setup wizard on a separate thread. | ||
| 58 | this.installStartEvent = new ManualResetEvent(false); | ||
| 59 | this.installExitEvent = new ManualResetEvent(false); | ||
| 60 | this.appThread = new Thread(this.Run); | ||
| 61 | this.appThread.SetApartmentState(ApartmentState.STA); | ||
| 62 | this.appThread.Start(); | ||
| 63 | |||
| 64 | // Wait for the setup wizard to either kickoff the install or prematurely exit. | ||
| 65 | int waitResult = WaitHandle.WaitAny(new WaitHandle[] { this.installStartEvent, this.installExitEvent }); | ||
| 66 | if (waitResult == 1) | ||
| 67 | { | ||
| 68 | // The setup wizard set the exit event instead of the start event. Cancel the installation. | ||
| 69 | throw new InstallCanceledException(); | ||
| 70 | } | ||
| 71 | else | ||
| 72 | { | ||
| 73 | switch (this.setupWizard.Operation) | ||
| 74 | { | ||
| 75 | case SetupOperationType.Repair: | ||
| 76 | session["REINSTALL"] = "ALL"; | ||
| 77 | break; | ||
| 78 | case SetupOperationType.Uninstall: | ||
| 79 | session["REMOVE"] = "ALL"; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | |||
| 83 | // Start the installation with a silenced internal UI. | ||
| 84 | // This "embedded external UI" will handle message types except for source resolution. | ||
| 85 | internalUILevel = InstallUIOptions.NoChange | InstallUIOptions.SourceResolutionOnly; | ||
| 86 | return true; | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | /// <summary> | ||
| 91 | /// Processes information and progress messages sent to the user interface. | ||
| 92 | /// </summary> | ||
| 93 | /// <param name="messageType">Message type.</param> | ||
| 94 | /// <param name="messageRecord">Record that contains message data.</param> | ||
| 95 | /// <param name="buttons">Message box buttons.</param> | ||
| 96 | /// <param name="icon">Message box icon.</param> | ||
| 97 | /// <param name="defaultButton">Message box default button.</param> | ||
| 98 | /// <returns>Result of processing the message.</returns> | ||
| 99 | public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, | ||
| 100 | MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) | ||
| 101 | { | ||
| 102 | // Synchronously send the message to the setup wizard window on its thread. | ||
| 103 | object result = this.setupWizard.Dispatcher.Invoke(DispatcherPriority.Send, | ||
| 104 | new Func<MessageResult>(delegate() | ||
| 105 | { | ||
| 106 | return this.setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); | ||
| 107 | })); | ||
| 108 | return (MessageResult) result; | ||
| 109 | } | ||
| 110 | |||
| 111 | /// <summary> | ||
| 112 | /// Shuts down the embedded UI at the end of the installation. | ||
| 113 | /// </summary> | ||
| 114 | /// <remarks> | ||
| 115 | /// If the installation was canceled during initialization, this method will not be called. | ||
| 116 | /// If the installation was canceled or failed at any later point, this method will be called at the end. | ||
| 117 | /// </remarks> | ||
| 118 | public void Shutdown() | ||
| 119 | { | ||
| 120 | // Wait for the user to exit the setup wizard. | ||
| 121 | this.setupWizard.Dispatcher.BeginInvoke(DispatcherPriority.Normal, | ||
| 122 | new Action(delegate() | ||
| 123 | { | ||
| 124 | this.setupWizard.EnableExit(); | ||
| 125 | })); | ||
| 126 | this.appThread.Join(); | ||
| 127 | } | ||
| 128 | |||
| 129 | /// <summary> | ||
| 130 | /// Creates the setup wizard and runs the application thread. | ||
| 131 | /// </summary> | ||
| 132 | private void Run() | ||
| 133 | { | ||
| 134 | this.app = new Application(); | ||
| 135 | this.setupWizard = new SetupWizard(this.installStartEvent, this.isMaintenance); | ||
| 136 | this.setupWizard.InitializeComponent(); | ||
| 137 | this.app.Run(this.setupWizard); | ||
| 138 | this.installExitEvent.Set(); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } | ||
diff --git a/src/test/dtf/EmbeddedUI/SetupWizard.xaml b/src/test/dtf/EmbeddedUI/SetupWizard.xaml deleted file mode 100644 index 97e406c2..00000000 --- a/src/test/dtf/EmbeddedUI/SetupWizard.xaml +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | |||
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 3 | |||
| 4 | |||
| 5 | <Window x:Class="WixToolset.Samples.EmbeddedUI.SetupWizard" | ||
| 6 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| 7 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| 8 | Title="Sample Embedded UI" Height="400" Width="540" Visibility="Visible"> | ||
| 9 | <Grid> | ||
| 10 | <TextBox Margin="8,8,8,63" Name="messagesTextBox" IsReadOnly="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" FontFamily="Lucida Console" FontSize="10" /> | ||
| 11 | <Button Height="23" HorizontalAlignment="Left" Name="repairButton" VerticalAlignment="Bottom" Width="75" Visibility="Hidden" Click="repairButton_Click" Margin="8,0,0,8">Repair</Button> | ||
| 12 | <Button Height="23" HorizontalAlignment="Left" Name="uninstallButton" VerticalAlignment="Bottom" Width="75" Visibility="Hidden" Click="uninstallButton_Click" Margin="91,0,0,8">Uninstall</Button> | ||
| 13 | <Button Height="23" HorizontalAlignment="Right" Name="installButton" VerticalAlignment="Bottom" Width="75" Click="installButton_Click" Margin="0,0,91,8">Install</Button> | ||
| 14 | <Button Height="23" HorizontalAlignment="Right" Name="exitButton" VerticalAlignment="Bottom" Width="75" Visibility="Hidden" Click="exitButton_Click" Margin="0,0,8,8">Exit</Button> | ||
| 15 | <Button Height="23" Margin="0,0,8,8" Name="cancelButton" VerticalAlignment="Bottom" Width="75" HorizontalAlignment="Right" Click="cancelButton_Click">Cancel</Button> | ||
| 16 | <ProgressBar Height="16" Margin="8,0,8,39" Name="progressBar" VerticalAlignment="Bottom" Visibility="Hidden" IsIndeterminate="False" /> | ||
| 17 | <Label Height="28" HorizontalAlignment="Left" Margin="8,0,0,4.48" Name="progressLabel" VerticalAlignment="Bottom" Width="120" Visibility="Hidden">0%</Label> | ||
| 18 | </Grid> | ||
| 19 | </Window> | ||
diff --git a/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs b/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs deleted file mode 100644 index a4345481..00000000 --- a/src/test/dtf/EmbeddedUI/SetupWizard.xaml.cs +++ /dev/null | |||
| @@ -1,154 +0,0 @@ | |||
| 1 | namespace WixToolset.Samples.EmbeddedUI | ||
| 2 | { | ||
| 3 | using System; | ||
| 4 | using System.Collections.Generic; | ||
| 5 | using System.Linq; | ||
| 6 | using System.Text; | ||
| 7 | using System.Threading; | ||
| 8 | using System.Windows; | ||
| 9 | using System.Windows.Controls; | ||
| 10 | using System.Windows.Data; | ||
| 11 | using System.Windows.Documents; | ||
| 12 | using System.Windows.Input; | ||
| 13 | using System.Windows.Media; | ||
| 14 | using System.Windows.Media.Imaging; | ||
| 15 | using System.Windows.Navigation; | ||
| 16 | using System.Windows.Shapes; | ||
| 17 | using WixToolset.Dtf.WindowsInstaller; | ||
| 18 | |||
| 19 | public enum SetupOperationType | ||
| 20 | { | ||
| 21 | Install, | ||
| 22 | Repair, | ||
| 23 | Uninstall | ||
| 24 | } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Interaction logic for SetupWizard.xaml | ||
| 28 | /// </summary> | ||
| 29 | public partial class SetupWizard : Window | ||
| 30 | { | ||
| 31 | private bool isMaintenance; | ||
| 32 | private ManualResetEvent installStartEvent; | ||
| 33 | private InstallProgressCounter progressCounter; | ||
| 34 | private bool canceled; | ||
| 35 | |||
| 36 | public SetupOperationType Operation { get; private set; } | ||
| 37 | |||
| 38 | public SetupWizard(ManualResetEvent installStartEvent, bool isMaintenance) | ||
| 39 | { | ||
| 40 | this.installStartEvent = installStartEvent; | ||
| 41 | this.progressCounter = new InstallProgressCounter(0.5); | ||
| 42 | this.isMaintenance = isMaintenance; | ||
| 43 | |||
| 44 | this.Loaded += this.SetupWizard_Loaded; | ||
| 45 | } | ||
| 46 | |||
| 47 | private void SetupWizard_Loaded(object sender, RoutedEventArgs e) | ||
| 48 | { | ||
| 49 | this.Loaded -= this.SetupWizard_Loaded; | ||
| 50 | |||
| 51 | if (this.isMaintenance) | ||
| 52 | { | ||
| 53 | this.installButton.Visibility = Visibility.Hidden; | ||
| 54 | this.repairButton.Visibility = Visibility.Visible; | ||
| 55 | this.uninstallButton.Visibility = Visibility.Visible; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, | ||
| 60 | MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) | ||
| 61 | { | ||
| 62 | try | ||
| 63 | { | ||
| 64 | this.progressCounter.ProcessMessage(messageType, messageRecord); | ||
| 65 | this.progressBar.Value = this.progressBar.Minimum + | ||
| 66 | this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum); | ||
| 67 | this.progressLabel.Content = "" + (int) Math.Round(100 * this.progressCounter.Progress) + "%"; | ||
| 68 | |||
| 69 | switch (messageType) | ||
| 70 | { | ||
| 71 | case InstallMessage.Error: | ||
| 72 | case InstallMessage.Warning: | ||
| 73 | case InstallMessage.Info: | ||
| 74 | string message = String.Format("{0}: {1}", messageType, messageRecord); | ||
| 75 | this.LogMessage(message); | ||
| 76 | break; | ||
| 77 | } | ||
| 78 | |||
| 79 | if (this.canceled) | ||
| 80 | { | ||
| 81 | this.canceled = false; | ||
| 82 | return MessageResult.Cancel; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | catch (Exception ex) | ||
| 86 | { | ||
| 87 | this.LogMessage(ex.ToString()); | ||
| 88 | this.LogMessage(ex.StackTrace); | ||
| 89 | } | ||
| 90 | |||
| 91 | return MessageResult.OK; | ||
| 92 | } | ||
| 93 | |||
| 94 | private void LogMessage(string message) | ||
| 95 | { | ||
| 96 | this.messagesTextBox.Text += Environment.NewLine + message; | ||
| 97 | this.messagesTextBox.ScrollToEnd(); | ||
| 98 | } | ||
| 99 | |||
| 100 | internal void EnableExit() | ||
| 101 | { | ||
| 102 | this.progressBar.Visibility = Visibility.Hidden; | ||
| 103 | this.progressLabel.Visibility = Visibility.Hidden; | ||
| 104 | this.cancelButton.Visibility = Visibility.Hidden; | ||
| 105 | this.exitButton.Visibility = Visibility.Visible; | ||
| 106 | } | ||
| 107 | |||
| 108 | private void installButton_Click(object sender, RoutedEventArgs e) | ||
| 109 | { | ||
| 110 | this.Operation = SetupOperationType.Install; | ||
| 111 | this.StartInstall(); | ||
| 112 | } | ||
| 113 | |||
| 114 | private void repairButton_Click(object sender, RoutedEventArgs e) | ||
| 115 | { | ||
| 116 | this.Operation = SetupOperationType.Repair; | ||
| 117 | this.StartInstall(); | ||
| 118 | } | ||
| 119 | |||
| 120 | private void uninstallButton_Click(object sender, RoutedEventArgs e) | ||
| 121 | { | ||
| 122 | this.Operation = SetupOperationType.Uninstall; | ||
| 123 | this.StartInstall(); | ||
| 124 | } | ||
| 125 | |||
| 126 | private void StartInstall() | ||
| 127 | { | ||
| 128 | this.installButton.Visibility = Visibility.Hidden; | ||
| 129 | this.repairButton.Visibility = Visibility.Hidden; | ||
| 130 | this.uninstallButton.Visibility = Visibility.Hidden; | ||
| 131 | this.progressBar.Visibility = Visibility.Visible; | ||
| 132 | this.progressLabel.Visibility = Visibility.Visible; | ||
| 133 | this.installStartEvent.Set(); | ||
| 134 | } | ||
| 135 | |||
| 136 | private void exitButton_Click(object sender, RoutedEventArgs e) | ||
| 137 | { | ||
| 138 | this.Close(); | ||
| 139 | } | ||
| 140 | |||
| 141 | private void cancelButton_Click(object sender, RoutedEventArgs e) | ||
| 142 | { | ||
| 143 | if (this.installButton.Visibility == Visibility.Visible) | ||
| 144 | { | ||
| 145 | this.Close(); | ||
| 146 | } | ||
| 147 | else | ||
| 148 | { | ||
| 149 | this.canceled = true; | ||
| 150 | this.cancelButton.IsEnabled = false; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | } | ||
| 154 | } | ||
