private void addCounterBtn_Click(object sender, EventArgs e) { String category = categoryCb.Text.ToString(); String instance = instanceCb.Text.ToString(); String name = nameCb.Text.ToString(); decimal criticalValue = numericUpDown1.Value; decimal sampleAmount = numericUpDown3.Value; bool isAbove = isAboveRadio.Checked; if (String.IsNullOrEmpty(category) || String.IsNullOrEmpty(name) || criticalValue == 0) { MessageBox.Show("Proszę wybrać wszystkie wartości"); return; } else { try { PerfCounter newCounter = new PerfCounter(category, instance, name, (int)sampleAmount, (float)criticalValue, isAbove); counters.Add(newCounter); categoryCb.Text = ""; instanceCb.Text = ""; nameCb.Text = ""; numericUpDown1.Value = 0; instanceCb.Enabled = false; nameCb.Enabled = false; addCounterToDataView(newCounter.getName(), newCounter.getQueueSize(), newCounter.getCritivalValue(), isAbove); } catch (System.InvalidOperationException ex) { MessageBox.Show("Nie udało się dodać licznika: " + ex.Message); } } }