protected override void OnApplicationTick(float dt) { base.OnApplicationTick(dt); if (Campaign.Current?.GameStarted == true) { if (OpenKey.Code.IsReleased() && (!OpenKey.Control.HasValue || OpenKey.Control.Value == (InputKey.LeftControl.IsDown() || InputKey.RightControl.IsDown())) && (!OpenKey.Shift.HasValue || OpenKey.Shift.Value == (InputKey.LeftShift.IsDown() || InputKey.RightShift.IsDown())) && (!OpenKey.Alt.HasValue || OpenKey.Alt.Value == (InputKey.LeftAlt.IsDown() || InputKey.RightAlt.IsDown())) ) { System.AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; System.AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; try { if (_instance == null) { _instance = new MainForm(); } QUERY_USER_NOTIFICATION_STATE pquns; SHQueryUserNotificationState(out pquns); Log.Debug($"SHQueryUserNotificationState: {pquns}"); if (pquns == QUERY_USER_NOTIFICATION_STATE.QUNS_RUNNING_D3D_FULL_SCREEN) { // fullscreen Log.Info("FullScreen is not supported. Please use 'Borderless Fullscreen' or 'Windowed' in Video Options"); return; } var curstate = Game.Current.GameStateManager.ActiveState; Log.Debug($"Active State: {curstate}"); string warningText = null; if (curstate is CharacterDeveloperState) { warningText = "Please do not edit while on Character screen. Please use Quests (J) screen for edits for consistency."; } else if (curstate is InventoryState) { warningText = "Please do not edit while on Inventory screen. Please use Quests (J) screen for edits for consistency."; } else if (curstate is PartyState) { warningText = "Please do not edit while on Party screen. Please use Quests (J) screen for edits for consistency."; } if (warningText != null) { Log.Info(warningText); if (!_userWarned) { _userWarned = true; var msgbox = new DarkUI.Forms.DarkMessageBox(warningText, "Consistency Warning" , DarkMessageBoxIcon.Error, DarkDialogButton.RetryCancel); msgbox.TopMost = true; var result = msgbox.ShowDialog(); if (result == DialogResult.Cancel) { return; } } } //var handle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; //Log.Debug($"Handle: {handle}"); //_instance.Show(new WindowWrapper(handle)); _instance.ShowDialog(); } catch (Exception ex) { Log.Debug(ex.Message); } finally { System.AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; System.AppDomain.CurrentDomain.FirstChanceException -= CurrentDomain_FirstChanceException; } } } }
private static DialogResult ShowDialog(string message, string caption, DarkMessageBoxIcon icon, DarkDialogButton buttons) { using var dlg = new DarkMessageBox(message, caption, icon, buttons); return(dlg.ShowDialog()); }
private static DialogResult ShowDialog(string message, string caption, DarkMessageBoxIcon icon, DarkDialogButton buttons) { using (var dlg = new DarkMessageBox(message, caption, icon, buttons)) { var result = dlg.ShowDialog(); return result; } }