From b533c0a311f049fe4d1899cf32c0492eeaabc116 Mon Sep 17 00:00:00 2001 From: Andrew Sampson Date: Sun, 9 Apr 2017 13:44:39 -0400 Subject: [PATCH] Add support for games without titles (Killing Floor), Add support for Unreal Engine games, Clean up some code. --- .gitignore | 1 + BorderlessGaming.cs | 33 ++-- BorderlessGaming.sln | 40 ++++- Common/Favorites.cs | 62 +++---- Common/HiddenProcesses.cs | 2 +- Common/ProcessDetails.cs | 111 ++++++------- Common/ProcessDetailsList.cs | 20 +-- Forms/AboutForm.cs | 4 +- Forms/DesktopAreaSelector.cs | 128 +++++++------- Forms/InputText.cs | 14 +- Forms/MainWindow.cs | 304 +++++++++++++++++----------------- Program_Steam.cs | 2 +- Utilities/AppEnvironment.cs | 18 +- Utilities/ExceptionHandler.cs | 12 +- Utilities/Tools.cs | 28 ++-- Utilities/UAC.cs | 6 +- WindowsAPI/Manipulation.cs | 91 +++++----- WindowsAPI/Native.cs | 140 +++++++++++++--- WindowsAPI/Windows.cs | 44 +++-- 19 files changed, 594 insertions(+), 466 deletions(-) diff --git a/.gitignore b/.gitignore index 5727de9..0799c0a 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,4 @@ Backup*/ UpgradeLog*.XML Installer/*setup.exe +.vs/ diff --git a/BorderlessGaming.cs b/BorderlessGaming.cs index 4145998..4f82630 100644 --- a/BorderlessGaming.cs +++ b/BorderlessGaming.cs @@ -68,12 +68,12 @@ public void Start() /// private void DoMainWork() { - while (!this.workerTaskToken.IsCancellationRequested) + while (!workerTaskToken.IsCancellationRequested) { // update the processlist - this.UpdateProcesses(); + UpdateProcesses(); - if (this.AutoHandleFavorites) + if (AutoHandleFavorites) { // check favorites against the cache foreach (var pd in _processDetails) @@ -100,7 +100,7 @@ private void UpdateProcesses() try { - if (!this.AutoHandleFavorites) + if (!AutoHandleFavorites) { MainWindow frm = MainWindow.ext(); @@ -111,30 +111,30 @@ private void UpdateProcesses() } catch { } // swallow any exceptions in attempting to check window minimize/visibility state - lock (this.updateLock) + lock (updateLock) { // check existing processes for changes (auto-prune) - for (int i = 0; i < this._processDetails.Count;) + for (int i = 0; i < _processDetails.Count;) { try { - ProcessDetails pd = this._processDetails[i]; + var pd = _processDetails[i]; - bool should_be_pruned = pd.ProcessHasExited; + var shouldBePruned = pd.ProcessHasExited; - if (!should_be_pruned) + if (!shouldBePruned) { - string current_title = ""; + var currentTitle = ""; if (!pd.NoAccess) { // 2 or 10 seconds until window title timeout, depending on slow-window detection mode - Tools.StartMethodMultithreadedAndWait(() => { current_title = Native.GetWindowTitle(pd.WindowHandle); }, (Utilities.AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); - should_be_pruned = should_be_pruned || (pd.WindowTitle != current_title); + Tools.StartMethodMultithreadedAndWait(() => { currentTitle = Native.GetWindowTitle(pd.WindowHandle); }, (AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); + shouldBePruned = shouldBePruned || (pd.WindowTitle != currentTitle); } } - if (should_be_pruned) + if (shouldBePruned) { if (pd.MadeBorderless) HandlePrunedProcess(pd); @@ -160,6 +160,7 @@ private void UpdateProcesses() if (!_processDetails.Select(p => p.Proc.Id).Contains(pd.Proc.Id) || !_processDetails.Select(p => p.WindowTitle).Contains(pd.WindowTitle)) _processDetails.Add(pd); + }, _processDetails.WindowPtrSet); } catch { } // swallow any exceptions in attempting to add new windows @@ -171,12 +172,12 @@ private void UpdateProcesses() public Task RefreshProcesses() { - lock (this.updateLock) + lock (updateLock) { - this._processDetails.ClearProcesses(); + _processDetails.ClearProcesses(); } - return Task.Factory.StartNew(this.UpdateProcesses); + return Task.Factory.StartNew(UpdateProcesses); } /// diff --git a/BorderlessGaming.sln b/BorderlessGaming.sln index 492e9af..2a0f0fa 100644 --- a/BorderlessGaming.sln +++ b/BorderlessGaming.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BorderlessGaming_Standalone_UserUAC", "BorderlessGaming_Standalone_UserUAC.csproj", "{25526352-8406-4773-BB5B-C2017E82FD65}" EndProject @@ -12,21 +12,49 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.Build.0 = Debug|Any CPU - {25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.ActiveCfg = Release|Any CPU - {25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.Build.0 = Release|Any CPU {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x64.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x64.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x86.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x86.Build.0 = Debug|Any CPU {25526352-8406-4773-BB5B-C2017E82FD65}.Release|Any CPU.ActiveCfg = Release|Any CPU {25526352-8406-4773-BB5B-C2017E82FD65}.Release|Any CPU.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Release|x64.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Release|x64.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Release|x86.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD65}.Release|x86.Build.0 = Release|Any CPU {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x64.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x64.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x86.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x86.Build.0 = Debug|Any CPU {25526352-8406-4773-BB5B-C2017E82FD66}.Release|Any CPU.ActiveCfg = Release|Any CPU {25526352-8406-4773-BB5B-C2017E82FD66}.Release|Any CPU.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Release|x64.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Release|x64.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Release|x86.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD66}.Release|x86.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x64.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x64.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x86.ActiveCfg = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x86.Build.0 = Debug|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|x64.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|x64.Build.0 = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|x86.ActiveCfg = Release|Any CPU + {25526352-8406-4773-BB5B-C2017E82FD64}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Common/Favorites.cs b/Common/Favorites.cs index 1ae8472..28f761b 100644 --- a/Common/Favorites.cs +++ b/Common/Favorites.cs @@ -19,7 +19,7 @@ public class Favorites : ObservableCollection public Favorites(string path) { this.path = path; - this.CollectionChanged += OnCollectionChanged; + CollectionChanged += OnCollectionChanged; Load(); } @@ -84,10 +84,7 @@ public void Load() public bool CanAdd(string item) { - foreach (var fav in this) - if (fav.SearchText == item) - return false; - return true; + return this.All(fav => fav.SearchText != item); } public bool CanRemove(string item) @@ -153,30 +150,37 @@ public override string ToString() // so that the ListView control knows how to d { string extra_details = ""; - if (this.Kind == FavoriteKinds.ByBinaryName) - extra_details += " [Process]"; - else if (this.Kind == FavoriteKinds.ByRegexString) - extra_details += " [Regex]"; - else if (this.Kind != FavoriteKinds.ByTitleText) - extra_details += " [?]"; - - extra_details += ((this.ShouldMaximize) ? " [Max]" : ""); - extra_details += ((this.SizeMode == SizeModes.NoChange) ? " [NoSize]" : ""); - extra_details += ((this.TopMost) ? " [Top]" : ""); - extra_details += ((this.RemoveMenus) ? " [NoMenu]" : ""); - extra_details += ((this.HideWindowsTaskbar) ? " [NoTaskbar]" : ""); - extra_details += ((this.HideMouseCursor) ? " [NoMouse]" : ""); - extra_details += ((this.DelayBorderless) ? " [Delay]" : ""); - - if (this.OffsetL != 0 || this.OffsetR != 0 || this.OffsetT != 0 || this.OffsetB != 0) - extra_details += " [" + this.OffsetL.ToString() + "L," + this.OffsetR.ToString() + "R," + - this.OffsetT.ToString() + "T," + this.OffsetB.ToString() + "B]"; - - if (this.PositionX != 0 || this.PositionY != 0 || this.PositionW != 0 || this.PositionH != 0) - extra_details += " [" + this.PositionX.ToString() + "x" + this.PositionY.ToString() + "-" + - (this.PositionX + this.PositionW).ToString() + "x" + (this.PositionY + this.PositionH).ToString() + "]"; - - return this.SearchText + extra_details; + switch (Kind) + { + case FavoriteKinds.ByBinaryName: + extra_details += " [Process]"; + break; + case FavoriteKinds.ByRegexString: + extra_details += " [Regex]"; + break; + default: + if (Kind != FavoriteKinds.ByTitleText) + extra_details += " [?]"; + break; + } + + extra_details += ((ShouldMaximize) ? " [Max]" : ""); + extra_details += ((SizeMode == SizeModes.NoChange) ? " [NoSize]" : ""); + extra_details += ((TopMost) ? " [Top]" : ""); + extra_details += ((RemoveMenus) ? " [NoMenu]" : ""); + extra_details += ((HideWindowsTaskbar) ? " [NoTaskbar]" : ""); + extra_details += ((HideMouseCursor) ? " [NoMouse]" : ""); + extra_details += ((DelayBorderless) ? " [Delay]" : ""); + + if (OffsetL != 0 || OffsetR != 0 || OffsetT != 0 || OffsetB != 0) + extra_details += " [" + OffsetL.ToString() + "L," + OffsetR.ToString() + "R," + + OffsetT.ToString() + "T," + OffsetB.ToString() + "B]"; + + if (PositionX != 0 || PositionY != 0 || PositionW != 0 || PositionH != 0) + extra_details += " [" + PositionX.ToString() + "x" + PositionY.ToString() + "-" + + (PositionX + PositionW).ToString() + "x" + (PositionY + PositionH).ToString() + "]"; + + return SearchText + extra_details; } catch { } diff --git a/Common/HiddenProcesses.cs b/Common/HiddenProcesses.cs index 5dd7eb3..4c4e52f 100644 --- a/Common/HiddenProcesses.cs +++ b/Common/HiddenProcesses.cs @@ -45,7 +45,7 @@ public HiddenProcesses(string path) alwaysHideSet = new HashSet(); userHideSet = new HashSet(); Init(); - this.CollectionChanged += OnCollectionChanged; + CollectionChanged += OnCollectionChanged; } private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) diff --git a/Common/ProcessDetails.cs b/Common/ProcessDetails.cs index 5ecfd4d..4fca87d 100644 --- a/Common/ProcessDetails.cs +++ b/Common/ProcessDetails.cs @@ -24,12 +24,12 @@ public class ProcessDetails public ProcessDetails(Process p, IntPtr hWnd) { - this.Proc = p; + Proc = p; - this.WindowHandle = hWnd; - this.WindowTitle = ""; + WindowHandle = hWnd; + WindowTitle = ""; //this.WindowTitle = WindowsAPI.Native.GetWindowTitle(this.WindowHandle); - Tools.StartMethodMultithreadedAndWait(() => { this.WindowTitle = WindowsAPI.Native.GetWindowTitle(this.WindowHandle); }, (Utilities.AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); + Tools.StartMethodMultithreadedAndWait(() => { WindowTitle = WindowsAPI.Native.GetWindowTitle(WindowHandle); }, (AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); //this.WindowClass = WindowsAPI.Native.GetWindowClassName(this.WindowHandle); // note: this isn't used, currently } @@ -40,19 +40,19 @@ public IntPtr WindowHandle { try { - if (this.ProcessHasExited) + if (ProcessHasExited) return IntPtr.Zero; - if (!WindowsAPI.Native.IsWindow(this._WindowHandle)) - this._WindowHandle = WindowsAPI.Native.GetMainWindowForProcess(this.Proc); + if (!WindowsAPI.Native.IsWindow(_WindowHandle)) + _WindowHandle = WindowsAPI.Native.GetMainWindowForProcess(Proc); } catch { } - return this._WindowHandle; + return _WindowHandle; } set { - this._WindowHandle = value; + _WindowHandle = value; } } @@ -62,15 +62,15 @@ public bool ProcessHasExited { try { - if (this.NoAccess) + if (NoAccess) return false; - if (this.Proc != null) - return this.Proc.HasExited; + if (Proc != null) + return Proc.HasExited; } catch (System.ComponentModel.Win32Exception) { - this.NoAccess = true; + NoAccess = true; return false; // Access is denied } @@ -86,14 +86,11 @@ public string BinaryName { try { - if (this.NoAccess) - return ""; - - return this.Proc.ProcessName; + return NoAccess ? "" : Proc.ProcessName; } catch { - this.NoAccess = true; + NoAccess = true; } return ""; @@ -104,35 +101,35 @@ public override string ToString() // so that the ListView control knows how to d { try { - if (!string.IsNullOrEmpty(this.DescriptionOverride)) - return this.DescriptionOverride; + if (!string.IsNullOrEmpty(DescriptionOverride)) + return DescriptionOverride; if (AppEnvironment.SettingValue("ViewAllProcessDetails", false)) { - WindowsAPI.WindowStyleFlags styleCurrentWindow_standard = WindowsAPI.Native.GetWindowLong(this.WindowHandle, WindowsAPI.WindowLongIndex.Style); - WindowsAPI.WindowStyleFlags styleCurrentWindow_extended = WindowsAPI.Native.GetWindowLong(this.WindowHandle, WindowsAPI.WindowLongIndex.ExtendedStyle); + WindowsAPI.WindowStyleFlags styleCurrentWindow_standard = WindowsAPI.Native.GetWindowLong(WindowHandle, WindowsAPI.WindowLongIndex.Style); + WindowsAPI.WindowStyleFlags styleCurrentWindow_extended = WindowsAPI.Native.GetWindowLong(WindowHandle, WindowsAPI.WindowLongIndex.ExtendedStyle); string extra_details = string.Format(" [{0:X8}.{1:X8}]", (UInt32)styleCurrentWindow_standard, (UInt32)styleCurrentWindow_extended); - if (this.WindowTitle.Trim().Length == 0) - return this.BinaryName + " [#" + this.Proc.Id.ToString() + "]" + extra_details; + if (WindowTitle.Trim().Length == 0) + return BinaryName + " [#" + Proc.Id.ToString() + "]" + extra_details; - return this.WindowTitle.Trim() + " [" + this.BinaryName + ", #" + this.Proc.Id.ToString() + "]" + extra_details; + return WindowTitle.Trim() + " [" + BinaryName + ", #" + Proc.Id.ToString() + "]" + extra_details; } - if (this.WindowTitle.Trim().Length == 0) - return this.BinaryName; + if (WindowTitle.Trim().Length == 0) + return BinaryName; bool ProcessNameIsDissimilarToWindowTitle = true; - if (this.WindowTitle_ForComparison.Length >= 5) - if (this.BinaryName_ForComparison.Length >= 5) - if (this.BinaryName_ForComparison.Substring(0, 5) == this.WindowTitle_ForComparison.Substring(0, 5)) + if (WindowTitle_ForComparison.Length >= 5) + if (BinaryName_ForComparison.Length >= 5) + if (BinaryName_ForComparison.Substring(0, 5) == WindowTitle_ForComparison.Substring(0, 5)) ProcessNameIsDissimilarToWindowTitle = false; if (ProcessNameIsDissimilarToWindowTitle) - return this.WindowTitle.Trim() + " [" + this.BinaryName + "]"; + return WindowTitle.Trim() + " [" + BinaryName + "]"; - return this.WindowTitle.Trim(); + return WindowTitle.Trim(); } catch { } @@ -144,7 +141,7 @@ private string WindowTitle_ForComparison { get { - return this.WindowTitle.Trim().ToLower().Replace(" ", "").Replace("_", ""); + return WindowTitle.Trim().ToLower().Replace(" ", "").Replace("_", ""); } } @@ -152,7 +149,7 @@ private string BinaryName_ForComparison { get { - return this.BinaryName.Trim().ToLower().Replace(" ", "").Replace("_", ""); + return BinaryName.Trim().ToLower().Replace(" ", "").Replace("_", ""); } } @@ -165,47 +162,41 @@ public bool WindowHasTargetableStyles Tools.StartMethodMultithreadedAndWait(() => { - WindowsAPI.WindowStyleFlags styleCurrentWindow_standard = WindowsAPI.Native.GetWindowLong(this.WindowHandle, WindowsAPI.WindowLongIndex.Style); + var styleCurrentWindowStandard = WindowsAPI.Native.GetWindowLong(WindowHandle, WindowsAPI.WindowLongIndex.Style); - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.Border) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.DialogFrame) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ThickFrame) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.SystemMenu) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.MaximizeBox) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.MinimizeBox) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.Border) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.DialogFrame) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ThickFrame) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.SystemMenu) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.MaximizeBox) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.MinimizeBox) > 0) targetable = true; if (!targetable) { - WindowsAPI.WindowStyleFlags styleCurrentWindow_extended = WindowsAPI.Native.GetWindowLong(this.WindowHandle, WindowsAPI.WindowLongIndex.ExtendedStyle); - - if (!targetable) if ((styleCurrentWindow_extended | WindowsAPI.WindowStyleFlags.ExtendedDlgModalFrame) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedComposited) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedWindowEdge) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedClientEdge) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedLayered) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedStaticEdge) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedToolWindow) > 0) targetable = true; - if (!targetable) if ((styleCurrentWindow_standard | WindowsAPI.WindowStyleFlags.ExtendedAppWindow) > 0) targetable = true; + var styleCurrentWindowExtended = WindowsAPI.Native.GetWindowLong(WindowHandle, WindowsAPI.WindowLongIndex.ExtendedStyle); + + if (!targetable) if ((styleCurrentWindowExtended | WindowsAPI.WindowStyleFlags.ExtendedDlgModalFrame) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedComposited) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedWindowEdge) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedClientEdge) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedLayered) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedStaticEdge) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedToolWindow) > 0) targetable = true; + if (!targetable) if ((styleCurrentWindowStandard | WindowsAPI.WindowStyleFlags.ExtendedAppWindow) > 0) targetable = true; } - }, (Utilities.AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); + }, (AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2); return targetable; } } public static implicit operator Process(ProcessDetails pd) { - if (pd == null) - return null; - - return pd.Proc; + return pd?.Proc; } public static implicit operator IntPtr(ProcessDetails pd) { - if (pd == null) - return IntPtr.Zero; - - return pd.WindowHandle; + return pd?.WindowHandle ?? IntPtr.Zero; } } } diff --git a/Common/ProcessDetailsList.cs b/Common/ProcessDetailsList.cs index 7d2afd6..560f76e 100644 --- a/Common/ProcessDetailsList.cs +++ b/Common/ProcessDetailsList.cs @@ -15,19 +15,19 @@ public class ProcessDetailsList : ObservableCollection //public override event NotifyCollectionChangedEventHandler CollectionChanged; - public HashSet WindowPtrSet { get { return _windowPtrSet; } } - public HashSet WindowTitleSet { get { return _windowTitleSet; } } - public HashSet ProcessTitleSet { get { return _windowTitleSet; } } + public HashSet WindowPtrSet => _windowPtrSet; + public HashSet WindowTitleSet => _windowTitleSet; + public HashSet ProcessTitleSet => _windowTitleSet; - public ProcessDetailsList() + public ProcessDetailsList() { - this._windowPtrSet = new HashSet(); - this._windowTitleSet = new HashSet(); - this._processTitleSet = new HashSet(); - this.CollectionChanged += OnCollectionChanged; + _windowPtrSet = new HashSet(); + _windowTitleSet = new HashSet(); + _processTitleSet = new HashSet(); + CollectionChanged += OnCollectionChanged; } - private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { @@ -63,7 +63,7 @@ public void ClearProcesses() internal ProcessDetails FromHandle(IntPtr hCurrentActiveWindow) { - return this.Where(pd => pd.WindowHandle == hCurrentActiveWindow).FirstOrDefault(); + return this.FirstOrDefault(pd => pd.WindowHandle == hCurrentActiveWindow); } } } diff --git a/Forms/AboutForm.cs b/Forms/AboutForm.cs index 50f297f..d4dc95b 100644 --- a/Forms/AboutForm.cs +++ b/Forms/AboutForm.cs @@ -15,8 +15,8 @@ public AboutForm() private void AboutFormLoad(object sender, EventArgs e) { // removed .Version.ToString(2) in favor of just .ToString() here so we can see the build number now - this.versionLabel.Text = "Borderless Gaming " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); - this._copyrightLabel.Text = "Copyright © 2014-" + DateTime.Now.Year.ToString() + " Andrew Sampson"; + versionLabel.Text = "Borderless Gaming " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); + _copyrightLabel.Text = "Copyright © 2014-" + DateTime.Now.Year.ToString() + " Andrew Sampson"; } #region Project and Maintainer Links diff --git a/Forms/DesktopAreaSelector.cs b/Forms/DesktopAreaSelector.cs index deef99f..01f08a0 100644 --- a/Forms/DesktopAreaSelector.cs +++ b/Forms/DesktopAreaSelector.cs @@ -66,11 +66,11 @@ private enum ClickAction : int public DesktopAreaSelector() { InitializeComponent(); - this.MouseDown += new MouseEventHandler(OnMouseClick); - this.MouseDoubleClick += new MouseEventHandler(OnMouseDoubleClick); - this.MouseUp += new MouseEventHandler(OnMouseUp); - this.MouseMove += new MouseEventHandler(OnMouseMove); - this.KeyUp += new KeyEventHandler(OnKeyPress); + MouseDown += new MouseEventHandler(OnMouseClick); + MouseDoubleClick += new MouseEventHandler(OnMouseDoubleClick); + MouseUp += new MouseEventHandler(OnMouseUp); + MouseMove += new MouseEventHandler(OnMouseMove); + KeyUp += new KeyEventHandler(OnKeyPress); } private void DesktopAreaSelector_Load(object sender, EventArgs e) @@ -80,10 +80,10 @@ private void DesktopAreaSelector_Load(object sender, EventArgs e) foreach (Screen screen in Screen.AllScreens) rect = Tools.GetContainingRectangle(rect, screen.WorkingArea); - this.Location = new Point(rect.Left, rect.Top); - this.Size = new Size(rect.Width, rect.Height); + Location = new Point(rect.Left, rect.Top); + Size = new Size(rect.Width, rect.Height); - this.grfxDrawingSurface = this.CreateGraphics(); + grfxDrawingSurface = CreateGraphics(); } private void DesktopAreaSelector_Shown(object sender, EventArgs e) @@ -101,7 +101,7 @@ private Point RealCursorPosition private Point TranslateRealPointToDrawn(Point p) { - return new Point(p.X - this.Location.X, p.Y - this.Location.Y); + return new Point(p.X - Location.X, p.Y - Location.Y); } /* @@ -123,8 +123,8 @@ private void OnKeyPress(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { - this.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Close(); + DialogResult = DialogResult.Cancel; + Close(); } } @@ -139,11 +139,11 @@ private void OnMouseDoubleClick(object sender, MouseEventArgs e) { if (RectangleDrawn && CursorPosition() == CursPos.WithinSelectionArea) - this.DialogResult = System.Windows.Forms.DialogResult.OK; + DialogResult = DialogResult.OK; else - this.DialogResult = System.Windows.Forms.DialogResult.Cancel; + DialogResult = DialogResult.Cancel; - this.Close(); + Close(); } private void OnMouseClick(object sender, MouseEventArgs e) @@ -161,8 +161,8 @@ private void OnMouseClick(object sender, MouseEventArgs e) RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; - DragClickRelative.X = this.RealCursorPosition.X; - DragClickRelative.Y = this.RealCursorPosition.Y; + DragClickRelative.X = RealCursorPosition.X; + DragClickRelative.Y = RealCursorPosition.Y; DragTopLeft = CurrentTopLeft; } @@ -198,53 +198,53 @@ private void OnMouseMove(object sender, MouseEventArgs e) private CursPos CursorPosition() { - if (((this.RealCursorPosition.X > CurrentTopLeft.X - 10 && this.RealCursorPosition.X < CurrentTopLeft.X + 10)) && ((this.RealCursorPosition.Y > CurrentTopLeft.Y + 10) && (this.RealCursorPosition.Y < CurrentBottomRight.Y - 10))) + if (((RealCursorPosition.X > CurrentTopLeft.X - 10 && RealCursorPosition.X < CurrentTopLeft.X + 10)) && ((RealCursorPosition.Y > CurrentTopLeft.Y + 10) && (RealCursorPosition.Y < CurrentBottomRight.Y - 10))) { - this.Cursor = Cursors.SizeWE; + Cursor = Cursors.SizeWE; return CursPos.LeftLine; } - if (((this.RealCursorPosition.X >= CurrentTopLeft.X - 10 && this.RealCursorPosition.X <= CurrentTopLeft.X + 10)) && ((this.RealCursorPosition.Y >= CurrentTopLeft.Y - 10) && (this.RealCursorPosition.Y <= CurrentTopLeft.Y + 10))) + if (((RealCursorPosition.X >= CurrentTopLeft.X - 10 && RealCursorPosition.X <= CurrentTopLeft.X + 10)) && ((RealCursorPosition.Y >= CurrentTopLeft.Y - 10) && (RealCursorPosition.Y <= CurrentTopLeft.Y + 10))) { - this.Cursor = Cursors.SizeNWSE; + Cursor = Cursors.SizeNWSE; return CursPos.TopLeft; } - if (((this.RealCursorPosition.X >= CurrentTopLeft.X - 10 && this.RealCursorPosition.X <= CurrentTopLeft.X + 10)) && ((this.RealCursorPosition.Y >= CurrentBottomRight.Y - 10) && (this.RealCursorPosition.Y <= CurrentBottomRight.Y + 10))) + if (((RealCursorPosition.X >= CurrentTopLeft.X - 10 && RealCursorPosition.X <= CurrentTopLeft.X + 10)) && ((RealCursorPosition.Y >= CurrentBottomRight.Y - 10) && (RealCursorPosition.Y <= CurrentBottomRight.Y + 10))) { - this.Cursor = Cursors.SizeNESW; + Cursor = Cursors.SizeNESW; return CursPos.BottomLeft; } - if (((this.RealCursorPosition.X > CurrentBottomRight.X - 10 && this.RealCursorPosition.X < CurrentBottomRight.X + 10)) && ((this.RealCursorPosition.Y > CurrentTopLeft.Y + 10) && (this.RealCursorPosition.Y < CurrentBottomRight.Y - 10))) + if (((RealCursorPosition.X > CurrentBottomRight.X - 10 && RealCursorPosition.X < CurrentBottomRight.X + 10)) && ((RealCursorPosition.Y > CurrentTopLeft.Y + 10) && (RealCursorPosition.Y < CurrentBottomRight.Y - 10))) { - this.Cursor = Cursors.SizeWE; + Cursor = Cursors.SizeWE; return CursPos.RightLine; } - if (((this.RealCursorPosition.X >= CurrentBottomRight.X - 10 && this.RealCursorPosition.X <= CurrentBottomRight.X + 10)) && ((this.RealCursorPosition.Y >= CurrentTopLeft.Y - 10) && (this.RealCursorPosition.Y <= CurrentTopLeft.Y + 10))) + if (((RealCursorPosition.X >= CurrentBottomRight.X - 10 && RealCursorPosition.X <= CurrentBottomRight.X + 10)) && ((RealCursorPosition.Y >= CurrentTopLeft.Y - 10) && (RealCursorPosition.Y <= CurrentTopLeft.Y + 10))) { - this.Cursor = Cursors.SizeNESW; + Cursor = Cursors.SizeNESW; return CursPos.TopRight; } - if (((this.RealCursorPosition.X >= CurrentBottomRight.X - 10 && this.RealCursorPosition.X <= CurrentBottomRight.X + 10)) && ((this.RealCursorPosition.Y >= CurrentBottomRight.Y - 10) && (this.RealCursorPosition.Y <= CurrentBottomRight.Y + 10))) + if (((RealCursorPosition.X >= CurrentBottomRight.X - 10 && RealCursorPosition.X <= CurrentBottomRight.X + 10)) && ((RealCursorPosition.Y >= CurrentBottomRight.Y - 10) && (RealCursorPosition.Y <= CurrentBottomRight.Y + 10))) { - this.Cursor = Cursors.SizeNWSE; + Cursor = Cursors.SizeNWSE; return CursPos.BottomRight; } - if (((this.RealCursorPosition.Y > CurrentTopLeft.Y - 10) && (this.RealCursorPosition.Y < CurrentTopLeft.Y + 10)) && ((this.RealCursorPosition.X > CurrentTopLeft.X + 10 && this.RealCursorPosition.X < CurrentBottomRight.X - 10))) + if (((RealCursorPosition.Y > CurrentTopLeft.Y - 10) && (RealCursorPosition.Y < CurrentTopLeft.Y + 10)) && ((RealCursorPosition.X > CurrentTopLeft.X + 10 && RealCursorPosition.X < CurrentBottomRight.X - 10))) { - this.Cursor = Cursors.SizeNS; + Cursor = Cursors.SizeNS; return CursPos.TopLine; } - if (((this.RealCursorPosition.Y > CurrentBottomRight.Y - 10) && (this.RealCursorPosition.Y < CurrentBottomRight.Y + 10)) && ((this.RealCursorPosition.X > CurrentTopLeft.X + 10 && this.RealCursorPosition.X < CurrentBottomRight.X - 10))) + if (((RealCursorPosition.Y > CurrentBottomRight.Y - 10) && (RealCursorPosition.Y < CurrentBottomRight.Y + 10)) && ((RealCursorPosition.X > CurrentTopLeft.X + 10 && RealCursorPosition.X < CurrentBottomRight.X - 10))) { - this.Cursor = Cursors.SizeNS; + Cursor = Cursors.SizeNS; return CursPos.BottomLine; } - if ((this.RealCursorPosition.X >= CurrentTopLeft.X + 10 && this.RealCursorPosition.X <= CurrentBottomRight.X - 10) && (this.RealCursorPosition.Y >= CurrentTopLeft.Y + 10 && this.RealCursorPosition.Y <= CurrentBottomRight.Y - 10)) + if ((RealCursorPosition.X >= CurrentTopLeft.X + 10 && RealCursorPosition.X <= CurrentBottomRight.X - 10) && (RealCursorPosition.Y >= CurrentTopLeft.Y + 10 && RealCursorPosition.Y <= CurrentBottomRight.Y - 10)) { - this.Cursor = Cursors.Hand; + Cursor = Cursors.Hand; return CursPos.WithinSelectionArea; } - this.Cursor = Cursors.No; + Cursor = Cursors.No; return CursPos.OutsideSelectionArea; } @@ -298,23 +298,23 @@ private void ResizeSelection() { if (CurrentAction == ClickAction.LeftSizing) { - if (this.RealCursorPosition.X < CurrentBottomRight.X - 10) + if (RealCursorPosition.X < CurrentBottomRight.X - 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentTopLeft.X = this.RealCursorPosition.X; + CurrentTopLeft.X = RealCursorPosition.X; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); } } if (CurrentAction == ClickAction.TopLeftSizing) { - if (this.RealCursorPosition.X < CurrentBottomRight.X - 10 && this.RealCursorPosition.Y < CurrentBottomRight.Y - 10) + if (RealCursorPosition.X < CurrentBottomRight.X - 10 && RealCursorPosition.Y < CurrentBottomRight.Y - 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentTopLeft.X = this.RealCursorPosition.X; - CurrentTopLeft.Y = this.RealCursorPosition.Y; + CurrentTopLeft.X = RealCursorPosition.X; + CurrentTopLeft.Y = RealCursorPosition.Y; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); @@ -322,12 +322,12 @@ private void ResizeSelection() } if (CurrentAction == ClickAction.BottomLeftSizing) { - if (this.RealCursorPosition.X < CurrentBottomRight.X - 10 && this.RealCursorPosition.Y > CurrentTopLeft.Y + 10) + if (RealCursorPosition.X < CurrentBottomRight.X - 10 && RealCursorPosition.Y > CurrentTopLeft.Y + 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentTopLeft.X = this.RealCursorPosition.X; - CurrentBottomRight.Y = this.RealCursorPosition.Y; + CurrentTopLeft.X = RealCursorPosition.X; + CurrentBottomRight.Y = RealCursorPosition.Y; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); @@ -335,23 +335,23 @@ private void ResizeSelection() } if (CurrentAction == ClickAction.RightSizing) { - if (this.RealCursorPosition.X > CurrentTopLeft.X + 10) + if (RealCursorPosition.X > CurrentTopLeft.X + 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentBottomRight.X = this.RealCursorPosition.X; + CurrentBottomRight.X = RealCursorPosition.X; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); } } if (CurrentAction == ClickAction.TopRightSizing) { - if (this.RealCursorPosition.X > CurrentTopLeft.X + 10 && this.RealCursorPosition.Y < CurrentBottomRight.Y - 10) + if (RealCursorPosition.X > CurrentTopLeft.X + 10 && RealCursorPosition.Y < CurrentBottomRight.Y - 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentBottomRight.X = this.RealCursorPosition.X; - CurrentTopLeft.Y = this.RealCursorPosition.Y; + CurrentBottomRight.X = RealCursorPosition.X; + CurrentTopLeft.Y = RealCursorPosition.Y; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); @@ -359,12 +359,12 @@ private void ResizeSelection() } if (CurrentAction == ClickAction.BottomRightSizing) { - if (this.RealCursorPosition.X > CurrentTopLeft.X + 10 && this.RealCursorPosition.Y > CurrentTopLeft.Y + 10) + if (RealCursorPosition.X > CurrentTopLeft.X + 10 && RealCursorPosition.Y > CurrentTopLeft.Y + 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentBottomRight.X = this.RealCursorPosition.X; - CurrentBottomRight.Y = this.RealCursorPosition.Y; + CurrentBottomRight.X = RealCursorPosition.X; + CurrentBottomRight.Y = RealCursorPosition.Y; RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); @@ -372,22 +372,22 @@ private void ResizeSelection() } if (CurrentAction == ClickAction.TopSizing) { - if (this.RealCursorPosition.Y < CurrentBottomRight.Y - 10) + if (RealCursorPosition.Y < CurrentBottomRight.Y - 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentTopLeft.Y = this.RealCursorPosition.Y; + CurrentTopLeft.Y = RealCursorPosition.Y; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); } } if (CurrentAction == ClickAction.BottomSizing) { - if (this.RealCursorPosition.Y > CurrentTopLeft.Y + 10) + if (RealCursorPosition.Y > CurrentTopLeft.Y + 10) { //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentBottomRight.Y = this.RealCursorPosition.Y; + CurrentBottomRight.Y = RealCursorPosition.Y; RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y; grfxDrawingSurface.DrawRectangle(MyPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); } @@ -401,8 +401,8 @@ private void DragSelection() //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, RectangleWidth, RectangleHeight); - CurrentTopLeft.X = this.DragTopLeft.X + (this.RealCursorPosition.X - DragClickRelative.X); - CurrentTopLeft.Y = this.DragTopLeft.Y + (this.RealCursorPosition.Y - DragClickRelative.Y); + CurrentTopLeft.X = DragTopLeft.X + (RealCursorPosition.X - DragClickRelative.X); + CurrentTopLeft.Y = DragTopLeft.Y + (RealCursorPosition.Y - DragClickRelative.Y); CurrentBottomRight.X = CurrentTopLeft.X + RectangleWidth; CurrentBottomRight.Y = CurrentTopLeft.Y + RectangleHeight; @@ -414,33 +414,33 @@ private void DragSelection() private void DrawSelection() { - this.Cursor = Cursors.Arrow; + Cursor = Cursors.Arrow; //Erase the previous rectangle grfxDrawingSurface.DrawRectangle(EraserPen, TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentTopLeft).Y, TranslateRealPointToDrawn(CurrentBottomRight).X - TranslateRealPointToDrawn(CurrentTopLeft).X, TranslateRealPointToDrawn(CurrentBottomRight).Y - TranslateRealPointToDrawn(CurrentTopLeft).Y); //Calculate X Coordinates - if (this.RealCursorPosition.X < ClickPoint.X) + if (RealCursorPosition.X < ClickPoint.X) { - CurrentTopLeft.X = this.RealCursorPosition.X; + CurrentTopLeft.X = RealCursorPosition.X; CurrentBottomRight.X = ClickPoint.X; } else { CurrentTopLeft.X = ClickPoint.X; - CurrentBottomRight.X = this.RealCursorPosition.X; + CurrentBottomRight.X = RealCursorPosition.X; } //Calculate Y Coordinates - if (this.RealCursorPosition.Y < ClickPoint.Y) + if (RealCursorPosition.Y < ClickPoint.Y) { - CurrentTopLeft.Y = this.RealCursorPosition.Y; + CurrentTopLeft.Y = RealCursorPosition.Y; CurrentBottomRight.Y = ClickPoint.Y; } else { CurrentTopLeft.Y = ClickPoint.Y; - CurrentBottomRight.Y = this.RealCursorPosition.Y; + CurrentBottomRight.Y = RealCursorPosition.Y; } //Draw a new rectangle diff --git a/Forms/InputText.cs b/Forms/InputText.cs index d22583e..9f5106c 100644 --- a/Forms/InputText.cs +++ b/Forms/InputText.cs @@ -12,18 +12,18 @@ public InputText() private void frmInputText_Shown(object sender, EventArgs e) { - this.txtInput.Focus(); + txtInput.Focus(); } public string Title { get { - return this.Text.Trim(); + return Text.Trim(); } set { - this.Text = value.Trim(); + Text = value.Trim(); } } @@ -31,11 +31,11 @@ public string Input { get { - return this.txtInput.Text.Trim(); + return txtInput.Text.Trim(); } set { - this.txtInput.Text = value.Trim(); + txtInput.Text = value.Trim(); } } @@ -43,11 +43,11 @@ public string Instructions { get { - return this.lblInstructions.Text.Trim(); + return lblInstructions.Text.Trim(); } set { - this.lblInstructions.Text = value.Trim(); + lblInstructions.Text = value.Trim(); } } } diff --git a/Forms/MainWindow.cs b/Forms/MainWindow.cs index 30bfbb2..4172829 100644 --- a/Forms/MainWindow.cs +++ b/Forms/MainWindow.cs @@ -49,10 +49,10 @@ public partial class MainWindow : Form private BorderlessGaming controller; public MainWindow() { - this.controller = new BorderlessGaming(this); - this.controller.Processes.CollectionChanged += Processes_CollectionChanged; - this.controller.Favorites.CollectionChanged += Favorites_CollectionChanged; - this.InitializeComponent(); + controller = new BorderlessGaming(this); + controller.Processes.CollectionChanged += Processes_CollectionChanged; + controller.Favorites.CollectionChanged += Favorites_CollectionChanged; + InitializeComponent(); } #region External access and processing @@ -75,12 +75,12 @@ public static void DoEvents() try { bool local__DoEventsEngaged = false; - lock (MainWindow._DoEvents_locker) + lock (_DoEvents_locker) { - local__DoEventsEngaged = MainWindow._DoEvents_engaged; + local__DoEventsEngaged = _DoEvents_engaged; if (!local__DoEventsEngaged) - MainWindow._DoEvents_engaged = true; + _DoEvents_engaged = true; } if (!local__DoEventsEngaged) @@ -89,9 +89,9 @@ public static void DoEvents() Application.DoEvents(); } - lock (MainWindow._DoEvents_locker) + lock (_DoEvents_locker) { - MainWindow._DoEvents_engaged = false; + _DoEvents_engaged = false; } } catch { } @@ -174,60 +174,60 @@ private void Favorites_CollectionChanged(object sender, System.Collections.Speci private void toolStripRunOnStartup_CheckChanged(object sender, EventArgs e) { - AutoStart.SetShortcut(this.toolStripRunOnStartup.Checked, Environment.SpecialFolder.Startup, "-silent -minimize"); + AutoStart.SetShortcut(toolStripRunOnStartup.Checked, Environment.SpecialFolder.Startup, "-silent -minimize"); - AppEnvironment.Setting("RunOnStartup", this.toolStripRunOnStartup.Checked); + AppEnvironment.Setting("RunOnStartup", toolStripRunOnStartup.Checked); } private void toolStripCheckForUpdates_CheckedChanged(object sender, EventArgs e) { - AppEnvironment.Setting("CheckForUpdates", this.toolStripCheckForUpdates.Checked); + AppEnvironment.Setting("CheckForUpdates", toolStripCheckForUpdates.Checked); } private void toolStripGlobalHotkey_CheckChanged(object sender, EventArgs e) { - AppEnvironment.Setting("UseGlobalHotkey", this.toolStripGlobalHotkey.Checked); + AppEnvironment.Setting("UseGlobalHotkey", toolStripGlobalHotkey.Checked); - this.RegisterHotkeys(); + RegisterHotkeys(); } private void toolStripMouseLock_CheckChanged(object sender, EventArgs e) { - AppEnvironment.Setting("UseMouseLockHotkey", this.toolStripMouseLock.Checked); + AppEnvironment.Setting("UseMouseLockHotkey", toolStripMouseLock.Checked); - this.RegisterHotkeys(); + RegisterHotkeys(); } private void useMouseHideHotkeyWinScrollLockToolStripMenuItem_CheckChanged(object sender, EventArgs e) { - AppEnvironment.Setting("UseMouseHideHotkey", this.useMouseHideHotkeyWinScrollLockToolStripMenuItem.Checked); + AppEnvironment.Setting("UseMouseHideHotkey", useMouseHideHotkeyWinScrollLockToolStripMenuItem.Checked); - this.RegisterHotkeys(); + RegisterHotkeys(); } private void startMinimizedToTrayToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - AppEnvironment.Setting("StartMinimized", this.startMinimizedToTrayToolStripMenuItem.Checked); + AppEnvironment.Setting("StartMinimized", startMinimizedToTrayToolStripMenuItem.Checked); } private void hideBalloonTipsToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - AppEnvironment.Setting("HideBalloonTips", this.hideBalloonTipsToolStripMenuItem.Checked); + AppEnvironment.Setting("HideBalloonTips", hideBalloonTipsToolStripMenuItem.Checked); } private void closeToTrayToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - AppEnvironment.Setting("CloseToTray", this.closeToTrayToolStripMenuItem.Checked); + AppEnvironment.Setting("CloseToTray", closeToTrayToolStripMenuItem.Checked); } private void useSlowerWindowDetectionToolStripMenuItem_Click(object sender, EventArgs e) { - AppEnvironment.Setting("SlowWindowDetection", this.useSlowerWindowDetectionToolStripMenuItem.Checked); + AppEnvironment.Setting("SlowWindowDetection", useSlowerWindowDetectionToolStripMenuItem.Checked); } private async void viewFullProcessDetailsToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - AppEnvironment.Setting("ViewAllProcessDetails", this.viewFullProcessDetailsToolStripMenuItem.Checked); + AppEnvironment.Setting("ViewAllProcessDetails", viewFullProcessDetailsToolStripMenuItem.Checked); await controller.RefreshProcesses(); } @@ -242,7 +242,7 @@ private void openDataFolderToolStripMenuItem_Click(object sender, EventArgs e) { try { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo + Process.Start(new ProcessStartInfo ( "explorer.exe", "/e,\"" + AppEnvironment.DataPath + "\",\"" + AppEnvironment.DataPath + "\"") @@ -258,7 +258,7 @@ private void pauseAutomaticProcessingToolStripMenuItem_Click(object sender, Even private void toggleMouseCursorVisibilityToolStripMenuItem_Click(object sender, EventArgs e) { - if (Manipulation.MouseCursorIsHidden || (MessageBox.Show("Do you really want to hide the mouse cursor?\r\n\r\nYou may have a difficult time finding the mouse again once it's hidden.\r\n\r\nIf you have enabled the global hotkey to toggle the mouse cursor visibility, you can press [Win + Scroll Lock] to toggle the mouse cursor on.\r\n\r\nAlso, exiting Borderless Gaming will immediately restore your mouse cursor.", "Really Hide Mouse Cursor?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)) + if (Manipulation.MouseCursorIsHidden || (MessageBox.Show("Do you really want to hide the mouse cursor?\r\n\r\nYou may have a difficult time finding the mouse again once it's hidden.\r\n\r\nIf you have enabled the global hotkey to toggle the mouse cursor visibility, you can press [Win + Scroll Lock] to toggle the mouse cursor on.\r\n\r\nAlso, exiting Borderless Gaming will immediately restore your mouse cursor.", "Really Hide Mouse Cursor?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)) Manipulation.ToggleMouseCursorVisibility(this); } @@ -305,26 +305,26 @@ private void lstProcesses_SelectedIndexChanged(object sender, EventArgs e) { bool valid_selection = false; - if (this.lstProcesses.SelectedItem != null) + if (lstProcesses.SelectedItem != null) { - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); valid_selection = pd.Manageable; } - this.btnMakeBorderless.Enabled = this.btnRestoreWindow.Enabled = this.addSelectedItem.Enabled = valid_selection; + btnMakeBorderless.Enabled = btnRestoreWindow.Enabled = addSelectedItem.Enabled = valid_selection; } private void lstFavorites_SelectedIndexChanged(object sender, EventArgs e) { - this.btnRemoveFavorite.Enabled = (this.lstFavorites.SelectedItem != null); + btnRemoveFavorite.Enabled = (lstFavorites.SelectedItem != null); } private void setWindowTitleToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -334,9 +334,9 @@ private void setWindowTitleToolStripMenuItem_Click(object sender, EventArgs e) private async void hideThisProcessToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -351,9 +351,9 @@ private async void hideThisProcessToolStripMenuItem_Click(object sender, EventAr /// private void btnMakeBorderless_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -363,9 +363,9 @@ private void btnMakeBorderless_Click(object sender, EventArgs e) private void btnRestoreWindow_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -378,9 +378,9 @@ private void btnRestoreWindow_Click(object sender, EventArgs e) /// private void byTheWindowTitleTextToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -400,9 +400,9 @@ private void byTheWindowTitleTextToolStripMenuItem_Click(object sender, EventArg /// private void byTheProcessBinaryNameToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -422,9 +422,9 @@ private void byTheProcessBinaryNameToolStripMenuItem_Click(object sender, EventA /// private void byTheWindowTitleTextregexToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; @@ -474,17 +474,17 @@ private void addSelectedItem_Click(object sender, EventArgs e) // assume that the button press to add to favorites will do so by window title (unless it's blank, then go by process name) - if (this.lstProcesses.SelectedItem == null) return; + if (lstProcesses.SelectedItem == null) return; - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) return; if (!string.IsNullOrEmpty(pd.WindowTitle)) - this.byTheWindowTitleTextToolStripMenuItem_Click(sender, e); + byTheWindowTitleTextToolStripMenuItem_Click(sender, e); else - this.byTheProcessBinaryNameToolStripMenuItem_Click(sender, e); + byTheProcessBinaryNameToolStripMenuItem_Click(sender, e); } private void RefreshFavoritesList(Favorites.Favorite fav = null) @@ -499,10 +499,10 @@ private void RefreshFavoritesList(Favorites.Favorite fav = null) /// private void btnRemoveFavorite_Click(object sender, EventArgs e) { - if (this.lstFavorites.SelectedItem == null) return; + if (lstFavorites.SelectedItem == null) return; //TODO move to controller. - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; @@ -512,37 +512,37 @@ private void btnRemoveFavorite_Click(object sender, EventArgs e) private void removeMenusToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstFavorites.SelectedItem == null) return; + if (lstFavorites.SelectedItem == null) return; - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.RemoveMenus = this.removeMenusToolStripMenuItem.Checked; + fav.RemoveMenus = removeMenusToolStripMenuItem.Checked; RefreshFavoritesList(fav); } private void alwaysOnTopToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.lstFavorites.SelectedItem == null) return; + if (lstFavorites.SelectedItem == null) return; - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.TopMost = this.alwaysOnTopToolStripMenuItem.Checked; + fav.TopMost = alwaysOnTopToolStripMenuItem.Checked; RefreshFavoritesList(fav); } private void adjustWindowBoundsToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; @@ -559,14 +559,14 @@ private void adjustWindowBoundsToolStripMenuItem_Click(object sender, EventArgs private void automaximizeToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.ShouldMaximize = this.automaximizeToolStripMenuItem.Checked; + fav.ShouldMaximize = automaximizeToolStripMenuItem.Checked; if (fav.ShouldMaximize) { @@ -582,48 +582,48 @@ private void automaximizeToolStripMenuItem_Click(object sender, EventArgs e) private void hideMouseCursorToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.HideMouseCursor = this.hideMouseCursorToolStripMenuItem.Checked; + fav.HideMouseCursor = hideMouseCursorToolStripMenuItem.Checked; RefreshFavoritesList(fav); } private void hideWindowsTaskbarToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.HideWindowsTaskbar = this.hideWindowsTaskbarToolStripMenuItem.Checked; + fav.HideWindowsTaskbar = hideWindowsTaskbarToolStripMenuItem.Checked; - this.RefreshFavoritesList(fav); + RefreshFavoritesList(fav); } private void setWindowSizeToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; DialogResult result = MessageBox.Show("Would you like to select the area using your mouse cursor?\r\n\r\nIf you answer No, you will be prompted for specific pixel dimensions.", "Select Area?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); - if (result == System.Windows.Forms.DialogResult.Cancel) + if (result == DialogResult.Cancel) return; - if (result == System.Windows.Forms.DialogResult.Yes) + if (result == DialogResult.Yes) { using (DesktopAreaSelector frmSelectArea = new DesktopAreaSelector()) { - if (frmSelectArea.ShowDialog() != System.Windows.Forms.DialogResult.OK) + if (frmSelectArea.ShowDialog() != DialogResult.OK) return; // Temporarily disable compiler warning CS1690: http://msdn.microsoft.com/en-us/library/x524dkh4.aspx @@ -655,19 +655,19 @@ private void setWindowSizeToolStripMenuItem_Click(object sender, EventArgs e) fav.ShouldMaximize = false; } - this.RefreshFavoritesList(fav); + RefreshFavoritesList(fav); } private void fullScreenToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.SizeMode = (this.fullScreenToolStripMenuItem.Checked) ? Favorites.Favorite.SizeModes.FullScreen : Favorites.Favorite.SizeModes.NoChange; + fav.SizeMode = (fullScreenToolStripMenuItem.Checked) ? Favorites.Favorite.SizeModes.FullScreen : Favorites.Favorite.SizeModes.NoChange; if (fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen) { @@ -679,20 +679,20 @@ private void fullScreenToolStripMenuItem_Click(object sender, EventArgs e) else fav.ShouldMaximize = false; - this.RefreshFavoritesList(fav); + RefreshFavoritesList(fav); } private void noSizeChangeToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.SizeMode = (this.noSizeChangeToolStripMenuItem.Checked) ? Favorites.Favorite.SizeModes.NoChange : Favorites.Favorite.SizeModes.FullScreen; + fav.SizeMode = (noSizeChangeToolStripMenuItem.Checked) ? Favorites.Favorite.SizeModes.NoChange : Favorites.Favorite.SizeModes.FullScreen; if (fav.SizeMode == Favorites.Favorite.SizeModes.NoChange) { @@ -707,19 +707,19 @@ private void noSizeChangeToolStripMenuItem_Click(object sender, EventArgs e) fav.PositionH = 0; } - this.RefreshFavoritesList(fav); + RefreshFavoritesList(fav); } private void delayBorderlessToolStripMenuItem_Click(object sender, EventArgs e) { - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; if (!controller.Favorites.CanRemove(fav.SearchText)) return; controller.Favorites.Remove(fav); - fav.DelayBorderless = this.delayBorderlessToolStripMenuItem.Checked; + fav.DelayBorderless = delayBorderlessToolStripMenuItem.Checked; RefreshFavoritesList(fav); } @@ -729,25 +729,25 @@ private void delayBorderlessToolStripMenuItem_Click(object sender, EventArgs e) /// private void mnuFavoritesContext_Opening(object sender, CancelEventArgs e) { - if (this.lstFavorites.SelectedItem == null) + if (lstFavorites.SelectedItem == null) { e.Cancel = true; return; } - Favorites.Favorite fav = (Favorites.Favorite)this.lstFavorites.SelectedItem; - this.fullScreenToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen; - this.automaximizeToolStripMenuItem.Checked = fav.ShouldMaximize; - this.alwaysOnTopToolStripMenuItem.Checked = fav.TopMost; - this.hideMouseCursorToolStripMenuItem.Checked = fav.HideMouseCursor; - this.hideWindowsTaskbarToolStripMenuItem.Checked = fav.HideWindowsTaskbar; - this.removeMenusToolStripMenuItem.Checked = fav.RemoveMenus; - - this.automaximizeToolStripMenuItem.Enabled = fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen; - this.adjustWindowBoundsToolStripMenuItem.Enabled = (fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen) && (!fav.ShouldMaximize); - this.setWindowSizeToolStripMenuItem.Enabled = fav.SizeMode != Favorites.Favorite.SizeModes.FullScreen; - this.setWindowSizeToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.SpecificSize; - this.noSizeChangeToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.NoChange; + Favorites.Favorite fav = (Favorites.Favorite)lstFavorites.SelectedItem; + fullScreenToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen; + automaximizeToolStripMenuItem.Checked = fav.ShouldMaximize; + alwaysOnTopToolStripMenuItem.Checked = fav.TopMost; + hideMouseCursorToolStripMenuItem.Checked = fav.HideMouseCursor; + hideWindowsTaskbarToolStripMenuItem.Checked = fav.HideWindowsTaskbar; + removeMenusToolStripMenuItem.Checked = fav.RemoveMenus; + + automaximizeToolStripMenuItem.Enabled = fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen; + adjustWindowBoundsToolStripMenuItem.Enabled = (fav.SizeMode == Favorites.Favorite.SizeModes.FullScreen) && (!fav.ShouldMaximize); + setWindowSizeToolStripMenuItem.Enabled = fav.SizeMode != Favorites.Favorite.SizeModes.FullScreen; + setWindowSizeToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.SpecificSize; + noSizeChangeToolStripMenuItem.Checked = fav.SizeMode == Favorites.Favorite.SizeModes.NoChange; } /// @@ -755,13 +755,13 @@ private void mnuFavoritesContext_Opening(object sender, CancelEventArgs e) /// private void processContext_Opening(object sender, CancelEventArgs e) { - if (this.lstProcesses.SelectedItem == null) + if (lstProcesses.SelectedItem == null) { e.Cancel = true; return; } - ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + ProcessDetails pd = ((ProcessDetails)lstProcesses.SelectedItem); if (!pd.Manageable) { @@ -769,18 +769,18 @@ private void processContext_Opening(object sender, CancelEventArgs e) return; } - this.contextAddToFavs.Enabled = controller.Favorites.CanAdd(pd.BinaryName) && controller.Favorites.CanAdd(pd.WindowTitle); + contextAddToFavs.Enabled = controller.Favorites.CanAdd(pd.BinaryName) && controller.Favorites.CanAdd(pd.WindowTitle); if (Screen.AllScreens.Length < 2) { - this.contextBorderlessOn.Visible = false; + contextBorderlessOn.Visible = false; } else { - this.contextBorderlessOn.Visible = true; + contextBorderlessOn.Visible = true; - if (this.contextBorderlessOn.HasDropDownItems) - this.contextBorderlessOn.DropDownItems.Clear(); + if (contextBorderlessOn.HasDropDownItems) + contextBorderlessOn.DropDownItems.Clear(); Rectangle superSize = Screen.PrimaryScreen.Bounds; @@ -795,21 +795,21 @@ private void processContext_Opening(object sender, CancelEventArgs e) string label = fixedDeviceName + ((screen.Primary) ? " (P)" : string.Empty); ToolStripMenuItem tsi = new ToolStripMenuItem(label); - tsi.Click += (s, ea) => { this.controller.RemoveBorder_ToSpecificScreen(pd, screen); }; + tsi.Click += (s, ea) => { controller.RemoveBorder_ToSpecificScreen(pd, screen); }; - this.contextBorderlessOn.DropDownItems.Add(tsi); + contextBorderlessOn.DropDownItems.Add(tsi); } // add supersize Option ToolStripMenuItem superSizeItem = new ToolStripMenuItem("SuperSize!"); - superSizeItem.Click += (s, ea) => { this.controller.RemoveBorder_ToSpecificRect(pd, superSize); }; + superSizeItem.Click += (s, ea) => { controller.RemoveBorder_ToSpecificRect(pd, superSize); }; - this.contextBorderlessOn.DropDownItems.Add(superSizeItem); + contextBorderlessOn.DropDownItems.Add(superSizeItem); } } - private System.Windows.Forms.ToolStripMenuItem disableSteamIntegrationToolStripMenuItem = null; + private ToolStripMenuItem disableSteamIntegrationToolStripMenuItem = null; /// /// Sets up the form @@ -817,61 +817,61 @@ private void processContext_Opening(object sender, CancelEventArgs e) private void MainWindow_Load(object sender, EventArgs e) { // set the title - this.Text = "Borderless Gaming " + Assembly.GetExecutingAssembly().GetName().Version.ToString(2) + ((UAC.Elevated) ? " [Administrator]" : ""); + Text = "Borderless Gaming " + Assembly.GetExecutingAssembly().GetName().Version.ToString(2) + ((UAC.Elevated) ? " [Administrator]" : ""); // load up settings - this.toolStripRunOnStartup.Checked = AppEnvironment.SettingValue("RunOnStartup", false); - this.toolStripGlobalHotkey.Checked = AppEnvironment.SettingValue("UseGlobalHotkey", false); - this.toolStripMouseLock.Checked = AppEnvironment.SettingValue("UseMouseLockHotkey", false); - this.toolStripCheckForUpdates.Checked = AppEnvironment.SettingValue("CheckForUpdates", true); - this.useMouseHideHotkeyWinScrollLockToolStripMenuItem.Checked = AppEnvironment.SettingValue("UseMouseHideHotkey", false); - this.startMinimizedToTrayToolStripMenuItem.Checked = AppEnvironment.SettingValue("StartMinimized", false); - this.hideBalloonTipsToolStripMenuItem.Checked = AppEnvironment.SettingValue("HideBalloonTips", false); - this.closeToTrayToolStripMenuItem.Checked = AppEnvironment.SettingValue("CloseToTray", false); - this.viewFullProcessDetailsToolStripMenuItem.Checked = AppEnvironment.SettingValue("ViewAllProcessDetails", false); - this.useSlowerWindowDetectionToolStripMenuItem.Checked = AppEnvironment.SettingValue("SlowWindowDetection", false); + toolStripRunOnStartup.Checked = AppEnvironment.SettingValue("RunOnStartup", false); + toolStripGlobalHotkey.Checked = AppEnvironment.SettingValue("UseGlobalHotkey", false); + toolStripMouseLock.Checked = AppEnvironment.SettingValue("UseMouseLockHotkey", false); + toolStripCheckForUpdates.Checked = AppEnvironment.SettingValue("CheckForUpdates", true); + useMouseHideHotkeyWinScrollLockToolStripMenuItem.Checked = AppEnvironment.SettingValue("UseMouseHideHotkey", false); + startMinimizedToTrayToolStripMenuItem.Checked = AppEnvironment.SettingValue("StartMinimized", false); + hideBalloonTipsToolStripMenuItem.Checked = AppEnvironment.SettingValue("HideBalloonTips", false); + closeToTrayToolStripMenuItem.Checked = AppEnvironment.SettingValue("CloseToTray", false); + viewFullProcessDetailsToolStripMenuItem.Checked = AppEnvironment.SettingValue("ViewAllProcessDetails", false); + useSlowerWindowDetectionToolStripMenuItem.Checked = AppEnvironment.SettingValue("SlowWindowDetection", false); // minimize the window if desired (hiding done in Shown) if (AppEnvironment.SettingValue("StartMinimized", false) || Tools.StartupParameters.Contains("-minimize")) - this.WindowState = FormWindowState.Minimized; + WindowState = FormWindowState.Minimized; else - this.WindowState = FormWindowState.Normal; + WindowState = FormWindowState.Normal; - if (Program.Steam_Loaded && this.disableSteamIntegrationToolStripMenuItem == null) + if (Program.Steam_Loaded && disableSteamIntegrationToolStripMenuItem == null) { - this.disableSteamIntegrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.disableSteamIntegrationToolStripMenuItem.Name = "disableSteamIntegrationToolStripMenuItem"; - this.disableSteamIntegrationToolStripMenuItem.Size = new Size(254, 22); - this.disableSteamIntegrationToolStripMenuItem.Text = "Disable Steam integration/hook"; - this.disableSteamIntegrationToolStripMenuItem.ToolTipText = "Prevents \"In-App\" on Steam"; - this.disableSteamIntegrationToolStripMenuItem.Checked = AppEnvironment.SettingValue("DisableSteamIntegration", false); - this.disableSteamIntegrationToolStripMenuItem.CheckOnClick = true; // let's do this before registering the CheckedChanged event - this.disableSteamIntegrationToolStripMenuItem.CheckedChanged += new System.EventHandler(this.disableSteamIntegrationToolStripMenuItem_CheckChanged); - this.toolsToolStripMenuItem.DropDownItems.Insert(0, this.disableSteamIntegrationToolStripMenuItem); + disableSteamIntegrationToolStripMenuItem = new ToolStripMenuItem(); + disableSteamIntegrationToolStripMenuItem.Name = "disableSteamIntegrationToolStripMenuItem"; + disableSteamIntegrationToolStripMenuItem.Size = new Size(254, 22); + disableSteamIntegrationToolStripMenuItem.Text = "Disable Steam integration/hook"; + disableSteamIntegrationToolStripMenuItem.ToolTipText = "Prevents \"In-App\" on Steam"; + disableSteamIntegrationToolStripMenuItem.Checked = AppEnvironment.SettingValue("DisableSteamIntegration", false); + disableSteamIntegrationToolStripMenuItem.CheckOnClick = true; // let's do this before registering the CheckedChanged event + disableSteamIntegrationToolStripMenuItem.CheckedChanged += new EventHandler(disableSteamIntegrationToolStripMenuItem_CheckChanged); + toolsToolStripMenuItem.DropDownItems.Insert(0, disableSteamIntegrationToolStripMenuItem); } } private void disableSteamIntegrationToolStripMenuItem_CheckChanged(object sender, EventArgs e) { - AppEnvironment.Setting("DisableSteamIntegration", this.disableSteamIntegrationToolStripMenuItem.Checked); + AppEnvironment.Setting("DisableSteamIntegration", disableSteamIntegrationToolStripMenuItem.Checked); } private void MainWindow_Shown(object sender, EventArgs e) { // hide the window if desired (this doesn't work well in Load) if (AppEnvironment.SettingValue("StartMinimized", false) || Tools.StartupParameters.Contains("-minimize")) - this.Hide(); + Hide(); // initialize favorite list - foreach (var ni in this.controller.Favorites) + foreach (var ni in controller.Favorites) lstFavorites.Items.Add(ni); // start Task API controller controller.Start(); // Update buttons' enabled/disabled state - this.lstProcesses_SelectedIndexChanged(sender, e); - this.lstFavorites_SelectedIndexChanged(sender, e); + lstProcesses_SelectedIndexChanged(sender, e); + lstFavorites_SelectedIndexChanged(sender, e); } /// @@ -884,7 +884,7 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) // Make them exit the game that triggered the taskbar to be hidden -- or -- use a global hotkey to restore it. if (Manipulation.WindowsTaskbarIsHidden) { - this.ClosingFromExitMenu = false; + ClosingFromExitMenu = false; e.Cancel = true; return; } @@ -895,13 +895,13 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) Manipulation.ToggleMouseCursorVisibility(this, Tools.Boolstate.True); // If the user didn't choose to exit from the tray icon context menu... - if (!this.ClosingFromExitMenu) + if (!ClosingFromExitMenu) { // ... and they have the preference set to close-to-tray ... if (AppEnvironment.SettingValue("CloseToTray", false)) { // ... then minimize the app and do not exit (minimizing will trigger another event to hide the form) - this.WindowState = FormWindowState.Minimized; + WindowState = FormWindowState.Minimized; e.Cancel = true; return; } @@ -910,11 +910,11 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) // At this point, we're okay to exit the application // Unregister all global hotkeys - this.UnregisterHotkeys(); + UnregisterHotkeys(); // Hide the tray icon. If we don't do this, then Environment.Exit() can sometimes ghost the icon in the // Windows system tray area. - this.trayIcon.Visible = false; + trayIcon.Visible = false; // Overkill... the form should just close naturally. Ideally we would just allow the form to close and // the remaining code in Program.cs would execute (if there were any), but this is how Borderless Gaming has @@ -952,32 +952,32 @@ private void btnRestoreWindow_MouseHover(object sender, EventArgs e) private void trayIcon_DoubleClick(object sender, EventArgs e) { - this.Show(); - this.WindowState = FormWindowState.Normal; + Show(); + WindowState = FormWindowState.Normal; } private bool ClosingFromExitMenu = false; private void exitToolStripMenuItem_Click(object sender, EventArgs e) { - this.ClosingFromExitMenu = true; - this.Close(); + ClosingFromExitMenu = true; + Close(); } private void MainWindow_Resize(object sender, EventArgs e) { - if (this.WindowState == FormWindowState.Minimized) + if (WindowState == FormWindowState.Minimized) { - this.trayIcon.Visible = true; + trayIcon.Visible = true; if (!AppEnvironment.SettingValue("HideBalloonTips", false) && !Tools.StartupParameters.Contains("-silent")) { // Display a balloon tooltip message for 2 seconds - this.trayIcon.BalloonTipText = string.Format(Resources.TrayMinimized, "Borderless Gaming"); - this.trayIcon.ShowBalloonTip(2000); + trayIcon.BalloonTipText = string.Format(Resources.TrayMinimized, "Borderless Gaming"); + trayIcon.ShowBalloonTip(2000); } if (!Manipulation.WindowsTaskbarIsHidden) - this.Hide(); + Hide(); } } @@ -990,16 +990,16 @@ private void MainWindow_Resize(object sender, EventArgs e) /// private void RegisterHotkeys() { - this.UnregisterHotkeys(); + UnregisterHotkeys(); if (AppEnvironment.SettingValue("UseGlobalHotkey", false)) - Native.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), MainWindow.MakeBorderless_HotKeyModifier, MainWindow.MakeBorderless_HotKey); + Native.RegisterHotKey(Handle, GetType().GetHashCode(), MakeBorderless_HotKeyModifier, MakeBorderless_HotKey); if (AppEnvironment.SettingValue("UseMouseLockHotkey", false)) - Native.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 0, MainWindow.MouseLock_HotKey); + Native.RegisterHotKey(Handle, GetType().GetHashCode(), 0, MouseLock_HotKey); if (AppEnvironment.SettingValue("UseMouseHideHotkey", false)) - Native.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), MainWindow.MouseHide_HotKeyModifier, MainWindow.MouseHide_HotKey); + Native.RegisterHotKey(Handle, GetType().GetHashCode(), MouseHide_HotKeyModifier, MouseHide_HotKey); } /// @@ -1007,7 +1007,7 @@ private void RegisterHotkeys() /// private void UnregisterHotkeys() { - Native.UnregisterHotKey(this.Handle, this.GetType().GetHashCode()); + Native.UnregisterHotKey(Handle, GetType().GetHashCode()); } /// @@ -1027,7 +1027,7 @@ protected override void WndProc(ref Message m) IntPtr hCurrentActiveWindow = Native.GetForegroundWindow(); // Only if that window isn't Borderless Windows itself - if (hCurrentActiveWindow != this.Handle) + if (hCurrentActiveWindow != Handle) { // Figure out the process details based on the current window handle ProcessDetails pd = controller.Processes.FromHandle(hCurrentActiveWindow); @@ -1043,7 +1043,7 @@ protected override void WndProc(ref Message m) Manipulation.RestoreWindow(pd); // Otherwise, this is a fresh request to remove the border from the current window else - this.controller.RemoveBorder(pd); + controller.RemoveBorder(pd); } return; // handled the message, do not call base WndProc for this message @@ -1061,7 +1061,7 @@ protected override void WndProc(ref Message m) IntPtr hWnd = Native.GetForegroundWindow(); // get size of clientarea - Native.RECT rect = new Native.RECT(); + Native.Rect rect = new Native.Rect(); Native.GetClientRect(hWnd, ref rect); // get top,left point of clientarea diff --git a/Program_Steam.cs b/Program_Steam.cs index 62e6e8f..fabe8f3 100644 --- a/Program_Steam.cs +++ b/Program_Steam.cs @@ -31,7 +31,7 @@ static void Main() else if (!Steamworks.Packsize.Test()) MessageBox.Show("Steam failed to PackTest!", "Error Loading Steam", MessageBoxButtons.OK, MessageBoxIcon.Warning); else - Program.Steam_Loaded = true; + Steam_Loaded = true; } catch (Exception ex) { diff --git a/Utilities/AppEnvironment.cs b/Utilities/AppEnvironment.cs index 5b12a90..1185716 100644 --- a/Utilities/AppEnvironment.cs +++ b/Utilities/AppEnvironment.cs @@ -11,7 +11,7 @@ public static string DataPath try { // No version! - return System.Environment.GetEnvironmentVariable("AppData").Trim() + "\\" + System.Windows.Forms.Application.CompanyName + "\\" + System.Windows.Forms.Application.ProductName; + return Environment.GetEnvironmentVariable("AppData").Trim() + "\\" + System.Windows.Forms.Application.CompanyName + "\\" + System.Windows.Forms.Application.ProductName; } catch { } @@ -32,14 +32,14 @@ public static string DataPath try { // Current working folder - return System.Environment.CurrentDirectory; + return Environment.CurrentDirectory; } catch { try { // Desktop - return System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + return Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); } catch { @@ -78,7 +78,7 @@ public static string Setting(string sKeyName) try { - sVal = AppEnvironment.RegistryKey.GetValue(sKeyName, string.Empty).ToString(); + sVal = RegistryKey.GetValue(sKeyName, string.Empty).ToString(); } catch { } @@ -91,11 +91,11 @@ public static void Setting(string sKeyName, object oKeyValue) { if ((oKeyValue == null) || (oKeyValue.ToString() == "")) { - AppEnvironment.RegistryKey.SetValue(sKeyName, string.Empty, Microsoft.Win32.RegistryValueKind.String); - AppEnvironment.RegistryKey.DeleteValue(sKeyName); + RegistryKey.SetValue(sKeyName, string.Empty, Microsoft.Win32.RegistryValueKind.String); + RegistryKey.DeleteValue(sKeyName); } else - AppEnvironment.RegistryKey.SetValue(sKeyName, oKeyValue.ToString()); + RegistryKey.SetValue(sKeyName, oKeyValue.ToString()); return; } @@ -125,14 +125,14 @@ public static bool SettingValue(string sAppKey, bool bDefault) { try { - string s = AppEnvironment.Setting(sAppKey); + string s = Setting(sAppKey); if (string.IsNullOrEmpty(s)) return bDefault; bool bRet = false; - if (bool.TryParse(AppEnvironment.Setting(sAppKey.Trim()).Trim().ToLower(), out bRet)) + if (bool.TryParse(Setting(sAppKey.Trim()).Trim().ToLower(), out bRet)) return bRet; } catch { } diff --git a/Utilities/ExceptionHandler.cs b/Utilities/ExceptionHandler.cs index 2fdf2d2..cd8a03b 100644 --- a/Utilities/ExceptionHandler.cs +++ b/Utilities/ExceptionHandler.cs @@ -15,10 +15,10 @@ public static void AddGlobalHandlers() { try { - if (!Directory.Exists(ExceptionHandler.LogsPath)) - Directory.CreateDirectory(ExceptionHandler.LogsPath); + if (!Directory.Exists(LogsPath)) + Directory.CreateDirectory(LogsPath); - string filePath = Path.Combine(ExceptionHandler.LogsPath, string.Format("UnhandledException_{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"))); + string filePath = Path.Combine(LogsPath, string.Format("UnhandledException_{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"))); File.AppendAllText(filePath, JsonConvert.SerializeObject(args.ExceptionObject, Formatting.Indented) + "\r\n\r\n"); @@ -33,10 +33,10 @@ public static void AddGlobalHandlers() { try { - if (!Directory.Exists(ExceptionHandler.LogsPath)) - Directory.CreateDirectory(ExceptionHandler.LogsPath); + if (!Directory.Exists(LogsPath)) + Directory.CreateDirectory(LogsPath); - string filePath = Path.Combine(ExceptionHandler.LogsPath, string.Format("ThreadException_{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"))); + string filePath = Path.Combine(LogsPath, string.Format("ThreadException_{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"))); File.AppendAllText(filePath, JsonConvert.SerializeObject(args.Exception, Formatting.Indented) + "\r\n\r\n"); diff --git a/Utilities/Tools.cs b/Utilities/Tools.cs index e3dd99b..8e0f7d1 100644 --- a/Utilities/Tools.cs +++ b/Utilities/Tools.cs @@ -55,7 +55,7 @@ private static bool HasInternetConnection public static void CheckForUpdates() { - if (Tools.HasInternetConnection) + if (HasInternetConnection) { try { @@ -110,7 +110,7 @@ public static void CheckForUpdates() if (MessageBox.Show(Resources.InfoUpdateAvailable, Resources.InfoUpdatesHeader, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { - Tools.GotoSite(_releasePageURL); + GotoSite(_releasePageURL); } } } @@ -191,35 +191,35 @@ public static string GetDataPath() try { // No version! - return System.Environment.GetEnvironmentVariable("AppData").Trim() + "\\" + System.Windows.Forms.Application.CompanyName + "\\" + System.Windows.Forms.Application.ProductName; + return Environment.GetEnvironmentVariable("AppData").Trim() + "\\" + Application.CompanyName + "\\" + Application.ProductName; } catch { } try { // Version, but chopped out - return System.Windows.Forms.Application.UserAppDataPath.Substring(0, System.Windows.Forms.Application.UserAppDataPath.LastIndexOf("\\")); + return Application.UserAppDataPath.Substring(0, Application.UserAppDataPath.LastIndexOf("\\")); } catch { try { // App launch folder - return System.Windows.Forms.Application.ExecutablePath.Substring(0, System.Windows.Forms.Application.ExecutablePath.LastIndexOf("\\")); + return Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")); } catch { try { // Current working folder - return System.Environment.CurrentDirectory; + return Environment.CurrentDirectory; } catch { try { // Desktop - return System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + return Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); } catch { @@ -241,14 +241,13 @@ public static void StartMethodMultithreadedAndWait(Action target, int iHowLongTo { try { - ThreadStart tsGenericMethod = new ThreadStart(() => { try { target(); } catch { } }); - Thread trdGenericThread = new Thread(tsGenericMethod); - trdGenericThread.IsBackground = true; + var tsGenericMethod = new ThreadStart(() => { try { target(); } catch { } }); + var trdGenericThread = new Thread(tsGenericMethod) {IsBackground = true}; trdGenericThread.Start(); - DateTime dtStartTime = DateTime.Now; + var dtStartTime = DateTime.Now; - for (; ; ) + for (;;) { if (iHowLongToWait > 0) { @@ -268,7 +267,10 @@ public static void StartMethodMultithreadedAndWait(Action target, int iHowLongTo Forms.MainWindow.DoEvents(); } } - catch { } + catch + { + // ignored + } } public static void StartMethodMultithreadedAndWait(Action target, double dHowLongToWait) diff --git a/Utilities/UAC.cs b/Utilities/UAC.cs index 9ddf9da..dc165e3 100644 --- a/Utilities/UAC.cs +++ b/Utilities/UAC.cs @@ -18,7 +18,7 @@ public static bool Elevated { try { - return UAC.IsElevated(); + return IsElevated(); } catch { } @@ -239,7 +239,7 @@ private SafeTokenHandle() : base(true) internal SafeTokenHandle(IntPtr handle) : base(true) { - base.SetHandle(handle); + SetHandle(handle); } [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] @@ -247,7 +247,7 @@ internal SafeTokenHandle(IntPtr handle) : base(true) protected override bool ReleaseHandle() { - return CloseHandle(base.handle); + return CloseHandle(handle); } } diff --git a/WindowsAPI/Manipulation.cs b/WindowsAPI/Manipulation.cs index 4e0566a..5578d5a 100644 --- a/WindowsAPI/Manipulation.cs +++ b/WindowsAPI/Manipulation.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Threading; using System.Windows.Forms; using BorderlessGaming.Forms; using BorderlessGaming.Common; @@ -22,7 +23,7 @@ public static class Manipulation private class OriginalScreenInfo { public Screen screen; - public Native.RECT workarea; // with Windows taskbar + public Native.Rect workarea; // with Windows taskbar } // Windows taskbar hidden data @@ -34,7 +35,7 @@ private class OriginalScreenInfo /// /// remove the menu, resize the window, remove border, and maximize /// - public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.MainWindow frmMain, IntPtr targetWindow, Rectangle targetFrame, Favorites.Favorite favDetails) + public static void MakeWindowBorderless(ProcessDetails processDetails, MainWindow frmMain, IntPtr targetWindow, Rectangle targetFrame, Favorites.Favorite favDetails) { // Automatically match a window to favorite details, if that information is available. // Note: if one is not available, the default settings will be used as a new Favorite() object. @@ -52,17 +53,17 @@ public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.Mai targetFrame = Screen.FromHandle(targetWindow).Bounds; // Get window styles - WindowStyleFlags styleCurrentWindow_standard = Native.GetWindowLong(targetWindow, WindowLongIndex.Style); - WindowStyleFlags styleCurrentWindow_extended = Native.GetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle); + var styleCurrentWindowStandard = Native.GetWindowLong(targetWindow, WindowLongIndex.Style); + var styleCurrentWindowExtended = Native.GetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle); // Compute new styles (XOR of the inverse of all the bits to filter) - WindowStyleFlags styleNewWindow_standard = + var styleNewWindowStandard = ( - styleCurrentWindow_standard + styleCurrentWindowStandard & ~( WindowStyleFlags.Caption // composite of Border and DialogFrame - // | WindowStyleFlags.Border - // | WindowStyleFlags.DialogFrame + // | WindowStyleFlags.Border + //| WindowStyleFlags.DialogFrame | WindowStyleFlags.ThickFrame | WindowStyleFlags.SystemMenu | WindowStyleFlags.MaximizeBox // same as TabStop @@ -70,9 +71,9 @@ public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.Mai ) ); - WindowStyleFlags styleNewWindow_extended = + var styleNewWindowExtended = ( - styleCurrentWindow_extended + styleCurrentWindowExtended & ~( WindowStyleFlags.ExtendedDlgModalFrame | WindowStyleFlags.ExtendedComposited @@ -89,10 +90,9 @@ public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.Mai if (processDetails != null) { // Save original details on this window so that we have a chance at undoing the process - processDetails.OriginalStyleFlags_Standard = styleCurrentWindow_standard; - processDetails.OriginalStyleFlags_Extended = styleCurrentWindow_extended; - Native.RECT rect_temp = new Native.RECT(); - Native.GetWindowRect(processDetails.WindowHandle, out rect_temp); + processDetails.OriginalStyleFlags_Standard = styleCurrentWindowStandard; + processDetails.OriginalStyleFlags_Extended = styleCurrentWindowExtended; + Native.GetWindowRect(processDetails.WindowHandle, out Native.Rect rect_temp); processDetails.OriginalLocation = new Rectangle(rect_temp.Left, rect_temp.Top, rect_temp.Right - rect_temp.Left, rect_temp.Bottom - rect_temp.Top); } @@ -119,16 +119,14 @@ public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.Mai if (frmMain.WindowState == FormWindowState.Minimized) frmMain.WindowState = FormWindowState.Normal; - Manipulation.ToggleWindowsTaskbarVisibility(Tools.Boolstate.False); + ToggleWindowsTaskbarVisibility(Tools.Boolstate.False); } // auto-hide the mouse cursor if (favDetails.HideMouseCursor) - Manipulation.ToggleMouseCursorVisibility(frmMain, Tools.Boolstate.False); + ToggleMouseCursorVisibility(frmMain, Tools.Boolstate.False); - // update window styles - Native.SetWindowLong(targetWindow, WindowLongIndex.Style, styleNewWindow_standard); - Native.SetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle, styleNewWindow_extended); + // update window position if (favDetails.SizeMode != Favorites.Favorite.SizeModes.NoChange) @@ -182,6 +180,11 @@ public static void MakeWindowBorderless(ProcessDetails processDetails, Forms.Mai ); } + Thread.Sleep(1000); + // update window styles + Native.SetWindowLong(targetWindow, WindowLongIndex.Style, styleNewWindowStandard); + Native.SetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle, styleNewWindowExtended); + // Make a note that we attempted to make the window borderless if (processDetails != null) { @@ -200,10 +203,10 @@ public static void RestoreWindow(ProcessDetails pd) if ((pd == null) || (!pd.MadeBorderless) || (pd.OriginalStyleFlags_Standard == 0)) return; - WindowsAPI.Native.SetWindowLong(pd.WindowHandle, WindowsAPI.WindowLongIndex.Style, pd.OriginalStyleFlags_Standard); - WindowsAPI.Native.SetWindowLong(pd.WindowHandle, WindowsAPI.WindowLongIndex.ExtendedStyle, pd.OriginalStyleFlags_Extended); - WindowsAPI.Native.SetWindowPos(pd.WindowHandle, IntPtr.Zero, pd.OriginalLocation.X, pd.OriginalLocation.Y, pd.OriginalLocation.Width, pd.OriginalLocation.Height, WindowsAPI.SetWindowPosFlags.ShowWindow | WindowsAPI.SetWindowPosFlags.NoZOrder); - WindowsAPI.Native.SetWindowPos(pd.WindowHandle, WindowsAPI.Native.HWND_NOTTOPMOST, 0, 0, 0, 0, WindowsAPI.SetWindowPosFlags.NoActivate | WindowsAPI.SetWindowPosFlags.NoMove | WindowsAPI.SetWindowPosFlags.NoSize); + Native.SetWindowLong(pd.WindowHandle, WindowLongIndex.Style, pd.OriginalStyleFlags_Standard); + Native.SetWindowLong(pd.WindowHandle, WindowLongIndex.ExtendedStyle, pd.OriginalStyleFlags_Extended); + Native.SetWindowPos(pd.WindowHandle, IntPtr.Zero, pd.OriginalLocation.X, pd.OriginalLocation.Y, pd.OriginalLocation.Width, pd.OriginalLocation.Height, SetWindowPosFlags.ShowWindow | SetWindowPosFlags.NoZOrder); + Native.SetWindowPos(pd.WindowHandle, Native.HWND_NOTTOPMOST, 0, 0, 0, 0, SetWindowPosFlags.NoActivate | SetWindowPosFlags.NoMove | SetWindowPosFlags.NoSize); pd.MadeBorderless = false; pd.MadeBorderlessAttempts = 0; } @@ -235,12 +238,12 @@ public static void ToggleWindowsTaskbarVisibility(Tools.Boolstate forced = Tools { OriginalScreenInfo osi = new OriginalScreenInfo(); osi.screen = screen; - osi.workarea = new Native.RECT(); + osi.workarea = new Native.Rect(); osi.workarea.Left = screen.WorkingArea.Left; osi.workarea.Top = screen.WorkingArea.Top; osi.workarea.Right = screen.WorkingArea.Right; osi.workarea.Bottom = screen.WorkingArea.Bottom; - Manipulation.OriginalScreens.Add(osi); + OriginalScreens.Add(osi); } } @@ -248,29 +251,29 @@ public static void ToggleWindowsTaskbarVisibility(Tools.Boolstate forced = Tools Native.ShowWindow(hTaskBar, (WantToMakeWindowsTaskbarVisible) ? WindowShowStyle.ShowNoActivate : WindowShowStyle.Hide); // Keep track of the taskbar state so we don't let the user accidentally close Borderless Gaming - Manipulation.WindowsTaskbarIsHidden = !WantToMakeWindowsTaskbarVisible; + WindowsTaskbarIsHidden = !WantToMakeWindowsTaskbarVisible; if (WantToMakeWindowsTaskbarVisible) { // If we're showing the taskbar, let's restore the original screen desktop work areas... - foreach (OriginalScreenInfo osi in Manipulation.OriginalScreens) + foreach (OriginalScreenInfo osi in OriginalScreens) Native.SystemParametersInfo(SPI.SPI_SETWORKAREA, 0, ref osi.workarea, SPIF.SPIF_SENDCHANGE); // ...and then forget them (we don't need them anymore) - Manipulation.OriginalScreens.Clear(); + OriginalScreens.Clear(); // And we need to redraw the system tray in case tray icons from other applications did something while the // taskbar was hidden. Simulating mouse movement over the system tray seems to be the best way to get this // done. - Manipulation.RedrawWindowsSystemTrayArea(); + RedrawWindowsSystemTrayArea(); } else { // If we're hiding the taskbar, let's set the screen desktop work area over the entire screen so that // maximizing windows works as expected. - foreach (OriginalScreenInfo osi in Manipulation.OriginalScreens) + foreach (OriginalScreenInfo osi in OriginalScreens) { - Native.RECT rect = new Native.RECT(); + Native.Rect rect = new Native.Rect(); rect.Left = osi.screen.Bounds.Left; rect.Top = osi.screen.Bounds.Top; rect.Right = osi.screen.Bounds.Right; @@ -285,18 +288,18 @@ public static void ToggleWindowsTaskbarVisibility(Tools.Boolstate forced = Tools catch { } } - public static void ToggleMouseCursorVisibility(Forms.MainWindow frmMain, Tools.Boolstate forced = Tools.Boolstate.Indeterminate) + public static void ToggleMouseCursorVisibility(MainWindow frmMain, Tools.Boolstate forced = Tools.Boolstate.Indeterminate) { - if (((forced == Tools.Boolstate.True) && (!Manipulation.MouseCursorIsHidden)) || ((forced == Tools.Boolstate.False) && Manipulation.MouseCursorIsHidden)) + if (((forced == Tools.Boolstate.True) && (!MouseCursorIsHidden)) || ((forced == Tools.Boolstate.False) && MouseCursorIsHidden)) return; - if ((forced == Tools.Boolstate.True) || Manipulation.MouseCursorIsHidden) + if ((forced == Tools.Boolstate.True) || MouseCursorIsHidden) { - Native.SetSystemCursor(Manipulation.hCursorOriginal, OCR_SYSTEM_CURSORS.OCR_NORMAL); - Native.DestroyIcon(Manipulation.hCursorOriginal); - Manipulation.hCursorOriginal = IntPtr.Zero; + Native.SetSystemCursor(hCursorOriginal, OCR_SYSTEM_CURSORS.OCR_NORMAL); + Native.DestroyIcon(hCursorOriginal); + hCursorOriginal = IntPtr.Zero; - Manipulation.MouseCursorIsHidden = false; + MouseCursorIsHidden = false; } else { @@ -304,9 +307,9 @@ public static void ToggleMouseCursorVisibility(Forms.MainWindow frmMain, Tools.B try { - Manipulation.hCursorOriginal = frmMain.Cursor.CopyHandle(); + hCursorOriginal = frmMain.Cursor.CopyHandle(); - if (Manipulation.curInvisibleCursor == null) + if (curInvisibleCursor == null) { // Can't load from a memory stream because the constructor new Cursor() does not accept animated or non-monochrome cursors fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".cur"; @@ -322,12 +325,12 @@ public static void ToggleMouseCursorVisibility(Forms.MainWindow frmMain, Tools.B fileStream.Close(); } - Manipulation.curInvisibleCursor = new Cursor(Native.LoadCursorFromFile(fileName)); + curInvisibleCursor = new Cursor(Native.LoadCursorFromFile(fileName)); } - Native.SetSystemCursor(Manipulation.curInvisibleCursor.CopyHandle(), OCR_SYSTEM_CURSORS.OCR_NORMAL); + Native.SetSystemCursor(curInvisibleCursor.CopyHandle(), OCR_SYSTEM_CURSORS.OCR_NORMAL); - Manipulation.MouseCursorIsHidden = true; + MouseCursorIsHidden = true; } catch { @@ -375,7 +378,7 @@ private static void RedrawWindowsSystemTrayArea() return; // Get the notification bounds - Native.RECT rect = new Native.RECT(); + Native.Rect rect = new Native.Rect(); Native.GetClientRect(hNotificationArea, ref rect); // Wiggle the mouse over the notification area diff --git a/WindowsAPI/Native.cs b/WindowsAPI/Native.cs index 404c0dc..4f7046b 100644 --- a/WindowsAPI/Native.cs +++ b/WindowsAPI/Native.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Drawing; using System.Runtime.InteropServices; using System.Text; @@ -88,7 +89,7 @@ public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("user32.dll", SetLastError = true)] - public static extern bool GetClientRect(IntPtr hWnd, ref RECT lpRect); + public static extern bool GetClientRect(IntPtr hWnd, ref Rect lpRect); [DllImport("user32.dll")] public static extern int ClientToScreen(IntPtr hwnd, [MarshalAs(UnmanagedType.Struct)] ref POINTAPI lpPoint); @@ -111,12 +112,99 @@ public struct POINTAPI #region Nested type: RECT [StructLayout(LayoutKind.Sequential)] - public struct RECT + public struct Rect { - public int Left; - public int Top; - public int Right; - public int Bottom; + public int Left, Top, Right, Bottom; + + public Rect(int left, int top, int right, int bottom) + { + Left = left; + Top = top; + Right = right; + Bottom = bottom; + } + + public Rect(Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { } + + public int X + { + get { return Left; } + set { Right -= (Left - value); Left = value; } + } + + public int Y + { + get { return Top; } + set { Bottom -= (Top - value); Top = value; } + } + + public int Height + { + get { return Bottom - Top; } + set { Bottom = value + Top; } + } + + public int Width + { + get { return Right - Left; } + set { Right = value + Left; } + } + + public Point Location + { + get { return new Point(Left, Top); } + set { X = value.X; Y = value.Y; } + } + + public Size Size + { + get { return new Size(Width, Height); } + set { Width = value.Width; Height = value.Height; } + } + + public static implicit operator Rectangle(Rect r) + { + return new Rectangle(r.Left, r.Top, r.Width, r.Height); + } + + public static implicit operator Rect(Rectangle r) + { + return new Rect(r); + } + + public static bool operator ==(Rect r1, Rect r2) + { + return r1.Equals(r2); + } + + public static bool operator !=(Rect r1, Rect r2) + { + return !r1.Equals(r2); + } + + public bool Equals(Rect r) + { + return r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom; + } + + public override bool Equals(object obj) + { + if (obj is Rect) + return Equals((Rect)obj); + if (obj is Rectangle) + return Equals(new Rect((Rectangle)obj)); + return false; + } + + public override int GetHashCode() + { + return ((Rectangle)this).GetHashCode(); + } + + public override string ToString() + { + return string.Format(System.Globalization.CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); + } } #endregion @@ -165,18 +253,18 @@ public static string GetWindowClassName(IntPtr hWnd) public static string GetWindowTitle(IntPtr hWnd) { // Allocate correct string length first - int length = (int)Native.SendMessage(hWnd, Native.WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero); + int length = (int)SendMessage(hWnd, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero); StringBuilder sbWindowTitle = new StringBuilder(length + 1); - Native.SendMessage(hWnd, Native.WM_GETTEXT, (IntPtr)sbWindowTitle.Capacity, sbWindowTitle); + SendMessage(hWnd, WM_GETTEXT, (IntPtr)sbWindowTitle.Capacity, sbWindowTitle); return sbWindowTitle.ToString(); } [DllImport("user32.dll", SetLastError = true)] - public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect); + public static extern bool GetWindowRect(IntPtr hwnd, out Rect lpRect); public static IntPtr FW(IntPtr hwndParent, string lpszClass) { - return Native.FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, string.Empty); + return FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, string.Empty); } [DllImport("user32.dll", SetLastError = true)] @@ -190,7 +278,7 @@ public static IntPtr FW(IntPtr hwndParent, string lpszClass) [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SystemParametersInfo(SPI uiAction, uint uiParam, ref RECT pvParam, SPIF fWinIni); + public static extern bool SystemParametersInfo(SPI uiAction, uint uiParam, ref Rect pvParam, SPIF fWinIni); [DllImport("user32.dll")] public static extern bool SetSystemCursor(IntPtr hcur, OCR_SYSTEM_CURSORS id); @@ -216,9 +304,9 @@ public static IntPtr FW(IntPtr hwndParent, string lpszClass) public static WindowStyleFlags GetWindowLong(IntPtr hWnd, WindowLongIndex nIndex) { if (IntPtr.Size == 8) - return Native.GetWindowLong64(hWnd, nIndex); + return GetWindowLong64(hWnd, nIndex); - return Native.GetWindowLong32(hWnd, nIndex); + return GetWindowLong32(hWnd, nIndex); } [DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)] @@ -233,9 +321,9 @@ public static WindowStyleFlags GetWindowLong(IntPtr hWnd, WindowLongIndex nIndex public static WindowStyleFlags SetWindowLong(IntPtr hWnd, WindowLongIndex nIndex, WindowStyleFlags dwNewLong) { if (IntPtr.Size == 8) - return Native.SetWindowLong64(hWnd, nIndex, dwNewLong); + return SetWindowLong64(hWnd, nIndex, dwNewLong); - return Native.SetWindowLong32(hWnd, nIndex, dwNewLong); + return SetWindowLong32(hWnd, nIndex, dwNewLong); } [DllImport("user32.dll")] @@ -256,13 +344,13 @@ public static WindowStyleFlags SetWindowLong(IntPtr hWnd, WindowLongIndex nIndex // Do some preferential treatment to windows private static bool GetMainWindowForProcess_EnumWindows(IntPtr hWndEnumerated, uint lParam) { - if (Native.GetMainWindowForProcess_Value == IntPtr.Zero) + if (GetMainWindowForProcess_Value == IntPtr.Zero) { - WindowStyleFlags styleCurrentWindow_standard = Native.GetWindowLong(hWndEnumerated, WindowsAPI.WindowLongIndex.Style); + WindowStyleFlags styleCurrentWindow_standard = GetWindowLong(hWndEnumerated, WindowLongIndex.Style); if (lParam == 0) // strict: windows that are visible and have a border { - if (Native.IsWindowVisible(hWndEnumerated)) + if (IsWindowVisible(hWndEnumerated)) { if ( @@ -273,18 +361,18 @@ private static bool GetMainWindowForProcess_EnumWindows(IntPtr hWndEnumerated, u ) ) { - Native.GetMainWindowForProcess_Value = hWndEnumerated; + GetMainWindowForProcess_Value = hWndEnumerated; return false; } } } else if (lParam == 1) // loose: windows that are visible { - if (Native.IsWindowVisible(hWndEnumerated)) + if (IsWindowVisible(hWndEnumerated)) { if (((uint)styleCurrentWindow_standard) != 0) { - Native.GetMainWindowForProcess_Value = hWndEnumerated; + GetMainWindowForProcess_Value = hWndEnumerated; return false; } } @@ -308,9 +396,9 @@ public static IntPtr GetMainWindowForProcess(Process process) { IntPtr hMainWindow = IntPtr.Zero; - lock (Native.GetMainWindowForProcess_Locker) + lock (GetMainWindowForProcess_Locker) { - Native.GetMainWindowForProcess_Value = IntPtr.Zero; + GetMainWindowForProcess_Value = IntPtr.Zero; // Help the UI stay alive Utilities.Tools.StartMethodMultithreadedAndWait(() => @@ -319,15 +407,15 @@ public static IntPtr GetMainWindowForProcess(Process process) { foreach (ProcessThread thread in process.Threads) { - if (Native.GetMainWindowForProcess_Value != IntPtr.Zero) + if (GetMainWindowForProcess_Value != IntPtr.Zero) break; - Native.EnumThreadWindows(thread.Id, Native.GetMainWindowForProcess_EnumWindows, i); + EnumThreadWindows(thread.Id, GetMainWindowForProcess_EnumWindows, i); } } }); - hMainWindow = Native.GetMainWindowForProcess_Value; + hMainWindow = GetMainWindowForProcess_Value; } if (hMainWindow != IntPtr.Zero) diff --git a/WindowsAPI/Windows.cs b/WindowsAPI/Windows.cs index 49a7da6..ccf2175 100644 --- a/WindowsAPI/Windows.cs +++ b/WindowsAPI/Windows.cs @@ -2,10 +2,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Forms; using BorderlessGaming.WindowsAPI; namespace BorderlessGaming.WindowsAPI @@ -24,25 +26,33 @@ public void QueryProcessesWithWindows(Action callback, HashSet GetMainWindowForProcess_EnumWindows(ptrList, hwnd, lParam); Native.EnumWindows(del, 0); Native.EnumWindows(del, 1); - foreach (var ptr in ptrList) + + foreach (var ptr in ptrList) { - string windowTitle = Native.GetWindowTitle(ptr); - //check if we already have this window in the list so we can avoid calling - //GetWindowThreadProcessId(its costly) - if (string.IsNullOrEmpty(windowTitle) || windowPtrSet.Contains(ptr.ToInt64())) - continue; - uint processId; - Native.GetWindowThreadProcessId(ptr, out processId); - callback(new ProcessDetails(Process.GetProcessById((int)processId), ptr) - { - Manageable = true - }); + + if (Native.GetWindowRect(ptr, out Native.Rect rect)) + { + if (((Rectangle)rect).IsEmpty) + { + continue; + } + //check if we already have this window in the list so we can avoid calling + //GetWindowThreadProcessId(its costly) + if (windowPtrSet.Contains(ptr.ToInt64())) + continue; + uint processId; + Native.GetWindowThreadProcessId(ptr, out processId); + callback(new ProcessDetails(Process.GetProcessById((int)processId), ptr) + { + Manageable = true + }); + } } } private static bool GetMainWindowForProcess_EnumWindows(List ptrList, IntPtr hWndEnumerated, uint lParam) { - WindowStyleFlags styleCurrentWindow_standard = Native.GetWindowLong(hWndEnumerated, WindowLongIndex.Style); + WindowStyleFlags styleCurrentWindowStandard = Native.GetWindowLong(hWndEnumerated, WindowLongIndex.Style); if (lParam == 0) // strict: windows that are visible and have a border { @@ -50,10 +60,10 @@ private static bool GetMainWindowForProcess_EnumWindows(List ptrList, In { if ( - ((styleCurrentWindow_standard & WindowStyleFlags.Caption) > 0) + ((styleCurrentWindowStandard & WindowStyleFlags.Caption) > 0) && ( - ((styleCurrentWindow_standard & WindowStyleFlags.Border) > 0) - || ((styleCurrentWindow_standard & WindowStyleFlags.ThickFrame) > 0) + ((styleCurrentWindowStandard & WindowStyleFlags.Border) > 0) + || ((styleCurrentWindowStandard & WindowStyleFlags.ThickFrame) > 0) ) ) { @@ -65,7 +75,7 @@ private static bool GetMainWindowForProcess_EnumWindows(List ptrList, In { if (Native.IsWindowVisible(hWndEnumerated)) { - if (((uint)styleCurrentWindow_standard) != 0) + if (((uint)styleCurrentWindowStandard) != 0) { ptrList.Add(hWndEnumerated); }