//Reloads the listview with packages private void ReloadPackageList() { updatingData = true; listViewPackages.Items.Clear(); listViewPackages.SelectedIndices.Clear(); selectedPackage = new CP_ConfigData(); foreach (CP_ConfigData package in packages) { ListViewItem lvi = new ListViewItem(package.packageName); listViewPackages.Items.Add(lvi); } if (selectedIndex < packages.Count && selectedIndex > -1) { listViewPackages.SelectedIndices.Add(selectedIndex); selectedPackage = packages[selectedIndex]; } SetInfoBox(); updatingData = false; }
//Add empty package to list private void buttonAddPackage_Click(object sender, EventArgs e) { CP_ConfigData newPackage = new CP_ConfigData(); packages.Add(newPackage); ReloadPackageList(); }
//Selects a new package and reloads info box private void listViewPackages_SelectedIndexChanged(object sender, EventArgs e) { if (!updatingData && listViewPackages.SelectedIndices.Count > 0) { selectedIndex = listViewPackages.SelectedIndices[0]; selectedPackage = packages[selectedIndex]; SetInfoBox(); } }