Exemple #1
0
 private void cmdSample_Click(object sender, EventArgs e)
 {
     try
     {
         PerfCounterCollectorEntry currentEntry = null;
         if (optCommon.Checked)
         {
             currentEntry = PerfCounterCollectorEntry.FromStringDefinition(txtComputerName.Text + "\\" + cboPerformanceCounter.Text);
         }
         else
         {
             currentEntry = PerfCounterCollectorEntry.FromStringDefinition(txtPerfCounter.Text);
         }
         if (currentEntry == null || currentEntry.Computer.Length == 0)
         {
             MessageBox.Show("Performance counter definition could not be created!", "Definition", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             float val = currentEntry.GetNextValue();
             Clipboard.SetText(val.ToString("F4"));
             MessageBox.Show(string.Format("Current value: {0}", val.ToString("F4")), "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
        public QuickMonDialogResult ShowEditEntry()
        {
            if (SelectedEntry == null)
            {
                SelectedEntry = PerfCounterCollectorEntry.FromStringDefinition(".\\Processor\\% Processor Time\\_Total");
            }
            cboPerformanceCounter.Items.Clear();
            cboPerformanceCounter.Items.AddRange(commonEntries.ToArray());

            LoadEntryDetails();

            return((QuickMonDialogResult)ShowDialog());
        }
Exemple #3
0
        private void cmdEditPerfCounter_Click(object sender, EventArgs e)
        {
            PerfCounterCollectorEntry thisEntry = PerfCounterCollectorEntry.FromStringDefinition(txtPerfCounter.Text);

            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)
            {
                SelectedEntry       = editPerfCounter.SelectedPCInstance;
                txtPerfCounter.Text = editPerfCounter.SelectedPCInstance.Description;
            }
        }
Exemple #4
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (IsValid())
         {
             PerfCounterCollectorEntry currentEntry = null;
             if (optCommon.Checked)
             {
                 currentEntry = PerfCounterCollectorEntry.FromStringDefinition(txtComputerName.Text + "\\" + cboPerformanceCounter.Text);
             }
             else
             {
                 currentEntry = PerfCounterCollectorEntry.FromStringDefinition(txtPerfCounter.Text);
             }
             if (currentEntry == null || currentEntry.Computer.Length == 0)
             {
                 MessageBox.Show("Performance counter definition could not be created!", "Definition", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 currentEntry.WarningValue = (float)warningNumericUpDown.Value;
                 currentEntry.ErrorValue   = (float)errorNumericUpDown.Value;
                 currentEntry.NumberOfSamplesPerRefresh = (int)nudNumberOfSamplesPerRefresh.Value;
                 currentEntry.MultiSampleWaitMS         = (int)nudMultiSampleWaitMS.Value;
                 SelectedEntry = currentEntry;
                 DialogResult  = System.Windows.Forms.DialogResult.OK;
                 Close();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }