├── .gitattributes ├── .gitignore ├── README.md ├── SetTheme.sln ├── SetThemeLib ├── HwndSearch.cs ├── HwndSearchTypes.cs ├── Kernel32.cs ├── PsApi.cs ├── SetThemeLib.csproj ├── Theme.cs ├── ThemesRepository.cs ├── User32.cs ├── UxTheme.cs └── WindowTheming.cs ├── SetThemeUI ├── EditWindow.Designer.cs ├── EditWindow.cs ├── EditWindow.resx ├── HwndSearchControl.Designer.cs ├── HwndSearchControl.cs ├── HwndSearchControl.resx ├── LogControl.Designer.cs ├── LogControl.cs ├── LogControl.resx ├── MainWindow.Designer.cs ├── MainWindow.cs ├── MainWindow.resx ├── ProcessModel.cs ├── Program.cs ├── Properties │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SelectProcessWindow.Designer.cs ├── SelectProcessWindow.cs ├── SelectProcessWindow.resx ├── SetThemeUI.csproj ├── ThemePickControl.Designer.cs ├── ThemePickControl.cs └── ThemePickControl.resx └── sctprev.gif /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SetTheme [![Build status](https://ci.appveyor.com/api/projects/status/4en0lf269f2h6m0a/branch/master?svg=true)](https://ci.appveyor.com/project/dz333n/winsettheme/branch/master) 2 | 3 | This program searches for windows and uses ``SetWindowTheme`` function. 4 | -------------------------------------------------------------------------------- /SetTheme.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29920.165 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetThemeLib", "SetThemeLib\SetThemeLib.csproj", "{F4717E4A-B9F9-48AA-960F-DB0BC69D598B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetThemeUI", "SetThemeUI\SetThemeUI.csproj", "{7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {F4717E4A-B9F9-48AA-960F-DB0BC69D598B}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {7CFC4C2F-A48C-4AA4-82ED-11145E51D65C}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {DD4279DD-CD93-45A3-B2CC-0B602569F2A0} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /SetThemeLib/HwndSearch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace SetThemeLib 9 | { 10 | public class HwndSearch 11 | { 12 | /// 13 | /// Searches HWNDs and invokes Action 14 | /// 15 | public static void ForEach(HwndSearchTypes type, object[] valuesRaw, Action action, Action onFail = null) 16 | { 17 | if (type == HwndSearchTypes.Specific) 18 | { 19 | foreach (var value in valuesRaw.Cast()) 20 | action(value); 21 | 22 | return; 23 | } 24 | 25 | User32.EnumWindows((mainHwnd, b) => 26 | { 27 | if (type == HwndSearchTypes.All) 28 | action(mainHwnd); 29 | else if (type == HwndSearchTypes.ForProcess) 30 | { 31 | uint proc; 32 | User32.GetWindowThreadProcessId(mainHwnd, out proc); 33 | 34 | IntPtr procHandle = Kernel32.OpenProcess(Kernel32.ProcessAccessFlags.QueryInformation | Kernel32.ProcessAccessFlags.VirtualMemoryRead, false, (int)proc); 35 | 36 | if (procHandle == IntPtr.Zero) 37 | { 38 | var error = Marshal.GetLastWin32Error(); 39 | 40 | if (error == 5) // Referencing to original SetClassicTheme we should ignore this error 41 | return true; 42 | 43 | onFail?.Invoke(mainHwnd, new Exception("Win32 error when OpenProcess: " + Marshal.GetLastWin32Error())); 44 | return true; 45 | } 46 | 47 | 48 | StringBuilder moduleName = new StringBuilder(1024); 49 | var moduleResult = PsApi.GetModuleFileNameEx(procHandle, IntPtr.Zero, moduleName, moduleName.Capacity); 50 | 51 | if (moduleResult == 0) 52 | { 53 | onFail?.Invoke(mainHwnd, new Exception("Failed to get module file name: " + moduleResult)); 54 | Kernel32.CloseHandle(procHandle); 55 | return true; 56 | } 57 | 58 | Kernel32.CloseHandle(procHandle); 59 | 60 | var moduleFile = new FileInfo(moduleName.ToString()); 61 | 62 | if (!valuesRaw.Select(x => x.ToString().ToLower()).Contains(moduleFile.Name.ToLower())) 63 | { 64 | return true; 65 | } 66 | 67 | action(mainHwnd); 68 | } 69 | else throw new NotImplementedException("Unknown search type: " + type); 70 | 71 | User32.EnumChildWindows(mainHwnd, (childHwnd, b2) => 72 | { 73 | action(childHwnd); 74 | return true; 75 | }, IntPtr.Zero); 76 | 77 | return true; 78 | }, IntPtr.Zero); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SetThemeLib/HwndSearchTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SetThemeLib 7 | { 8 | public enum HwndSearchTypes 9 | { 10 | All, 11 | ForProcess, 12 | Specific 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SetThemeLib/Kernel32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Runtime.ConstrainedExecution; 6 | using System.Runtime.InteropServices; 7 | using System.Security; 8 | using System.Text; 9 | 10 | namespace SetThemeLib 11 | { 12 | public class Kernel32 13 | { 14 | [DllImport("kernel32.dll", SetLastError = true)] 15 | [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] 16 | [SuppressUnmanagedCodeSecurity] 17 | [return: MarshalAs(UnmanagedType.Bool)] 18 | public static extern bool CloseHandle(IntPtr hObject); 19 | 20 | [DllImport("kernel32.dll", SetLastError = true)] 21 | public static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId); 22 | 23 | public static IntPtr OpenProcess(Process proc, ProcessAccessFlags flags) 24 | { 25 | return OpenProcess(flags, false, proc.Id); 26 | } 27 | 28 | [Flags] 29 | public enum ProcessAccessFlags : uint 30 | { 31 | All = 0x001F0FFF, 32 | Terminate = 0x00000001, 33 | CreateThread = 0x00000002, 34 | VirtualMemoryOperation = 0x00000008, 35 | VirtualMemoryRead = 0x00000010, 36 | VirtualMemoryWrite = 0x00000020, 37 | DuplicateHandle = 0x00000040, 38 | CreateProcess = 0x000000080, 39 | SetQuota = 0x00000100, 40 | SetInformation = 0x00000200, 41 | QueryInformation = 0x00000400, 42 | QueryLimitedInformation = 0x00001000, 43 | Synchronize = 0x00100000 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SetThemeLib/PsApi.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace SetThemeLib 8 | { 9 | public class PsApi 10 | { 11 | [DllImport("psapi.dll")] 12 | public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, [In] [MarshalAs(UnmanagedType.U4)] int nSize); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SetThemeLib/SetThemeLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net40 4 | 5 | 6 | -------------------------------------------------------------------------------- /SetThemeLib/Theme.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SetThemeLib 7 | { 8 | public class Theme 9 | { 10 | public string Value { get; private set; } 11 | public string Description { get; private set; } 12 | public Action ExtraAction { get; private set; } 13 | 14 | public Theme(string value, string description, Action extraAction = null) 15 | { 16 | Value = value; 17 | Description = description; 18 | ExtraAction = extraAction; 19 | } 20 | 21 | public override string ToString() 22 | => $"ThemeAppName: {(Value != null ? Value : "null")}"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SetThemeLib/ThemesRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SetThemeLib 7 | { 8 | public class ThemesRepository 9 | { 10 | public static Theme[] Themes = { 11 | new Theme(null, "Supposed to be a default theming"), 12 | new Theme(" ", "Classic theming"), 13 | new Theme("Explorer", "Gives list-view control the appearance of a Windows Explorer list"), 14 | new Theme("DarkMode_Explorer", "Seems to be dark variation of Explorer theme"), 15 | new Theme("Explorer", "Explorer + apply Win32 dark theme", WindowTheming.AllowDarkMode), 16 | new Theme("DarkMode_Explorer", "DarkMode_Explorer + apply Win32 dark theme", WindowTheming.AllowDarkMode), 17 | new Theme("Start", ""), 18 | new Theme("TaskBar", ""), 19 | new Theme("TrayNotify", ""), 20 | new Theme("TrayNotifyHoriz", ""), 21 | new Theme("TrayNotifyVert", ""), 22 | new Theme("TaskBand", ""), 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SetThemeLib/User32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace SetThemeLib 8 | { 9 | public class User32 10 | { 11 | public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); 12 | 13 | [DllImport("user32.dll")] 14 | [return: MarshalAs(UnmanagedType.Bool)] 15 | public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); 16 | 17 | [DllImport("user32.dll")] 18 | [return: MarshalAs(UnmanagedType.Bool)] 19 | public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam); 20 | 21 | [DllImport("user32.dll", SetLastError = true)] 22 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); 23 | 24 | // When you don't want the ProcessId, use this overload and pass IntPtr.Zero for the second parameter 25 | [DllImport("user32.dll")] 26 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SetThemeLib/UxTheme.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace SetThemeLib 8 | { 9 | public class UxTheme 10 | { 11 | [DllImport("uxtheme.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] 12 | public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); 13 | 14 | [DllImport("uxtheme.dll", SetLastError = true, EntryPoint = "#133")] 15 | public static extern bool AllowDarkModeForWindow(IntPtr a_HWND, bool a_Allow); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SetThemeLib/WindowTheming.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace SetThemeLib 8 | { 9 | public class WindowTheming 10 | { 11 | /// 12 | /// Sets theming for specified HWND 13 | /// 14 | public static int Set(IntPtr hwnd, Theme theme) 15 | { 16 | theme.ExtraAction?.Invoke(hwnd); 17 | var result = UxTheme.SetWindowTheme(hwnd, theme.Value, null); 18 | 19 | return result; 20 | } 21 | 22 | /// 23 | /// Applies dark theming for win32 application 24 | /// 25 | public static void AllowDarkMode(IntPtr hwnd) 26 | { 27 | UxTheme.AllowDarkModeForWindow(hwnd, true); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SetThemeUI/EditWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class EditWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.btnCancel = new System.Windows.Forms.Button(); 32 | this.btnOK = new System.Windows.Forms.Button(); 33 | this.label = new System.Windows.Forms.Label(); 34 | this.textBox1 = new System.Windows.Forms.TextBox(); 35 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 36 | this.tableLayoutPanel1.SuspendLayout(); 37 | this.SuspendLayout(); 38 | // 39 | // btnCancel 40 | // 41 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 42 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 43 | this.btnCancel.Location = new System.Drawing.Point(291, 155); 44 | this.btnCancel.Name = "btnCancel"; 45 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 46 | this.btnCancel.TabIndex = 0; 47 | this.btnCancel.Text = "Cancel"; 48 | this.btnCancel.UseVisualStyleBackColor = true; 49 | // 50 | // btnOK 51 | // 52 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 53 | this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK; 54 | this.btnOK.Location = new System.Drawing.Point(210, 155); 55 | this.btnOK.Name = "btnOK"; 56 | this.btnOK.Size = new System.Drawing.Size(75, 23); 57 | this.btnOK.TabIndex = 1; 58 | this.btnOK.Text = "OK"; 59 | this.btnOK.UseVisualStyleBackColor = true; 60 | // 61 | // label 62 | // 63 | this.label.AutoSize = true; 64 | this.label.Location = new System.Drawing.Point(3, 0); 65 | this.label.Name = "label"; 66 | this.label.Size = new System.Drawing.Size(35, 13); 67 | this.label.TabIndex = 2; 68 | this.label.Text = "label1"; 69 | // 70 | // textBox1 71 | // 72 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 73 | | System.Windows.Forms.AnchorStyles.Left) 74 | | System.Windows.Forms.AnchorStyles.Right))); 75 | this.textBox1.Location = new System.Drawing.Point(3, 16); 76 | this.textBox1.MinimumSize = new System.Drawing.Size(348, 116); 77 | this.textBox1.Multiline = true; 78 | this.textBox1.Name = "textBox1"; 79 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 80 | this.textBox1.Size = new System.Drawing.Size(348, 118); 81 | this.textBox1.TabIndex = 3; 82 | // 83 | // tableLayoutPanel1 84 | // 85 | this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 86 | | System.Windows.Forms.AnchorStyles.Left) 87 | | System.Windows.Forms.AnchorStyles.Right))); 88 | this.tableLayoutPanel1.AutoSize = true; 89 | this.tableLayoutPanel1.ColumnCount = 1; 90 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 91 | this.tableLayoutPanel1.Controls.Add(this.label, 0, 0); 92 | this.tableLayoutPanel1.Controls.Add(this.textBox1, 0, 1); 93 | this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12); 94 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 95 | this.tableLayoutPanel1.RowCount = 2; 96 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); 97 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); 98 | this.tableLayoutPanel1.Size = new System.Drawing.Size(354, 137); 99 | this.tableLayoutPanel1.TabIndex = 4; 100 | // 101 | // EditWindow 102 | // 103 | this.AcceptButton = this.btnOK; 104 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 106 | this.AutoSize = true; 107 | this.CancelButton = this.btnCancel; 108 | this.ClientSize = new System.Drawing.Size(378, 190); 109 | this.Controls.Add(this.tableLayoutPanel1); 110 | this.Controls.Add(this.btnOK); 111 | this.Controls.Add(this.btnCancel); 112 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 113 | this.MaximizeBox = false; 114 | this.MinimizeBox = false; 115 | this.Name = "EditWindow"; 116 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 117 | this.Text = "Edit"; 118 | this.Load += new System.EventHandler(this.EditWindow_Load); 119 | this.tableLayoutPanel1.ResumeLayout(false); 120 | this.tableLayoutPanel1.PerformLayout(); 121 | this.ResumeLayout(false); 122 | this.PerformLayout(); 123 | 124 | } 125 | 126 | #endregion 127 | 128 | private System.Windows.Forms.Button btnCancel; 129 | private System.Windows.Forms.Button btnOK; 130 | private System.Windows.Forms.Label label; 131 | private System.Windows.Forms.TextBox textBox1; 132 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 133 | } 134 | } 135 | 136 | -------------------------------------------------------------------------------- /SetThemeUI/EditWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace SetThemeUI 11 | { 12 | public partial class EditWindow : Form 13 | { 14 | public EditWindow() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public EditWindow(string title, string label, string text = "") : this() 20 | { 21 | this.label.Text = label; 22 | this.Text = title; 23 | this.textBox1.Text = text; 24 | } 25 | 26 | public string Result => textBox1.Text; 27 | 28 | private void EditWindow_Load(object sender, EventArgs e) 29 | { 30 | var pos = this.textBox1.TextLength; 31 | this.textBox1.Select(pos >= 1 ? pos - 1 : 0, 0); 32 | this.textBox1.ScrollToCaret(); 33 | this.textBox1.Focus(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SetThemeUI/EditWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SetThemeUI/HwndSearchControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class HwndSearchControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.rbAllHwnds = new System.Windows.Forms.RadioButton(); 32 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 33 | this.BtnSelectWindows = new System.Windows.Forms.Button(); 34 | this.BtnSelectProcesses = new System.Windows.Forms.Button(); 35 | this.btnEditProps = new System.Windows.Forms.Button(); 36 | this.rbSpecificHWNDs = new System.Windows.Forms.RadioButton(); 37 | this.rbProcess = new System.Windows.Forms.RadioButton(); 38 | this.groupBox1.SuspendLayout(); 39 | this.SuspendLayout(); 40 | // 41 | // rbAllHwnds 42 | // 43 | this.rbAllHwnds.AutoSize = true; 44 | this.rbAllHwnds.Checked = true; 45 | this.rbAllHwnds.Location = new System.Drawing.Point(6, 19); 46 | this.rbAllHwnds.Name = "rbAllHwnds"; 47 | this.rbAllHwnds.Size = new System.Drawing.Size(146, 17); 48 | this.rbAllHwnds.TabIndex = 0; 49 | this.rbAllHwnds.TabStop = true; 50 | this.rbAllHwnds.Text = "Find all available HWNDs"; 51 | this.rbAllHwnds.UseVisualStyleBackColor = true; 52 | this.rbAllHwnds.CheckedChanged += new System.EventHandler(this.CheckChanged); 53 | // 54 | // groupBox1 55 | // 56 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 57 | | System.Windows.Forms.AnchorStyles.Left) 58 | | System.Windows.Forms.AnchorStyles.Right))); 59 | this.groupBox1.Controls.Add(this.BtnSelectWindows); 60 | this.groupBox1.Controls.Add(this.BtnSelectProcesses); 61 | this.groupBox1.Controls.Add(this.btnEditProps); 62 | this.groupBox1.Controls.Add(this.rbSpecificHWNDs); 63 | this.groupBox1.Controls.Add(this.rbProcess); 64 | this.groupBox1.Controls.Add(this.rbAllHwnds); 65 | this.groupBox1.Location = new System.Drawing.Point(3, 3); 66 | this.groupBox1.Name = "groupBox1"; 67 | this.groupBox1.Size = new System.Drawing.Size(276, 171); 68 | this.groupBox1.TabIndex = 1; 69 | this.groupBox1.TabStop = false; 70 | this.groupBox1.Text = "HWND Search"; 71 | // 72 | // BtnSelectWindows 73 | // 74 | this.BtnSelectWindows.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.5F); 75 | this.BtnSelectWindows.Location = new System.Drawing.Point(118, 62); 76 | this.BtnSelectWindows.Name = "BtnSelectWindows"; 77 | this.BtnSelectWindows.Size = new System.Drawing.Size(24, 23); 78 | this.BtnSelectWindows.TabIndex = 5; 79 | this.BtnSelectWindows.Text = "..."; 80 | this.BtnSelectWindows.UseVisualStyleBackColor = true; 81 | this.BtnSelectWindows.Click += new System.EventHandler(this.BtnSelectWindows_Click); 82 | // 83 | // BtnSelectProcesses 84 | // 85 | this.BtnSelectProcesses.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.5F); 86 | this.BtnSelectProcesses.Location = new System.Drawing.Point(200, 39); 87 | this.BtnSelectProcesses.Name = "BtnSelectProcesses"; 88 | this.BtnSelectProcesses.Size = new System.Drawing.Size(24, 23); 89 | this.BtnSelectProcesses.TabIndex = 4; 90 | this.BtnSelectProcesses.Text = "..."; 91 | this.BtnSelectProcesses.UseVisualStyleBackColor = true; 92 | this.BtnSelectProcesses.Click += new System.EventHandler(this.BtnSelectProcesses_Click); 93 | // 94 | // btnEditProps 95 | // 96 | this.btnEditProps.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 97 | | System.Windows.Forms.AnchorStyles.Right))); 98 | this.btnEditProps.Location = new System.Drawing.Point(6, 142); 99 | this.btnEditProps.Name = "btnEditProps"; 100 | this.btnEditProps.Size = new System.Drawing.Size(264, 23); 101 | this.btnEditProps.TabIndex = 3; 102 | this.btnEditProps.Text = "Edit values"; 103 | this.btnEditProps.UseVisualStyleBackColor = true; 104 | this.btnEditProps.Click += new System.EventHandler(this.btnEditProps_Click); 105 | // 106 | // rbSpecificHWNDs 107 | // 108 | this.rbSpecificHWNDs.AutoSize = true; 109 | this.rbSpecificHWNDs.Location = new System.Drawing.Point(6, 65); 110 | this.rbSpecificHWNDs.Name = "rbSpecificHWNDs"; 111 | this.rbSpecificHWNDs.Size = new System.Drawing.Size(106, 17); 112 | this.rbSpecificHWNDs.TabIndex = 2; 113 | this.rbSpecificHWNDs.Text = "Specific HWNDs"; 114 | this.rbSpecificHWNDs.UseVisualStyleBackColor = true; 115 | this.rbSpecificHWNDs.CheckedChanged += new System.EventHandler(this.CheckChanged); 116 | // 117 | // rbProcess 118 | // 119 | this.rbProcess.AutoSize = true; 120 | this.rbProcess.Location = new System.Drawing.Point(6, 42); 121 | this.rbProcess.Name = "rbProcess"; 122 | this.rbProcess.Size = new System.Drawing.Size(188, 17); 123 | this.rbProcess.TabIndex = 1; 124 | this.rbProcess.Text = "Find HWNDs for specified process"; 125 | this.rbProcess.UseVisualStyleBackColor = true; 126 | this.rbProcess.CheckedChanged += new System.EventHandler(this.CheckChanged); 127 | // 128 | // HwndSearchControl 129 | // 130 | this.Controls.Add(this.groupBox1); 131 | this.Name = "HwndSearchControl"; 132 | this.Size = new System.Drawing.Size(282, 177); 133 | this.groupBox1.ResumeLayout(false); 134 | this.groupBox1.PerformLayout(); 135 | this.ResumeLayout(false); 136 | 137 | } 138 | 139 | #endregion 140 | 141 | private System.Windows.Forms.RadioButton rbAllHwnds; 142 | private System.Windows.Forms.GroupBox groupBox1; 143 | private System.Windows.Forms.RadioButton rbSpecificHWNDs; 144 | private System.Windows.Forms.RadioButton rbProcess; 145 | private System.Windows.Forms.Button btnEditProps; 146 | private System.Windows.Forms.Button BtnSelectWindows; 147 | private System.Windows.Forms.Button BtnSelectProcesses; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /SetThemeUI/HwndSearchControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using SetThemeLib; 10 | 11 | namespace SetThemeUI 12 | { 13 | public partial class HwndSearchControl : UserControl 14 | { 15 | public HwndSearchTypes SearchType 16 | { 17 | get 18 | { 19 | if (rbAllHwnds.Checked) 20 | return HwndSearchTypes.All; 21 | else if (rbProcess.Checked) 22 | return HwndSearchTypes.ForProcess; 23 | else if (rbSpecificHWNDs.Checked) 24 | return HwndSearchTypes.Specific; 25 | else 26 | throw new NotImplementedException("Unknown HWNDs search type"); 27 | } 28 | } 29 | 30 | public List SearchValues = new List(); 31 | 32 | public HwndSearchControl() 33 | { 34 | InitializeComponent(); 35 | CheckChanged(null, null); 36 | } 37 | 38 | private void btnEditProps_Click(object sender, EventArgs e) 39 | { 40 | using (var editWnd = new EditWindow( 41 | "Edit properties...", 42 | "You can specify few or more values. Split using ;", 43 | SearchValues.Count >= 1 ? 44 | SearchValues.Select(x => x.ToString()).Aggregate((i, j) => i + ";" + j) : "")) 45 | { 46 | var dialogResult = editWnd.ShowDialog(); 47 | 48 | if (dialogResult == DialogResult.OK) 49 | { 50 | SearchValues.Clear(); 51 | 52 | if (SearchType == HwndSearchTypes.ForProcess) 53 | SearchValues.AddRange(editWnd.Result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())); 54 | else if (SearchType == HwndSearchTypes.Specific) 55 | foreach (var hwndText in editWnd.Result.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())) 56 | { 57 | try 58 | { 59 | var hwndLong = long.Parse(hwndText, System.Globalization.NumberStyles.Any); 60 | SearchValues.Add(new IntPtr(hwndLong)); 61 | } 62 | catch (Exception ex) 63 | { 64 | MessageBox.Show(ex.ToString(), "Unable to convert your HWNDs", MessageBoxButtons.OK, MessageBoxIcon.Error); 65 | } 66 | } 67 | } 68 | } 69 | } 70 | 71 | private void CheckChanged(object sender, EventArgs e) 72 | { 73 | btnEditProps.Enabled = SearchType != HwndSearchTypes.All; 74 | BtnSelectProcesses.Enabled = SearchType == HwndSearchTypes.ForProcess; 75 | BtnSelectWindows.Enabled = false; // SearchType == HwndSearchTypes.Specific; // TODO 76 | } 77 | 78 | private void BtnSelectProcesses_Click(object sender, EventArgs e) 79 | { 80 | using (var processesWnd = new SelectProcessWindow()) 81 | { 82 | if (processesWnd.ShowDialog() == DialogResult.OK) 83 | { 84 | SearchValues.Clear(); 85 | SearchValues.AddRange(processesWnd.SelectedProcesses.Select(x => x.Name)); 86 | } 87 | } 88 | } 89 | 90 | private void BtnSelectWindows_Click(object sender, EventArgs e) 91 | { 92 | 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /SetThemeUI/HwndSearchControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SetThemeUI/LogControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class LogControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.tbLog = new System.Windows.Forms.TextBox(); 32 | this.SuspendLayout(); 33 | // 34 | // tbLog 35 | // 36 | this.tbLog.Dock = System.Windows.Forms.DockStyle.Fill; 37 | this.tbLog.Location = new System.Drawing.Point(0, 0); 38 | this.tbLog.Multiline = true; 39 | this.tbLog.Name = "tbLog"; 40 | this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 41 | this.tbLog.Size = new System.Drawing.Size(150, 150); 42 | this.tbLog.TabIndex = 1; 43 | // 44 | // LogControl 45 | // 46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 48 | this.Controls.Add(this.tbLog); 49 | this.Name = "LogControl"; 50 | this.ResumeLayout(false); 51 | this.PerformLayout(); 52 | 53 | } 54 | 55 | #endregion 56 | 57 | public System.Windows.Forms.TextBox tbLog; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SetThemeUI/LogControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace SetThemeUI 11 | { 12 | public partial class LogControl : UserControl 13 | { 14 | public LogControl() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public void Write(string text) 20 | { 21 | if (InvokeRequired) 22 | { 23 | Invoke(new Action(() => Write(text))); 24 | return; 25 | } 26 | 27 | tbLog.AppendText(text); 28 | } 29 | 30 | public void WriteLine(string text) => Write(text + Environment.NewLine); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SetThemeUI/LogControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SetThemeUI/MainWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class MainWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 32 | this.hwndSearchControl1 = new SetThemeUI.HwndSearchControl(); 33 | this.themePickControl1 = new SetThemeUI.ThemePickControl(); 34 | this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); 35 | this.log = new SetThemeUI.LogControl(); 36 | this.btnPerform = new System.Windows.Forms.Button(); 37 | this.tableLayoutPanel1.SuspendLayout(); 38 | this.tableLayoutPanel2.SuspendLayout(); 39 | this.SuspendLayout(); 40 | // 41 | // tableLayoutPanel1 42 | // 43 | this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 44 | | System.Windows.Forms.AnchorStyles.Left) 45 | | System.Windows.Forms.AnchorStyles.Right))); 46 | this.tableLayoutPanel1.ColumnCount = 2; 47 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 48 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 49 | this.tableLayoutPanel1.Controls.Add(this.hwndSearchControl1, 0, 0); 50 | this.tableLayoutPanel1.Controls.Add(this.themePickControl1, 1, 0); 51 | this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12); 52 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 53 | this.tableLayoutPanel1.RowCount = 1; 54 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 49.54683F)); 55 | this.tableLayoutPanel1.Size = new System.Drawing.Size(550, 155); 56 | this.tableLayoutPanel1.TabIndex = 1; 57 | // 58 | // hwndSearchControl1 59 | // 60 | this.hwndSearchControl1.Dock = System.Windows.Forms.DockStyle.Fill; 61 | this.hwndSearchControl1.Location = new System.Drawing.Point(3, 3); 62 | this.hwndSearchControl1.Name = "hwndSearchControl1"; 63 | this.hwndSearchControl1.Size = new System.Drawing.Size(269, 149); 64 | this.hwndSearchControl1.TabIndex = 0; 65 | // 66 | // themePickControl1 67 | // 68 | this.themePickControl1.Dock = System.Windows.Forms.DockStyle.Fill; 69 | this.themePickControl1.Location = new System.Drawing.Point(278, 3); 70 | this.themePickControl1.Name = "themePickControl1"; 71 | this.themePickControl1.Size = new System.Drawing.Size(269, 149); 72 | this.themePickControl1.TabIndex = 1; 73 | // 74 | // tableLayoutPanel2 75 | // 76 | this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 77 | | System.Windows.Forms.AnchorStyles.Right))); 78 | this.tableLayoutPanel2.ColumnCount = 1; 79 | this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 80 | this.tableLayoutPanel2.Controls.Add(this.log, 0, 1); 81 | this.tableLayoutPanel2.Controls.Add(this.btnPerform, 0, 0); 82 | this.tableLayoutPanel2.Location = new System.Drawing.Point(12, 173); 83 | this.tableLayoutPanel2.Name = "tableLayoutPanel2"; 84 | this.tableLayoutPanel2.RowCount = 2; 85 | this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); 86 | this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); 87 | this.tableLayoutPanel2.Size = new System.Drawing.Size(550, 227); 88 | this.tableLayoutPanel2.TabIndex = 2; 89 | // 90 | // log 91 | // 92 | this.log.Dock = System.Windows.Forms.DockStyle.Fill; 93 | this.log.Location = new System.Drawing.Point(3, 43); 94 | this.log.Name = "log"; 95 | this.log.Size = new System.Drawing.Size(544, 181); 96 | this.log.TabIndex = 0; 97 | // 98 | // btnPerform 99 | // 100 | this.btnPerform.Dock = System.Windows.Forms.DockStyle.Fill; 101 | this.btnPerform.Location = new System.Drawing.Point(3, 3); 102 | this.btnPerform.Name = "btnPerform"; 103 | this.btnPerform.Size = new System.Drawing.Size(544, 34); 104 | this.btnPerform.TabIndex = 1; 105 | this.btnPerform.Text = "Perform SetWindowTheme for each HWND"; 106 | this.btnPerform.UseVisualStyleBackColor = true; 107 | this.btnPerform.Click += new System.EventHandler(this.btnPerform_Click); 108 | // 109 | // MainWindow 110 | // 111 | this.AcceptButton = this.btnPerform; 112 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 113 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 114 | this.ClientSize = new System.Drawing.Size(574, 412); 115 | this.Controls.Add(this.tableLayoutPanel2); 116 | this.Controls.Add(this.tableLayoutPanel1); 117 | this.Name = "MainWindow"; 118 | this.Text = "SetTheme"; 119 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWindow_FormClosing); 120 | this.Load += new System.EventHandler(this.MainWindow_Load); 121 | this.tableLayoutPanel1.ResumeLayout(false); 122 | this.tableLayoutPanel2.ResumeLayout(false); 123 | this.ResumeLayout(false); 124 | 125 | } 126 | 127 | #endregion 128 | 129 | private LogControl log; 130 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 131 | private HwndSearchControl hwndSearchControl1; 132 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; 133 | private System.Windows.Forms.Button btnPerform; 134 | private ThemePickControl themePickControl1; 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /SetThemeUI/MainWindow.cs: -------------------------------------------------------------------------------- 1 | using SetThemeLib; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using System.Windows.Forms; 11 | 12 | namespace SetThemeUI 13 | { 14 | public partial class MainWindow : Form 15 | { 16 | public MainWindow() 17 | { 18 | InitializeComponent(); 19 | 20 | log.WriteLine("OS: " + Environment.OSVersion.ToString()); 21 | log.WriteLine("TIP: It's recommended to run this program with admin permissions!"); 22 | } 23 | 24 | private bool _isWorking; 25 | public bool IsWorking 26 | { 27 | get => _isWorking; 28 | set 29 | { 30 | if (InvokeRequired) 31 | { 32 | Invoke(new Action(() => IsWorking = value)); 33 | return; 34 | } 35 | 36 | _isWorking = value; 37 | 38 | Cursor = value ? Cursors.AppStarting : null; 39 | 40 | tableLayoutPanel1.Enabled = !value; 41 | btnPerform.Enabled = !value; 42 | } 43 | } 44 | 45 | private void MainWindow_Load(object sender, EventArgs e) 46 | { 47 | 48 | } 49 | 50 | private void btnPerform_Click(object sender, EventArgs e) 51 | { 52 | new Thread(() => 53 | { 54 | var time = DateTime.Now; 55 | 56 | IsWorking = true; 57 | log.WriteLine("Beginning..."); 58 | 59 | try 60 | { 61 | HwndSearch.ForEach(hwndSearchControl1.SearchType, hwndSearchControl1.SearchValues.ToArray(), (hwnd) => 62 | { 63 | try 64 | { 65 | // log.WriteLine("Setting theming for " + hwnd); 66 | var result = WindowTheming.Set(hwnd, themePickControl1.SelectedTheme); 67 | 68 | if (result != 0) 69 | { 70 | log.WriteLine($"Failed to process {hwnd:X2}: {result}"); // TODO: error string here 71 | } 72 | } 73 | catch (Exception ex) 74 | { 75 | log.WriteLine("Failed to process HWND: " + hwnd); 76 | log.WriteLine(ex.ToString()); 77 | } 78 | }, (hwnd, ex) => 79 | { 80 | log.WriteLine("Failed search for HWND: " + hwnd); 81 | log.WriteLine(ex.ToString()); 82 | }); 83 | } 84 | catch (Exception ex) 85 | { 86 | 87 | log.WriteLine("Global error happened."); 88 | log.WriteLine(ex.ToString()); 89 | } 90 | 91 | log.WriteLine("Completed in " + (DateTime.Now - time)); 92 | IsWorking = false; 93 | }).Start(); 94 | } 95 | 96 | private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) 97 | { 98 | if (IsWorking) 99 | { 100 | var msg = MessageBox.Show("The program is working. Force exit?", "SetTheme", MessageBoxButtons.YesNo); 101 | 102 | if (msg == DialogResult.Yes) 103 | Environment.Exit(0); 104 | else 105 | e.Cancel = true; 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /SetThemeUI/MainWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SetThemeUI/ProcessModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace SetThemeUI 9 | { 10 | public class ProcessModel 11 | { 12 | public Process Process { get; set; } 13 | 14 | public string Name => Process.ProcessName + ".exe" ; // this is actually incorrect 15 | 16 | public override string ToString() => Name; 17 | 18 | public ProcessModel(Process process) => Process = process; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SetThemeUI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace SetThemeUI 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new MainWindow()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SetThemeUI/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SetThemeUI.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SetThemeUI.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SetThemeUI/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /SetThemeUI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SetThemeUI.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SetThemeUI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SetThemeUI/SelectProcessWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class SelectProcessWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 32 | this.panel1 = new System.Windows.Forms.Panel(); 33 | this.BtnCancel = new System.Windows.Forms.Button(); 34 | this.BtnOK = new System.Windows.Forms.Button(); 35 | this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); 36 | this.label1 = new System.Windows.Forms.Label(); 37 | this.TbFilter = new System.Windows.Forms.TextBox(); 38 | this.LbMain = new System.Windows.Forms.CheckedListBox(); 39 | this.tableLayoutPanel1.SuspendLayout(); 40 | this.panel1.SuspendLayout(); 41 | this.flowLayoutPanel1.SuspendLayout(); 42 | this.SuspendLayout(); 43 | // 44 | // tableLayoutPanel1 45 | // 46 | this.tableLayoutPanel1.ColumnCount = 1; 47 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 48 | this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 2); 49 | this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 0); 50 | this.tableLayoutPanel1.Controls.Add(this.LbMain, 0, 1); 51 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 52 | this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 53 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 54 | this.tableLayoutPanel1.RowCount = 3; 55 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); 56 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 57 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); 58 | this.tableLayoutPanel1.Size = new System.Drawing.Size(255, 255); 59 | this.tableLayoutPanel1.TabIndex = 0; 60 | // 61 | // panel1 62 | // 63 | this.panel1.Controls.Add(this.BtnOK); 64 | this.panel1.Controls.Add(this.BtnCancel); 65 | this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; 66 | this.panel1.Location = new System.Drawing.Point(3, 223); 67 | this.panel1.Name = "panel1"; 68 | this.panel1.Size = new System.Drawing.Size(249, 29); 69 | this.panel1.TabIndex = 0; 70 | // 71 | // BtnCancel 72 | // 73 | this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 74 | this.BtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 75 | this.BtnCancel.Location = new System.Drawing.Point(165, 3); 76 | this.BtnCancel.Name = "BtnCancel"; 77 | this.BtnCancel.Size = new System.Drawing.Size(75, 23); 78 | this.BtnCancel.TabIndex = 0; 79 | this.BtnCancel.Text = "Cancel"; 80 | this.BtnCancel.UseVisualStyleBackColor = true; 81 | // 82 | // BtnOK 83 | // 84 | this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 85 | this.BtnOK.DialogResult = System.Windows.Forms.DialogResult.OK; 86 | this.BtnOK.Location = new System.Drawing.Point(84, 3); 87 | this.BtnOK.Name = "BtnOK"; 88 | this.BtnOK.Size = new System.Drawing.Size(75, 23); 89 | this.BtnOK.TabIndex = 1; 90 | this.BtnOK.Text = "OK"; 91 | this.BtnOK.UseVisualStyleBackColor = true; 92 | // 93 | // flowLayoutPanel1 94 | // 95 | this.flowLayoutPanel1.Controls.Add(this.label1); 96 | this.flowLayoutPanel1.Controls.Add(this.TbFilter); 97 | this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 98 | this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); 99 | this.flowLayoutPanel1.Name = "flowLayoutPanel1"; 100 | this.flowLayoutPanel1.Size = new System.Drawing.Size(249, 24); 101 | this.flowLayoutPanel1.TabIndex = 1; 102 | // 103 | // label1 104 | // 105 | this.label1.Location = new System.Drawing.Point(3, 0); 106 | this.label1.Name = "label1"; 107 | this.label1.Size = new System.Drawing.Size(38, 23); 108 | this.label1.TabIndex = 0; 109 | this.label1.Text = "Filter:"; 110 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 111 | // 112 | // TbFilter 113 | // 114 | this.TbFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 115 | | System.Windows.Forms.AnchorStyles.Right))); 116 | this.TbFilter.Location = new System.Drawing.Point(47, 3); 117 | this.TbFilter.Name = "TbFilter"; 118 | this.TbFilter.Size = new System.Drawing.Size(193, 20); 119 | this.TbFilter.TabIndex = 1; 120 | this.TbFilter.TextChanged += new System.EventHandler(this.TbFilter_TextChanged); 121 | // 122 | // LbMain 123 | // 124 | this.LbMain.Dock = System.Windows.Forms.DockStyle.Fill; 125 | this.LbMain.FormattingEnabled = true; 126 | this.LbMain.Location = new System.Drawing.Point(3, 33); 127 | this.LbMain.Name = "LbMain"; 128 | this.LbMain.Size = new System.Drawing.Size(249, 184); 129 | this.LbMain.TabIndex = 2; 130 | // 131 | // SelectProcessWindow 132 | // 133 | this.AcceptButton = this.BtnOK; 134 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 135 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 136 | this.CancelButton = this.BtnCancel; 137 | this.ClientSize = new System.Drawing.Size(255, 255); 138 | this.ControlBox = false; 139 | this.Controls.Add(this.tableLayoutPanel1); 140 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; 141 | this.MaximizeBox = false; 142 | this.MinimizeBox = false; 143 | this.Name = "SelectProcessWindow"; 144 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 145 | this.Text = "Select processes"; 146 | this.Load += new System.EventHandler(this.SelectProcessWindow_Load); 147 | this.tableLayoutPanel1.ResumeLayout(false); 148 | this.panel1.ResumeLayout(false); 149 | this.flowLayoutPanel1.ResumeLayout(false); 150 | this.flowLayoutPanel1.PerformLayout(); 151 | this.ResumeLayout(false); 152 | 153 | } 154 | 155 | #endregion 156 | 157 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 158 | private System.Windows.Forms.Panel panel1; 159 | private System.Windows.Forms.Button BtnOK; 160 | private System.Windows.Forms.Button BtnCancel; 161 | private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; 162 | private System.Windows.Forms.Label label1; 163 | private System.Windows.Forms.TextBox TbFilter; 164 | private System.Windows.Forms.CheckedListBox LbMain; 165 | } 166 | } -------------------------------------------------------------------------------- /SetThemeUI/SelectProcessWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Diagnostics; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using System.Windows.Forms; 11 | 12 | namespace SetThemeUI 13 | { 14 | public partial class SelectProcessWindow : Form 15 | { 16 | public ProcessModel[] SelectedProcesses 17 | => LbMain.SelectedItems.Cast().ToArray(); 18 | 19 | public SelectProcessWindow() 20 | { 21 | InitializeComponent(); 22 | TbFilter_TextChanged(null, null); 23 | } 24 | 25 | private void SelectProcessWindow_Load(object sender, EventArgs e) 26 | { 27 | 28 | } 29 | 30 | private void TbFilter_TextChanged(object sender, EventArgs e) 31 | { 32 | LbMain.Items.Clear(); 33 | LbMain.Items.AddRange(Process.GetProcesses() 34 | .Where(x => x.ProcessName.ToLower().Contains(TbFilter.Text.ToLower())) 35 | .Select(x => new ProcessModel(x)) 36 | .ToArray()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SetThemeUI/SelectProcessWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /SetThemeUI/SetThemeUI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net40 5 | WinExe 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /SetThemeUI/ThemePickControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace SetThemeUI 2 | { 3 | partial class ThemePickControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 32 | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 33 | this.comboBox1 = new System.Windows.Forms.ComboBox(); 34 | this.labelDescription = new System.Windows.Forms.Label(); 35 | this.groupBox1.SuspendLayout(); 36 | this.tableLayoutPanel1.SuspendLayout(); 37 | this.SuspendLayout(); 38 | // 39 | // groupBox1 40 | // 41 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 42 | | System.Windows.Forms.AnchorStyles.Left) 43 | | System.Windows.Forms.AnchorStyles.Right))); 44 | this.groupBox1.Controls.Add(this.tableLayoutPanel1); 45 | this.groupBox1.Location = new System.Drawing.Point(3, 3); 46 | this.groupBox1.Name = "groupBox1"; 47 | this.groupBox1.Size = new System.Drawing.Size(276, 171); 48 | this.groupBox1.TabIndex = 0; 49 | this.groupBox1.TabStop = false; 50 | this.groupBox1.Text = "Themes"; 51 | // 52 | // tableLayoutPanel1 53 | // 54 | this.tableLayoutPanel1.ColumnCount = 1; 55 | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 56 | this.tableLayoutPanel1.Controls.Add(this.comboBox1, 0, 0); 57 | this.tableLayoutPanel1.Controls.Add(this.labelDescription, 0, 1); 58 | this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 59 | this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 16); 60 | this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 61 | this.tableLayoutPanel1.RowCount = 2; 62 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); 63 | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); 64 | this.tableLayoutPanel1.Size = new System.Drawing.Size(270, 152); 65 | this.tableLayoutPanel1.TabIndex = 1; 66 | this.tableLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel1_Paint); 67 | // 68 | // comboBox1 69 | // 70 | this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 71 | | System.Windows.Forms.AnchorStyles.Right))); 72 | this.comboBox1.FormattingEnabled = true; 73 | this.comboBox1.Location = new System.Drawing.Point(3, 3); 74 | this.comboBox1.Name = "comboBox1"; 75 | this.comboBox1.Size = new System.Drawing.Size(264, 21); 76 | this.comboBox1.TabIndex = 0; 77 | this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); 78 | // 79 | // labelDescription 80 | // 81 | this.labelDescription.Dock = System.Windows.Forms.DockStyle.Fill; 82 | this.labelDescription.Location = new System.Drawing.Point(3, 27); 83 | this.labelDescription.Name = "labelDescription"; 84 | this.labelDescription.Size = new System.Drawing.Size(264, 125); 85 | this.labelDescription.TabIndex = 1; 86 | this.labelDescription.Text = "Theme description will appear here."; 87 | // 88 | // ThemePickControl 89 | // 90 | this.Controls.Add(this.groupBox1); 91 | this.Name = "ThemePickControl"; 92 | this.Size = new System.Drawing.Size(282, 177); 93 | this.groupBox1.ResumeLayout(false); 94 | this.tableLayoutPanel1.ResumeLayout(false); 95 | this.ResumeLayout(false); 96 | 97 | } 98 | 99 | #endregion 100 | 101 | private System.Windows.Forms.GroupBox groupBox1; 102 | private System.Windows.Forms.ComboBox comboBox1; 103 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 104 | private System.Windows.Forms.Label labelDescription; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /SetThemeUI/ThemePickControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using SetThemeLib; 10 | 11 | namespace SetThemeUI 12 | { 13 | public partial class ThemePickControl : UserControl 14 | { 15 | public Theme SelectedTheme 16 | { 17 | get 18 | { 19 | var item = comboBox1.SelectedItem; 20 | if (item != null && item is Theme) 21 | return (Theme)item; 22 | else 23 | return null; 24 | } 25 | } 26 | 27 | public ThemePickControl() 28 | { 29 | InitializeComponent(); 30 | 31 | foreach (var theme in ThemesRepository.Themes) 32 | comboBox1.Items.Add(theme); 33 | 34 | comboBox1.SelectedItem = comboBox1.Items[0]; 35 | } 36 | 37 | private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) 38 | { 39 | 40 | } 41 | 42 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 43 | { 44 | var theme = SelectedTheme; 45 | 46 | if (theme != null) 47 | labelDescription.Text = theme.Description; 48 | else 49 | labelDescription.Text = "Select a theme"; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SetThemeUI/ThemePickControl.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /sctprev.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dz333n/WinSetTheme/e4a807164247b725242f04e9fb363ac77f2db5e9/sctprev.gif --------------------------------------------------------------------------------