diff --git a/Properties/PublishProfiles/FolderProfile.pubxml.user b/Properties/PublishProfiles/FolderProfile.pubxml.user index f46b0f7..37c351f 100644 --- a/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2024-06-18T16:11:20.9585577Z||;True|2024-06-18T17:54:04.9775606+02:00||;True|2024-06-18T17:53:03.5685184+02:00||;True|2024-06-18T17:52:26.3088028+02:00||;True|2024-06-17T11:12:58.4583359+02:00||;True|2024-06-17T10:36:25.6841440+02:00||;True|2024-06-14T11:31:32.6934516+02:00||;True|2024-06-14T11:31:23.3706499+02:00||;True|2024-06-14T11:31:18.7205494+02:00||;True|2024-06-13T09:43:43.5390795+02:00||;True|2024-06-13T08:57:35.0322797+02:00||;True|2024-06-06T15:42:28.6568298+02:00||;True|2024-06-06T15:40:12.6240419+02:00||;True|2024-06-06T13:48:19.4662781+02:00||;True|2024-06-06T12:38:52.6425012+02:00||;True|2024-06-06T12:31:36.7948282+02:00||;True|2024-06-06T10:35:12.1369025+02:00||;True|2024-06-06T10:34:54.5189019+02:00||;True|2024-06-05T23:32:06.1114024+02:00||;True|2024-05-27T18:47:08.3065316+02:00||;True|2024-05-27T18:43:26.7575713+02:00||;True|2024-05-27T16:16:44.1211325+02:00||;True|2024-05-27T16:16:29.4947310+02:00||;True|2024-05-27T11:07:49.8981157+02:00||;True|2024-05-27T11:07:01.1240671+02:00||;True|2024-05-27T11:06:53.1694382+02:00||;True|2024-05-27T09:10:47.9526993+02:00||;True|2024-05-27T09:10:02.8503554+02:00||;True|2024-05-27T09:09:35.2317189+02:00||;True|2024-05-27T08:58:09.8645241+02:00||;True|2024-05-27T08:52:52.8051920+02:00||;True|2024-05-27T08:45:19.6197985+02:00||;True|2024-05-24T11:02:27.2916636+02:00||;True|2024-05-24T08:59:01.6326756+02:00||;True|2024-05-23T09:17:13.9644300+02:00||;True|2024-05-23T09:05:46.2467509+02:00||;True|2024-05-22T22:13:45.9526537+02:00||;True|2024-05-22T22:09:03.4000755+02:00||;True|2024-05-22T22:08:00.0350517+02:00||;True|2024-05-22T21:44:48.4725626+02:00||;True|2024-05-22T21:32:35.3627900+02:00||;True|2024-05-22T19:33:34.6467061+02:00||;True|2024-05-19T19:19:28.1467287+02:00||;True|2024-05-19T19:17:09.7006733+02:00||;True|2024-05-19T19:14:06.6668981+02:00||;True|2024-05-19T14:42:07.1301968+02:00||;True|2024-05-19T14:38:02.4943907+02:00||;True|2024-05-19T09:20:51.2871097+02:00||;True|2024-05-19T09:18:16.6124371+02:00||;True|2024-05-19T09:15:08.6048404+02:00||;True|2024-05-18T22:34:28.8521894+02:00||;True|2024-05-18T22:22:14.4673452+02:00||;True|2024-05-18T21:56:58.6143811+02:00||;True|2024-05-18T07:41:43.4161277+02:00||;True|2024-05-17T11:48:43.3293227+02:00||;True|2024-05-17T09:31:58.9329403+02:00||;True|2024-05-17T09:25:57.4957904+02:00||;True|2024-05-16T19:52:10.0997229+02:00||;True|2024-05-16T18:17:01.7850021+02:00||;True|2024-05-15T09:33:00.6957135+02:00||;True|2024-05-15T08:32:31.7735956+02:00||;True|2024-05-13T17:25:21.1454345+02:00||;True|2024-05-13T17:15:09.7285346+02:00||;True|2024-05-13T16:52:20.9054581+02:00||;True|2024-05-13T16:51:27.0891569+02:00||;True|2024-05-13T16:50:34.5522468+02:00||;True|2024-05-13T16:49:22.6946988+02:00||; + True|2024-06-18T17:31:38.9594414Z||;True|2024-06-18T18:11:20.9585577+02:00||;True|2024-06-18T17:54:04.9775606+02:00||;True|2024-06-18T17:53:03.5685184+02:00||;True|2024-06-18T17:52:26.3088028+02:00||;True|2024-06-17T11:12:58.4583359+02:00||;True|2024-06-17T10:36:25.6841440+02:00||;True|2024-06-14T11:31:32.6934516+02:00||;True|2024-06-14T11:31:23.3706499+02:00||;True|2024-06-14T11:31:18.7205494+02:00||;True|2024-06-13T09:43:43.5390795+02:00||;True|2024-06-13T08:57:35.0322797+02:00||;True|2024-06-06T15:42:28.6568298+02:00||;True|2024-06-06T15:40:12.6240419+02:00||;True|2024-06-06T13:48:19.4662781+02:00||;True|2024-06-06T12:38:52.6425012+02:00||;True|2024-06-06T12:31:36.7948282+02:00||;True|2024-06-06T10:35:12.1369025+02:00||;True|2024-06-06T10:34:54.5189019+02:00||;True|2024-06-05T23:32:06.1114024+02:00||;True|2024-05-27T18:47:08.3065316+02:00||;True|2024-05-27T18:43:26.7575713+02:00||;True|2024-05-27T16:16:44.1211325+02:00||;True|2024-05-27T16:16:29.4947310+02:00||;True|2024-05-27T11:07:49.8981157+02:00||;True|2024-05-27T11:07:01.1240671+02:00||;True|2024-05-27T11:06:53.1694382+02:00||;True|2024-05-27T09:10:47.9526993+02:00||;True|2024-05-27T09:10:02.8503554+02:00||;True|2024-05-27T09:09:35.2317189+02:00||;True|2024-05-27T08:58:09.8645241+02:00||;True|2024-05-27T08:52:52.8051920+02:00||;True|2024-05-27T08:45:19.6197985+02:00||;True|2024-05-24T11:02:27.2916636+02:00||;True|2024-05-24T08:59:01.6326756+02:00||;True|2024-05-23T09:17:13.9644300+02:00||;True|2024-05-23T09:05:46.2467509+02:00||;True|2024-05-22T22:13:45.9526537+02:00||;True|2024-05-22T22:09:03.4000755+02:00||;True|2024-05-22T22:08:00.0350517+02:00||;True|2024-05-22T21:44:48.4725626+02:00||;True|2024-05-22T21:32:35.3627900+02:00||;True|2024-05-22T19:33:34.6467061+02:00||;True|2024-05-19T19:19:28.1467287+02:00||;True|2024-05-19T19:17:09.7006733+02:00||;True|2024-05-19T19:14:06.6668981+02:00||;True|2024-05-19T14:42:07.1301968+02:00||;True|2024-05-19T14:38:02.4943907+02:00||;True|2024-05-19T09:20:51.2871097+02:00||;True|2024-05-19T09:18:16.6124371+02:00||;True|2024-05-19T09:15:08.6048404+02:00||;True|2024-05-18T22:34:28.8521894+02:00||;True|2024-05-18T22:22:14.4673452+02:00||;True|2024-05-18T21:56:58.6143811+02:00||;True|2024-05-18T07:41:43.4161277+02:00||;True|2024-05-17T11:48:43.3293227+02:00||;True|2024-05-17T09:31:58.9329403+02:00||;True|2024-05-17T09:25:57.4957904+02:00||;True|2024-05-16T19:52:10.0997229+02:00||;True|2024-05-16T18:17:01.7850021+02:00||;True|2024-05-15T09:33:00.6957135+02:00||;True|2024-05-15T08:32:31.7735956+02:00||;True|2024-05-13T17:25:21.1454345+02:00||;True|2024-05-13T17:15:09.7285346+02:00||;True|2024-05-13T16:52:20.9054581+02:00||;True|2024-05-13T16:51:27.0891569+02:00||;True|2024-05-13T16:50:34.5522468+02:00||;True|2024-05-13T16:49:22.6946988+02:00||; \ No newline at end of file diff --git a/mainMenu.cs b/mainMenu.cs index c4f4bfe..203d2b9 100644 --- a/mainMenu.cs +++ b/mainMenu.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using Flurl; using System.IO; +using System.IO.Packaging; namespace Manga_Library_Manager { @@ -29,7 +30,7 @@ public override string ToString() } public static string selectedLanguage; - public static bool noWarning; + public static bool noWarning, checkUpdates; private List books = new List(); private AutoCompleteStringCollection searchTextBoxAutomcompleteStrings = new AutoCompleteStringCollection(); private List files = new List(), ratingsList = new List(); @@ -86,6 +87,15 @@ private void mainMenu_Load(object sender, EventArgs e) books = file.SelectToken("Library").ToObject>(); selectedLanguage = file.SelectToken("Language").Value(); noWarning = file.SelectToken("NoWarning").Value(); + if (file.SelectToken("FormatVersion").Value() > 2) + checkUpdates = file.SelectToken("CheckUpdates").Value(); + else + { + if (MessageBox.Show("Would you like the program to automatically check for updates?\nYou can always change this later in the settings.", "Check for updates", MessageBoxButtons.YesNo) == DialogResult.No) + checkUpdates = false; + else + checkUpdates = true; + } } } catch @@ -98,6 +108,10 @@ private void mainMenu_Load(object sender, EventArgs e) books = JsonConvert.DeserializeObject>(line); selectedLanguage = "en"; noWarning = false; + if (MessageBox.Show("Would you like the program to automatically check for updates?\nYou can always change this later in the settings.", "Check for updates", MessageBoxButtons.YesNo) == DialogResult.No) + checkUpdates = false; + else + checkUpdates = true; } goto ItJustWorks; } @@ -131,6 +145,7 @@ private void mainMenu_Load(object sender, EventArgs e) { selectedLanguage = "en"; noWarning = false; + checkUpdates = false; books = JsonConvert.DeserializeObject>(jsonDump); MessageBox.Show("Import successful!\nYour settings have been reset.", "Import successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -153,6 +168,33 @@ private void mainMenu_Load(object sender, EventArgs e) } } ItJustWorks: + if (checkUpdates == true) + Task.Run(() => + { + using HttpClient client = new HttpClient(); + client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.UserAgent.ParseAdd("Manga Library Manager for Windows by (github) ErisLoona"); + try + { + JObject githubResponse = JObject.Parse(client.GetStringAsync("https://api.github.com/repos/erisloona/manga-library-manager/releases/latest").Result); + List versionNumbers = new List(); + versionNumbers.AddRange(githubResponse.SelectToken("tag_name").Value().Substring(1).Split(".")); + string[] currentVersion = FileVersionInfo.GetVersionInfo(Environment.ProcessPath).FileVersion.Split("."); + bool update = false; + for (int i = 0; i < versionNumbers.Count; i++) + if (Convert.ToInt32(versionNumbers[i]) > Convert.ToInt32(currentVersion[i])) + { + update = true; + break; + } + if (update == true) + { + if (MessageBox.Show("A new version is available!\nWould you like to go download it?", "Update found", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) + Process.Start(new ProcessStartInfo(githubResponse.SelectToken("html_url").Value()) { UseShellExecute = true }); + } + } + catch { } + }); mangaList.BeginUpdate(); foreach (eBook book in books) { @@ -1024,9 +1066,10 @@ private void mainMenu_FormClosing(object sender, FormClosingEventArgs e) try { JObject saveFile = new JObject(); - saveFile["FormatVersion"] = 2; + saveFile["FormatVersion"] = 3; saveFile["Language"] = selectedLanguage; saveFile["NoWarning"] = noWarning; + saveFile["CheckUpdates"] = checkUpdates; saveFile["Library"] = JToken.FromObject(books); using (StreamWriter writer = new StreamWriter("Manga Library Manager.json")) { diff --git a/userSettings.Designer.cs b/userSettings.Designer.cs index 2140b6d..ce5da67 100644 --- a/userSettings.Designer.cs +++ b/userSettings.Designer.cs @@ -38,6 +38,7 @@ private void InitializeComponent() label2 = new Label(); importButton = new Button(); toolTip = new ToolTip(components); + checkUpdatesCheckbox = new CheckBox(); SuspendLayout(); // // donateButton @@ -49,7 +50,7 @@ private void InitializeComponent() donateButton.FlatStyle = FlatStyle.Flat; donateButton.Font = new Font("Calibri", 8.25F, FontStyle.Bold, GraphicsUnit.Point, 0); donateButton.ForeColor = Color.Black; - donateButton.Location = new Point(156, 150); + donateButton.Location = new Point(156, 175); donateButton.Margin = new Padding(7, 5, 7, 5); donateButton.Name = "donateButton"; donateButton.Size = new Size(50, 22); @@ -64,7 +65,7 @@ private void InitializeComponent() creditsLabel.AutoSize = true; creditsLabel.Font = new Font("Calibri", 9F, FontStyle.Bold, GraphicsUnit.Point, 0); creditsLabel.ForeColor = Color.FromArgb(248, 200, 220); - creditsLabel.Location = new Point(107, 173); + creditsLabel.Location = new Point(107, 198); creditsLabel.Name = "creditsLabel"; creditsLabel.Size = new Size(103, 14); creditsLabel.TabIndex = 12; @@ -108,7 +109,7 @@ private void InitializeComponent() // label2.AutoSize = true; label2.Font = new Font("Calibri", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - label2.Location = new Point(-1, 162); + label2.Location = new Point(-1, 187); label2.Name = "label2"; label2.Size = new Size(92, 26); label2.TabIndex = 16; @@ -123,7 +124,7 @@ private void InitializeComponent() importButton.FlatStyle = FlatStyle.Flat; importButton.Font = new Font("Calibri", 9F, FontStyle.Bold, GraphicsUnit.Point, 0); importButton.ForeColor = Color.Black; - importButton.Location = new Point(61, 114); + importButton.Location = new Point(61, 139); importButton.Margin = new Padding(7, 5, 7, 5); importButton.Name = "importButton"; importButton.Size = new Size(89, 24); @@ -133,12 +134,25 @@ private void InitializeComponent() importButton.UseVisualStyleBackColor = false; importButton.Click += importButton_Click; // + // checkUpdatesCheckbox + // + checkUpdatesCheckbox.AutoSize = true; + checkUpdatesCheckbox.Font = new Font("Calibri", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 0); + checkUpdatesCheckbox.Location = new Point(43, 109); + checkUpdatesCheckbox.Name = "checkUpdatesCheckbox"; + checkUpdatesCheckbox.Size = new Size(124, 19); + checkUpdatesCheckbox.TabIndex = 18; + checkUpdatesCheckbox.Text = "Check for updates"; + checkUpdatesCheckbox.UseVisualStyleBackColor = true; + checkUpdatesCheckbox.CheckedChanged += checkUpdatesCheckbox_CheckedChanged; + // // userSettings // AutoScaleDimensions = new SizeF(8F, 19F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.DimGray; - ClientSize = new Size(210, 187); + ClientSize = new Size(210, 215); + Controls.Add(checkUpdatesCheckbox); Controls.Add(importButton); Controls.Add(label2); Controls.Add(warnCheckBox); @@ -173,5 +187,6 @@ private void InitializeComponent() private Label label2; private Button importButton; private ToolTip toolTip; + private CheckBox checkUpdatesCheckbox; } } \ No newline at end of file diff --git a/userSettings.cs b/userSettings.cs index 33938d3..3721e9c 100644 --- a/userSettings.cs +++ b/userSettings.cs @@ -18,6 +18,7 @@ public userSettings() private void userSettings_Load(object sender, EventArgs e) { warnCheckBox.Checked = !mainMenu.noWarning; + checkUpdatesCheckbox.Checked = mainMenu.checkUpdates; foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) if (languages.ContainsValue(culture.TwoLetterISOLanguageName) == false) languages[culture.EnglishName] = culture.TwoLetterISOLanguageName; @@ -43,6 +44,11 @@ private void warnCheckBox_CheckedChanged(object sender, EventArgs e) mainMenu.noWarning = !warnCheckBox.Checked; } + private void checkUpdatesCheckbox_CheckedChanged(object sender, EventArgs e) + { + mainMenu.checkUpdates = checkUpdatesCheckbox.Checked; + } + private void importButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Warning! This will overwrite your entire current library!\nAre you sure you want to continue?", "Import library", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)