From bfb855081c250eccbceeb571d1678fcbaeb63309 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Fri, 18 Dec 2015 18:00:52 +0200 Subject: [PATCH] Added a restart Discord checkbox --- WindowsInstaller/BetterDiscordWI/FormMain.cs | 1 + .../BetterDiscordWI/panels/Panel1.Designer.cs | 14 +++++++++++- .../BetterDiscordWI/panels/Panel1.cs | 22 ++++++++----------- .../BetterDiscordWI/panels/Panel2.cs | 5 +++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/WindowsInstaller/BetterDiscordWI/FormMain.cs b/WindowsInstaller/BetterDiscordWI/FormMain.cs index afbd606..a56c51a 100644 --- a/WindowsInstaller/BetterDiscordWI/FormMain.cs +++ b/WindowsInstaller/BetterDiscordWI/FormMain.cs @@ -13,6 +13,7 @@ namespace BetterDiscordWI private int _index; public String DiscordPath; + public Boolean RestartDiscord = false; public String Sha; public Boolean finished = false; diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs index acd82f4..8eb80b1 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel1.Designer.cs @@ -33,6 +33,7 @@ this.label2 = new System.Windows.Forms.Label(); this.tbPath = new BetterDiscordWI.components.CTextBox(); this.label3 = new System.Windows.Forms.Label(); + this.cbRestart = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label1 @@ -73,7 +74,6 @@ this.tbPath.Name = "tbPath"; this.tbPath.Size = new System.Drawing.Size(377, 26); this.tbPath.TabIndex = 4; - this.tbPath.Text = "feawfewafewa"; // // label3 // @@ -84,10 +84,21 @@ this.label3.TabIndex = 5; this.label3.Text = "*Installer will kill Discord process."; // + // cbRestart + // + this.cbRestart.AutoSize = true; + this.cbRestart.Location = new System.Drawing.Point(23, 117); + this.cbRestart.Name = "cbRestart"; + this.cbRestart.Size = new System.Drawing.Size(175, 17); + this.cbRestart.TabIndex = 6; + this.cbRestart.Text = "Restart Discord after installation"; + this.cbRestart.UseVisualStyleBackColor = true; + // // Panel1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbRestart); this.Controls.Add(this.label3); this.Controls.Add(this.tbPath); this.Controls.Add(this.label2); @@ -107,5 +118,6 @@ private System.Windows.Forms.Label label2; private components.CTextBox tbPath; private System.Windows.Forms.Label label3; + private System.Windows.Forms.CheckBox cbRestart; } } diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs index d81aed7..90cdefe 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs @@ -28,21 +28,16 @@ namespace BetterDiscordWI.panels foreach(String s in directories) { Debug.Print(s); - if (s.Contains("app-")) + if (!s.Contains("app-")) continue; + if (highestVersion == null) { - - - if (highestVersion == null) - { - highestVersion = s; - continue; - } - - if (String.CompareOrdinal(s, highestVersion) > 0) - { - highestVersion = s; - } + highestVersion = s; + continue; + } + if (String.CompareOrdinal(s, highestVersion) > 0) + { + highestVersion = s; } } @@ -57,6 +52,7 @@ namespace BetterDiscordWI.panels public void BtnNext() { GetParent().DiscordPath = tbPath.Text; + GetParent().RestartDiscord = cbRestart.Checked; GetParent().SwitchPanel(2); } diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs index f244ce1..ca4aa92 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs @@ -239,6 +239,11 @@ namespace BetterDiscordWI.panels GetParent().btnCancel.Text = "OK"; GetParent().btnCancel.Enabled = true; }); + + if (GetParent().RestartDiscord) + { + Process.Start(GetParent().DiscordPath + "\\Discord.exe"); + } } public FormMain GetParent()