示例#1
0
        private void addMultiButton_Click(object sender, EventArgs e)
        {
            int index = Convert.ToInt32(addMultiIndex.Value);
            int value = Convert.ToInt32(addMultiValue.Value);

            if (index >= gridMultiset.Count)
            {
                MessageBox.Show("Index nie może być większy niż max index: " + (gridMultiset.Count - 1).ToString() + ".\n" + "Aby dodać element na końcu zbioru wpisz index: -1 ");
            }
            else if (index == -1)
            {
                gridMultiset.Add(new multiSet()
                {
                    elementOfmultiSet = value
                });
                MultisetGrid.Refresh();
            }
            else
            {
                gridMultiset.Insert(index, new multiSet()
                {
                    elementOfmultiSet = value
                });
                MultisetGrid.Refresh();
            }
        }
示例#2
0
        private void MistakesButton_Click(object sender, EventArgs e)
        {
            Random randomNumber = new Random();
            int    minValue     = 1;
            int    maxValue     = 100;
            int    mistakes     = Convert.ToInt32(NumMistakes.Value);

            if (mistakes == 0)
            {
                MessageBox.Show("Nie można wstawić 0 błędów " + "\n");
            }
            if (mistakes > gridMultiset.Count)
            {
                MessageBox.Show("Nie można wstawić więcej błędów niż liczba elementów: " + gridMultiset.Count.ToString() + "\n");
            }
            else
            {
                for (int i = 0; i < mistakes; i++)
                {
                    int index = randomNumber.Next(0, gridMultiset.Count);
                    int value = randomNumber.Next(minValue: minValue, maxValue: maxValue);
                    gridMultiset[index] = new multiSet()
                    {
                        elementOfmultiSet = value
                    };
                }
                MultisetGrid.Refresh();
            }
        }
示例#3
0
 // ------------- DELETE FROM GRID -------------
 private void MultisetGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     if (e.ColumnIndex == 1)
     {
         gridMultiset.RemoveAt(e.RowIndex);
         MultisetGrid.Refresh();
     }
 }