private void PerfCounterEditAlert_Shown(object sender, EventArgs e) { currentEntry = new PerfCounterCollectorEntry(); if (SelectedEntry != null) { currentEntry = ((PerfCounterCollectorEntry)SelectedEntry).Clone(); } else //Show add performance window. { PerfCounterEdit editPerfCounter = new PerfCounterEdit(); editPerfCounter.InitialMachine = InitialMachine; editPerfCounter.InitialCategory = "Processor"; editPerfCounter.InitialCounter = "% Processor Time"; editPerfCounter.InitialInstance = "_Total"; if (editPerfCounter.ShowDialog() == System.Windows.Forms.DialogResult.OK) { currentEntry = editPerfCounter.SelectedPCInstance; } else { DialogResult = System.Windows.Forms.DialogResult.Cancel; Close(); return; } } txtPerfCounter.Text = currentEntry.ToString(); warningNumericUpDown.Value = (decimal)currentEntry.WarningValue; errorNumericUpDown.Value = (decimal)currentEntry.ErrorValue; }
private void cmdEditPerfCounter_Click(object sender, EventArgs e) { PerfCounterCollectorEntry thisEntry = (PerfCounterCollectorEntry)currentEntry; PerfCounterEdit editPerfCounter = new PerfCounterEdit(); editPerfCounter.InitialMachine = thisEntry.Computer; editPerfCounter.InitialCategory = thisEntry.Category; editPerfCounter.InitialCounter = thisEntry.Counter; editPerfCounter.InitialInstance = thisEntry.Instance; if (editPerfCounter.ShowDialog() == System.Windows.Forms.DialogResult.OK) { currentEntry = editPerfCounter.SelectedPCInstance; txtPerfCounter.Text = currentEntry.ToString(); } }