Exemplo n.º 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);
     }
 }
Exemplo n.º 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());
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
     }
 }