public static void Label(string labelName, string labelText, Vector3 labeledPosition, Color color) { ensurePingRunnerExists(); PingLabel label; if (!_labels.TryGetValue(labelName, out label)) { _labels[labelName] = label = new PingLabel() { labeledPosition = labeledPosition, color = color, text = labelText }; } else { label.labeledPosition = labeledPosition; label.color = color; label.text = labelText; } }
// Инициализация пингера private bool InitPinger() { try { MainNotifyIcon.Visible = true; MainNotifyIcon.Icon = Properties.Resources.red; MainNotifyIcon.Text = disabledText; PingBox.Image = disabledImage; PingLabel.Text = disabledText; // + Проверка подключения к сети интернет Pinger.CheckingInterval = AppHelper.Configuration.Pinger.TimerInterval; Pinger.Timeout = AppHelper.Configuration.Pinger.PingTimeout; Pinger.Host = AppHelper.Configuration.Pinger.HostIP; Pinger.PingerEvent += delegate(PingStatus status) { try { if (status == PingStatus.Success) { MainNotifyIcon.Icon = enabledIcon; MainNotifyIcon.Text = enabledText; PingBox.InvokeIfRequired(() => PingBox.Image = enabledImage); PingLabel.InvokeIfRequired(() => PingLabel.Text = enabledText); } else if (status == PingStatus.Error) { MainNotifyIcon.Icon = disabledIcon; MainNotifyIcon.Text = disabledText; PingBox.InvokeIfRequired(() => PingBox.Image = disabledImage); PingLabel.InvokeIfRequired(() => PingLabel.Text = disabledText); } else if (status == PingStatus.DnsError) { MainNotifyIcon.Icon = dnsErrorIcon; MainNotifyIcon.Text = dnsErrorText; PingBox.InvokeIfRequired(() => PingBox.Image = dnsErrorImage); PingLabel.InvokeIfRequired(() => PingLabel.Text = dnsErrorText); } } catch (Exception ex) { AppHelper.CreateMessage("Ошибка:\r\n" + ex.ToString(), MessageType.Error, false, true, true); } }; return(true); // - Проверка подключения к сети интернет } catch (Exception ex) { AppHelper.CreateMessage("Ошибка:\r\n" + ex.ToString(), MessageType.Error, false, true, true); Load += (s, e) => Application.Exit(); return(false); } }