public static List <PCMonInstance> GetCountersFromCounterDefinitionList(string counterDefinitionList) { List <PCMonInstance> counters = new List <PCMonInstance>(); XmlDocument config = new XmlDocument(); config.LoadXml(counterDefinitionList); XmlElement root = config.DocumentElement; foreach (XmlNode n in root.GetElementsByTagName("string")) { PCMonInstance newCounter = new PCMonInstance(string.Format("<xml>{0}</xml>", n.InnerText)); counters.Add(newCounter); } return(counters); }
private void cmdOK_Click(object sender, EventArgs e) { if (CheckForValidCounter()) { SelectedPCMonInstances = new List <PCMonInstance>(); if (lvwInstance.Items.Count > 0) { foreach (ListViewItem lviCounter in lvwCounter.SelectedItems) { foreach (ListViewItem lviInst in lvwInstance.SelectedItems) { PCMonInstance newPCMonInstance = new PCMonInstance(); newPCMonInstance.Machine = txtComputer.Text; newPCMonInstance.Category = lvwCategory.SelectedItems[0].Text; newPCMonInstance.Counter = lviCounter.Text; newPCMonInstance.Instance = lviInst.Text; newPCMonInstance.Scale = double.Parse(cboScale.SelectedItem.ToString()); newPCMonInstance.SetName(); SelectedPCMonInstances.Add(newPCMonInstance); } } } else { foreach (ListViewItem lviCounter in lvwCounter.SelectedItems) { PCMonInstance newPCMonInstance = new PCMonInstance(); newPCMonInstance.Machine = txtComputer.Text; newPCMonInstance.Category = lvwCategory.SelectedItems[0].Text; newPCMonInstance.Counter = lviCounter.Text; newPCMonInstance.Instance = ""; newPCMonInstance.Scale = double.Parse(cboScale.SelectedItem.ToString()); newPCMonInstance.SetName(); SelectedPCMonInstances.Add(newPCMonInstance); } } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
public int CompareTo(object obj) { PCMonInstance otherInstance = (PCMonInstance)obj; return(CounterDefinition().CompareTo(otherInstance.CounterDefinition())); }
public override bool Equals(object obj) { PCMonInstance otherInstance = (PCMonInstance)obj; return(CompareTo(otherInstance) == 0);// CounterDefinition().Equals(otherInstance.CounterDefinition()); }
private void cmdOK_Click(object sender, EventArgs e) { if (txtComputer.Text.Length == 0) { MessageBox.Show("You must specify the computer!", "Computer", MessageBoxButtons.OK, MessageBoxIcon.Error); txtComputer.Focus(); } else if (cboCategory.SelectedIndex == -1) { MessageBox.Show("You must specify the category!", "Category", MessageBoxButtons.OK, MessageBoxIcon.Error); cboCategory.Focus(); } else if (cboCounter.SelectedIndex == -1) { MessageBox.Show("You must specify the counter!", "Counter", MessageBoxButtons.OK, MessageBoxIcon.Error); cboCounter.Focus(); } else if (cboInstance.Items.Count > 0 && cboInstance.SelectedIndex == -1) { MessageBox.Show("You must specify the instance!", "Instance", MessageBoxButtons.OK, MessageBoxIcon.Error); cboInstance.Focus(); } else if (cboScale.SelectedIndex == -1) { MessageBox.Show("You must specify the scale!", "Scale", MessageBoxButtons.OK, MessageBoxIcon.Error); cboScale.Focus(); } else { try { string key = txtComputer.Text + "\\" + cboCategory.Text + "\\" + cboCounter.Text + "\\"; if (cboInstance.Text.Length > 0) { if (cboInstance.Text.Contains("\\")) { key += "\"" + cboInstance.Text + "\""; } else { key += cboInstance.Text; } } key += "\\" + cboScale.SelectedItem.ToString(); key += "\\" + cboPlotStyle.SelectedIndex.ToString(); SelectedPCMonInstance = new PCMonInstance(key); SelectedPCMonInstance.Scale = double.Parse(cboScale.SelectedItem.ToString()); SelectedPCMonInstance.PlotStyle = cboPlotStyle.SelectedIndex; SelectedPCMonInstance.PlotColor = pictureBoxColor.BackColor; InitialColor = pictureBoxColor.BackColor; SelectedPCMonInstance.CreatePCInstance(); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }