From 713520cf2d040f886748fdb60cde2da690dcd492 Mon Sep 17 00:00:00 2001 From: Eric McDaniel Date: Fri, 6 Mar 2026 21:19:40 -0600 Subject: [PATCH 1/3] Rearrange user config options --- LumenLabInstallerForm.Designer.cs | 118 ++++++++++++++++++++++++------ LumenLabInstallerForm.cs | 35 +++++++-- LumenLabInstallerForm.resx | 2 +- 3 files changed, 126 insertions(+), 29 deletions(-) diff --git a/LumenLabInstallerForm.Designer.cs b/LumenLabInstallerForm.Designer.cs index 3e09d6b..58359cd 100644 --- a/LumenLabInstallerForm.Designer.cs +++ b/LumenLabInstallerForm.Designer.cs @@ -57,10 +57,15 @@ private void InitializeComponent() TxtNumLeds = new NumericUpDown(); contextMenuStrip1 = new ContextMenuStrip(components); groupBox1 = new GroupBox(); + LblControllerType = new Label(); + RadPS4 = new RadioButton(); + RadPS3 = new RadioButton(); LblInstalledVersion = new RichTextBox(); LblLatestRelease = new RichTextBox(); label1 = new Label(); label2 = new Label(); + ChkClearMemory = new CheckBox(); + LblUpdateAlert = new RichTextBox(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)DgvGitHubReleases).BeginInit(); menuStrip1.SuspendLayout(); @@ -78,9 +83,9 @@ private void InitializeComponent() BtnFlashFirmware.Enabled = false; BtnFlashFirmware.FlatStyle = FlatStyle.System; BtnFlashFirmware.ForeColor = SystemColors.ActiveCaptionText; - BtnFlashFirmware.Location = new Point(691, 303); + BtnFlashFirmware.Location = new Point(683, 292); BtnFlashFirmware.Name = "BtnFlashFirmware"; - BtnFlashFirmware.Size = new Size(207, 26); + BtnFlashFirmware.Size = new Size(187, 26); BtnFlashFirmware.TabIndex = 0; BtnFlashFirmware.Text = "Install Latest Release"; BtnFlashFirmware.UseVisualStyleBackColor = true; @@ -91,7 +96,7 @@ private void InitializeComponent() pictureBox1.BackColor = Color.Transparent; pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; pictureBox1.Image = (Image)resources.GetObject("pictureBox1.Image"); - pictureBox1.Location = new Point(72, 51); + pictureBox1.Location = new Point(77, 47); pictureBox1.Name = "pictureBox1"; pictureBox1.Size = new Size(277, 75); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; @@ -120,17 +125,17 @@ private void InitializeComponent() DgvGitHubReleases.BackgroundColor = SystemColors.ControlDarkDark; DgvGitHubReleases.BorderStyle = BorderStyle.None; DgvGitHubReleases.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - DgvGitHubReleases.Location = new Point(466, 137); + DgvGitHubReleases.Location = new Point(466, 115); DgvGitHubReleases.Name = "DgvGitHubReleases"; - DgvGitHubReleases.Size = new Size(432, 150); + DgvGitHubReleases.Size = new Size(432, 165); DgvGitHubReleases.TabIndex = 3; // // BtnSync // BtnSync.Enabled = false; - BtnSync.Location = new Point(767, 78); + BtnSync.Location = new Point(487, 292); BtnSync.Name = "BtnSync"; - BtnSync.Size = new Size(131, 48); + BtnSync.Size = new Size(174, 26); BtnSync.TabIndex = 4; BtnSync.Text = "Refresh Device List"; BtnSync.UseVisualStyleBackColor = true; @@ -229,7 +234,7 @@ private void InitializeComponent() // LblMacAddress.AutoSize = true; LblMacAddress.Enabled = false; - LblMacAddress.Location = new Point(40, 71); + LblMacAddress.Location = new Point(40, 101); LblMacAddress.Name = "LblMacAddress"; LblMacAddress.Size = new Size(158, 15); LblMacAddress.TabIndex = 12; @@ -239,7 +244,7 @@ private void InitializeComponent() // TxtMacAddress.Enabled = false; TxtMacAddress.Font = new Font("Consolas", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - TxtMacAddress.Location = new Point(201, 67); + TxtMacAddress.Location = new Point(201, 97); TxtMacAddress.Name = "TxtMacAddress"; TxtMacAddress.PlaceholderText = "00:00:00:00:00"; TxtMacAddress.Size = new Size(130, 25); @@ -250,7 +255,7 @@ private void InitializeComponent() // LblSerialBaud.AutoSize = true; LblSerialBaud.Enabled = false; - LblSerialBaud.Location = new Point(40, 102); + LblSerialBaud.Location = new Point(40, 132); LblSerialBaud.Name = "LblSerialBaud"; LblSerialBaud.Size = new Size(68, 15); LblSerialBaud.TabIndex = 14; @@ -260,7 +265,7 @@ private void InitializeComponent() // LblBoundaries.AutoSize = true; LblBoundaries.Enabled = false; - LblBoundaries.Location = new Point(40, 132); + LblBoundaries.Location = new Point(40, 162); LblBoundaries.Name = "LblBoundaries"; LblBoundaries.Size = new Size(69, 15); LblBoundaries.TabIndex = 16; @@ -270,7 +275,7 @@ private void InitializeComponent() // TxtBound1.Enabled = false; TxtBound1.Font = new Font("Consolas", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - TxtBound1.Location = new Point(125, 128); + TxtBound1.Location = new Point(125, 158); TxtBound1.Maximum = new decimal(new int[] { 300, 0, 0, 0 }); TxtBound1.Name = "TxtBound1"; TxtBound1.Size = new Size(65, 25); @@ -281,7 +286,7 @@ private void InitializeComponent() // TxtBound2.Enabled = false; TxtBound2.Font = new Font("Consolas", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - TxtBound2.Location = new Point(195, 128); + TxtBound2.Location = new Point(195, 158); TxtBound2.Maximum = new decimal(new int[] { 300, 0, 0, 0 }); TxtBound2.Name = "TxtBound2"; TxtBound2.Size = new Size(65, 25); @@ -292,7 +297,7 @@ private void InitializeComponent() // TxtBound3.Enabled = false; TxtBound3.Font = new Font("Consolas", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - TxtBound3.Location = new Point(266, 128); + TxtBound3.Location = new Point(266, 158); TxtBound3.Maximum = new decimal(new int[] { 300, 0, 0, 0 }); TxtBound3.Name = "TxtBound3"; TxtBound3.Size = new Size(65, 25); @@ -304,7 +309,7 @@ private void InitializeComponent() TxtSerialBaud.Enabled = false; TxtSerialBaud.Font = new Font("Consolas", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); TxtSerialBaud.Increment = new decimal(new int[] { 100, 0, 0, 0 }); - TxtSerialBaud.Location = new Point(201, 97); + TxtSerialBaud.Location = new Point(201, 127); TxtSerialBaud.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); TxtSerialBaud.Name = "TxtSerialBaud"; TxtSerialBaud.Size = new Size(130, 25); @@ -330,7 +335,10 @@ private void InitializeComponent() // groupBox1 // groupBox1.Controls.Add(ChkCustomizeConfiguration); + groupBox1.Controls.Add(LblControllerType); + groupBox1.Controls.Add(RadPS4); groupBox1.Controls.Add(LblTotalLeds); + groupBox1.Controls.Add(RadPS3); groupBox1.Controls.Add(TxtNumLeds); groupBox1.Controls.Add(LblMacAddress); groupBox1.Controls.Add(TxtSerialBaud); @@ -340,31 +348,66 @@ private void InitializeComponent() groupBox1.Controls.Add(TxtBound2); groupBox1.Controls.Add(LblBoundaries); groupBox1.Controls.Add(TxtBound1); - groupBox1.Location = new Point(29, 150); + groupBox1.Location = new Point(29, 136); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(368, 181); + groupBox1.Size = new Size(368, 201); groupBox1.TabIndex = 23; groupBox1.TabStop = false; // + // LblControllerType + // + LblControllerType.AutoSize = true; + LblControllerType.Enabled = false; + LblControllerType.Location = new Point(40, 69); + LblControllerType.Name = "LblControllerType"; + LblControllerType.Size = new Size(91, 15); + LblControllerType.TabIndex = 22; + LblControllerType.Text = "Controller Type:"; + // + // RadPS4 + // + RadPS4.AutoSize = true; + RadPS4.Enabled = false; + RadPS4.Location = new Point(271, 67); + RadPS4.Name = "RadPS4"; + RadPS4.Size = new Size(44, 19); + RadPS4.TabIndex = 30; + RadPS4.Text = "PS4"; + RadPS4.UseVisualStyleBackColor = true; + // + // RadPS3 + // + RadPS3.AutoSize = true; + RadPS3.Checked = true; + RadPS3.Enabled = false; + RadPS3.Location = new Point(219, 67); + RadPS3.Name = "RadPS3"; + RadPS3.Size = new Size(44, 19); + RadPS3.TabIndex = 29; + RadPS3.TabStop = true; + RadPS3.Text = "PS3"; + RadPS3.UseVisualStyleBackColor = true; + // // LblInstalledVersion // LblInstalledVersion.BackColor = SystemColors.ControlDark; LblInstalledVersion.BorderStyle = BorderStyle.None; LblInstalledVersion.Font = new Font("Segoe UI", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - LblInstalledVersion.Location = new Point(600, 81); + LblInstalledVersion.Location = new Point(615, 67); LblInstalledVersion.Name = "LblInstalledVersion"; - LblInstalledVersion.Size = new Size(142, 21); + LblInstalledVersion.Size = new Size(69, 21); LblInstalledVersion.TabIndex = 25; LblInstalledVersion.Text = "N/A"; + LblInstalledVersion.TextChanged += LblInstalledVersion_TextChanged; // // LblLatestRelease // LblLatestRelease.BackColor = SystemColors.ControlDark; LblLatestRelease.BorderStyle = BorderStyle.None; LblLatestRelease.Font = new Font("Segoe UI", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); - LblLatestRelease.Location = new Point(600, 105); + LblLatestRelease.Location = new Point(787, 67); LblLatestRelease.Name = "LblLatestRelease"; - LblLatestRelease.Size = new Size(142, 21); + LblLatestRelease.Size = new Size(96, 21); LblLatestRelease.TabIndex = 26; LblLatestRelease.Text = "N/A"; // @@ -372,7 +415,7 @@ private void InitializeComponent() // label1.AutoSize = true; label1.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 0); - label1.Location = new Point(492, 83); + label1.Location = new Point(509, 69); label1.Margin = new Padding(0); label1.Name = "label1"; label1.Size = new Size(106, 17); @@ -383,19 +426,43 @@ private void InitializeComponent() // label2.AutoSize = true; label2.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 0); - label2.Location = new Point(497, 107); + label2.Location = new Point(683, 69); label2.Margin = new Padding(0); label2.Name = "label2"; label2.Size = new Size(101, 17); label2.TabIndex = 28; label2.Text = "Latest Available:"; // + // ChkClearMemory + // + ChkClearMemory.AutoSize = true; + ChkClearMemory.Location = new Point(615, 329); + ChkClearMemory.Name = "ChkClearMemory"; + ChkClearMemory.Size = new Size(119, 19); + ChkClearMemory.TabIndex = 29; + ChkClearMemory.Text = "Clear High Score?"; + ChkClearMemory.UseVisualStyleBackColor = true; + ChkClearMemory.CheckedChanged += ChkClearMemory_CheckedChanged; + // + // LblUpdateAlert + // + LblUpdateAlert.BackColor = SystemColors.ControlDark; + LblUpdateAlert.BorderStyle = BorderStyle.None; + LblUpdateAlert.Font = new Font("Segoe UI", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 0); + LblUpdateAlert.Location = new Point(466, 88); + LblUpdateAlert.Name = "LblUpdateAlert"; + LblUpdateAlert.Size = new Size(432, 21); + LblUpdateAlert.TabIndex = 30; + LblUpdateAlert.Text = ""; + // // LumenLabInstallerForm // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = SystemColors.ControlDark; ClientSize = new Size(944, 566); + Controls.Add(LblUpdateAlert); + Controls.Add(ChkClearMemory); Controls.Add(label2); Controls.Add(label1); Controls.Add(LblLatestRelease); @@ -464,5 +531,10 @@ private void InitializeComponent() private ToolStripMenuItem loadConfigToolStripMenuItem; private Label label1; private Label label2; + private RadioButton RadPS3; + private RadioButton RadPS4; + private Label LblControllerType; + private CheckBox ChkClearMemory; + private RichTextBox LblUpdateAlert; } } diff --git a/LumenLabInstallerForm.cs b/LumenLabInstallerForm.cs index 1fc83d7..3229418 100644 --- a/LumenLabInstallerForm.cs +++ b/LumenLabInstallerForm.cs @@ -82,7 +82,7 @@ private async void LumenLabInstallerForm_Shown(object sender, EventArgs e) try { await QueryGitHub(); - await ReadDevice(); + await ReadConnectedDeviceVersion(); } catch (Exception ex) { @@ -127,7 +127,7 @@ private async Task QueryGitHub() // PopulateReleaseTable(releases); } - private async Task ReadDevice() + private async Task ReadConnectedDeviceVersion() { BtnSync.Enabled = false; this.UseWaitCursor = true; @@ -175,11 +175,19 @@ private void AppendLog(string text) private async void BtnFlashFirmware_Click(object sender, EventArgs e) { BtnFlashFirmware.Enabled = false; + string? port = await _deviceService.DetectLumenLabPortAsync(); + if (port == null) + { + LblInstalledVersion.Text = "N/A"; + MessageBox.Show("LumenLab was disconnected. Please connect the device and run again.", "No LumenLab detected", MessageBoxButtons.RetryCancel, MessageBoxIcon.Stop); + return; + } + var selectedRelease = GetSelectedRelease(); if (selectedRelease == null) { - MessageBox.Show("Please select a version to install."); + MessageBox.Show("Please select a version to install.", "Select Version", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -187,7 +195,7 @@ private async void BtnFlashFirmware_Click(object sender, EventArgs e) if (selectedReleaseVersionId < _context.FirmwareVersion) { - var result = MessageBox.Show($"You are about to install LumenLab version {selectedReleaseVersionId}, however you already have a newer version {_context.FirmwareVersion} installed.\n\nAre you sure you want to downgrade?", "Continue with downgrade?", MessageBoxButtons.OKCancel); + var result = MessageBox.Show($"You are about to install LumenLab version {selectedReleaseVersionId}, however you already have a newer version {_context.FirmwareVersion} installed.\n\nAre you sure you want to downgrade?", "Continue with downgrade?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); MessageBox.Show($"You selected {result}"); } @@ -223,7 +231,7 @@ private async void BtnFlashFirmware_Click(object sender, EventArgs e) } private async void BtnSync_Click(object sender, EventArgs e) { - await ReadDevice(); + await ReadConnectedDeviceVersion(); } private GitHubRelease? GetSelectedRelease() @@ -244,6 +252,9 @@ private void ChkCustomizeConfiguration_CheckedChanged(object sender, EventArgs e TxtNumLeds.Enabled = !TxtNumLeds.Enabled; LblTotalLeds.Enabled = !LblTotalLeds.Enabled; + LblControllerType.Enabled = !LblControllerType.Enabled; + RadPS3.Enabled = !RadPS3.Enabled; + TxtMacAddress.Enabled = !TxtMacAddress.Enabled; LblMacAddress.Enabled = !LblMacAddress.Enabled; @@ -269,5 +280,19 @@ private void toggleDebugWindowToolStripMenuItem_Click(object sender, EventArgs e this.Height -= outputBox.Height; } } + + private void ChkClearMemory_CheckedChanged(object sender, EventArgs e) + { + if (ChkClearMemory.Checked) + { + MessageBox.Show("Nice try, cheater.", "Failed to erase high score ", MessageBoxButtons.OK, MessageBoxIcon.Error); + ChkClearMemory.Checked = false; + } + } + + private void LblInstalledVersion_TextChanged(object sender, EventArgs e) + { + + } } } diff --git a/LumenLabInstallerForm.resx b/LumenLabInstallerForm.resx index 9915450..0ad3897 100644 --- a/LumenLabInstallerForm.resx +++ b/LumenLabInstallerForm.resx @@ -525,7 +525,7 @@ 132, 17 - 30 + 25 From 836f0c894ab6559aa2cf1d40dade6697b16fb8a7 Mon Sep 17 00:00:00 2001 From: Eric McDaniel Date: Sat, 7 Mar 2026 11:00:09 -0600 Subject: [PATCH 2/3] Check if device is plugged in --- LumenLabInstallerForm.Designer.cs | 8 ++++++-- LumenLabInstallerForm.cs | 21 ++++++++++++++++++--- Models/GitHubRelease.cs | 20 ++++++++++---------- Services/GitHubReleaseService.cs | 8 +++----- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/LumenLabInstallerForm.Designer.cs b/LumenLabInstallerForm.Designer.cs index 58359cd..ecd9b19 100644 --- a/LumenLabInstallerForm.Designer.cs +++ b/LumenLabInstallerForm.Designer.cs @@ -1,4 +1,6 @@ -namespace LumenLabInstaller +using System.Windows.Forms; + +namespace LumenLabInstaller { partial class LumenLabInstallerForm { @@ -453,7 +455,9 @@ private void InitializeComponent() LblUpdateAlert.Name = "LblUpdateAlert"; LblUpdateAlert.Size = new Size(432, 21); LblUpdateAlert.TabIndex = 30; - LblUpdateAlert.Text = ""; + LblUpdateAlert.Text = "Plug in your LumenLab to continue."; + LblUpdateAlert.SelectAll(); + LblUpdateAlert.SelectionAlignment = HorizontalAlignment.Center; // // LumenLabInstallerForm // diff --git a/LumenLabInstallerForm.cs b/LumenLabInstallerForm.cs index 3229418..89ab15d 100644 --- a/LumenLabInstallerForm.cs +++ b/LumenLabInstallerForm.cs @@ -153,6 +153,7 @@ private async Task ReadConnectedDeviceVersion() LblInstalledVersion.Text = $"v{_context.FirmwareVersion.ToString()}"; outputBox.AppendText($"{version}{Environment.NewLine}"); + //if (_context.FirmwareVersion == ) BtnFlashFirmware.Enabled = true; } @@ -193,10 +194,24 @@ private async void BtnFlashFirmware_Click(object sender, EventArgs e) var selectedReleaseVersionId = new Version(selectedRelease.TagName.Substring(1)); - if (selectedReleaseVersionId < _context.FirmwareVersion) + DialogResult userDialogSelection; + if (selectedReleaseVersionId == _context.FirmwareVersion) { - var result = MessageBox.Show($"You are about to install LumenLab version {selectedReleaseVersionId}, however you already have a newer version {_context.FirmwareVersion} installed.\n\nAre you sure you want to downgrade?", "Continue with downgrade?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); - MessageBox.Show($"You selected {result}"); + userDialogSelection = MessageBox.Show($"You are about to install LumenLab version {selectedReleaseVersionId}, however you already have a that version installed.\n\nAre you sure you want to overwrite?", "Continue with overwrite?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); + if (userDialogSelection == DialogResult.Cancel) + { + MessageBox.Show("LumenLab firmware upgrade operation cancelled.", "Operation canceled", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + } + else if (selectedReleaseVersionId < _context.FirmwareVersion) + { + userDialogSelection = MessageBox.Show($"You are about to install LumenLab version {selectedReleaseVersionId}, however you already have a newer version {_context.FirmwareVersion} installed.\n\nAre you sure you want to downgrade?", "Continue with downgrade?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); + if (userDialogSelection == DialogResult.Cancel) + { + MessageBox.Show("LumenLab firmware upgrade operation cancelled.", "Operation canceled", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } } MessageBox.Show(selectedRelease.TagName); diff --git a/Models/GitHubRelease.cs b/Models/GitHubRelease.cs index 676f43f..d545999 100644 --- a/Models/GitHubRelease.cs +++ b/Models/GitHubRelease.cs @@ -9,39 +9,39 @@ namespace LumenLabInstaller.Models { public class GitHubRelease { - public string TagName { get; set; } + public string? TagName { get; set; } public DateTime PublishedAt { get; set; } - public string Name { get; set; } - public List Assets { get; set; } = new(); + public string? Name { get; set; } + public List Assets { get; set; } = []; } public class GitHubAsset { - public string Name { get; set; } - public string BrowserDownloadUrl { get; set; } + public string? Name { get; set; } + public string? BrowserDownloadUrl { get; set; } } public class GitHubReleaseApiModel { [JsonPropertyName("tag_name")] - public string TagName { get; set; } + public string? TagName { get; set; } [JsonPropertyName("published_at")] public DateTime PublishedAt { get; set; } [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get; set; } [JsonPropertyName("assets")] - public List Assets { get; set; } + public List? Assets { get; set; } } public class GitHubAssetApiModel { [JsonPropertyName("name")] - public string Name { get; set; } + public string? Name { get; set; } [JsonPropertyName("browser_download_url")] - public string BrowserDownloadUrl { get; set; } + public string? BrowserDownloadUrl { get; set; } } } diff --git a/Services/GitHubReleaseService.cs b/Services/GitHubReleaseService.cs index 6b93207..545c989 100644 --- a/Services/GitHubReleaseService.cs +++ b/Services/GitHubReleaseService.cs @@ -31,9 +31,7 @@ public async Task> GetReleasesAsync() var requiredAssets = new HashSet(StringComparer.OrdinalIgnoreCase) { - "firmware.bin", - "bootloader.bin", - "partitions.bin" + "lumenlab-firmware.zip" // can be expanded to include PS4 controllers }; var filtered = apiReleases.Select(r => new GitHubRelease @@ -45,11 +43,11 @@ public async Task> GetReleasesAsync() { Name = a.Name, BrowserDownloadUrl = a.BrowserDownloadUrl - }).ToList() ?? new List() + }).ToList() ?? [] }) .Where(release => { - if (release.Assets.Count < 3) return false; + if (release.Assets.Count != 1) return false; var assetNames = release.Assets .Select(a => a.Name) From b438faa769e0b9aa259b61b33fbcca39c33082af Mon Sep 17 00:00:00 2001 From: Eric McDaniel Date: Sat, 7 Mar 2026 12:00:29 -0600 Subject: [PATCH 3/3] Remove null dereference --- LumenLabInstallerForm.Designer.cs | 1 - LumenLabInstallerForm.cs | 37 +++++++++---------- Models/GitHubRelease.cs | 6 +-- ...tallerContextcs.cs => InstallerContext.cs} | 2 + 4 files changed, 23 insertions(+), 23 deletions(-) rename Models/{InstallerContextcs.cs => InstallerContext.cs} (86%) diff --git a/LumenLabInstallerForm.Designer.cs b/LumenLabInstallerForm.Designer.cs index ecd9b19..c47e021 100644 --- a/LumenLabInstallerForm.Designer.cs +++ b/LumenLabInstallerForm.Designer.cs @@ -400,7 +400,6 @@ private void InitializeComponent() LblInstalledVersion.Size = new Size(69, 21); LblInstalledVersion.TabIndex = 25; LblInstalledVersion.Text = "N/A"; - LblInstalledVersion.TextChanged += LblInstalledVersion_TextChanged; // // LblLatestRelease // diff --git a/LumenLabInstallerForm.cs b/LumenLabInstallerForm.cs index 89ab15d..ee9f13e 100644 --- a/LumenLabInstallerForm.cs +++ b/LumenLabInstallerForm.cs @@ -20,8 +20,7 @@ public partial class LumenLabInstallerForm : Form private readonly FirmwareService _firmwareService; private readonly BinaryDownloadService _downloadService; - private List _availableReleases = new(); - private BindingSource _releaseBindingSource = new(); + private BindingSource _releaseBindingSource = []; public LumenLabInstallerForm(BinaryDownloadService downloadService, @@ -98,15 +97,15 @@ private async Task QueryGitHub() var releaseService = new GitHubReleaseService(); var releases = await releaseService.GetReleasesAsync(); - _availableReleases = releases; + _context.AvailableReleases = releases.OrderByDescending(r => r.PublishedAt).ToList(); var gridRows = releases .OrderByDescending(r => r.PublishedAt) .Select(r => new ReleaseGridRow { - TagName = r.TagName, - Name = r.Name.Substring(r.Name.IndexOf("-") + 2), - PublishedAt = r.PublishedAt, + TagName = r.TagName ?? string.Empty, + Name = r.Name?.Substring(r.Name.IndexOf("-") + 2) ?? string.Empty, + PublishedAt = r.PublishedAt ?? new DateTime(), Release = r }) .ToList(); @@ -117,10 +116,10 @@ private async Task QueryGitHub() foreach (var release in releases) { - outputBox.AppendText($"{release.TagName} - {release.PublishedAt}{Environment.NewLine}"); + WriteToLogs($"{release.TagName} - {release.PublishedAt}"); foreach (var asset in release.Assets) { - outputBox.AppendText($" Asset: {asset.Name} -> {asset.BrowserDownloadUrl}{Environment.NewLine}"); + WriteToLogs($" Asset: {asset.Name} -> {asset.BrowserDownloadUrl}"); } } @@ -134,30 +133,30 @@ private async Task ReadConnectedDeviceVersion() BtnFlashFirmware.Enabled = false; LblInstalledVersion.Text = "N/A"; - outputBox.AppendText($"Scanning USB ports to find LumenLab.{Environment.NewLine}"); + WriteToLogs($"Scanning USB ports to find LumenLab."); string? port = await _deviceService.DetectLumenLabPortAsync(); _context.PortName = port; if (port == null) { - outputBox.AppendText("LumenLab not detected." + Environment.NewLine); + WriteToLogs("LumenLab not detected."); } else { - outputBox.AppendText($"LumenLab detected on {port}" + Environment.NewLine); + WriteToLogs($"LumenLab detected on {port}"); string version = await _firmwareService.ReadFirmwareVersionAsync(port); _context.FirmwareVersion = new Version(version.Substring(1)); LblInstalledVersion.Text = $"v{_context.FirmwareVersion.ToString()}"; - outputBox.AppendText($"{version}{Environment.NewLine}"); + WriteToLogs(version); //if (_context.FirmwareVersion == ) BtnFlashFirmware.Enabled = true; } - outputBox.AppendText($"Scan complete.{Environment.NewLine}"); + WriteToLogs($"Scan complete."); BtnSync.Enabled = true; this.UseWaitCursor = false; } @@ -170,7 +169,7 @@ private void AppendLog(string text) return; } - outputBox.AppendText(text + Environment.NewLine); + WriteToLogs(text); } private async void BtnFlashFirmware_Click(object sender, EventArgs e) @@ -224,14 +223,14 @@ private async void BtnFlashFirmware_Click(object sender, EventArgs e) //try //{ // var cts = new CancellationTokenSource(); - // outputBox.AppendText("Downloading LumenLab v0.3.0." + Environment.NewLine); + // WriteToLogs("Downloading LumenLab v0.3.0."); // var result = await _downloadService.DownloadAsync( // new Uri("https://github.com/ericmcdaniel/lumenlab/archive/refs/tags/v0.3.0.zip"), // Path.Combine(AppPaths.BinariesPath, "lumenlab_v0-3-0.zip") // ); - // outputBox.AppendText("Download complete." + Environment.NewLine); - // outputBox.AppendText($"Downloaded {result.BytesWritten.Bytes()}." + Environment.NewLine); + // WriteToLogs("Download complete."); + // WriteToLogs($"Downloaded {result.BytesWritten.Bytes()}."); // await ToolManager.RunEsptoolAsync("--chip esp32 --baud 921600 write_flash -z 0x1000 C:\\Users\\McDan\\development\\lumenlab\\.pio\\build\\release\\bootloader.bin 0x8000 C:\\Users\\McDan\\development\\lumenlab\\.pio\\build\\release\\partitions.bin 0x10000 C:\\Users\\McDan\\development\\lumenlab\\.pio\\build\\release\\firmware.bin", AppendLog, cts.Token); //} @@ -305,9 +304,9 @@ private void ChkClearMemory_CheckedChanged(object sender, EventArgs e) } } - private void LblInstalledVersion_TextChanged(object sender, EventArgs e) + private void WriteToLogs(string log) { - + outputBox.AppendText($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}] - {log}{Environment.NewLine}"); } } } diff --git a/Models/GitHubRelease.cs b/Models/GitHubRelease.cs index d545999..7f21162 100644 --- a/Models/GitHubRelease.cs +++ b/Models/GitHubRelease.cs @@ -10,9 +10,9 @@ namespace LumenLabInstaller.Models public class GitHubRelease { public string? TagName { get; set; } - public DateTime PublishedAt { get; set; } + public DateTime? PublishedAt { get; set; } public string? Name { get; set; } - public List Assets { get; set; } = []; + public List? Assets { get; set; } = []; } public class GitHubAsset @@ -27,7 +27,7 @@ public class GitHubReleaseApiModel public string? TagName { get; set; } [JsonPropertyName("published_at")] - public DateTime PublishedAt { get; set; } + public DateTime? PublishedAt { get; set; } [JsonPropertyName("name")] public string? Name { get; set; } diff --git a/Models/InstallerContextcs.cs b/Models/InstallerContext.cs similarity index 86% rename from Models/InstallerContextcs.cs rename to Models/InstallerContext.cs index 9b554b2..d4e96ec 100644 --- a/Models/InstallerContextcs.cs +++ b/Models/InstallerContext.cs @@ -13,5 +13,7 @@ public sealed class InstallerContext public Version? FirmwareVersion { get; set; } public bool DeviceDetected => !string.IsNullOrWhiteSpace(PortName); + + public List? AvailableReleases = []; } }