void fPanicNet_FormPanicNetClosed(bool StopTracking) { fPanicNet.Dispose(); fPanicNet = null; if (StopTracking) { UserStop(false); } }
void WatchIP_NetError(object sender) { prevPanic = false; //в любом случае устанавливаем серую иконку, текст подсказки //и отключаем пункты меню с информацией об IP CurrentIcon = TrayIconType.NoNetwork; BeginInvoke((MethodInvoker) delegate { mnuMyIP.Enabled = false; mnuOthIP.Enabled = false; TrayIcons.TrayIcon(CurrentIcon, niMain, ScriptWarnings); niMain.Text = CommonFunctions.CutTipText(WatchIP.ErrorMessage); }); //ошибка уже была и была такая же, уходим if (prevNetError == WatchIP.ErrorMessage) { return; } else { prevNetError = WatchIP.ErrorMessage; } //другая ошибка или первый раз //показываем balloon BeginInvoke((MethodInvoker) delegate { niMain.ShowBalloonTip(5000, "Network Error!", WatchIP.ErrorMessage, ToolTipIcon.Warning); }); //если надо - покажем окошко if (settings.ComNetErr == NetErrorMessage.Window) { BeginInvoke((MethodInvoker) delegate { if (fPanicNet == null) { fPanicNet = new frmPanicNet(); fPanicNet.ErrorMessage = WatchIP.ErrorMessage; fPanicNet.FormPanicNetClosed += new frmPanicNet.OnFormPanicNetClosed(fPanicNet_FormPanicNetClosed); fPanicNet.Show(); } }); } }