private void button7_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { EditMonitoringForm frm = new EditMonitoringForm(); String name = treeView1.SelectedNode.Text; MonitoringData dat = (MonitoringData)Globals.Settings.Monitors[name]; frm.name = dat.name; frm.bannertext = dat.bannertext; frm.ignorebanner = dat.ignorebanner; frm.ip = dat.ip; frm.port = dat.port; frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { MonitoringData d = new MonitoringData(); d.bannertext = frm.bannertext; d.ignorebanner = frm.ignorebanner; d.ip = frm.ip; d.name = frm.name; d.port = frm.port; Globals.Settings.Monitors.Add(d.name, d); } } }
private void timer2_Tick(object sender, EventArgs e) { foreach (TreeNode n in treeView1.Nodes) { MonitoringData m = (MonitoringData)Globals.Settings.Monitors[n.Text]; if (m != null) { using (TcpClient tcpClient = new TcpClient()) { bool portisopen = false; try { tcpClient.Connect(m.ip, m.port); portisopen = true; } catch (Exception) { portisopen = false; } if (portisopen) { n.ImageIndex = 0; n.SelectedImageIndex = 0; } else { n.ImageIndex = 1; n.SelectedImageIndex = 1; } } } } }
private void button8_Click(object sender, EventArgs e) { AddMonitoringForm frm = new AddMonitoringForm(); frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { MonitoringData d = new MonitoringData(); d.bannertext = frm.bannertext; d.ignorebanner = frm.ignorebanner; d.ip = frm.ip; d.name = frm.name; d.port = frm.port; Globals.Settings.Monitors.Add(d.name, d); treeView1.Nodes.Add(d.name, d.name, 1, 1); TreeNode[] n = treeView1.Nodes.Find(d.name, true); } }