private void _tbHostOptions_Click(object sender, EventArgs e) { if (_selectedPinger != null) { HostOptions dlg = new HostOptions(); dlg.ShowDialog(this, _selectedPinger); } }
public void AddNewHost(HostPinger host) { HostOptions dlg = new HostOptions(); if (dlg.ShowDialog(this, host) == DialogResult.OK) { bool exists = false; lock (_hosts) { foreach (HostPinger hp in _hosts) { if (hp.HostIP != null && hp.HostIP == dlg.Host.HostIP) { exists = true; break; } } } if (exists) { MessageBox.Show("Host already exists.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } dlg.Host.Logger = DefaultLogger.Instance; dlg.Host.OnPing += new OnPingDelegate(OnHostPing); dlg.Host.OnStopPinging += new OnHostPingerCommandDelegate(hp_OnStopPinging); dlg.Host.OnStartPinging += new OnHostPingerCommandDelegate(hp_OnStartPinging); lock (_hosts) { _hosts.Add(dlg.Host); HostDataSeries series = new HostDataSeries(this, dlg.Host); _dataSeries.Add(dlg.Host, series); // _graphManager.RegisterSeries(series); } _hostListChanged = true; if (MessageBox.Show("Start pinging of the host?", "Start", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { dlg.Host.Start(); } } }
private void _tbAddNewHost_Click(object sender, EventArgs e) { HostOptions dlg = new HostOptions(); if (dlg.ShowDialog(this, null) == DialogResult.OK) { foreach (HostPinger hp in _hosts) { if (hp.HostIP == dlg.Host.HostIP) { MessageBox.Show("Host already exists.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } _hosts.Add(dlg.Host); dlg.Host.OnPing += new PingDelegate(OnHostPing); } }