diff --git a/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.Designer.cs b/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.Designer.cs index a0ef746..3d69652 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.Designer.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.Designer.cs @@ -1,5 +1,5 @@  -namespace PersistentWindows.SystrayShell +namespace PersistentWindows.Common { partial class HotKeyWindow { @@ -148,7 +148,7 @@ namespace PersistentWindows.SystrayShell this.Controls.Add(this.buttonCloseTab); this.Controls.Add(this.buttonNextTab); this.Controls.Add(this.buttonPrevTab); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.KeyPreview = true; this.MaximizeBox = false; this.MinimizeBox = false; @@ -156,7 +156,6 @@ namespace PersistentWindows.SystrayShell this.Opacity = 0.5D; this.ShowInTaskbar = false; this.TopMost = true; - this.Load += new System.EventHandler(this.HotKeyWindow_Load); this.ResumeLayout(false); } diff --git a/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.cs b/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.cs index d360f09..323f0ec 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/HotKeyWindow.cs @@ -11,7 +11,7 @@ using System.Windows.Forms; using PersistentWindows.Common.WinApiBridge; -namespace PersistentWindows.SystrayShell +namespace PersistentWindows.Common { public partial class HotKeyWindow : Form { @@ -291,14 +291,10 @@ namespace PersistentWindows.SystrayShell User32.SetForegroundWindow(Handle); } - private void HotKeyWindow_Load(object sender, EventArgs e) + private static IntPtr GetForegroundWindow() { - Icon = Program.IdleIcon; + return PersistentWindowProcessor.GetForegroundWindow(); } - static IntPtr GetForegroundWindow() - { - return Program.GetForegroundWindow(); - } } } diff --git a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs index f9ab708..7c2377b 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs @@ -50,12 +50,12 @@ namespace PersistentWindows.Common private HashSet allUserMoveWindows = new HashSet(); private HashSet unResponsiveWindows = new HashSet(); private HashSet noRecordWindows = new HashSet(); - private IntPtr desktopWindow = User32.GetDesktopWindow(); + private static IntPtr desktopWindow = User32.GetDesktopWindow(); private IntPtr vacantDeskWindow = IntPtr.Zero; // windows that are not to be restored - private HashSet noRestoreWindows = new HashSet(); //windows excluded from auto-restore - private HashSet noRestoreWindowsTmp = new HashSet(); //user moved windows during restore + private static HashSet noRestoreWindows = new HashSet(); //windows excluded from auto-restore + private static HashSet noRestoreWindowsTmp = new HashSet(); //user moved windows during restore // realtime fixing window location private IntPtr curMovingWnd = IntPtr.Zero; @@ -70,7 +70,7 @@ namespace PersistentWindows.Common private Timer captureTimer; private string curDisplayKey; // current display config name public string dbDisplayKey = null; - private Dictionary windowTitle = new Dictionary(); // for matching running window with DB record + private static Dictionary windowTitle = new Dictionary(); // for matching running window with DB record private Queue pendingMoveEvents = new Queue(); // queue of window with possible position change for capture private HashSet normalSessions = new HashSet(); //normal user sessions, for differentiating full screen game session or other transient session public bool manualNormalSession = false; //user need to manually take snapshot or save/restore from db to flag normal session @@ -878,7 +878,7 @@ namespace PersistentWindows.Common return isFullScreen; } - private string GetWindowTitle(IntPtr hwnd, bool use_cache = true) + private static string GetWindowTitle(IntPtr hwnd, bool use_cache = true) { if (use_cache && windowTitle.ContainsKey(hwnd)) return windowTitle[hwnd]; @@ -898,7 +898,7 @@ namespace PersistentWindows.Common return ""; } - private bool IsMinimized(IntPtr hwnd) + private static bool IsMinimized(IntPtr hwnd) { bool result = User32.IsIconic(hwnd) || !User32.IsWindowVisible(hwnd); long style = User32.GetWindowLong(hwnd, User32.GWL_STYLE); @@ -1225,7 +1225,7 @@ namespace PersistentWindows.Common } - private bool IsTopLevelWindow(IntPtr hwnd) + private static bool IsTopLevelWindow(IntPtr hwnd) { if (IsTaskBar(hwnd)) return true; @@ -1847,7 +1847,7 @@ namespace PersistentWindows.Common return fixZorder == 2 || (restoringSnapshot && fixZorder > 0); } - public IntPtr GetForegroundWindow() + public static IntPtr GetForegroundWindow() { IntPtr topMostWindow = User32.GetTopWindow(desktopWindow); for (IntPtr hwnd = topMostWindow; hwnd != IntPtr.Zero; hwnd = User32.GetWindow(hwnd, 2)) @@ -2749,7 +2749,7 @@ namespace PersistentWindows.Common } - private string GetWindowClassName(IntPtr hwnd) + private static string GetWindowClassName(IntPtr hwnd) { int nChars = 4096; StringBuilder buf = new StringBuilder(nChars); @@ -2765,7 +2765,7 @@ namespace PersistentWindows.Common return true; } - private bool IsTaskBar(IntPtr hwnd) + private static bool IsTaskBar(IntPtr hwnd) { if (!User32.IsWindow(hwnd)) return false; diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs index 7e69b02..2f19e65 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Windows.Forms; +using PersistentWindows.Common; using PersistentWindows.Common.WinApiBridge; namespace PersistentWindows.SystrayShell diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs index 4724227..c894da4 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs @@ -623,12 +623,12 @@ namespace PersistentWindows.SystrayShell static public void RecallLastKilledPosition() { - pwp.RecallLastKilledPosition(pwp.GetForegroundWindow()); + pwp.RecallLastKilledPosition(PersistentWindowProcessor.GetForegroundWindow()); } static public void CenterWindow() { - pwp.CenterWindow(pwp.GetForegroundWindow()); + pwp.CenterWindow(PersistentWindowProcessor.GetForegroundWindow()); } static public void PauseAutoRestore() @@ -731,7 +731,7 @@ namespace PersistentWindows.SystrayShell public static IntPtr GetForegroundWindow() { - return pwp.GetForegroundWindow(); + return PersistentWindowProcessor.GetForegroundWindow(); } } }