//Add empty server to list private void buttonAddServer_Click(object sender, EventArgs e) { SB_ServerData newServer = new SB_ServerData(); servers.Add(newServer); ReloadServerList(); }
//Selects a new server and reloads info box private void listViewServers_SelectedIndexChanged(object sender, EventArgs e) { if (!updatingData && listViewServers.SelectedIndices.Count > 0) { selectedIndex = listViewServers.SelectedIndices[0]; selectedServer = servers[selectedIndex]; SetInfoBox(); } }
//Reloads the listview with servers private void ReloadServerList() { updatingData = true; listViewServers.Items.Clear(); listViewServers.SelectedIndices.Clear(); selectedServer = new SB_ServerData(); foreach (SB_ServerData server in servers) { ListViewItem lvi = new ListViewItem(server.serverName); listViewServers.Items.Add(lvi); } if (selectedIndex < servers.Count && selectedIndex > -1) { listViewServers.SelectedIndices.Add(selectedIndex); selectedServer = servers[selectedIndex]; } SetInfoBox(); updatingData = false; }