public static void CloseSuspendedWindow() { lock (suspendedLock) { if (window != null) { window.Close(); window = null; } } }
public static void ShowSuspendedWindow(bool alwaysShow = false) { lock (suspendedLock) { if (window != null) { window.Close(); window = null; } Screen screen; Process tibia_process = ProcessManager.GetTibiaProcess(); if (tibia_process == null) { screen = Screen.FromControl(MainForm.mainForm); } else { screen = Screen.FromHandle(tibia_process.MainWindowHandle); } window = new AutoHotkeySuspendedMode(alwaysShow); int position_x = 0, position_y = 0; int suspendedX = SettingsManager.getSettingInt("SuspendedNotificationXOffset"); int suspendedY = SettingsManager.getSettingInt("SuspendedNotificationYOffset"); int xOffset = suspendedX < 0 ? 10 : suspendedX; int yOffset = suspendedY < 0 ? 10 : suspendedY; int anchor = SettingsManager.getSettingInt("SuspendedNotificationAnchor"); switch (anchor) { case 3: position_x = screen.WorkingArea.Right - xOffset - window.Width; position_y = screen.WorkingArea.Bottom - yOffset - window.Height; break; case 2: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Bottom - yOffset - window.Height; break; case 0: position_x = screen.WorkingArea.Left + xOffset; position_y = screen.WorkingArea.Top + yOffset; break; default: position_x = screen.WorkingArea.Right - xOffset - window.Width; position_y = screen.WorkingArea.Top + yOffset; break; } window.StartPosition = FormStartPosition.Manual; window.SetDesktopLocation(position_x, position_y); window.TopMost = true; window.Show(); } }
private void CloseSuspendedWindow() { lock (suspendedLock) { if (window != null && !window.IsDisposed) { try { window.Close(); } catch { } window = null; } } }