Skip to content

Commit

Permalink
Merge pull request #7 from lansalot/NewFeatures
Browse files Browse the repository at this point in the history
Fixed CSV path and also refresh if no CSV
  • Loading branch information
lansalot authored Apr 18, 2024
2 parents d90d67b + 12909f4 commit ce6ff8e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions TeensyFlasher/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ void LogMessage(string Text)
}
void UpdateFirmwareBox()
{
foreach (var line in File.ReadAllLines(localCSV))
lbFirmware.DataSource = null;
teensyFirmwareItems.Clear();
if (File.Exists(localCSV))
{
var parts = line.Split(',');
teensyFirmwareItems.Add(new TeensyFirmwareItem(parts[0], parts[1]));
foreach (var line in File.ReadAllLines(localCSV))
{
var parts = line.Split(',');
teensyFirmwareItems.Add(new TeensyFirmwareItem(parts[0], parts[1]));
}
}
var hexFiles = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.hex");
foreach (var hexFile in hexFiles)
Expand All @@ -86,6 +91,7 @@ void UpdateFirmwareBox()
lbFirmware.DisplayMember = "DisplayText";
lbFirmware.ValueMember = "Location";
lbFirmware.SelectedIndex = -1;
lbFirmware.Refresh();
// add any *.hex files in current folder to the list

}
Expand All @@ -99,10 +105,7 @@ public frmMain()
lbTeensies.Items.Add(teensy);
}
if (lbTeensies.Items.Count > 0) lbTeensies.SelectedIndex = 0;
if (File.Exists(localCSV))
{
UpdateFirmwareBox();
}
UpdateFirmwareBox();
}

private void ConnectedTeensiesChanged(object sender, NotifyCollectionChangedEventArgs e)
Expand Down Expand Up @@ -161,7 +164,7 @@ bool DownloadFile(string url, string localFile)
}
private void btnRefreshTeensy_Click(object sender, EventArgs e)
{
string url = "https://raw.githubusercontent.com/lansalot/AOGConfigOMatic/main/Firmwares.csv";
string url = "https://raw.githubusercontent.com/lansalot/AOGConfigOMatic/main/TeensyFlasher/Firmwares.csv";
DownloadFile(url, localCSV);
UpdateFirmwareBox();
}
Expand Down

0 comments on commit ce6ff8e

Please sign in to comment.