diff --git a/BandagedBD/FormMain.Designer.cs b/BandagedBD/FormMain.Designer.cs index 16c9ac9..bea8933 100644 --- a/BandagedBD/FormMain.Designer.cs +++ b/BandagedBD/FormMain.Designer.cs @@ -62,7 +62,7 @@ namespace BandagedBD { this.lblTitle.ForeColor = System.Drawing.Color.White; this.lblTitle.Location = new System.Drawing.Point(82, 37); this.lblTitle.Name = "lblTitle"; - this.lblTitle.Size = new System.Drawing.Size(153, 18); + this.lblTitle.Size = new System.Drawing.Size(145, 16); this.lblTitle.TabIndex = 5; this.lblTitle.Text = "BandagedBD Setup"; // @@ -88,7 +88,7 @@ namespace BandagedBD { this.linkLabel1.LinkColor = global::BandagedBD.Properties.Settings.Default.Accent; this.linkLabel1.Location = new System.Drawing.Point(172, 471); this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(120, 16); + this.linkLabel1.Size = new System.Drawing.Size(95, 13); this.linkLabel1.TabIndex = 34; this.linkLabel1.TabStop = true; this.linkLabel1.Text = "Consider donating."; @@ -103,7 +103,7 @@ namespace BandagedBD { this.label1.ForeColor = global::BandagedBD.Properties.Settings.Default.TextColor; this.label1.Location = new System.Drawing.Point(13, 471); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(153, 16); + this.label1.Size = new System.Drawing.Size(120, 13); this.label1.TabIndex = 33; this.label1.Text = "Enjoying BandagedBD?"; // @@ -175,6 +175,7 @@ namespace BandagedBD { this.Name = "FormMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "BandagedBD Installer v0.3.2"; + this.Load += new System.EventHandler(this.FormMain_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/BandagedBD/FormMain.cs b/BandagedBD/FormMain.cs index de2690f..5f0ba86 100644 --- a/BandagedBD/FormMain.cs +++ b/BandagedBD/FormMain.cs @@ -1,8 +1,9 @@ using BandagedBD.Panels; using System; +using System.Net; using System.Collections.Generic; -using System.Drawing; using System.Windows.Forms; +using System.Threading.Tasks; namespace BandagedBD { @@ -13,6 +14,9 @@ namespace BandagedBD { private PanelTypes CurrentPanel = PanelTypes.NONE; public PanelTypes Action = PanelTypes.NONE; + private string currentTag = "v" + Properties.Resources.Version; + private string remoteTag = "v"; + private Dictionary panelMap = new Dictionary(); @@ -37,6 +41,10 @@ namespace BandagedBD { if (!Properties.Settings.Default.AgreedToTerms) SwitchPanel(PanelTypes.License); else SwitchPanel(PanelTypes.Action); + + Task.Run(checkForUpdate).ContinueWith(result => { + if (result.Result) showUpdateNotice(); + }); } public void SetTitle(string title) => lblTitle.Text = title; @@ -97,5 +105,52 @@ namespace BandagedBD { private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Utilities.OpenProcess("https://paypal.me/ZackRauen"); } + + private async Task checkForUpdate() + { + string endpoint = "https://api.github.com/repos/rauenzi/BBDInstaller/releases/latest"; + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; + + string tagNameKey = "\"tag_name\":"; + using (var wc = new TimedWebClient()) + { + + try + { + wc.Headers.Set("User-Agent", "BBDInstaller"); + string json = wc.DownloadString(endpoint); + int tagNameIndex = json.IndexOf(tagNameKey); + int versionStart = tagNameIndex + tagNameKey.Length + 1; + int versionEnd = json.IndexOf("\"", versionStart); + remoteTag = json.Substring(versionStart, versionEnd - versionStart); + return string.CompareOrdinal(remoteTag, currentTag) > 0; + } + catch + { + return false; + } + + } + } + + private void showUpdateNotice() + { + DialogResult confirmResult = MessageBox.Show($"There is a newer version of the installer available ({remoteTag}). Would you like to download it now?", "Update Available!", MessageBoxButtons.YesNo); + if (confirmResult == DialogResult.Yes) + { + Utilities.OpenProcess($"https://github.com/rauenzi/BBDInstaller/releases/download/{remoteTag}/BandagedBD.exe"); + Application.Exit(); + } + else + { + Application.Exit(); + } + } + + private void FormMain_Load(object sender, EventArgs e) + { + + } } } diff --git a/BandagedBD/Panels/InstallConfigPanel.Designer.cs b/BandagedBD/Panels/InstallConfigPanel.Designer.cs index bd62d05..7b65fd0 100644 --- a/BandagedBD/Panels/InstallConfigPanel.Designer.cs +++ b/BandagedBD/Panels/InstallConfigPanel.Designer.cs @@ -44,7 +44,7 @@ this.cbShouldRestart.Cursor = System.Windows.Forms.Cursors.Hand; this.cbShouldRestart.FlatAppearance.CheckedBackColor = System.Drawing.Color.Transparent; this.cbShouldRestart.ForeColor = global::BandagedBD.Properties.Settings.Default.TextColor; - this.cbShouldRestart.Location = new System.Drawing.Point(9, 212); + this.cbShouldRestart.Location = new System.Drawing.Point(10, 212); this.cbShouldRestart.Name = "cbShouldRestart"; this.cbShouldRestart.Size = new System.Drawing.Size(162, 17); this.cbShouldRestart.TabIndex = 5; @@ -53,7 +53,9 @@ // // discordLocator // - this.discordLocator.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.discordLocator.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.discordLocator.BackColor = System.Drawing.Color.Transparent; this.discordLocator.Location = new System.Drawing.Point(0, 3); this.discordLocator.Name = "discordLocator"; @@ -65,7 +67,7 @@ this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top; this.label1.AutoSize = true; this.label1.ForeColor = global::BandagedBD.Properties.Settings.Default.TextColor; - this.label1.Location = new System.Drawing.Point(6, 186); + this.label1.Location = new System.Drawing.Point(7, 186); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(95, 13); this.label1.TabIndex = 8; @@ -75,12 +77,14 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(this.label1); this.Controls.Add(this.cbShouldRestart); this.Controls.Add(this.discordLocator); this.Name = "InstallConfigPanel"; - this.Size = new System.Drawing.Size(662, 284); + this.Size = new System.Drawing.Size(665, 284); this.Load += new System.EventHandler(this.InstallConfigPanel_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/BandagedBD/Panels/InstallPanel.cs b/BandagedBD/Panels/InstallPanel.cs index 1007d9f..fad8de1 100644 --- a/BandagedBD/Panels/InstallPanel.cs +++ b/BandagedBD/Panels/InstallPanel.cs @@ -19,7 +19,6 @@ namespace BandagedBD.Panels { private InstallConfigPanel config => (InstallConfigPanel) Window.GetPanel(PanelTypes.InstallConfig); - private WebHeaderCollection Headers = new WebHeaderCollection { ["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11" }; private readonly SynchronizationContext _synchronizationContext; private int progressChunk => 100 / config.paths.Length; private int iteration = 0; @@ -76,7 +75,7 @@ namespace BandagedBD.Panels { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; - using (var wc = new TimedWebClient { Headers = this.Headers }) { + using (var wc = new TimedWebClient()) { wc.DownloadProgressChanged += (sender, args) => { setProgress(args.ProgressPercentage / 2); }; diff --git a/BandagedBD/Panels/RepairConfigPanel.Designer.cs b/BandagedBD/Panels/RepairConfigPanel.Designer.cs index cb32d9f..d92b80e 100644 --- a/BandagedBD/Panels/RepairConfigPanel.Designer.cs +++ b/BandagedBD/Panels/RepairConfigPanel.Designer.cs @@ -114,7 +114,9 @@ // // discordLocator // - this.discordLocator.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.discordLocator.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.discordLocator.BackColor = System.Drawing.Color.Transparent; this.discordLocator.Location = new System.Drawing.Point(0, 2); this.discordLocator.Name = "discordLocator"; @@ -129,7 +131,7 @@ this.label1.ForeColor = global::BandagedBD.Properties.Settings.Default.TextColor; this.label1.Location = new System.Drawing.Point(141, 307); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(181, 16); + this.label1.Size = new System.Drawing.Size(144, 13); this.label1.TabIndex = 31; this.label1.Text = "Can\'t find your problem here?"; // @@ -144,7 +146,7 @@ this.linkLabel1.LinkColor = global::BandagedBD.Properties.Settings.Default.Accent; this.linkLabel1.Location = new System.Drawing.Point(328, 307); this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(143, 16); + this.linkLabel1.Size = new System.Drawing.Size(114, 13); this.linkLabel1.TabIndex = 32; this.linkLabel1.TabStop = true; this.linkLabel1.Text = "Try this troubleshooter."; diff --git a/BandagedBD/Panels/UninstallConfigPanel.Designer.cs b/BandagedBD/Panels/UninstallConfigPanel.Designer.cs index 1912f50..1805aa8 100644 --- a/BandagedBD/Panels/UninstallConfigPanel.Designer.cs +++ b/BandagedBD/Panels/UninstallConfigPanel.Designer.cs @@ -81,7 +81,9 @@ // // discordLocator // - this.discordLocator.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.discordLocator.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.discordLocator.BackColor = System.Drawing.Color.Transparent; this.discordLocator.Location = new System.Drawing.Point(0, 3); this.discordLocator.Name = "discordLocator"; diff --git a/BandagedBD/Properties/Resources.Designer.cs b/BandagedBD/Properties/Resources.Designer.cs index 064c16b..a1c11bb 100644 --- a/BandagedBD/Properties/Resources.Designer.cs +++ b/BandagedBD/Properties/Resources.Designer.cs @@ -101,11 +101,11 @@ namespace BandagedBD.Properties { } /// - /// Looks up a localized string similar to Copyright (c) 2015 - Present Jiiks | 2017 - Present Zerebos + /// Looks up a localized string similar to Copyright (c) 2017 - Present Zerebos /// ///Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: /// - ///The above cop [rest of string was truncated]";. + ///The above copyright notice and this [rest of string was truncated]";. /// internal static string License { get { diff --git a/BandagedBD/Properties/Resources.resx b/BandagedBD/Properties/Resources.resx index 569df1b..9926a22 100644 --- a/BandagedBD/Properties/Resources.resx +++ b/BandagedBD/Properties/Resources.resx @@ -195,7 +195,7 @@ - Copyright (c) 2015 - Present Jiiks | 2017 - Present Zerebos + Copyright (c) 2017 - Present Zerebos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/BandagedBD/Utilities.cs b/BandagedBD/Utilities.cs index a8fe6a3..3b04d1a 100644 --- a/BandagedBD/Utilities.cs +++ b/BandagedBD/Utilities.cs @@ -174,6 +174,10 @@ namespace BandagedBD { } public class TimedWebClient : WebClient { + public WebHeaderCollection DefaultHeaders = new WebHeaderCollection { ["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11" }; + public TimedWebClient() { + Headers = DefaultHeaders; + } protected override WebRequest GetWebRequest(Uri uri) { WebRequest w = base.GetWebRequest(uri); w.Timeout = 5 * 60 * 1000;