public static void TrayIcon(TrayIconType TargetIcon, NotifyIcon ni, bool warning) { ni.Icon = trayIcons[(int)TargetIcon]; if (warning) { SetWarning(ni); } }
void WatchIP_Connecting(object sender) { ScriptWarnings = false; CurrentIcon = TrayIconType.Connecting; BeginInvoke((MethodInvoker) delegate { TrayIcons.TrayIcon(CurrentIcon, niMain, ScriptWarnings); niMain.Text = CommonFunctions.CutTipText(("Connecting...\n" + niMain.Text)); }); }
void WatchIP_IPOK(object sender) { CurrentIcon = TrayIconType.OK; prevNetError = string.Empty; prevPanic = false; PlayAlarm = true; BeginInvoke((MethodInvoker) delegate { TrayIcons.TrayIcon(CurrentIcon, niMain, ScriptWarnings); niMain.Text = CommonFunctions.CutTipText(WatchIP.IPShortInfo); }); }
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(); } }); } }
void WatchIP_FatalError(object sender) { CurrentIcon = TrayIconType.Panic; BeginInvoke((MethodInvoker) delegate { mnuMyIP.Enabled = false; mnuOthIP.Enabled = false; TrayIcons.TrayIcon(CurrentIcon, niMain, ScriptWarnings); niMain.Text = "Fatal error"; niMain.ShowBalloonTip(5000, "Fatal Error", WatchIP.ErrorMessage, ToolTipIcon.Error); CommonFunctions.ErrMessage(WatchIP.ErrorMessage); WatchIP.StopWatch(); }); }
void CountryWarning(string IP, string Country, string ISOCode) { string msg = "Обнаружен IP нежелательной страны: " + IP + " " + Country + " (" + ISOCode + ")"; CurrentIcon = TrayIconType.Panic; BeginInvoke((MethodInvoker) delegate { TrayIcons.TrayIcon(CurrentIcon, niMain, ScriptWarnings); niMain.Text = CommonFunctions.CutTipText(msg); if (PlayAlarm) { niMain.ShowBalloonTip(5000, "Нежелательный IP", msg, ToolTipIcon.Error); } }); CommonFunctions.PlayAlarmSound(settings.ComAlarmSoundPath, Properties.Resources.panicsound, settings.ComAlarmSound && PlayAlarm); PlayAlarm = false; }
public SelectableTrayIcon(TrayIconType trayIcon) { TrayIcon = trayIcon; ImageSource = ResourceProvider.GetResource(TrayIcon.GetDescription()); }
/// <summary> /// Create a windows tray notification /// </summary> public static void CreateTrayNotification(string text, TrayIconType trayIcon = 0, bool useSound = true) { MtaClient.CreateTrayNotification(text, trayIcon.ToString().ToLower(), useSound); }