-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathForm2.cs
66 lines (58 loc) · 1.93 KB
/
Form2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Blaseball_Livestream
{
public partial class Form2 : Form
{
SelectedSeason selectedSeason;
public Form2(List<SaveGame> saveGames, SelectedSeason selector)
{
InitializeComponent();
selectedSeason = selector;
List<int> seasons = new List<int>();
foreach(SaveGame game in saveGames)
{
if (!seasons.Contains(game.seasonTracked)) { seasons.Add(game.seasonTracked); }
}
foreach(int seasonNum in seasons)
{
listBoxSeasons.Items.Add(new SeasonDisplay(seasonNum));
}
listBoxSeasons.Items.Add(new SeasonDisplay(-1));
listBoxSeasons.SetSelected(0, true);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void SeasonAccept_Click(object sender, EventArgs e)
{
selectedSeason.seasonDisplay = listBoxSeasons.SelectedItem as SeasonDisplay;
if (selectedSeason.seasonDisplay != null) { Close(); }
}
}
public class SeasonDisplay : IComparable<SeasonDisplay>
{
public SeasonDisplay(int newIndex)
{
index = newIndex;
}
public int index;
public override string ToString()
{
if(index == -1) { return "All seasons"; }
else if (index % 10000 == 0) { return string.Concat("Season ", ((index / 10000) + 1).ToString()); }
else { return string.Concat("Postseason ", ((index - 5000) / 10000) + 1).ToString(); }
}
public int CompareTo(SeasonDisplay other)
{
return other.index.CompareTo(index);
}
}
}