Skip to content

Commit

Permalink
Use Years.txt to get list of valid years.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSinn committed Apr 23, 2019
1 parent 20d0628 commit 4e93a4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
18 changes: 14 additions & 4 deletions CSAUSBTool/CSAUSBTool.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;

Expand Down Expand Up @@ -29,10 +30,7 @@ public CSAUSBTool(IReadOnlyList<string> args)
_competitions[9999] = new FrcSeason(9999, FrcSeason.GetWebList(args[0]));
}

//TODO: Find a better way of enumerating the valid years. Maybe a single file listing valid years?
_competitions[2019] = new FrcSeason(2019, FrcSeason.GetWebList(2019));
_competitions[2018] = new FrcSeason(2018, FrcSeason.GetWebList(2018));
_competitions[2017] = new FrcSeason(2017, FrcSeason.GetWebList(2017));
ValidYears().ForEach(year => _competitions[year] = new FrcSeason(year));

// Bind year objects to the selector.
yearSelection.DataSource = new BindingSource(_competitions, null);
Expand Down Expand Up @@ -124,6 +122,18 @@ private void downloadButton_Click(object sender, EventArgs e)
}
}

private List<int> ValidYears()
{
var years = new List<int>();
using (var client = new WebClient())
{
var data = client.DownloadString(new Uri("https://raw.githubusercontent.com/JamieSinn/CSA-USB-Tool/master/Years.txt"));
var lines = data.Split('\n').ToList();
lines.ForEach(line => years.Add(int.Parse(line)));
}

return years;
}
private void SelectedItems_SelectedIndexChanged(object sender, EventArgs e)
{
_selectedSoftwares.Clear();
Expand Down
5 changes: 5 additions & 0 deletions CSAUSBTool/FrcSeason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public class FrcSeason
public int Year;
public List<ControlSystemsSoftware> Software;

public FrcSeason(int year)
{
Year = year;
Software = GetWebList(year);
}
public FrcSeason(int year, List<ControlSystemsSoftware> software)
{
Year = year;
Expand Down
4 changes: 2 additions & 2 deletions Years.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2017
2019
2018
2019
2017

0 comments on commit 4e93a4d

Please sign in to comment.