private void cmdOK_Click(object sender, EventArgs e) { if (SelectedEntry != null) { SelectedEntry.Name = txtName.Text; SelectedEntry.Enabled = chkEnabled.Checked; ICollectorConfig conf = (ICollectorConfig)SelectedEntry.AgentConfig; conf.Entries.Clear(); if (!ShowTreeView) { foreach (ListViewItem lvi in lvwEntries.Items) { conf.Entries.Add((ICollectorConfigEntry)lvi.Tag); } } else //TreeView { foreach (TreeNode nod in tvwEntries.Nodes) { conf.Entries.Add((ICollectorConfigEntry)nod.Tag); } } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } }
private void CheckOkEnabled() { bool collectorEntriesCheck = currentEditingEntry.IsFolder; if (currentEditingEntry.Collector != null && currentEditingEntry.Collector.AgentConfig != null) { ICollectorConfig icc = (ICollectorConfig)currentEditingEntry.Collector.AgentConfig; collectorEntriesCheck = icc.Entries.Count > 0; } cmdOK.Enabled = collectorEntriesCheck && (txtName.Text.Length > 0) && cboParentCollector.SelectedIndex > -1 && ((!chkRemoteAgentEnabled.Checked && !chkForceRemoteExcuteOnChildCollectors.Checked) || txtRemoteAgentServer.Text.Length > 0); cmdRemoteAgentTest.Enabled = chkRemoteAgentEnabled.Checked && collectorEntriesCheck && txtRemoteAgentServer.Text.Length > 0; }
private void addCollectorConfigEntryToolStripButton_Click(object sender, EventArgs e) { if (currentEditingEntry.Collector != null && currentEditingEntry.Collector.AgentConfig != null) { ICollectorConfig currentConfig = (ICollectorConfig)currentEditingEntry.Collector.AgentConfig; ICollectorConfigEntry entry = null; if (SelectedEntry.ShowEditConfigEntry(ref entry)) { if (entry != null) { currentConfig.Entries.Add(entry); } currentEditingEntry.InitialConfiguration = currentEditingEntry.Collector.AgentConfig.ToConfig(); ApplyConfigToControls(); } } }
private void deleteCollectorConfigEntryToolStripButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete the selected entry(s)", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (lvwEntries.Visible) { foreach (int index in (from int i in lvwEntries.SelectedIndices orderby i descending select i)) { ICollectorConfigEntry entry = (ICollectorConfigEntry)lvwEntries.Items[index].Tag; ICollectorConfig cnf = ((ICollectorConfig)currentEditingEntry.Collector.AgentConfig); cnf.Entries.Remove(entry); lvwEntries.Items.RemoveAt(index); } } else { ICollectorConfig cnf = ((ICollectorConfig)currentEditingEntry.Collector.AgentConfig); if (tvwEntries.SelectedNode.Nodes.Count > 0) { ICollectorConfigEntry entry = (ICollectorConfigEntry)tvwEntries.SelectedNode.Tag; cnf.Entries.Remove(entry); tvwEntries.SelectedNode.Nodes.Clear(); } else { ICollectorConfigEntry entry = (ICollectorConfigEntry)tvwEntries.SelectedNode.Parent.Tag; ICollectorConfigSubEntry subEntry = (from ent in entry.SubItems where ent.Description == tvwEntries.SelectedNode.Text select ent).FirstOrDefault(); if (subEntry != null) { entry.SubItems.Remove(subEntry); } } tvwEntries.Nodes.Remove(tvwEntries.SelectedNode); } currentEditingEntry.InitialConfiguration = currentEditingEntry.Collector.AgentConfig.ToConfig(); CheckOkEnabled(); } }
private void llblRawEdit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (SelectedEntry != null) { ICollectorConfig conf = (ICollectorConfig)SelectedEntry.AgentConfig; conf.Entries.Clear(); if (!ShowTreeView) { foreach (ListViewItem lvi in lvwEntries.Items) { conf.Entries.Add((ICollectorConfigEntry)lvi.Tag); } } else //TreeView { } RAWXmlEditor editor = new RAWXmlEditor(); string oldMarkUp = conf.ToXml(); editor.SelectedMarkup = oldMarkUp; if (editor.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { conf.FromXml(editor.SelectedMarkup); if (editor.SelectedMarkup != null && editor.SelectedMarkup.Length > 0 && conf.Entries.Count == 0) { if (MessageBox.Show("Editing the raw config resulted in no loadable entries!\r\nDo you want to accept this?", "No entries", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.No) { conf.FromXml(oldMarkUp); } } } catch (Exception ex) { MessageBox.Show("An error occured while processing the config!\r\n" + ex.Message, "Edit config", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } LoadEntries(); } } }