From a7aad1a5ef25bd28112ba2a32751bdbb4896e183 Mon Sep 17 00:00:00 2001 From: Frozd Date: Tue, 10 Mar 2026 16:02:23 +0100 Subject: [PATCH] feat: autoupdater --- CarManager3Setup/CarManager3Setup.vdproj | 6 +- CarManagerV3/CarManagerV3.csproj | 4 +- .../Forms/Components/AnimatedProgressBar.cs | 180 ++++++++++++++++++ .../Forms/Components/AnimatedProgressBar.resx | 120 ++++++++++++ CarManagerV3/Forms/MainForm.Designer.cs | 47 ++++- CarManagerV3/Forms/MainForm.cs | 46 ++++- CarManagerV3/Forms/MainForm.resx | 12 +- .../Forms/UpdatePromptForm.Designer.cs | 1 + CarManagerV3/Forms/UpdatePromptForm.cs | 35 +++- .../Forms/Util/PleaseWait.Designer.cs | 67 ++++--- CarManagerV3/Forms/Util/PleaseWait.cs | 9 +- CarManagerV3/Manager/Updater.cs | 52 +++-- 12 files changed, 507 insertions(+), 72 deletions(-) create mode 100644 CarManagerV3/Forms/Components/AnimatedProgressBar.cs create mode 100644 CarManagerV3/Forms/Components/AnimatedProgressBar.resx diff --git a/CarManager3Setup/CarManager3Setup.vdproj b/CarManager3Setup/CarManager3Setup.vdproj index f1976d6..8e2ab6d 100644 --- a/CarManager3Setup/CarManager3Setup.vdproj +++ b/CarManager3Setup/CarManager3Setup.vdproj @@ -332,15 +332,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Car Manager 3" - "ProductCode" = "8:{79688954-DAEC-4255-BF3C-8FD89EEC28AA}" - "PackageCode" = "8:{6ED782FF-C62F-45E9-B6A8-756604C01717}" + "ProductCode" = "8:{8FDFF7ED-D464-4F87-BA8F-BDC1000520E4}" + "PackageCode" = "8:{83DA7553-805F-4A70-921B-9A6FB0787780}" "UpgradeCode" = "8:{6FF57925-465E-4DB9-85DA-CE933191A3DD}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.3.0" + "ProductVersion" = "8:1.4.0" "Manufacturer" = "8:Jaro Digital" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" diff --git a/CarManagerV3/CarManagerV3.csproj b/CarManagerV3/CarManagerV3.csproj index bb0eb27..4f45086 100644 --- a/CarManagerV3/CarManagerV3.csproj +++ b/CarManagerV3/CarManagerV3.csproj @@ -15,7 +15,7 @@ false true 0 - 1.3.0 + 1.4.0 false false true @@ -25,7 +25,7 @@ CarMgm_Icon.ico Car Manager 3 Car Manager 3 - 1.3.0 + 1.4.0 diff --git a/CarManagerV3/Forms/Components/AnimatedProgressBar.cs b/CarManagerV3/Forms/Components/AnimatedProgressBar.cs new file mode 100644 index 0000000..f1b1ce6 --- /dev/null +++ b/CarManagerV3/Forms/Components/AnimatedProgressBar.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CarManagerV3 +{ + public class AnimatedProgressBar : UserControl + { + private Timer animationTimer; + private float animationPosition = 0f; + private Color primaryColor = Color.FromArgb(0, 120, 215); + private Color secondaryColor = Color.FromArgb(100, 180, 255); + private Color backgroundColor = Color.FromArgb(240, 240, 240); + + public AnimatedProgressBar() + { + this.SetStyle( + ControlStyles.AllPaintingInWmPaint | + ControlStyles.UserPaint | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw, + true); + + this.Height = 8; + + // Initialize animation timer + animationTimer = new Timer(); + animationTimer.Interval = 20; // 50 FPS + animationTimer.Tick += AnimationTimer_Tick; + animationTimer.Start(); + } + + private void AnimationTimer_Tick(object sender, EventArgs e) + { + animationPosition += 2f; + if (animationPosition > this.Width + 100) + { + animationPosition = -100; + } + this.Invalidate(); + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + // Draw background with rounded corners + using (GraphicsPath path = GetRoundedRect(ClientRectangle, 4)) + { + using (SolidBrush bgBrush = new SolidBrush(backgroundColor)) + { + g.FillPath(bgBrush, path); + } + } + + // Create animated gradient bar + float barWidth = 100f; + RectangleF barRect = new RectangleF(animationPosition, 0, barWidth, this.Height); + + if (barRect.Right > 0 && barRect.Left < this.Width) + { + using (GraphicsPath barPath = GetRoundedRect(barRect, 4)) + { + // Create gradient brush + using (LinearGradientBrush gradientBrush = new LinearGradientBrush( + barRect, + Color.Transparent, + Color.Transparent, + LinearGradientMode.Horizontal)) + { + ColorBlend colorBlend = new ColorBlend(); + colorBlend.Colors = new Color[] { + Color.FromArgb(0, primaryColor), + primaryColor, + secondaryColor, + primaryColor, + Color.FromArgb(0, primaryColor) + }; + colorBlend.Positions = new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f }; + gradientBrush.InterpolationColors = colorBlend; + + // Clip to control bounds + Region oldClip = g.Clip; + using (GraphicsPath clipPath = GetRoundedRect(ClientRectangle, 4)) + { + g.SetClip(clipPath); + g.FillPath(gradientBrush, barPath); + g.Clip = oldClip; + } + } + } + } + + // Draw subtle border + using (GraphicsPath borderPath = GetRoundedRect(ClientRectangle, 4)) + { + using (Pen borderPen = new Pen(Color.FromArgb(220, 220, 220), 1)) + { + g.DrawPath(borderPen, borderPath); + } + } + } + + private GraphicsPath GetRoundedRect(RectangleF rect, float radius) + { + GraphicsPath path = new GraphicsPath(); + float diameter = radius * 2; + + path.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90); + path.AddArc(rect.Right - diameter, rect.Y, diameter, diameter, 270, 90); + path.AddArc(rect.Right - diameter, rect.Bottom - diameter, diameter, diameter, 0, 90); + path.AddArc(rect.X, rect.Bottom - diameter, diameter, diameter, 90, 90); + path.CloseFigure(); + + return path; + } + + public void StartAnimation() + { + animationTimer.Start(); + } + + public void StopAnimation() + { + animationTimer.Stop(); + } + + //protected override void Dispose(bool disposing) + //{ + // if (disposing) + // { + // animationTimer?.Stop(); + // animationTimer?.Dispose(); + // } + // base.Dispose(disposing); + //} + + // Properties for customization + public Color PrimaryColor + { + get => primaryColor; + set + { + primaryColor = value; + this.Invalidate(); + } + } + + public Color SecondaryColor + { + get => secondaryColor; + set + { + secondaryColor = value; + this.Invalidate(); + } + } + + public Color ProgressBackColor + { + get => backgroundColor; + set + { + backgroundColor = value; + this.Invalidate(); + } + } + } +} diff --git a/CarManagerV3/Forms/Components/AnimatedProgressBar.resx b/CarManagerV3/Forms/Components/AnimatedProgressBar.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/CarManagerV3/Forms/Components/AnimatedProgressBar.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CarManagerV3/Forms/MainForm.Designer.cs b/CarManagerV3/Forms/MainForm.Designer.cs index ba77bb9..b02d733 100644 --- a/CarManagerV3/Forms/MainForm.Designer.cs +++ b/CarManagerV3/Forms/MainForm.Designer.cs @@ -49,11 +49,14 @@ addCarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); clearSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); openWelcomeScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); clearRecentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); imageList1 = new System.Windows.Forms.ImageList(components); - settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + gitRepositoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); tableLayoutPanel1.SuspendLayout(); tlpControls.SuspendLayout(); tlpSearch.SuspendLayout(); @@ -171,7 +174,7 @@ // menuStrip1.BackColor = System.Drawing.SystemColors.ButtonFace; menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, editToolStripMenuItem, toolsToolStripMenuItem }); + menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, editToolStripMenuItem, toolsToolStripMenuItem, aboutToolStripMenuItem }); menuStrip1.Location = new System.Drawing.Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new System.Drawing.Size(902, 28); @@ -240,24 +243,31 @@ // addCarToolStripMenuItem // addCarToolStripMenuItem.Name = "addCarToolStripMenuItem"; - addCarToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + addCarToolStripMenuItem.Size = new System.Drawing.Size(174, 26); addCarToolStripMenuItem.Text = "Add Car"; addCarToolStripMenuItem.Click += addCarToolStripMenuItem_Click; // // importToolStripMenuItem // importToolStripMenuItem.Name = "importToolStripMenuItem"; - importToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + importToolStripMenuItem.Size = new System.Drawing.Size(174, 26); importToolStripMenuItem.Text = "Import"; importToolStripMenuItem.Click += importToolStripMenuItem_Click; // // clearSearchToolStripMenuItem // clearSearchToolStripMenuItem.Name = "clearSearchToolStripMenuItem"; - clearSearchToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + clearSearchToolStripMenuItem.Size = new System.Drawing.Size(174, 26); clearSearchToolStripMenuItem.Text = "Clear Search"; clearSearchToolStripMenuItem.Click += clearSearchToolStripMenuItem_Click; // + // settingsToolStripMenuItem + // + settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + settingsToolStripMenuItem.Size = new System.Drawing.Size(174, 26); + settingsToolStripMenuItem.Text = "Settings"; + settingsToolStripMenuItem.Click += settingsToolStripMenuItem_Click; + // // toolsToolStripMenuItem // toolsToolStripMenuItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; @@ -290,12 +300,26 @@ imageList1.Images.SetKeyName(0, "Icon_Search.png"); imageList1.Images.SetKeyName(1, "Icon_Add.png"); // - // settingsToolStripMenuItem + // aboutToolStripMenuItem // - settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - settingsToolStripMenuItem.Size = new System.Drawing.Size(224, 26); - settingsToolStripMenuItem.Text = "Settings"; - settingsToolStripMenuItem.Click += settingsToolStripMenuItem_Click; + aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { checkForUpdatesToolStripMenuItem, gitRepositoryToolStripMenuItem }); + aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + aboutToolStripMenuItem.Size = new System.Drawing.Size(64, 24); + aboutToolStripMenuItem.Text = "About"; + // + // checkForUpdatesToolStripMenuItem + // + checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; + checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + checkForUpdatesToolStripMenuItem.Text = "Check for Updates"; + checkForUpdatesToolStripMenuItem.Click += checkForUpdatesToolStripMenuItem_Click; + // + // gitRepositoryToolStripMenuItem + // + gitRepositoryToolStripMenuItem.Name = "gitRepositoryToolStripMenuItem"; + gitRepositoryToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + gitRepositoryToolStripMenuItem.Text = "Git Repository"; + gitRepositoryToolStripMenuItem.Click += gitRepositoryToolStripMenuItem_Click; // // MainForm // @@ -348,5 +372,8 @@ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem clearRecentFilesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem gitRepositoryToolStripMenuItem; } } \ No newline at end of file diff --git a/CarManagerV3/Forms/MainForm.cs b/CarManagerV3/Forms/MainForm.cs index 8479a2f..45f23d5 100644 --- a/CarManagerV3/Forms/MainForm.cs +++ b/CarManagerV3/Forms/MainForm.cs @@ -61,11 +61,17 @@ namespace CarManagerV3 } refreshRecents(); - - if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease)) + try { - UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(), Updater.GetLatestVersion()); - updatePrompt.ShowDialog(); + if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease)) + { + UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(), Updater.GetLatestVersion()); + updatePrompt.ShowDialog(); + } + } + catch (Exception ex) + { + Console.Error.WriteLine("Error checking for updates: " + ex.Message); } @@ -150,7 +156,7 @@ namespace CarManagerV3 Console.WriteLine($"[L] Updating car: {car.Id}"); // changes card = existing; - if(force) card.LoadImage(); // reload image if forced refresh + if (force) card.LoadImage(); // reload image if forced refresh } else { @@ -558,5 +564,35 @@ namespace CarManagerV3 settingsForm.ShowDialog(); } + + private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + if (Updater.IsUpdateAvailable(Properties.Settings.Default.AllowPrerelease)) + { + UpdatePromptForm updatePrompt = new UpdatePromptForm(Updater.GetCurrentVersion(), Updater.GetLatestVersion()); + updatePrompt.ShowDialog(); + } + else + { + MessageBox.Show($"You are already using the latest version. ({Updater.GetCurrentVersion()})", "No Updates Available", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + catch (Exception ex) + { + MessageBox.Show("Error checking for updates: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void gitRepositoryToolStripMenuItem_Click(object sender, EventArgs e) + { + // Open the Git repository in the user's default browser + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo + { + FileName = "https://git.jaro.digital/frozd/carmanager-3", + UseShellExecute = true + }); + } } } diff --git a/CarManagerV3/Forms/MainForm.resx b/CarManagerV3/Forms/MainForm.resx index 2e63906..ca05122 100644 --- a/CarManagerV3/Forms/MainForm.resx +++ b/CarManagerV3/Forms/MainForm.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + @@ -139,9 +142,6 @@ VXs21p8MAVc2KdQAvwAAAABJRU5ErkJggg== - - 17, 17 - 153, 17 @@ -150,15 +150,15 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAYAQAAAJNU0Z0AUkBTAIBAQIB - AAGIAQABiAEAARQBAAEUAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABUAMAARQDAAEBAQABIAYAARn/ + AAGYAQABmAEAARQBAAEUAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABUAMAARQDAAEBAQABIAYAARn/ AP8AzAADCAEKAyMBMgMuAUYDFgEe/wAtAAMIAQoDIwEyAk8BTgGXAlYBVAGrAy4BRv8ALQADIwEyAk8B TgGXAf8BmQEzAf8DTgGWAyMBMiwAA10BzAT/9AADKAE8Ak8BTgGXAl8BWwHTA04BlgMjATIDCAEKLAAD XQHMBP/UAAMDAQQDDwETA0QBewJPAU4BlwNNAZIDQAFuAwYBBwMpAT0DTgGYAlsBWQHAAk8BTgGXAyMB MgMIAQowAANdAcwE/9AAAxMBGgMxAU0DRAF5AlwBWQHBAmEBXQHPAl0BWwHKAlcBVQG0Az8BbQNSAaMC WwFZAcADTgGYAygBPDgAA10BzAT/zAADAwEEAzEBTQJZAVcBvAJgAV0BzgNLAYwDQAFvA0ABbwNLAYwC - YAFdAc4BggFxAVMB9AJTAVEBogMpAT08AANdAcwE/8wAAw8BEwNEAXkCYAFdAc4DBgEIBAIIAAQCAwYB + YAFdAc4BfAFtAVMB9AJTAVEBogMpAT08AANdAcwE/8wAAw8BEwNEAXkCYAFdAc4DBgEIBAIIAAQCAwYB CAJgAV0BzgM+AWsDBAEFKAADXQHMLP+4AANEAXkDWgG/A0sBjAQCEAAEAgNLAYwCWgFYAbcDQQFxKAAD - UgGjA10BzANdAcwDXQHMA10BzAOJAfUE/wNdAcwDXQHMA10BzANdAcwDXQHMuAACTwFOAZcCYAFdAc4D + UgGjA10BzANdAcwDXQHMA10BzAOFAfUE/wNdAcwDXQHMA10BzANdAcwDXQHMuAACTwFOAZcCYAFdAc4D QAFvGAADQAFvAl8BXAHLA04BlDwAA10BzAT/zAACTwFOAZcCYAFdAc4DQAFvGAADQAFvAl4BWwHNA04B ljwAA10BzAT/zAADRAF6AlsBWQHAA0sBjAQCEAAEAgNLAYwCWgFYAb0CRAFDAXc8AANdAcwE/8wAAw4B EgNEAXgCYAFdAc4DBgEIBAIIAAQCAwYBCAJgAV0BzgJDAUIBdQMMAQ88AANdAcwE/8wAAwMBBAMxAU0C diff --git a/CarManagerV3/Forms/UpdatePromptForm.Designer.cs b/CarManagerV3/Forms/UpdatePromptForm.Designer.cs index 3c44380..9a52e17 100644 --- a/CarManagerV3/Forms/UpdatePromptForm.Designer.cs +++ b/CarManagerV3/Forms/UpdatePromptForm.Designer.cs @@ -151,6 +151,7 @@ btnReadChangelog.TabIndex = 1; btnReadChangelog.Text = "Changelog"; btnReadChangelog.UseVisualStyleBackColor = true; + btnReadChangelog.Click += btnReadChangelog_Click; // // UpdatePromptForm // diff --git a/CarManagerV3/Forms/UpdatePromptForm.cs b/CarManagerV3/Forms/UpdatePromptForm.cs index 2d59a03..cf95a73 100644 --- a/CarManagerV3/Forms/UpdatePromptForm.cs +++ b/CarManagerV3/Forms/UpdatePromptForm.cs @@ -18,6 +18,7 @@ namespace CarManagerV3.Forms InitializeComponent(); lblInstalledVersion.Text = lblInstalledVersion.Text.Replace("?.?.?", currentVersion); lblLatestVersion.Text = lblLatestVersion.Text.Replace("?.?.?", latestVersion); + } private void btnDismissUpdate_Click(object sender, EventArgs e) @@ -25,9 +26,39 @@ namespace CarManagerV3.Forms this.Close(); } - private async void btnInstallUpdate_Click(object sender, EventArgs e) + private void btnInstallUpdate_Click(object sender, EventArgs e) { - Updater.DownloadNewestInstaller(); + /* + var msgbox = new PleaseWait(); + msgbox.Show(); + Application.DoEvents(); + StateManager.UpdateCar(car); + Image fooimg = ImageManager.GetImage(car); + msgbox.Close(); + this.Close(); + */ + PleaseWait loadForm = new PleaseWait("Downloading the newest version..."); + try + { + this.Enabled = false; + loadForm.Show(); + Application.DoEvents(); + //return; + Updater.DownloadNewestInstaller(); + } + catch (Exception ex) + { + MessageBox.Show("An error occurred while trying to download the update: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + this.Enabled = true; + loadForm.Close(); + this.Close(); + + } + + private void btnReadChangelog_Click(object sender, EventArgs e) + { + Updater.openReleasePage(); } } } diff --git a/CarManagerV3/Forms/Util/PleaseWait.Designer.cs b/CarManagerV3/Forms/Util/PleaseWait.Designer.cs index ed9b848..4b5d3ad 100644 --- a/CarManagerV3/Forms/Util/PleaseWait.Designer.cs +++ b/CarManagerV3/Forms/Util/PleaseWait.Designer.cs @@ -28,50 +28,69 @@ /// private void InitializeComponent() { - progressBar1 = new System.Windows.Forms.ProgressBar(); label1 = new System.Windows.Forms.Label(); lblContent = new System.Windows.Forms.Label(); + animatedProgressBar1 = new AnimatedProgressBar(); + flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + flowLayoutPanel1.SuspendLayout(); SuspendLayout(); // - // progressBar1 - // - progressBar1.Location = new System.Drawing.Point(12, 78); - progressBar1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - progressBar1.Name = "progressBar1"; - progressBar1.Size = new System.Drawing.Size(422, 29); - progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; - progressBar1.TabIndex = 0; - progressBar1.Click += progressBar1_Click; - // // label1 // label1.AutoSize = true; - label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); - label1.Location = new System.Drawing.Point(12, 16); + label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); + label1.Location = new System.Drawing.Point(13, 10); label1.Name = "label1"; - label1.Size = new System.Drawing.Size(121, 20); + label1.Size = new System.Drawing.Size(140, 25); label1.TabIndex = 1; label1.Text = "Please wait..."; + label1.UseWaitCursor = true; // // lblContent // lblContent.AutoSize = true; - lblContent.Location = new System.Drawing.Point(13, 41); + lblContent.Location = new System.Drawing.Point(13, 40); + lblContent.Margin = new System.Windows.Forms.Padding(3, 5, 3, 10); lblContent.Name = "lblContent"; lblContent.Size = new System.Drawing.Size(144, 20); lblContent.TabIndex = 2; lblContent.Text = "Saving your changes"; + lblContent.UseWaitCursor = true; + // + // animatedProgressBar1 + // + animatedProgressBar1.Location = new System.Drawing.Point(13, 73); + animatedProgressBar1.Name = "animatedProgressBar1"; + animatedProgressBar1.PrimaryColor = System.Drawing.Color.FromArgb(0, 120, 215); + animatedProgressBar1.ProgressBackColor = System.Drawing.Color.FromArgb(240, 240, 240); + animatedProgressBar1.SecondaryColor = System.Drawing.Color.FromArgb(100, 180, 255); + animatedProgressBar1.Size = new System.Drawing.Size(408, 22); + animatedProgressBar1.TabIndex = 3; + animatedProgressBar1.UseWaitCursor = true; + // + // flowLayoutPanel1 + // + flowLayoutPanel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom; + flowLayoutPanel1.Controls.Add(label1); + flowLayoutPanel1.Controls.Add(lblContent); + flowLayoutPanel1.Controls.Add(animatedProgressBar1); + flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + flowLayoutPanel1.Name = "flowLayoutPanel1"; + flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(10); + flowLayoutPanel1.Size = new System.Drawing.Size(437, 153); + flowLayoutPanel1.TabIndex = 4; + flowLayoutPanel1.UseWaitCursor = true; + flowLayoutPanel1.WrapContents = false; // // PleaseWait // AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoSize = true; - ClientSize = new System.Drawing.Size(446, 121); + ClientSize = new System.Drawing.Size(437, 153); ControlBox = false; - Controls.Add(lblContent); - Controls.Add(label1); - Controls.Add(progressBar1); + Controls.Add(flowLayoutPanel1); FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); MaximizeBox = false; @@ -79,16 +98,20 @@ Name = "PleaseWait"; ShowIcon = false; ShowInTaskbar = false; + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; Text = "Please Wait"; + TopMost = true; + UseWaitCursor = true; + flowLayoutPanel1.ResumeLayout(false); + flowLayoutPanel1.PerformLayout(); ResumeLayout(false); - PerformLayout(); } #endregion - - private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lblContent; + private AnimatedProgressBar animatedProgressBar1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; } } \ No newline at end of file diff --git a/CarManagerV3/Forms/Util/PleaseWait.cs b/CarManagerV3/Forms/Util/PleaseWait.cs index 5adc7aa..6e41c72 100644 --- a/CarManagerV3/Forms/Util/PleaseWait.cs +++ b/CarManagerV3/Forms/Util/PleaseWait.cs @@ -8,11 +8,16 @@ namespace CarManagerV3 public PleaseWait(string content = "Saving your changes...") { InitializeComponent(); + + this.SetStyle(ControlStyles.OptimizedDoubleBuffer | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.UserPaint, true); + // loading animation - progressBar1.Style = ProgressBarStyle.Marquee; - progressBar1.MarqueeAnimationSpeed = 30; + animatedProgressBar1.StartAnimation(); lblContent.Text = content; + } private void progressBar1_Click(object sender, EventArgs e) diff --git a/CarManagerV3/Manager/Updater.cs b/CarManagerV3/Manager/Updater.cs index 42b0e08..019744c 100644 --- a/CarManagerV3/Manager/Updater.cs +++ b/CarManagerV3/Manager/Updater.cs @@ -21,7 +21,7 @@ namespace CarManagerV3.Manager private static DateTime lastChecked = DateTime.MinValue; private static readonly int CacheDurationMinutes = 60; private static bool cacheIncludesPrerelease = false; - private static readonly string debugVersion = "1.2.0"; + private static readonly string debugVersion = null;//"1.2.0"; public static string GetCurrentVersion() { @@ -111,7 +111,7 @@ namespace CarManagerV3.Manager } - public static async void DownloadNewestInstaller(bool includePreRelease = false) + public static void DownloadNewestInstaller(bool includePreRelease = false) { string latestVersion = GetLatestVersion(includePreRelease); if (latestVersion == null) @@ -137,27 +137,25 @@ namespace CarManagerV3.Manager break; } } + if (downloadUrl != null) { - PleaseWait loadForm = new PleaseWait("Downloading the newest version..."); - loadForm.Show(); - Application.DoEvents(); - await Task.Run(() => + + + // Download the installer to the users set Data dir, run it, and then exit the application. + string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"CarManagerInstaller_{latestVersion}.msi"); + using (var downloadClient = new System.Net.WebClient()) { - // Download the installer to the users set Data dir, run it, and then exit the application. - string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"CarManagerInstaller_{latestVersion}.msi"); - using (var downloadClient = new System.Net.WebClient()) - { - downloadClient.DownloadFile(downloadUrl, tempFilePath); - } - // Use ProcessStartInfo with UseShellExecute to launch the MSI file - var processStartInfo = new System.Diagnostics.ProcessStartInfo - { - FileName = tempFilePath, - UseShellExecute = true - }; - System.Diagnostics.Process.Start(processStartInfo); - }); + downloadClient.DownloadFile(downloadUrl, tempFilePath); + } + // Use ProcessStartInfo with UseShellExecute to launch the MSI file + var processStartInfo = new System.Diagnostics.ProcessStartInfo + { + FileName = tempFilePath, + UseShellExecute = true + }; + System.Diagnostics.Process.Start(processStartInfo); + Application.Exit(); } @@ -181,5 +179,19 @@ namespace CarManagerV3.Manager string latestVersion = GetLatestVersion(includePreRelease); return IsNewerVersion(latestVersion, currentVersion); } + + public static void openReleasePage(string version = null) + { + if(version == null) + { + version = GetLatestVersion(true); + } + string releaseUrl = $"https://git.jaro.digital/{GitRepoOwner}/{GitRepoName}/releases/tag/{version}"; + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo + { + FileName = releaseUrl, + UseShellExecute = true + }); + } } }