Otw[] DrillSortList(Otw[] temp) { Otw temp_x; // sortujemy tymczasowa tablice for (int i = 0; i < 100; i++) { for (int j = 1; j < 100; j++) { if (temp[j].srednica < temp[j - 1].srednica && temp[j].srednica > 0) { temp_x = temp[j]; temp[j] = temp[j - 1]; temp[j - 1] = temp_x; } } } return temp; }
Otw[] DrillDiamList() { Otw[] temp = new Otw[100]; // sprawdzamy czy w oknie sa jakies srednice otworow if (ListaOtworowListBox.Items.Count > 0) { // zczytujemy liste srednic z okna for (int i = 0; i < ListaOtworowListBox.Items.Count; i++) { temp[i].stan = ListaOtworowListBox.GetItemCheckState(i); temp[i].srednica = Convert.ToDouble(ListaOtworowListBox.Items[i]); } } else { // jesli nie ma, robimy nowa liste double[] tablica = new double[100]; bool jest_srednica = true; int various_drills = 1; tablica[0] = ListOfDrills[0].diameter; temp[0].srednica = Convert.ToDouble(ListOfDrills[0].diameter); temp[0].stan = CheckState.Checked; for (int i = 1; i < ListOfDrills.Count; i++) { for (int j = 0; j < various_drills; j++) { // sprawdzamy czy dana średnica otworu jest już obecna if (tablica[j] != ListOfDrills[i].diameter && tablica[j] > 0) jest_srednica = false; else { jest_srednica = true; break; } } // jeśli nie jest obecna, to dopisujemy do listy if (!jest_srednica) { tablica[various_drills] = ListOfDrills[i].diameter; temp[various_drills].srednica = Convert.ToDouble(ListOfDrills[i].diameter); temp[various_drills++].stan = CheckState.Checked; } } } return temp; }
void DrillFillList(Otw[] temp) { ListaOtworowListBox.Items.Clear(); // uzupelniamy liste otworow for (int i = 0; i < 100; i++) { if (temp[i].srednica > 0) ListaOtworowListBox.Items.Add(temp[i].srednica, temp[i].stan); } }