From f14a160d0c61c4dbe71efe915fd77e9e181c14f6 Mon Sep 17 00:00:00 2001 From: koyu Date: Fri, 12 Jan 2024 23:06:10 +0100 Subject: [PATCH] Don't spam update notifications --- PlaySync/Main.Designer.cs | 10 ++++---- PlaySync/Main.cs | 49 +++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/PlaySync/Main.Designer.cs b/PlaySync/Main.Designer.cs index 84e4e5a..46ec041 100644 --- a/PlaySync/Main.Designer.cs +++ b/PlaySync/Main.Designer.cs @@ -432,21 +432,21 @@ private void InitializeComponent() // aboutToolStripMenuItem // this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.aboutToolStripMenuItem.Text = "About"; this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); // // checkForUpdatesToolStripMenuItem // this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; - this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.checkForUpdatesToolStripMenuItem.Text = "Check for updates"; this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); // // visitKoyuspaceToolStripMenuItem // this.visitKoyuspaceToolStripMenuItem.Name = "visitKoyuspaceToolStripMenuItem"; - this.visitKoyuspaceToolStripMenuItem.Size = new System.Drawing.Size(170, 22); + this.visitKoyuspaceToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.visitKoyuspaceToolStripMenuItem.Text = "Visit koyu.space"; this.visitKoyuspaceToolStripMenuItem.Click += new System.EventHandler(this.visitKoyuspaceToolStripMenuItem_Click); // @@ -514,14 +514,14 @@ private void InitializeComponent() // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem2.Size = new System.Drawing.Size(166, 22); this.toolStripMenuItem2.Text = "Launch at startup"; this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem1.Size = new System.Drawing.Size(166, 22); this.toolStripMenuItem1.Text = "Exit"; this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click); // diff --git a/PlaySync/Main.cs b/PlaySync/Main.cs index e68751e..596c8cf 100644 --- a/PlaySync/Main.cs +++ b/PlaySync/Main.cs @@ -12,6 +12,7 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using Microsoft.Win32; +using static System.Net.Mime.MediaTypeNames; namespace PlaySync { @@ -24,7 +25,9 @@ public partial class Main : Form bool pluggedin = false; bool syncing = false; bool cansync = false; - string version = "1"; + bool updateshown = false; + bool autostart = false; + string version = "2"; string oldtext = ""; string deviceinfo = ""; string[] games; @@ -74,7 +77,6 @@ public Main() toolStripMenuItem2.Checked = false; } string[] args = Environment.GetCommandLineArgs(); - bool autostart = false; foreach (string arg in args) { if (arg == "--autostart") @@ -84,26 +86,6 @@ public Main() this.WindowState = FormWindowState.Minimized; } } - if (!autostart) - { - try - { - string pubv = new WebClient().DownloadString("https://updates.koyu.space/playsync/latest"); - if (pubv.Split('\n')[0] != version) - { - DialogResult result = MessageBox.Show("New update available. Download now?", "New update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (result == DialogResult.Yes) - { - launchUrl("https://updates.koyu.space/playsync/playsync.zip"); - } - } - else - { - MessageBox.Show("PlaySync is up to date!", "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - catch { } - } } private void readGames(string readfolder) @@ -1211,6 +1193,27 @@ private void Main_Load(object sender, EventArgs e) Environment.Exit(0); } notifyIcon1.ContextMenuStrip = contextMenuStrip1; + if (!autostart && !updateshown) + { + updateshown = true; + try + { + string pubv = new WebClient().DownloadString("https://updates.koyu.space/playsync/latest"); + if (pubv.Split('\n')[0] != version) + { + Thread t = new Thread(() => { + DialogResult result = MessageBox.Show("New update available. Download now?", "New update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + launchUrl("https://updates.koyu.space/playsync/playsync.zip"); + } + } + ); + t.Start(); + } + } + catch { } + } } private void toDeviceToolStripMenuItem_Click(object sender, EventArgs e) @@ -1231,7 +1234,7 @@ private void toolStripMenuItem2_Click(object sender, EventArgs e) else { RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); - rk.SetValue("PlaySync", "\"" + Application.ExecutablePath + "\" --autostart"); + rk.SetValue("PlaySync", "\"" + System.Windows.Forms.Application.ExecutablePath + "\" --autostart"); toolStripMenuItem2.Checked = true; } }