private void ClearBattleNotification() { try { try { if (mn != null) mn.CloseForm(); } catch (Exception ex) { Logger.Log(202, ex); } try { if (bn != null) bn.CloseForm(); } catch (Exception ex) { Logger.Log(203, ex); } StopSound(); if (notificationTimer.Enabled) notificationTimer.Stop(); } catch (Exception ex) { Logger.Log(204, ex); } finally { bn = null; mn = null; } }
public void ShowBattleNotification(IMain m, Battle battle, bool showCurrent = false, bool simulation = false) { ClearBattleNotification(); BattleNotificationSettings settings = UserSettings.Instance.GetBattleNotificationSettings(); if (settings.Basic.ShowBattleDialog || settings.Basic.ShowMapDialog) { bool mapOK = SetMap(battle, showCurrent, simulation); double timeLeft = battle.TimeLeft; if (settings.Basic.ShowBattleDialog) bn = new BattleNotification(battle, timeLeft, 0, settings); int height = bn == null ? 0 : bn.Height + 20; mn = new MapNotification(battle, timeLeft, height, MapSizeIndexToWidth(settings.Basic.MapSize), mapOK, settings); } SetupWindowsDisplayBehaviour(settings); if (settings.Basic.ShowMapDialog) m.ShowNotification(mn); if (settings.Basic.ShowBattleDialog) m.ShowNotification(bn); SetupSound(settings); SetupLifeTime(settings); }
public void ShowNotification(BaseNotification n) { if (InvokeRequired) { Invoke(new MethodInvoker(delegate () { ShowNotification(n); })); } else { n.Show(); } }