private void LoadSelectedTemplate() { if (lvwTemplates.SelectedItems.Count == 1 && lvwTemplates.SelectedItems[0].Tag is QuickMonTemplate) { cboType.Enabled = cboTypeFilter.SelectedIndex == 5; txtName.Enabled = true; cboClass.Enabled = true; txtDescription.Enabled = true; QuickMonTemplate t = (QuickMonTemplate)lvwTemplates.SelectedItems[0].Tag; cboType.SelectedIndex = (int)t.TemplateType; txtName.Text = t.Name; cboClass.Text = t.ForClass; txtDescription.Text = t.Description; txtConfig.Text = XmlFormattingUtils.NormalizeXML(t.Config); SetSaveButton(false); } else { cboType.Enabled = lvwTemplates.SelectedItems.Count == 0 && cboTypeFilter.SelectedIndex == 5; txtName.Enabled = lvwTemplates.SelectedItems.Count == 0; cboClass.Enabled = lvwTemplates.SelectedItems.Count == 0; txtDescription.Enabled = lvwTemplates.SelectedItems.Count == 0; txtName.Text = ""; cboClass.Text = ""; txtDescription.Text = ""; txtConfig.Text = ""; SetSaveButton(false); } }
private void RAWXmlEditor_Load(object sender, EventArgs e) { if (SelectedMarkup != null && SelectedMarkup.Length > 0) { txtConfig.Text = XmlFormattingUtils.NormalizeXML(SelectedMarkup); } }
private void cmdFormat_Click(object sender, EventArgs e) { bool changedBefore = cmdSaveTemplate.Enabled; txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text); cmdSaveTemplate.Enabled = changedBefore; }
private void EditRAWMarkup_Load(object sender, EventArgs e) { if (SelectedMarkup != null) { txtConfig.Text = XmlFormattingUtils.NormalizeXML(SelectedMarkup); } }
private void llblRawEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (editingNotifierEntry.InitialConfiguration != null) { EditRAWMarkup editRaw = new EditRAWMarkup(); editRaw.SelectedMarkup = XmlFormattingUtils.NormalizeXML(editingNotifierEntry.InitialConfiguration); editRaw.AgentType = editingNotifierEntry.NotifierRegistrationName; editRaw.UseNotifierType = true; editRaw.CurrentMonitorPack = monitorPack; if (editRaw.ShowDialog() == System.Windows.Forms.DialogResult.OK) { editingNotifierEntry.CreateAndConfigureEntry(editingNotifierEntry.NotifierRegistrationName, editRaw.SelectedMarkup, true, false); if (editingNotifierEntry.Notifier != null && editingNotifierEntry.Notifier.AgentConfig != null) { INotifierConfig config = (INotifierConfig)editingNotifierEntry.Notifier.AgentConfig; lblConfigSummary.Text = config.ConfigSummary; } } } } catch (Exception ex) { MessageBox.Show(string.Format("Error setting configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void llblImportConfig_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { ImportCollectorConfig importCollectorConfig = new ImportCollectorConfig(); importCollectorConfig.IsCollector = !UseNotifierType; if (CurrentMonitorPack != null) { importCollectorConfig.CurrentMonitorPack = CurrentMonitorPack; } importCollectorConfig.AgentType = AgentType; if (importCollectorConfig.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtConfig.Text = XmlFormattingUtils.NormalizeXML(importCollectorConfig.SelectedConfig); } }
private void LoadSelectedPreset(AgentPresetConfig agentPresetConfig) { if (!isLoadingEditPreset) { isLoadingEditPreset = true; cboAgentType.SelectedItem = (from RegisteredAgent a in cboAgentType.Items where a.ClassName.EndsWith(agentPresetConfig.AgentClassName) select a).FirstOrDefault(); txtDescription.Text = agentPresetConfig.Description; txtConfig.Text = XmlFormattingUtils.NormalizeXML(agentPresetConfig.Config); txtConfig.SelectionStart = 0; txtConfig.DoCaretVisible(); isLoadingEditPreset = false; } }
private void cmdManualConfig_Click(object sender, EventArgs e) { try { if ((editingCollectorEntry.Collector == null || editingCollectorEntry.Collector.AgentConfig == null) && cboCollector.SelectedItem != null) // || SelectedEntry.Collector.AgentConfig.to .Configuration == null || SelectedEntry.Configuration.Length == 0) && cboCollector.SelectedItem != null) { RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem; ICollector col = CollectorEntry.CreateCollectorEntry(ar); txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString()); } else { txtConfig.Text = XmlFormattingUtils.NormalizeXML(editingCollectorEntry.Collector.AgentConfig.ToConfig()); } } catch (Exception ex) { MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ShowManualConfig(); }
private void cmdManualConfig_Click(object sender, EventArgs e) { try { if ((SelectedEntry.Configuration == null || SelectedEntry.Configuration.Length == 0) && cboNotifier.SelectedItem != null) { AgentRegistration ar = (AgentRegistration)cboNotifier.SelectedItem; INotifier col = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName); txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString()); } else { txtConfig.Text = XmlFormattingUtils.NormalizeXML(SelectedEntry.Configuration); } } catch (Exception ex) { MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ShowManualConfig(); }
private void llblRawEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (currentEditingEntry.InitialConfiguration != null) { EditRAWMarkup editRaw = new EditRAWMarkup(); editRaw.SelectedMarkup = XmlFormattingUtils.NormalizeXML(currentEditingEntry.InitialConfiguration); editRaw.AgentType = currentEditingEntry.CollectorRegistrationName; editRaw.CurrentMonitorPack = monitorPack; if (editRaw.ShowDialog() == System.Windows.Forms.DialogResult.OK) { currentEditingEntry.CreateAndConfigureEntry(currentEditingEntry.CollectorRegistrationName, editRaw.SelectedMarkup, true, false); ApplyConfigToControls(); } } } catch (Exception ex) { MessageBox.Show(string.Format("Error setting configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } CheckOkEnabled(); }
private void cboClass_SelectedIndexChanged(object sender, EventArgs e) { //if (txtConfig.Text.Length == 0) if (cboType.SelectedIndex == 2 || cboType.SelectedIndex == 4) { RegisteredAgent ra = (from r in RegisteredAgentCache.Agents where r.ClassName.EndsWith(cboClass.Text) select r).FirstOrDefault(); if (ra != null) { IAgent a; if (ra.IsCollector) { a = CollectorHost.CreateCollectorFromClassName(ra.ClassName.Replace("QuickMon.Collectors.", "")); } else { a = NotifierHost.CreateNotifierFromClassName(ra.ClassName.Replace("QuickMon.Notifiers.", "")); } if (a != null) { string agentConfig = a.AgentConfig.GetDefaultOrEmptyXml(); if (cboType.SelectedIndex == 2) { txtConfig.Text = Properties.Resources.BlankTemplateCollectorAgent.Replace("{0}", agentConfig); } else if (cboType.SelectedIndex == 4) { txtConfig.Text = Properties.Resources.BlankTemplateNotifierAgent.Replace("{0}", agentConfig); } txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text); } } } IsSaveEnabled(); }
private void SaveSelectedTemplate() { ListViewItem lvi; QuickMonTemplate t; if (txtName.Text.Trim().Length == 0) { MessageBox.Show("You must specify the a name for the template!", "Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtName.Focus(); return; } if (cboType.SelectedIndex == -1) { MessageBox.Show("You must specify the template type!", "Type", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboType.Focus(); return; } if (txtConfig.Text.Trim().Length == 0) { MessageBox.Show("You must specify the config for the template!", "Config", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtConfig.Focus(); return; } if (((TemplateType)cboType.SelectedIndex) == TemplateType.CollectorHost) { try { System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument(); xdoc.LoadXml(txtConfig.Text); System.Xml.XmlElement root = xdoc.DocumentElement; if (root.ReadXmlElementAttr("uniqueId", "") == "" || root.ReadXmlElementAttr("dependOnParentId", "") == "") { root.SetAttributeValue("uniqueId", ""); root.SetAttributeValue("dependOnParentId", ""); txtConfig.Text = XmlFormattingUtils.NormalizeXML(xdoc.OuterXml); } } catch (Exception ex) { MessageBox.Show("Invalid config!\r\n" + ex.Message, "Config", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (lvwTemplates.SelectedItems.Count == 1 && lvwTemplates.SelectedItems[0].Tag is QuickMonTemplate) { lvi = lvwTemplates.SelectedItems[0]; t = (QuickMonTemplate)lvwTemplates.SelectedItems[0].Tag; } else { lvi = new ListViewItem(txtName.Text); lvi.SubItems.Add(cboClass.Text); lvi.SubItems.Add(txtDescription.Text); t = new QuickMonTemplate(); lvwTemplates.Items.Add(lvi); } t.Name = txtName.Text; t.TemplateType = (TemplateType)cboType.SelectedIndex; t.ForClass = cboClass.Text; t.Description = txtDescription.Text; t.Config = txtConfig.Text; ListViewGroup lg = (from ListViewGroup g in lvwTemplates.Groups where (g.Header == "Monitor Pack" && t.TemplateType == TemplateType.MonitorPack) || (g.Header == "Collector Host" && t.TemplateType == TemplateType.CollectorHost) || (g.Header == "Collector Agent" && t.TemplateType == TemplateType.CollectorAgent) || (g.Header == "Notifier Host" && t.TemplateType == TemplateType.NotifierHost) || (g.Header == "Notifier Agent" && t.TemplateType == TemplateType.NotifierAgent) select g).FirstOrDefault(); lvi.Selected = true; lvi.Text = t.Name; lvi.SubItems[1].Text = t.ForClass; lvi.SubItems[2].Text = t.Description; lvi.Group = lg; lvi.Tag = t; SaveAllTemplates(); SetSaveButton(false); }
private void cmdFormat_Click(object sender, EventArgs e) { txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text); }
private void formatToolStripMenuItem_Click(object sender, EventArgs e) { txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text); }