|
3 | 3 | using System.Diagnostics; |
4 | 4 | using System.Globalization; |
5 | 5 | using System.IO; |
| 6 | +using System.Linq; |
| 7 | +using System.Management; |
6 | 8 | using System.Net; |
7 | 9 | using System.Text.RegularExpressions; |
| 10 | +using System.Threading; |
8 | 11 | using System.Threading.Tasks; |
9 | 12 | using System.Windows.Forms; |
10 | 13 | using static System.Net.WebRequestMethods; |
@@ -41,15 +44,16 @@ static class Program |
41 | 44 | public static float minimalVersionSupport = 11.0f; |
42 | 45 | public static float maximalVersionSupport = 17.0f; |
43 | 46 |
|
44 | | - private static readonly string DAISY_APP_URL = "https://github.com/daisy/pipeline-ui/releases/download/1.9.0/daisy-pipeline-setup-1.9.0.exe"; |
| 47 | + private static readonly string appVersion = "1.10.0"; |
| 48 | + private static readonly string DAISY_APP_URL = $"https://github.com/daisy/pipeline-ui/releases/download/{appVersion}/daisy-pipeline-setup-{appVersion}.exe"; |
45 | 49 |
|
46 | 50 | /// <summary> |
47 | 51 | /// The main entry point for the application. |
48 | 52 | /// </summary> |
49 | 53 | [STAThread] |
50 | 54 | static void Main() |
51 | 55 | { |
52 | | - |
| 56 | + |
53 | 57 | #if X64INSTALLER // only |
54 | 58 | bool installerIsForOffice32Bits = false; |
55 | 59 | #else // x86 only installer or unified installer default version installed |
@@ -164,17 +168,21 @@ static void Main() |
164 | 168 | var process = Process.Start(daisySetupPath); |
165 | 169 | process.WaitForExit(); |
166 | 170 | bool installApp = true; |
167 | | - // Offer to install the daisy pipeline app if not installed |
168 | | - RegistryKey softwareKeys = Registry.CurrentUser.OpenSubKey(@"Software"); |
169 | | - foreach (string subKey in softwareKeys.GetSubKeyNames()) { |
170 | | - RegistryKey software = softwareKeys.OpenSubKey(subKey); |
171 | | - if (software.GetValue("ShortcutName") != null && software.GetValue("ShortcutName").ToString() == "DAISY Pipeline") { |
| 171 | + // Check SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
| 172 | + RegistryKey lKeyApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); |
| 173 | + foreach (string subKey in lKeyApp.GetSubKeyNames()) { |
| 174 | + RegistryKey appKey = lKeyApp.OpenSubKey(subKey); |
| 175 | + string displayName = appKey.GetValue("DisplayName")?.ToString() ?? ""; |
| 176 | + string displayVersion = appKey.GetValue("DisplayVersion")?.ToString() ?? ""; |
| 177 | + if ( |
| 178 | + displayName.StartsWith("DAISY Pipeline") && displayVersion == appVersion |
| 179 | + ) { |
172 | 180 | installApp = false; |
173 | 181 | break; |
174 | 182 | } |
175 | 183 | } |
176 | 184 | if (installApp) { |
177 | | - if (MessageBox.Show("SaveAsDAISY can now use the DAISY Pipeline app as backend for the conversions.\r\n" + |
| 185 | + if (MessageBox.Show($"SaveAsDAISY can use the DAISY Pipeline app {appVersion} as backend for the conversions.\r\n" + |
178 | 186 | "Do you want to download and install the DAISY Pipeline app now?\r\n", "Download DAISY Pipeline app", MessageBoxButtons.YesNo, |
179 | 187 | MessageBoxIcon.Question |
180 | 188 | ) == DialogResult.Yes |
@@ -212,15 +220,20 @@ static void Main() |
212 | 220 | using (var client = new System.Net.WebClient()) { |
213 | 221 | ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; |
214 | 222 | client.DownloadFile(DAISY_APP_URL, installerPath); |
215 | | - progressDialog.Close(); |
216 | | - progressDialog = null; |
| 223 | + |
217 | 224 | } |
| 225 | + label.Text = "Installing DAISY Pipeline app..."; |
218 | 226 | ProcessStartInfo exec = new ProcessStartInfo() { |
219 | 227 | FileName = installerPath, |
220 | 228 | UseShellExecute = true, |
221 | 229 | Arguments = "/S" // silent install |
222 | 230 | }; |
223 | 231 | process = System.Diagnostics.Process.Start(exec); |
| 232 | + process.WaitForExit(); |
| 233 | + label.Text = "DAISY Pipeline app is installed"; |
| 234 | + Thread.Sleep(3000); |
| 235 | + progressDialog.Close(); |
| 236 | + progressDialog = null; |
224 | 237 |
|
225 | 238 | } |
226 | 239 | catch (Exception ex) { |
|
0 commit comments