├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── SkinFramWorkCore.sln ├── SkinFramWorkCore ├── DebugConsole.cs ├── DwmWindowCaption.cs ├── Interop │ ├── Dwmapi │ │ └── Inetrop.DwmExtendFrameIntoClientArea.cs │ ├── Gdi32 │ │ ├── Interop.CreateRoundRectRgn.cs │ │ ├── Interop.CreateSolidBrush.cs │ │ ├── Interop.DeleteObject.cs │ │ ├── Interop.ExcludeClipRect.cs │ │ ├── Interop.GetObjectType.cs │ │ ├── Interop.GetRegionData.cs │ │ ├── Interop.HBRUSH.cs │ │ ├── Interop.HDC.cs │ │ ├── Interop.HGDIOBJ.cs │ │ ├── Interop.HRGN.cs │ │ ├── Interop.OBJ.cs │ │ ├── Interop.RGNDATAHEADER.cs │ │ └── Interop.SelectObject.cs │ ├── IHandle.cs │ ├── Interop.BOOL.cs │ ├── Interop.ERROR.cs │ ├── Interop.HIWORD.cs │ ├── Interop.HRESULT.cs │ ├── Interop.LOWORD.cs │ ├── Interop.Libraries.cs │ ├── Interop.RECT.cs │ ├── Interop.WindowsMessages.cs │ ├── LRESULT.cs │ ├── User32 │ │ ├── Interop.GCL.cs │ │ ├── Interop.GWLIndex.cs │ │ ├── Interop.GetClientRect.cs │ │ ├── Interop.GetParent.cs │ │ ├── Interop.GetWindowDC.cs │ │ ├── Interop.GetWindowLong.cs │ │ ├── Interop.GetWindowRect.cs │ │ ├── Interop.NCCALCSIZE_PARAMS.cs │ │ ├── Interop.OffsetRect.cs │ │ ├── Interop.ReleaseDC.cs │ │ ├── Interop.SWPFlags.cs │ │ ├── Interop.SetClassLong.cs │ │ ├── Interop.SetWindowLong.cs │ │ ├── Interop.SetWindowPos.cs │ │ ├── Interop.SetWindowRgn.cs │ │ ├── Interop.SystemMetric.cs │ │ ├── Interop.TME.cs │ │ ├── Interop.TrackMouseEvent.cs │ │ ├── Interp.GetSystemMetrics.cs │ │ ├── Introp.PAINTSTRUCT.cs │ │ └── NCHITTEST.cs │ ├── UxTheme │ │ ├── Interop.BPPF.cs │ │ ├── Interop.BP_BUFFERFORMAT.cs │ │ ├── Interop.BP_PAINTPARAMS.cs │ │ ├── Interop.BeginBufferedPaint.cs │ │ ├── Interop.CloseThemeData.cs │ │ ├── Interop.DTTOPTS.cs │ │ ├── Interop.DrawThemeTextEx.cs │ │ ├── Interop.EndBufferedPaint.cs │ │ ├── Interop.GetThemeInt.cs │ │ ├── Interop.GetThemeRect.cs │ │ ├── Interop.GetThemeStream.cs │ │ ├── Interop.HPAINTBUFFER.cs │ │ ├── Interop.MARGINS.cs │ │ ├── Interop.OpenThemeData.cs │ │ └── Interop.SetWindowTheme.cs │ ├── interop.WindowStyles.cs │ └── kernel32 │ │ ├── Interop.FreeLibrary.cs │ │ ├── Interop.GetModuleHandle.cs │ │ ├── Interop.LoadLibrary.cs │ │ └── Interop.LoadLibraryFlags.cs ├── MdiNativeWindow.cs ├── Resources │ └── atlas.png ├── SkinExtensions.cs ├── SkinForm.Designer.cs ├── SkinForm.cs ├── SkinForm.resx ├── SkinFramWorkCore.csproj ├── Windows10Caption.cs └── Windows8Caption.cs └── TestApp1 ├── App.config ├── MDIParent1.Designer.cs ├── MDIParent1.cs ├── MDIParent1.resx ├── Program.cs ├── Properties ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Resources └── 4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg └── TestApp1.csproj /.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 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | /SkinFramWorkCore/Interop/User32/Interop.TITLEBARINFOEX.cs 365 | /nuget.config 366 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Skin FramWork Core is custome Desktop Window manager theme library form for themeing the nonclient area of window in .Net Core Winforms 2 | 3 | 4 | Some of Theme feature: 5 | 6 | 1- Nonclient area Border width 7 | 8 | 2- Nonclient area Caption height 9 | 10 | 3- Nonclient area transparency 11 | 12 | 4- Nonclient area Active caption color 13 | 14 | 5- Nonclient area InActive caption color 15 | 16 | 6-Nonclient area Round Conrner Radius 17 | 18 | 7- full right tol left Nonclient area support 19 | 20 | 8- Support right tol left Background image 21 | 22 | 9- Support theme for both mdi form and it's Children 23 | 24 | and more ........... 25 | 26 | ![2022-11-04_14-33-17](https://user-images.githubusercontent.com/12494184/199973702-0420c9e3-136f-43bd-8ad0-b7cd2e66afbd.png) 27 | 28 | ![2022-11-03_11-21-38](https://user-images.githubusercontent.com/12494184/199977447-eb19a0cc-b936-4579-a001-a4a261efb796.png) 29 | 30 | ![2022-11-04_12-58-47](https://user-images.githubusercontent.com/12494184/199977479-4928ea57-91fa-48a3-b604-3ae660ef7ff8.png) 31 | 32 | ![2022-11-04_14-53-31](https://user-images.githubusercontent.com/12494184/199977491-029797e5-10e2-43f9-aaa5-647a364746f6.png) 33 | 34 | ![Untitled](https://user-images.githubusercontent.com/12494184/199978396-bc637282-4c4e-44da-9dd8-ed4bacb048f4.png) 35 | 36 | ![2022-11-04_15-13-34](https://user-images.githubusercontent.com/12494184/199981123-69e44559-5169-4d9f-bdd5-0b27317aa9f7.png) 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /SkinFramWorkCore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33103.184 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkinFramWorkCore", "SkinFramWorkCore\SkinFramWorkCore.csproj", "{2D1532E1-CB47-467C-AB40-3C910A0100AE}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp1", "TestApp1\TestApp1.csproj", "{12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {2D1532E1-CB47-467C-AB40-3C910A0100AE} = {2D1532E1-CB47-467C-AB40-3C910A0100AE} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Release|Any CPU.Build.0 = Release|Any CPU 23 | {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Release|Any CPU.Build.0 = Release|Any CPU 27 | EndGlobalSection 28 | GlobalSection(SolutionProperties) = preSolution 29 | HideSolutionNode = FALSE 30 | EndGlobalSection 31 | GlobalSection(ExtensibilityGlobals) = postSolution 32 | SolutionGuid = {DE73BF27-2043-49AC-B80B-8A09CE4224E9} 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /SkinFramWorkCore/DebugConsole.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.Runtime.InteropServices; 6 | namespace SkinFramWorkCore 7 | { 8 | public class DebugConsole 9 | { 10 | #region Methods 11 | /// 12 | /// Show Debug messages in Console Window 13 | /// 14 | public static void Show() 15 | { 16 | var consoleAttached = true; 17 | if (AttachConsole(ATTACH_PARRENT) == 0 18 | && Marshal.GetLastWin32Error() != ERROR_ACCESS_DENIED) 19 | { 20 | consoleAttached = Debugger.IsAttached || AllocConsole() != 0; 21 | 22 | } 23 | Trace.Listeners.Add(new ConsoleTraceListener { TraceOutputOptions = TraceOptions.Timestamp | TraceOptions.Callstack }); 24 | } 25 | 26 | public static void ShowConsole(IList cmdArgs) 27 | { 28 | if (cmdArgs.Count > 0 && cmdArgs[0].ToLower().Equals("/ShowDebug".ToLower())) 29 | { 30 | Show(); 31 | } 32 | } 33 | 34 | public static void WriteLine(object ex) 35 | { 36 | // System.Threading.Thread.Sleep(200); 37 | #if DEBUG 38 | Debug.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 39 | Debug.WriteLine(DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm:ss.fff tt", CultureInfo.CurrentCulture)); 40 | if (ex is Exception | ex.GetType().BaseType == typeof(Exception)) 41 | { 42 | Debug.WriteLine($"Exception Message:{((Exception)ex).Message}"); 43 | if (((Exception)ex).InnerException != null) 44 | { 45 | Debug.WriteLine($"Inner Exception:{((Exception)ex).InnerException}"); 46 | } 47 | Debug.WriteLine($"StackTrace:\r\n{((Exception)ex).StackTrace}"); 48 | } 49 | else 50 | { 51 | Debug.WriteLine(ex); 52 | } 53 | 54 | Debug.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 55 | Debug.WriteLine("\r\n"); 56 | #else 57 | Trace.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 58 | Trace.WriteLine(DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm:ss.fff tt", CultureInfo.CurrentCulture)); 59 | if (ex is Exception | ex.GetType().BaseType == typeof(Exception)) 60 | { 61 | Trace.WriteLine($"Exception Message:{((Exception)ex).Message}"); 62 | if (((Exception)ex).InnerException != null) 63 | { 64 | Trace.WriteLine($"Inner Exception:{((Exception)ex).InnerException}"); 65 | } 66 | Trace.WriteLine($"StackTrace:\r\n{((Exception)ex).StackTrace}"); 67 | Trace.WriteLine("\r\n"); 68 | } 69 | else 70 | { 71 | Debug.WriteLine(ex); 72 | } 73 | Trace.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 74 | Trace.WriteLine("\r\n"); 75 | #endif 76 | } 77 | 78 | public static void WriteLine(object ex, int millisecondsTimeout) 79 | { 80 | System.Threading.Thread.Sleep(millisecondsTimeout); 81 | #if DEBUG 82 | Debug.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 83 | Debug.WriteLine(DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm:ss.fff tt", CultureInfo.CurrentCulture)); 84 | if (ex is Exception | ex.GetType().BaseType == typeof(Exception)) 85 | { 86 | Debug.WriteLine($"Exception Message:{((Exception)ex).Message}"); 87 | if (((Exception)ex).InnerException != null) 88 | { 89 | Debug.WriteLine($"Inner Exception:{((Exception)ex).InnerException}"); 90 | } 91 | Debug.WriteLine($"StackTrace:\r\n{((Exception)ex).StackTrace}"); 92 | } 93 | else 94 | { 95 | Debug.WriteLine(ex); 96 | } 97 | 98 | Debug.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 99 | Debug.WriteLine("\r\n"); 100 | #else 101 | Trace.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 102 | Trace.WriteLine(DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm:ss.fff tt", CultureInfo.CurrentCulture)); 103 | if (ex is Exception | ex.GetType().BaseType == typeof(Exception)) 104 | { 105 | Trace.WriteLine($"Exception Message:{((Exception)ex).Message}"); 106 | if (((Exception)ex).InnerException != null) 107 | { 108 | Trace.WriteLine($"Inner Exception:{((Exception)ex).InnerException}"); 109 | } 110 | Trace.WriteLine($"StackTrace:\r\n{((Exception)ex).StackTrace}"); 111 | Trace.WriteLine("\r\n"); 112 | } 113 | else 114 | { 115 | Debug.WriteLine(ex); 116 | } 117 | Trace.WriteLine("-------------------------------------------------------------------------------------------------------------------"); 118 | Trace.WriteLine("\r\n"); 119 | #endif 120 | } 121 | 122 | public static void Clear() 123 | { 124 | try 125 | { 126 | Console.Clear(); 127 | } 128 | catch 129 | { 130 | // ignored 131 | } 132 | } 133 | #endregion 134 | 135 | #region Win API Functions and Constants 136 | /// 137 | /// Allocates a new console for the calling process. 138 | /// 139 | /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.To get extended error information, call GetLastError. 140 | [DllImport("kernel32.dll", EntryPoint = "AllocConsole", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 141 | private static extern int AllocConsole(); 142 | /// 143 | /// Attaches the calling process to the console of the specified process. 144 | /// 145 | /// The identifier of the process whose console is to be used. This parameter can be one of the following values. 146 | /// A- pid :Use the console of the specified process. B- ATTACH_PARENT_PROCESS :Use the console of the parent of the current process. 147 | /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.To get extended error information, call GetLastError. 148 | 149 | [DllImport("kernel32.dll", EntryPoint = "AttachConsole", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 150 | private static extern uint AttachConsole(uint dwProcessId); 151 | // ReSharper disable once InconsistentNaming 152 | /// 153 | /// System Error Code The system cannot open the file Access is denied. 154 | /// 155 | private const uint ERROR_ACCESS_DENIED = 5; 156 | // ReSharper disable once InconsistentNaming 157 | /// 158 | /// Use the console of the parent of the current process. 159 | /// 160 | private const uint ATTACH_PARRENT = 0xFFFFFFFF; 161 | 162 | #endregion 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /SkinFramWorkCore/DwmWindowCaption.cs: -------------------------------------------------------------------------------- 1 | namespace SkinFramWorkCore 2 | { 3 | public abstract class DwmWindowCaption 4 | { 5 | public abstract int BUTTONACTIVECAPTION { get; set; } 6 | public abstract int BUTTONINACTIVECAPTION { get; set; } 7 | public abstract int BUTTONACTIVECLOSE { get; set; } 8 | public abstract int BUTTONINACTIVECLOSE { get; set; } 9 | public abstract int BUTTONCLOSEGLYPH96 { get; set; } 10 | public abstract int BUTTONCLOSEGLYPH120 { get; set; } 11 | public abstract int BUTTONCLOSEGLYPH144 { get; set; } 12 | public abstract int BUTTONCLOSEGLYPH192 { get; set; } 13 | public abstract int BUTTONMAXGLYPH96 { get; set; } 14 | public abstract int BUTTONMAXGLYPH120 { get; set; } 15 | public abstract int BUTTONMAXGLYPH144 { get; set; } 16 | public abstract int BUTTONMAXGLYPH192 { get; set; } 17 | public abstract int BUTTONMINGLYPH96 { get; set; } 18 | public abstract int BUTTONMINGLYPH120 { get; set; } 19 | public abstract int BUTTONMINGLYPH144 { get; set; } 20 | public abstract int BUTTONMINGLYPH192 { get; set; } 21 | public abstract int BUTTONRESTOREGLYPH96 { get; set; } 22 | public abstract int BUTTONRESTOREGLYPH120 { get; set; } 23 | public abstract int BUTTONRESTOREGLYPH144 { get; set; } 24 | public abstract int BUTTONRESTOREGLYPH192 { get; set; } 25 | public virtual int BUTTONCLOSEGLYPH96DARK { get; set; } 26 | public virtual int BUTTONCLOSEGLYPH120DARK { get; set; } 27 | public virtual int BUTTONCLOSEGLYPH144DARK { get; set; } 28 | public virtual int BUTTONCLOSEGLYPH192DARK { get; set; } 29 | public virtual int BUTTONMAXGLYPH96DARK { get; set; } 30 | public virtual int BUTTONMAXGLYPH120DARK { get; set; } 31 | public virtual int BUTTONMAXGLYPH144DARK { get; set; } 32 | public virtual int BUTTONMAXGLYPH192DARK { get; set; } 33 | public virtual int BUTTONMINGLYPH96DARK { get; set; } 34 | public virtual int BUTTONMINGLYPH120DARK { get; set; } 35 | public virtual int BUTTONMINGLYPH144DARK { get; set; } 36 | public virtual int BUTTONMINGLYPH192DARK { get; set; } 37 | public virtual int BUTTONRESTOREGLYPH96DARK { get; set; } 38 | public virtual int BUTTONRESTOREGLYPH120DARK { get; set; } 39 | public virtual int BUTTONRESTOREGLYPH144DARK { get; set; } 40 | public virtual int BUTTONRESTOREGLYPH192DARK { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Dwmapi/Inetrop.DwmExtendFrameIntoClientArea.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | internal static partial class Interop 8 | { 9 | internal static partial class Dwmapi 10 | { 11 | [DllImport(Libraries.Dwmapi, CharSet = CharSet.Auto, ExactSpelling = false)] 12 | public static extern HRESULT DwmExtendFrameIntoClientArea(IntPtr hWnd, ref UxTheme.MARGINS pMarInset); 13 | public static HRESULT DwmExtendFrameIntoClientArea(IHandle hWnd, ref UxTheme.MARGINS pMarInset) 14 | { 15 | var result = DwmExtendFrameIntoClientArea(hWnd.Handle, ref pMarInset); 16 | GC.KeepAlive(hWnd); 17 | return result; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.CreateRoundRectRgn.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | internal static partial class Interop 7 | { 8 | internal static partial class Gdi32 9 | { 10 | [DllImport(Libraries.Gdi32)] 11 | public static extern HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.CreateSolidBrush.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | [DllImport(Libraries.Gdi32, ExactSpelling = true, SetLastError = true)] 12 | public static extern HBRUSH CreateSolidBrush(int crColor); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.DeleteObject.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | [DllImport(Libraries.Gdi32, ExactSpelling = true)] 12 | public static extern BOOL DeleteObject(IntPtr hObject); 13 | 14 | public static BOOL DeleteObject(HGDIOBJ hObject) => DeleteObject(hObject.Handle); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.ExcludeClipRect.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | internal static partial class Interop 7 | { 8 | internal static partial class Gdi32 9 | { 10 | [DllImport(Libraries.Gdi32)] 11 | public static extern int ExcludeClipRect(HDC hdc, int left, int top, int right, int bottom); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.GetObjectType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | internal static partial class Gdi32 11 | { 12 | // This does set last error but *only* in one error case that doesn't add any real value. 13 | [DllImport(Libraries.Gdi32, ExactSpelling = true)] 14 | public static extern OBJ GetObjectType(HGDIOBJ h); 15 | 16 | public static OBJ GetObjectType(HandleRef h) 17 | { 18 | OBJ result = GetObjectType((HGDIOBJ)h.Handle); 19 | GC.KeepAlive(h.Wrapper); 20 | return result; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.GetRegionData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | [DllImport(Libraries.Gdi32, ExactSpelling = true)] 12 | public static extern uint GetRegionData(IntPtr hRgn, uint nCount, IntPtr lpRgnData); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.HBRUSH.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | using System; 5 | internal static partial class Interop 6 | { 7 | internal static partial class Gdi32 8 | { 9 | public readonly struct HBRUSH 10 | { 11 | public IntPtr Handle { get; } 12 | 13 | public HBRUSH(IntPtr handle) => Handle = handle; 14 | 15 | public bool IsNull => Handle == IntPtr.Zero; 16 | 17 | public static explicit operator IntPtr(HBRUSH hbrush) => hbrush.Handle; 18 | public static explicit operator HBRUSH(IntPtr hbrush) => new HBRUSH(hbrush); 19 | public static implicit operator HGDIOBJ(HBRUSH hbrush) => new HGDIOBJ(hbrush.Handle); 20 | public static explicit operator HBRUSH(HGDIOBJ hbrush) => new HBRUSH(hbrush.Handle); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | public readonly struct HDC 12 | { 13 | public IntPtr Handle { get; } 14 | 15 | public HDC(IntPtr handle) => Handle = handle; 16 | 17 | public bool IsNull => Handle == IntPtr.Zero; 18 | 19 | public static explicit operator IntPtr(HDC hdc) => hdc.Handle; 20 | public static explicit operator HDC(IntPtr hdc) => new HDC(hdc); 21 | public static implicit operator HGDIOBJ(HDC hdc) => new HGDIOBJ(hdc.Handle); 22 | 23 | public static bool operator ==(HDC value1, HDC value2) => value1.Handle == value2.Handle; 24 | public static bool operator !=(HDC value1, HDC value2) => value1.Handle != value2.Handle; 25 | public override bool Equals(object? obj) => obj is HDC hdc && hdc.Handle == Handle; 26 | public override int GetHashCode() => Handle.GetHashCode(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.HGDIOBJ.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | public struct HGDIOBJ 12 | { 13 | public IntPtr Handle { get; } 14 | 15 | public HGDIOBJ(IntPtr handle) => Handle = handle; 16 | 17 | public bool IsNull => Handle == IntPtr.Zero; 18 | 19 | public static explicit operator IntPtr(HGDIOBJ hgdiobj) => hgdiobj.Handle; 20 | public static explicit operator HGDIOBJ(IntPtr hgdiobj) => new HGDIOBJ(hgdiobj); 21 | 22 | public static bool operator ==(HGDIOBJ value1, HGDIOBJ value2) => value1.Handle == value2.Handle; 23 | public static bool operator !=(HGDIOBJ value1, HGDIOBJ value2) => value1.Handle != value2.Handle; 24 | public override bool Equals(object? obj) => obj is HGDIOBJ hgdiobj && hgdiobj.Handle == Handle; 25 | public override int GetHashCode() => Handle.GetHashCode(); 26 | 27 | public OBJ ObjectType => GetObjectType(this); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.HRGN.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Buffers; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | public readonly struct HRGN 12 | { 13 | public IntPtr Handle { get; } 14 | 15 | public HRGN(IntPtr handle) => Handle = handle; 16 | 17 | public bool IsNull => Handle == IntPtr.Zero; 18 | 19 | public static implicit operator HGDIOBJ(HRGN hrgn) => new HGDIOBJ(hrgn.Handle); 20 | public static explicit operator IntPtr(HRGN hrgn) => hrgn.Handle; 21 | public static explicit operator HRGN(IntPtr hrgn) => new HRGN(hrgn); 22 | 23 | public unsafe RECT[] GetRegionRects() 24 | { 25 | uint regionDataSize = GetRegionData(Handle, 0, IntPtr.Zero); 26 | if (regionDataSize == 0) 27 | { 28 | return Array.Empty(); 29 | } 30 | 31 | byte[] buffer = ArrayPool.Shared.Rent((int)regionDataSize); 32 | 33 | fixed (byte* b = buffer) 34 | { 35 | if (GetRegionData(Handle, regionDataSize, (IntPtr)b) != regionDataSize) 36 | { 37 | return Array.Empty(); 38 | } 39 | 40 | RECT[] result = RGNDATAHEADER.GetRegionRects((RGNDATAHEADER*)b); 41 | ArrayPool.Shared.Return(buffer); 42 | return result; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | internal static partial class Gdi32 8 | { 9 | public enum OBJ : int 10 | { 11 | PEN = 1, 12 | BRUSH = 2, 13 | DC = 3, 14 | METADC = 4, 15 | PAL = 5, 16 | FONT = 6, 17 | BITMAP = 7, 18 | REGION = 8, 19 | METAFILE = 9, 20 | MEMDC = 10, 21 | EXTPEN = 11, 22 | ENHMETADC = 12, 23 | ENHMETAFILE = 13, 24 | COLORSPACE = 14 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.RGNDATAHEADER.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | #pragma warning disable CS0649 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class Gdi32 10 | { 11 | public struct RGNDATAHEADER 12 | { 13 | public uint dwSize; 14 | public uint iType; 15 | public uint nCount; 16 | public uint nRgnSize; 17 | public RECT rcBound; 18 | 19 | public unsafe static RECT[] GetRegionRects(RGNDATAHEADER* regionData) 20 | { 21 | if (regionData is null || regionData->nCount == 0) 22 | { 23 | return Array.Empty(); 24 | } 25 | 26 | // Region RECTs directly follow the header 27 | return new Span((byte*)regionData + regionData->dwSize, (int)regionData->nCount).ToArray(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Gdi32/Interop.SelectObject.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | internal static partial class Gdi32 11 | { 12 | [DllImport(Libraries.Gdi32, SetLastError = true, ExactSpelling = true)] 13 | public static extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h); 14 | 15 | public static HGDIOBJ SelectObject(IHandle hdc, HGDIOBJ h) 16 | { 17 | HGDIOBJ lastObject = SelectObject((HDC)hdc.Handle, h); 18 | GC.KeepAlive(hdc); 19 | return lastObject; 20 | } 21 | 22 | public static HGDIOBJ SelectObject(HandleRef hdc, HGDIOBJ h) 23 | { 24 | HGDIOBJ lastObject = SelectObject((HDC)hdc.Handle, h); 25 | GC.KeepAlive(hdc.Wrapper); 26 | return lastObject; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/IHandle.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | /// 9 | /// Used to abstract access to classes that contain a potentially owned handle. 10 | /// NOTE: This ultimately should be replaced by . 11 | /// 12 | /// 13 | /// 14 | /// The key benefit of this is that we can keep the owning class from being 15 | /// collected during interop calls. wraps arbitrary 16 | /// owners with target handles. Having this interface allows implicit use 17 | /// of the classes (such as System.Windows.Forms.Control) that 18 | /// meet this common pattern in interop and encourages correct alignment 19 | /// with the proper owner. 20 | /// 21 | /// 22 | /// Note that keeping objects alive is necessary ONLY when the object has 23 | /// a finalizer that will explicitly close the handle. 24 | /// 25 | /// 26 | internal interface IHandle 27 | { 28 | public IntPtr Handle { get; } 29 | } 30 | 31 | /// 32 | /// Used to abstract access to classes that contain a potentially owned handle. 33 | /// 34 | /// 35 | /// 36 | /// The key benefit of this is that we can keep the owning class from being collected during interop calls. 37 | /// wraps arbitrary owners with target handles. Having this interface allows implicit use 38 | /// of the classes (such as System.Windows.Forms.Control) that meet this common pattern in interop and encourages 39 | /// correct alignment with the proper owner. 40 | /// 41 | /// 42 | /// Note that keeping objects alive is necessary ONLY when the object has a finalizer that will explicitly 43 | /// close the handle. 44 | /// 45 | /// 46 | /// When implementing P/Invoke wrappers that take this interface they should not directly take 47 | /// , but should take a generic "T" that is constrained to IHandle{T}. Doing 48 | /// it this way prevents boxing of structs. The "T" parameters should also be marked as 49 | /// to allow structs to be passed by reference instead of by value. 50 | /// 51 | /// 52 | /// When implementing this on a struct it is important that either the struct itself is marked as readonly 53 | /// or these properties are to avoid extra struct copies. 54 | /// 55 | /// 56 | internal interface IHandle where THandle : unmanaged 57 | { 58 | THandle Handle { get; } 59 | 60 | /// 61 | /// Owner of the that might close it when finalized. Default is the 62 | /// implementer. 63 | /// 64 | /// 65 | /// 66 | /// This allows decoupling the owner from the provider and avoids boxing when 67 | /// is on a struct. See for a concrete usage. 68 | /// 69 | /// 70 | object? Wrapper => this; 71 | } 72 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.BOOL.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using static Interop; 6 | 7 | internal partial class Interop 8 | { 9 | /// 10 | /// Blittable version of Windows BOOL type. It is convenient in situations where 11 | /// manual marshalling is required, or to avoid overhead of regular bool marshalling. 12 | /// 13 | /// 14 | /// Some Windows APIs return arbitrary integer values although the return type is defined 15 | /// as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE 16 | /// or bResult == BOOL.FALSE . 17 | /// 18 | internal enum BOOL : int 19 | { 20 | FALSE = 0, 21 | TRUE = 1, 22 | } 23 | } 24 | 25 | internal static class BoolExtensions 26 | { 27 | public static bool IsTrue(this BOOL b) => b != BOOL.FALSE; 28 | public static bool IsFalse(this BOOL b) => b == BOOL.FALSE; 29 | public static BOOL ToBOOL(this bool b) => b ? BOOL.TRUE : BOOL.FALSE; 30 | } 31 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.ERROR.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal partial class Interop 6 | { 7 | // https://docs.microsoft.com/windows/win32/debug/system-error-codes--0-499- 8 | internal static class ERROR 9 | { 10 | public const int ACCESS_DENIED = 0x0005; 11 | public const int INVALID_HANDLE = 0x0006; 12 | public const int INVALID_PARAMETER = 0x0057; 13 | public const int INSUFFICIENT_BUFFER = 0x007A; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.HIWORD.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | internal static int HIWORD(int i) 8 | { 9 | return (short)(i >> 16); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.HRESULT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using static Interop; 3 | 4 | internal static partial class Interop 5 | { 6 | internal enum HRESULT : int 7 | { 8 | S_OK = 0, 9 | S_FALSE = 1, 10 | DRAGDROP_S_DROP = 0x00040100, 11 | DRAGDROP_S_CANCEL = 0x00040101, 12 | DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102, 13 | 14 | E_NOTIMPL = unchecked((int)0x80004001), 15 | E_NOINTERFACE = unchecked((int)0x80004002), 16 | E_POINTER = unchecked((int)0x80004003), 17 | E_ABORT = unchecked((int)0x80004004), 18 | E_FAIL = unchecked((int)0x80004005), 19 | 20 | // These are CLR HRESULTs 21 | InvalidArgFailure = unchecked((int)0x80008081), 22 | CoreHostLibLoadFailure = unchecked((int)0x80008082), 23 | CoreHostLibMissingFailure = unchecked((int)0x80008083), 24 | CoreHostEntryPointFailure = unchecked((int)0x80008084), 25 | CoreHostCurHostFindFailure = unchecked((int)0x80008085), 26 | CoreClrResolveFailure = unchecked((int)0x80008087), 27 | CoreClrBindFailure = unchecked((int)0x80008088), 28 | CoreClrInitFailure = unchecked((int)0x80008089), 29 | CoreClrExeFailure = unchecked((int)0x8000808a), 30 | LibHostExecModeFailure = unchecked((int)0x80008090), 31 | LibHostSdkFindFailure = unchecked((int)0x80008091), 32 | LibHostInvalidArgs = unchecked((int)0x80008092), 33 | InvalidConfigFile = unchecked((int)0x80008093), 34 | AppArgNotRunnable = unchecked((int)0x80008094), 35 | AppHostExeNotBoundFailure = unchecked((int)0x80008095), 36 | FrameworkMissingFailure = unchecked((int)0x80008096), 37 | HostApiFailed = unchecked((int)0x80008097), 38 | HostApiBufferTooSmall = unchecked((int)0x80008098), 39 | LibHostUnknownCommand = unchecked((int)0x80008099), 40 | LibHostAppRootFindFailure = unchecked((int)0x8000809a), 41 | SdkResolverResolveFailure = unchecked((int)0x8000809b), 42 | FrameworkCompatFailure = unchecked((int)0x8000809c), 43 | FrameworkCompatRetry = unchecked((int)0x8000809d), 44 | 45 | RPC_E_CHANGED_MODE = unchecked((int)0x80010106), 46 | DISP_E_MEMBERNOTFOUND = unchecked((int)0x80020003), 47 | DISP_E_PARAMNOTFOUND = unchecked((int)0x80020004), 48 | DISP_E_UNKNOWNNAME = unchecked((int)0x80020006), 49 | DISP_E_EXCEPTION = unchecked((int)0x80020009), 50 | DISP_E_UNKNOWNLCID = unchecked((int)0x8002000C), 51 | DISP_E_DIVBYZERO = unchecked((int)0x80020012), 52 | TYPE_E_BADMODULEKIND = unchecked((int)0x800288BD), 53 | STG_E_INVALIDFUNCTION = unchecked((int)0x80030001), 54 | STG_E_FILENOTFOUND = unchecked((int)0x80030002), 55 | STG_E_ACCESSDENIED = unchecked((int)0x80030005), 56 | STG_E_INVALIDPOINTER = unchecked((int)0x80030009), 57 | STG_E_INVALIDPARAMETER = unchecked((int)0x80030057), 58 | STG_E_INVALIDFLAG = unchecked((int)0x800300FF), 59 | OLE_E_ADVISENOTSUPPORTED = unchecked((int)0x80040003), 60 | OLE_E_NOCONNECTION = unchecked((int)0x80040004), 61 | OLE_E_PROMPTSAVECANCELLED = unchecked((int)0x8004000C), 62 | OLE_E_INVALIDRECT = unchecked((int)0x8004000D), 63 | DV_E_FORMATETC = unchecked((int)0x80040064), 64 | DV_E_TYMED = unchecked((int)0x80040069), 65 | DV_E_DVASPECT = unchecked((int)0x8004006B), 66 | DRAGDROP_E_NOTREGISTERED = unchecked((int)0x80040100), 67 | DRAGDROP_E_ALREADYREGISTERED = unchecked((int)0x80040101), 68 | VIEW_E_DRAW = unchecked((int)0x80040140), 69 | INPLACE_E_NOTOOLSPACE = unchecked((int)0x800401A1), 70 | CO_E_OBJNOTREG = unchecked((int)0x800401FB), 71 | CO_E_OBJISREG = unchecked((int)0x800401FC), 72 | E_ACCESSDENIED = unchecked((int)0x80070005), 73 | E_OUTOFMEMORY = unchecked((int)0x8007000E), 74 | E_INVALIDARG = unchecked((int)0x80070057), 75 | ERROR_CANCELLED = unchecked((int)0x800704C7), 76 | } 77 | } 78 | 79 | internal static class HResultExtensions 80 | { 81 | public static bool Succeeded(this HRESULT hr) => hr >= 0; 82 | 83 | public static bool Failed(this HRESULT hr) => hr < 0; 84 | 85 | public static string AsString(this HRESULT hr) 86 | => Enum.IsDefined(typeof(HRESULT), hr) 87 | ? $"HRESULT {hr} [0x{(int)hr:X} ({(int)hr:D})]" 88 | : $"HRESULT [0x{(int)hr:X} ({(int)hr:D})]"; 89 | } -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.LOWORD.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | internal static int LOWORD(int i) 8 | { 9 | return (short)(i & 0xFFFF); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.Libraries.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | public static class Libraries 8 | { 9 | public const string Comctl32 = "comctl32.dll"; 10 | public const string Comdlg32 = "comdlg32.dll"; 11 | public const string Gdi32 = "gdi32.dll"; 12 | public const string Gdiplus = "gdiplus.dll"; 13 | public const string Hhctrl = "hhctrl.ocx"; 14 | public const string Imm32 = "imm32.dll"; 15 | public const string Kernel32 = "kernel32.dll"; 16 | public const string NtDll = "ntdll.dll"; 17 | public const string Ole32 = "ole32.dll"; 18 | public const string Oleacc = "oleacc.dll"; 19 | public const string Oleaut32 = "oleaut32.dll"; 20 | public const string Powrprof = "Powrprof.dll"; 21 | public const string Propsys = "Propsys.dll"; 22 | public const string RichEdit41 = "MsftEdit.DLL"; 23 | public const string SHCore = "SHCore.dll"; 24 | public const string Shell32 = "shell32.dll"; 25 | public const string Shlwapi = "shlwapi.dll"; 26 | public const string UiaCore = "UIAutomationCore.dll"; 27 | public const string User32 = "user32.dll"; 28 | public const string UxTheme = "uxtheme.dll"; 29 | public const string Dwmapi = "dwmapi.dll"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/Interop.RECT.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Drawing; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | /// 11 | /// The RECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners. 12 | /// 13 | [StructLayout(LayoutKind.Sequential)] 14 | public struct RECT 15 | { 16 | /// 17 | /// Specifies the x-coordinate of the upper-left corner of the rectangle. 18 | /// 19 | public int left; 20 | /// 21 | /// Specifies the y-coordinate of the upper-left corner of the rectangle. 22 | /// 23 | public int top; 24 | /// 25 | /// Specifies the x-coordinate of the lower-right corner of the rectangle. 26 | /// 27 | public int right; 28 | /// 29 | /// Specifies the y-coordinate of the lower-right corner of the rectangle. 30 | /// 31 | public int bottom; 32 | /// 33 | /// Initializes a new instance of the RECT class with the specified location and size 34 | /// 35 | /// Specifies the x-coordinate of the upper-left corner of the rectangle. 36 | /// Specifies the y-coordinate of the upper-left corner of the rectangle. 37 | /// Specifies the x-coordinate of the lower-right corner of the rectangle. 38 | /// Specifies the y-coordinate of the lower-right corner of the rectangle. 39 | public RECT(int left, int top, int right, int bottom) 40 | { 41 | this.left = left; 42 | this.top = top; 43 | this.right = right; 44 | this.bottom = bottom; 45 | } 46 | /// 47 | /// Initializes a new instance of the RECT class from specified 48 | /// 49 | /// Rectangle that will convert to RECT 50 | public RECT(Rectangle rectangle) 51 | { 52 | left = rectangle.Left; 53 | top = rectangle.Top; 54 | right = rectangle.Right; 55 | bottom = rectangle.Bottom; 56 | } 57 | /// 58 | /// Initializes a new instance of the Rectangle class from specified 59 | /// 60 | /// Rectangle that will convert to RECT 61 | public static implicit operator Rectangle(RECT r) 62 | => Rectangle.FromLTRB(r.left, r.top, r.right, r.bottom); 63 | /// 64 | /// Initializes a new instance of the RECT class from specified 65 | /// 66 | /// Rectangle that will convert to RECT 67 | public static implicit operator RECT(Rectangle r) 68 | => new RECT(r); 69 | public RECT RtlRect(int width) 70 | { 71 | return new RECT(width - Width - left, top, width - left, bottom); 72 | } 73 | /// 74 | /// Specifies the x-coordinate of the upper-left corner of the rectangle. 75 | /// 76 | public int X => left; 77 | /// 78 | /// Specifies the y-coordinate of the upper-left corner of the rectangle. 79 | /// 80 | public int Y => top; 81 | /// 82 | /// The width of the rectangle. 83 | /// 84 | public int Width 85 | => right - left; 86 | /// 87 | /// The height of the rectangle. 88 | /// 89 | public int Height 90 | => bottom - top; 91 | /// 92 | /// The of the rectangle. 93 | /// 94 | public Size Size 95 | => new Size(Width, Height); 96 | 97 | public override string ToString() 98 | => $"{{{left}, {top}, {right}, {bottom} (LTRB)}}"; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/LRESULT.cs: -------------------------------------------------------------------------------- 1 |  2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | // See the LICENSE file in the project root for more information. 5 | #pragma warning disable CS8765 6 | using System; 7 | internal readonly partial struct LRESULT : IEquatable 8 | { 9 | internal readonly IntPtr Value; 10 | internal LRESULT(IntPtr value) => this.Value = value; 11 | public static implicit operator IntPtr(LRESULT value) => value.Value; 12 | public static explicit operator LRESULT(IntPtr value) => new LRESULT(value); 13 | public static bool operator ==(LRESULT left, LRESULT right) => left.Value == right.Value; 14 | public static bool operator !=(LRESULT left, LRESULT right) => !(left == right); 15 | 16 | public bool Equals(LRESULT other) => this.Value == other.Value; 17 | public override bool Equals(object obj) => obj is LRESULT other && this.Equals(other); 18 | public override int GetHashCode() => this.Value.GetHashCode(); 19 | } 20 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GCL.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | internal static partial class User32 8 | { 9 | public enum GCL : int 10 | { 11 | /// 12 | /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. 13 | /// 14 | GCLP_WNDPROC = -24, 15 | 16 | /// 17 | /// Retrieves an ATOM value that uniquely identifies the window class. This is the same atom that the RegisterClassEx function returns. 18 | /// 19 | GCW_ATOM = -32, 20 | /// 21 | /// Retrieves a handle to the background brush associated with the class. 22 | /// 23 | GCLP_HBRBACKGROUND=-10 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GWLIndex.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the.NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | /// 12 | /// The zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. used by and 13 | /// 14 | public enum GWLIndex 15 | { 16 | /// 17 | /// Retrieves the . 18 | /// 19 | GWL_STYLE = -16, 20 | /// 21 | /// Retrieves the extended window styles. 22 | /// 23 | GWL_EXSTYLE = -20, 24 | /// 25 | /// Retrieves a handle to the application instance. 26 | /// 27 | GWL_HINSTANCE = -6, 28 | /// 29 | /// Retrieves a handle to the parent window, if any. 30 | /// 31 | GWL_HWNDPARENT = -8, 32 | /// 33 | /// Retrieves the identifier of the window. 34 | /// 35 | GWL_ID = -12, 36 | /// 37 | /// Retrieves the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero. 38 | /// 39 | GWL_USERDATA = -21, 40 | /// 41 | /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. 42 | /// 43 | GWL_WNDPROC = -4 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GetClientRect.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public static extern BOOL GetClientRect(IntPtr hWnd, ref RECT lpRect); 13 | 14 | public static BOOL GetClientRect(IHandle hWnd, ref RECT lpRect) 15 | { 16 | BOOL result = GetClientRect(hWnd.Handle, ref lpRect); 17 | GC.KeepAlive(hWnd); 18 | return result; 19 | } 20 | 21 | public static BOOL GetClientRect(HandleRef hWnd, ref RECT lpRect) 22 | { 23 | BOOL result = GetClientRect(hWnd.Handle, ref lpRect); 24 | GC.KeepAlive(hWnd.Wrapper); 25 | return result; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GetParent.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public static extern IntPtr GetParent(IntPtr hWnd); 13 | 14 | public static IntPtr GetParent(IHandle hWnd) 15 | { 16 | IntPtr result = GetParent(hWnd.Handle); 17 | GC.KeepAlive(hWnd); 18 | return result; 19 | } 20 | 21 | public static IntPtr GetParent(HandleRef hWnd) 22 | { 23 | IntPtr result = GetParent(hWnd.Handle); 24 | GC.KeepAlive(hWnd.Wrapper); 25 | return result; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GetWindowDC.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32)] 12 | public static extern Gdi32.HDC GetWindowDC(IntPtr hWnd); 13 | 14 | public static Gdi32.HDC GetWindowDC(IHandle hWnd) 15 | { 16 | Gdi32.HDC result = GetWindowDC(hWnd.Handle); 17 | GC.KeepAlive(hWnd); 18 | return result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GetWindowLong.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | // We only ever call this on 32 bit so IntPtr is correct 12 | [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] 13 | private static extern IntPtr GetWindowLongW(IntPtr hWnd, GWLIndex nIndex); 14 | 15 | [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] 16 | public static extern IntPtr GetWindowLongPtrW(IntPtr hWnd, GWLIndex nIndex); 17 | 18 | public static IntPtr GetWindowLong(IntPtr hWnd, GWLIndex nIndex) 19 | { 20 | if (IntPtr.Size == 4) 21 | { 22 | return GetWindowLongW(hWnd, nIndex); 23 | } 24 | 25 | return GetWindowLongPtrW(hWnd, nIndex); 26 | } 27 | 28 | public static IntPtr GetWindowLong(IHandle hWnd, GWLIndex nIndex) 29 | { 30 | IntPtr result = GetWindowLong(hWnd.Handle, nIndex); 31 | GC.KeepAlive(hWnd); 32 | return result; 33 | } 34 | 35 | public static IntPtr GetWindowLong(HandleRef hWnd, GWLIndex nIndex) 36 | { 37 | IntPtr result = GetWindowLong(hWnd.Handle, nIndex); 38 | GC.KeepAlive(hWnd.Wrapper); 39 | return result; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.GetWindowRect.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public unsafe static extern BOOL GetWindowRect(IntPtr hWnd, ref RECT rect); 13 | 14 | public static BOOL GetWindowRect(HandleRef hWnd, ref RECT rect) 15 | { 16 | BOOL result = GetWindowRect(hWnd.Handle, ref rect); 17 | GC.KeepAlive(hWnd.Wrapper); 18 | return result; 19 | } 20 | 21 | public static BOOL GetWindowRect(IHandle hWnd, ref RECT rect) 22 | { 23 | BOOL result = GetWindowRect(hWnd.Handle, ref rect); 24 | GC.KeepAlive(hWnd); 25 | return result; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.NCCALCSIZE_PARAMS.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | #pragma warning disable CS0649 5 | using System; 6 | internal static partial class Interop 7 | { 8 | internal static partial class User32 9 | { 10 | internal struct NCCALCSIZE_PARAMS 11 | { 12 | public RECT rgrc0; 13 | public RECT rgrc1; 14 | public RECT rgrc2; 15 | public IntPtr lppos; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.OffsetRect.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32)] 12 | public static extern int OffsetRect(ref RECT lpRect, int x, int y); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.ReleaseDC.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public static extern int ReleaseDC(IntPtr hWnd, Gdi32.HDC hDC); 13 | 14 | public static int ReleaseDC(HandleRef hWnd, Gdi32.HDC hDC) 15 | { 16 | int result = ReleaseDC(hWnd.Handle, hDC); 17 | GC.KeepAlive(hWnd.Wrapper); 18 | return result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.SWPFlags.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the.NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | /// 12 | /// The window sizing and positioning flags used in function. 13 | /// 14 | [Flags] 15 | public enum SWPFlags 16 | { 17 | /// 18 | /// Retains the current size (ignores the cx and cy parameters). 19 | /// 20 | SWP_NOSIZE = 0x0001, 21 | /// 22 | /// Retains the current position (ignores X and Y parameters). 23 | /// 24 | SWP_NOMOVE = 0x0002, 25 | /// 26 | /// Retains the current Z order (ignores the hWndInsertAfter parameter). 27 | /// 28 | SWP_NOZORDER = 0x0004, 29 | /// 30 | /// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing. 31 | /// 32 | SWP_NOREDRAW = 0x0008, 33 | /// 34 | /// Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter). 35 | /// 36 | SWP_NOACTIVATE = 0x0010, 37 | /// 38 | /// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed. 39 | /// 40 | SWP_FRAMECHANGED = 0x0020, 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.SetClassLong.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | // We only ever call this on 32 bit so IntPtr is correct 12 | [DllImport(Libraries.User32, ExactSpelling = true)] 13 | private static extern IntPtr SetClassLongW(IntPtr hwnd, GCL nIndex, IntPtr dwNewLong); 14 | 15 | [DllImport(Libraries.User32, ExactSpelling = true)] 16 | private static extern IntPtr SetClassLongPtrW(IntPtr hwnd, GCL nIndex, IntPtr dwNewLong); 17 | 18 | public static IntPtr SetClassLong(IntPtr hWnd, GCL nIndex, IntPtr dwNewLong) 19 | { 20 | if (IntPtr.Size == 4) 21 | { 22 | return SetClassLongW(hWnd, nIndex, dwNewLong); 23 | } 24 | 25 | return SetClassLongPtrW(hWnd, nIndex, dwNewLong); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.SetWindowLong.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | // We only ever call this on 32 bit so IntPtr is correct 12 | [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] 13 | private static extern IntPtr SetWindowLongW(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong); 14 | 15 | [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] 16 | public static extern IntPtr SetWindowLongPtrW(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong); 17 | 18 | public static IntPtr SetWindowLong(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong) 19 | { 20 | if (IntPtr.Size == 4) 21 | { 22 | return SetWindowLongW(hWnd, nIndex, dwNewLong); 23 | } 24 | 25 | return SetWindowLongPtrW(hWnd, nIndex, dwNewLong); 26 | } 27 | 28 | public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, IntPtr dwNewLong) 29 | { 30 | IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong); 31 | GC.KeepAlive(hWnd); 32 | return result; 33 | } 34 | 35 | public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, IHandle dwNewLong) 36 | { 37 | IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong.Handle); 38 | GC.KeepAlive(hWnd); 39 | GC.KeepAlive(dwNewLong); 40 | return result; 41 | } 42 | 43 | public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, HandleRef dwNewLong) 44 | { 45 | IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong.Handle); 46 | GC.KeepAlive(hWnd); 47 | GC.KeepAlive(dwNewLong.Wrapper); 48 | return result; 49 | } 50 | 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.SetWindowPos.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | public static IntPtr HWND_TOP = (IntPtr)0; 12 | public static IntPtr HWND_BOTTOM = (IntPtr)1; 13 | public static IntPtr HWND_TOPMOST = (IntPtr)(-1); 14 | public static IntPtr HWND_NOTOPMOST = (IntPtr)(-2); 15 | public static IntPtr HWND_MESSAGE = (IntPtr)(-3); 16 | 17 | [DllImport(Libraries.User32, ExactSpelling = true)] 18 | public static extern BOOL SetWindowPos( 19 | IntPtr hWnd, 20 | IntPtr hWndInsertAfter, 21 | int x = 0, 22 | int y = 0, 23 | int cx = 0, 24 | int cy = 0, 25 | SWPFlags flags = (SWPFlags)0); 26 | 27 | public static BOOL SetWindowPos( 28 | HandleRef hWnd, 29 | IntPtr hWndInsertAfter, 30 | int x = 0, 31 | int y = 0, 32 | int cx = 0, 33 | int cy = 0, 34 | SWPFlags flags = (SWPFlags)0) 35 | { 36 | BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter, x, y, cx, cy, flags); 37 | GC.KeepAlive(hWnd.Wrapper); 38 | return result; 39 | } 40 | 41 | public static BOOL SetWindowPos( 42 | HandleRef hWnd, 43 | HandleRef hWndInsertAfter, 44 | int x = 0, 45 | int y = 0, 46 | int cx = 0, 47 | int cy = 0, 48 | SWPFlags flags = (SWPFlags)0) 49 | { 50 | BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter.Handle, x, y, cx, cy, flags); 51 | GC.KeepAlive(hWnd.Wrapper); 52 | GC.KeepAlive(hWndInsertAfter.Wrapper); 53 | return result; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.SetWindowRgn.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public static extern int SetWindowRgn(IntPtr hwnd, Gdi32.HRGN hrgn, bool fRedraw); 13 | 14 | public static int SetWindowRgn(IHandle hwnd, Gdi32.HRGN hrgn, bool fRedraw) 15 | { 16 | int result = SetWindowRgn(hwnd.Handle, hrgn, fRedraw); 17 | GC.KeepAlive(hwnd); 18 | return result; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.TME.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [Flags] 12 | public enum TME : uint 13 | { 14 | HOVER = 0x00000001, 15 | LEAVE = 0x00000002, 16 | NONCLIENT = 0x00000010, 17 | QUERY = 0x40000000, 18 | CANCEL = 0x80000000, 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interop.TrackMouseEvent.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock; 8 | 9 | internal static partial class Interop 10 | { 11 | internal static partial class User32 12 | { 13 | public struct TRACKMOUSEEVENT 14 | { 15 | public uint cbSize; 16 | public TME dwFlags; 17 | public IntPtr hwndTrack; 18 | public uint dwHoverTime; 19 | 20 | public bool IsDefault() 21 | { 22 | return cbSize == 0 && dwFlags == 0 && hwndTrack == IntPtr.Zero && dwHoverTime == 0; 23 | } 24 | } 25 | 26 | [DllImport(Libraries.User32, ExactSpelling = true)] 27 | public static extern BOOL TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Interp.GetSystemMetrics.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | 7 | internal static partial class Interop 8 | { 9 | internal static partial class User32 10 | { 11 | [DllImport(Libraries.User32, ExactSpelling = true)] 12 | public static extern int GetSystemMetrics(SystemMetric nIndex); 13 | 14 | [DllImport(Libraries.User32, ExactSpelling = true)] 15 | private static extern int GetSystemMetricsForDpi(SystemMetric nIndex, uint dpi); 16 | } 17 | } -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/Introp.PAINTSTRUCT.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the.NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | internal static partial class User32 11 | { 12 | [StructLayout(LayoutKind.Sequential, Pack = 4)] 13 | internal struct PAINTSTRUCT 14 | { 15 | public IntPtr hdc; 16 | public int fErase; 17 | public RECT rcPaint; 18 | public int fRestore; 19 | public int fIncUpdate; 20 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] rgbReserved; 21 | } 22 | 23 | [DllImport("user32.dll")] 24 | internal static extern Gdi32.HDC BeginPaint(IntPtr hWnd, ref PAINTSTRUCT paintStruct); 25 | 26 | [DllImport("user32.dll")] 27 | internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT paintStruct); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/User32/NCHITTEST.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | internal static partial class User32 8 | { 9 | /// 10 | /// Location of cursor hot spot returnet in WM_NCHITTEST. 11 | /// 12 | public enum NCHITTEST 13 | { 14 | /// 15 | /// On the screen background or on a dividing line between windows 16 | /// (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). 17 | /// 18 | HTERROR = (-2), 19 | /// 20 | /// In a window currently covered by another window in the same thread 21 | /// (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). 22 | /// 23 | HTTRANSPARENT = (-1), 24 | /// 25 | /// On the screen background or on a dividing line between windows. 26 | /// 27 | HTNOWHERE = 0, 28 | /// In a client area. 29 | HTCLIENT = 1, 30 | /// In a title bar. 31 | HTCAPTION = 2, 32 | /// In a window menu or in a Close button in a child window. 33 | HTSYSMENU = 3, 34 | /// In a size box (same as HTSIZE). 35 | HTGROWBOX = 4, 36 | /// In a menu. 37 | HTMENU = 5, 38 | /// In a horizontal scroll bar. 39 | HTHSCROLL = 6, 40 | /// In the vertical scroll bar. 41 | HTVSCROLL = 7, 42 | /// In a Minimize button. 43 | HTMINBUTTON = 8, 44 | /// In a Maximize button. 45 | HTMAXBUTTON = 9, 46 | /// In the left border of a resizable window 47 | /// (the user can click the mouse to resize the window horizontally). 48 | HTLEFT = 10, 49 | /// 50 | /// In the right border of a resizable window 51 | /// (the user can click the mouse to resize the window horizontally). 52 | /// 53 | HTRIGHT = 11, 54 | /// In the upper-horizontal border of a window. 55 | HTTOP = 12, 56 | /// In the upper-left corner of a window border. 57 | HTTOPLEFT = 13, 58 | /// In the upper-right corner of a window border. 59 | HTTOPRIGHT = 14, 60 | /// In the lower-horizontal border of a resizable window 61 | /// (the user can click the mouse to resize the window vertically). 62 | HTBOTTOM = 15, 63 | /// In the lower-left corner of a border of a resizable window 64 | /// (the user can click the mouse to resize the window diagonally). 65 | HTBOTTOMLEFT = 16, 66 | /// In the lower-right corner of a border of a resizable window 67 | /// (the user can click the mouse to resize the window diagonally). 68 | HTBOTTOMRIGHT = 17, 69 | /// In the border of a window that does not have a sizing border. 70 | HTBORDER = 18, 71 | 72 | HTOBJECT = 19, 73 | /// In a Close button. 74 | HTCLOSE = 20, 75 | /// In a Help button. 76 | HTHELP = 21, 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.BPPF.cs: -------------------------------------------------------------------------------- 1 | internal static partial class Interop 2 | { 3 | public static partial class UxTheme 4 | { 5 | /// 6 | /// value used in struct 7 | /// 8 | public enum BPPF : uint 9 | { 10 | /// 11 | /// Initialize the buffer to ARGB = {0, 0, 0, 0} during B This erases the previous contents of the buffer. 12 | /// 13 | Erase = 1, 14 | /// 15 | /// Do not apply the clip region of the target DC to the double buffer. If this flag is not set and if the target DC is a window DC, then clipping due to overlapping windows is applied to the double buffer. 16 | /// 17 | NoClip = 2, 18 | /// 19 | /// A non-client DC is being used. 20 | /// 21 | NonClient = 4 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.BP_BUFFERFORMAT.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | public static partial class UxTheme 8 | { 9 | public enum BP_BUFFERFORMAT 10 | { 11 | /// 12 | /// Compatible bitmap. The number of bits per pixel is based on the color format of the device associated with the HDC specified with BeginBufferedPaint or BeginBufferedAnimation—typically, this is the display device. 13 | /// 14 | CompatibleBitmap, 15 | /// 16 | /// Bottom-up device-independent bitmap. The origin of the bitmap is the lower-left corner. Uses 32 bits per pixel. 17 | /// 18 | DIB, 19 | /// 20 | /// Top-down device-independent bitmap. The origin of the bitmap is the upper-left corner. Uses 32 bits per pixel. 21 | /// 22 | TopDownDIB, 23 | /// 24 | /// Top-down, monochrome, device-independent bitmap. Uses 1 bit per pixel. 25 | /// 26 | TopDownMonoDIB 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.BP_PAINTPARAMS.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System.Drawing; 7 | using System; 8 | 9 | internal static partial class Interop 10 | { 11 | public static partial class UxTheme 12 | { 13 | 14 | 15 | /// 16 | /// Defines paint operation parameters for . 17 | /// 18 | [StructLayout(LayoutKind.Sequential)] 19 | public struct BP_PAINTPARAMS : IDisposable 20 | { 21 | /// 22 | /// The size, in bytes, of this structure 23 | /// 24 | private readonly int cbSize; 25 | /// 26 | /// 27 | /// 28 | private readonly BPPF Flags; 29 | /// 30 | /// A pointer to exclusion RECT structure. This rectangle is excluded from the clipping region. May be NULL for no exclusion rectangle. 31 | /// 32 | private IntPtr prcExclude; 33 | /// 34 | /// A pointer to BLENDFUNCTION structure, which controls blending by specifying the blending functions for source and destination bitmaps. If NULL, the source buffer is copied to the destination with no blending. 35 | /// 36 | private IntPtr pBlendFunction; 37 | 38 | public BP_PAINTPARAMS(BPPF flags) 39 | { 40 | cbSize = Marshal.SizeOf(typeof(BP_PAINTPARAMS)); 41 | Flags = flags; 42 | prcExclude = pBlendFunction = IntPtr.Zero; 43 | } 44 | 45 | [StructLayout(LayoutKind.Sequential)] 46 | public struct BLENDFUNCTION 47 | { 48 | public byte BlendOp; 49 | public byte BlendFlags; 50 | public byte SourceConstantAlpha; 51 | public byte AlphaFormat; 52 | 53 | public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) 54 | { 55 | BlendOp = op; 56 | BlendFlags = flags; 57 | SourceConstantAlpha = alpha; 58 | AlphaFormat = format; 59 | } 60 | } 61 | 62 | public Rectangle Exclude 63 | { 64 | get 65 | { 66 | return Marshal.PtrToStructure(prcExclude); 67 | } 68 | set 69 | { 70 | if (prcExclude == IntPtr.Zero) 71 | prcExclude = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RECT))); 72 | Marshal.StructureToPtr(value, prcExclude, false); 73 | } 74 | } 75 | 76 | public BLENDFUNCTION BlendFunction 77 | { 78 | get { return Marshal.PtrToStructure(pBlendFunction); } 79 | set 80 | { 81 | if (pBlendFunction == IntPtr.Zero) 82 | pBlendFunction = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BLENDFUNCTION))); 83 | Marshal.StructureToPtr(value, pBlendFunction, false); 84 | } 85 | } 86 | 87 | public void Dispose() 88 | { 89 | if (prcExclude != IntPtr.Zero) 90 | Marshal.FreeHGlobal(prcExclude); 91 | if (pBlendFunction != IntPtr.Zero) 92 | Marshal.FreeHGlobal(pBlendFunction); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.BeginBufferedPaint.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | internal static partial class Interop 7 | { 8 | public static partial class UxTheme 9 | { 10 | /// 11 | /// Begins a buffered paint operation. 12 | /// 13 | /// The handle of the target DC on which the buffer will be painted. 14 | /// A pointer to a RECT structure that specifies the area of the target DC in which to paint. 15 | /// A member of the enumeration that specifies the format of the buffer. 16 | /// A pointer to a structure that defines the paint operation parameters. This value can be NULL. 17 | /// When this function returns, points to the handle of the new device context. 18 | /// Type: 19 | /// A handle to the buffered paint context. If this function fails, the return value is NULL, and phdc is NULL. To get extended error information, call GetLastError. 20 | [DllImport(Libraries.UxTheme, SetLastError = true)] 21 | 22 | public static extern HPAINTBUFFER BeginBufferedPaint(Gdi32.HDC hdc, ref RECT prcTarget, BP_BUFFERFORMAT dwFormat, ref BP_PAINTPARAMS pPaintParams, out Gdi32.HDC phdc); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.CloseThemeData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | [DllImport(Libraries.UxTheme, ExactSpelling = true)] 13 | public static extern HRESULT CloseThemeData(IntPtr hTheme); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.DTTOPTS.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Drawing; 7 | using System.Runtime.InteropServices; 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | [StructLayout(LayoutKind.Sequential)] 13 | public struct DTTOPTS 14 | { 15 | public int dwSize; 16 | public int dwFlags; 17 | public int crText; 18 | public int crBorder; 19 | public int crShadow; 20 | public int iTextShadowType; 21 | public Point ptShadowOffset; 22 | public int iBorderSize; 23 | public int iFontPropId; 24 | public int iColorPropId; 25 | public int iStateId; 26 | public bool fApplyOverlay; 27 | public int iGlowSize; 28 | public int pfnDrawTextCallback; 29 | public IntPtr lParam; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.DrawThemeTextEx.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | internal static partial class Interop 8 | { 9 | public static partial class UxTheme 10 | { 11 | [DllImport(Libraries.UxTheme, CharSet = CharSet.Unicode)] 12 | public static extern HRESULT DrawThemeTextEx(IntPtr hTheme, Gdi32.HDC hdc, int iPartId, int iStateId, string text, int iCharCount, int dwFlags, ref RECT pRect, ref DTTOPTS pOptions); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.EndBufferedPaint.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | using System.Runtime.InteropServices; 5 | internal static partial class Interop 6 | { 7 | public static partial class UxTheme 8 | { 9 | [DllImport(Libraries.UxTheme)] 10 | public static extern HRESULT EndBufferedPaint(HPAINTBUFFER hBufferedPaint, [MarshalAs(UnmanagedType.Bool)] bool fUpdateTarget); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeInt.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | [DllImport(Libraries.UxTheme, ExactSpelling = true)] 13 | public static extern HRESULT GetThemeInt(IntPtr hTheme, int iPartId, int iStateId, int iPropId, ref int piVal); 14 | 15 | public static HRESULT GetThemeInt(IHandle hTheme, int iPartId, int iStateId, int iPropId, ref int piVal) 16 | { 17 | HRESULT hr = GetThemeInt(hTheme.Handle, iPartId, iStateId, iPropId, ref piVal); 18 | GC.KeepAlive(hTheme); 19 | return hr; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeRect.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | internal static partial class Interop 8 | { 9 | public static partial class UxTheme 10 | { 11 | [DllImport(Libraries.UxTheme)] 12 | public static extern HRESULT GetThemeRect(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out RECT pRect); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeStream.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | internal static partial class Interop 8 | { 9 | public static partial class UxTheme 10 | { 11 | [DllImport(Libraries.UxTheme)] 12 | public static extern int GetThemeStream(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out IntPtr ppvStream, out uint pcbStream, IntPtr hInst); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.HPAINTBUFFER.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | #pragma warning disable CS8765 5 | using System; 6 | using System.Reflection.Metadata; 7 | using System.Runtime.InteropServices; 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | /// Provides a handle to a paint buffer. 13 | [StructLayout(LayoutKind.Sequential)] 14 | public struct HPAINTBUFFER : IHandle, IEquatable 15 | { 16 | public IntPtr Handle { get; } 17 | public HPAINTBUFFER(IntPtr preHandle) => Handle = preHandle; 18 | public bool IsNull => Handle == IntPtr.Zero; 19 | public static explicit operator IntPtr(HPAINTBUFFER h) => h.Handle; 20 | public static implicit operator HPAINTBUFFER(IntPtr h) => new HPAINTBUFFER(h); 21 | public static bool operator !=(HPAINTBUFFER h1, HPAINTBUFFER h2) => !(h1 == h2); 22 | public static bool operator ==(HPAINTBUFFER h1, HPAINTBUFFER h2) => h1.Equals(h2); 23 | public bool Equals(HPAINTBUFFER other) => Handle == other.Handle; 24 | public override bool Equals(object obj) => obj is HPAINTBUFFER h && Equals(h); 25 | public override int GetHashCode() => Handle.GetHashCode(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.MARGINS.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | internal static partial class Interop 6 | { 7 | public static partial class UxTheme 8 | { 9 | public struct MARGINS 10 | { 11 | public int cxLeftWidth; 12 | public int cxRightWidth; 13 | public int cyTopHeight; 14 | public int cyBottomHeight; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.OpenThemeData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | [DllImport(Libraries.UxTheme, ExactSpelling = true, CharSet = CharSet.Unicode)] 13 | public static extern IntPtr OpenThemeData(IntPtr hwnd, string pszClassList); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/UxTheme/Interop.SetWindowTheme.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal static partial class Interop 9 | { 10 | public static partial class UxTheme 11 | { 12 | [DllImport(Libraries.UxTheme, CharSet = CharSet.Unicode, ExactSpelling = true)] 13 | public static extern HRESULT SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/interop.WindowStyles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | internal static partial class Interop 3 | { 4 | [Flags] 5 | public enum WindowStyles : uint 6 | { 7 | /// 8 | /// The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style. 9 | /// 10 | WS_OVERLAPPED = 0x00000000, 11 | /// 12 | /// The window is a pop-up window. This style cannot be used with the WS_CHILD style. 13 | /// 14 | WS_POPUP = 0x80000000, 15 | /// 16 | /// The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style. 17 | /// 18 | WS_CHILD = 0x40000000, 19 | /// 20 | /// The window is initially minimized. Same as the WS_ICONIC style. 21 | /// 22 | WS_MINIMIZE = 0x20000000, 23 | /// 24 | /// The window is initially visible. 25 | /// This style can be turned on and off by using the ShowWindow or SetWindowPos function. 26 | /// 27 | WS_VISIBLE = 0x10000000, 28 | /// 29 | /// The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function. 30 | /// 31 | WS_DISABLED = 0x08000000, 32 | /// 33 | /// Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window. 34 | /// 35 | WS_CLIPSIBLINGS = 0x04000000, 36 | /// 37 | /// Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. 38 | /// 39 | WS_CLIPCHILDREN = 0x02000000, 40 | /// 41 | /// The window is initially maximized. 42 | /// 43 | WS_MAXIMIZE = 0x01000000, 44 | /// 45 | /// The window has a thin-line border 46 | /// 47 | WS_BORDER = 0x00800000, 48 | /// 49 | /// The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. 50 | /// 51 | WS_DLGFRAME = 0x00400000, 52 | WS_VSCROLL = 0x00200000, 53 | /// 54 | /// The window has a horizontal scroll bar. 55 | /// 56 | WS_HSCROLL = 0x00100000, 57 | WS_SYSMENU = 0x00080000, 58 | /// 59 | /// The window has a sizing border. Same as the WS_SIZEBOX style. 60 | /// 61 | WS_THICKFRAME = 0x00040000, 62 | /// 63 | /// The window is the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. 64 | /// 65 | WS_GROUP = 0x00020000, 66 | /// 67 | /// The window is a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. 68 | /// 69 | WS_TABSTOP = 0x00010000, 70 | /// 71 | /// The window has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. 72 | /// 73 | 74 | WS_MINIMIZEBOX = 0x00020000, 75 | /// 76 | /// The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. 77 | /// 78 | WS_MAXIMIZEBOX = 0x00010000, 79 | /// 80 | /// The window has a title bar (includes the WS_BORDER style). 81 | /// 82 | WS_CAPTION = WS_BORDER | WS_DLGFRAME, 83 | /// 84 | /// The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. 85 | /// 86 | WS_TILED = WS_OVERLAPPED, 87 | /// 88 | /// The window is initially minimized. Same as the WS_MINIMIZE style. 89 | /// 90 | WS_ICONIC = WS_MINIMIZE, 91 | WS_SIZEBOX = WS_THICKFRAME, 92 | /// 93 | /// The window is an overlapped window. Same as the WS_OVERLAPPEDWINDOW style. 94 | /// 95 | WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, 96 | /// 97 | /// The window is an overlapped window. Same as the WS_TILEDWINDOW style. 98 | /// 99 | WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, 100 | /// 101 | /// The window is a pop-up window. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. 102 | /// 103 | WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, 104 | /// 105 | /// Same as the WS_CHILD style. 106 | /// 107 | WS_CHILDWINDOW = WS_CHILD, 108 | 109 | //Extended Window Styles 110 | 111 | /// 112 | /// The window has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter. 113 | /// 114 | WS_EX_DLGMODALFRAME = 0x00000001, 115 | /// 116 | /// The window does not pass its window layout to its child windows. 117 | /// 118 | WS_EX_NOPARENTNOTIFY = 0x00000004, 119 | /// 120 | /// The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function. 121 | /// 122 | WS_EX_TOPMOST = 0x00000008, 123 | /// 124 | /// The window accepts drag-drop files. 125 | /// 126 | WS_EX_ACCEPTFILES = 0x00000010, 127 | /// 128 | /// The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. 129 | ///To achieve transparency without these restrictions, use the SetWindowRgn function. 130 | /// 131 | WS_EX_TRANSPARENT = 0x00000020, 132 | 133 | /// 134 | /// The window is a MDI child window. 135 | /// 136 | 137 | WS_EX_MDICHILD = 0x00000040, 138 | WS_EX_TOOLWINDOW = 0x00000080, 139 | WS_EX_WINDOWEDGE = 0x00000100, 140 | WS_EX_CLIENTEDGE = 0x00000200, 141 | WS_EX_CONTEXTHELP = 0x00000400, 142 | 143 | WS_EX_RIGHT = 0x00001000, 144 | WS_EX_LEFT = 0x00000000, 145 | WS_EX_RTLREADING = 0x00002000, 146 | WS_EX_LTRREADING = 0x00000000, 147 | WS_EX_LEFTSCROLLBAR = 0x00004000, 148 | WS_EX_RIGHTSCROLLBAR = 0x00000000, 149 | 150 | WS_EX_CONTROLPARENT = 0x00010000, 151 | WS_EX_STATICEDGE = 0x00020000, 152 | WS_EX_APPWINDOW = 0x00040000, 153 | 154 | WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE), 155 | WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST), 156 | 157 | WS_EX_LAYERED = 0x00080000, 158 | 159 | WS_EX_NOINHERITLAYOUT = 0x00100000, 160 | WS_EX_LAYOUTRTL = 0x00400000, 161 | 162 | /// 163 | /// Paints all descendants of a window in bottom-to-top painting order using double-buffering. Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects, but only if the descendent window also has the WS_EX_TRANSPARENT bit set. Double-buffering allows the window and its descendents to be painted without flicker. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. 164 | /// 165 | 166 | WS_EX_COMPOSITED = 0x02000000, 167 | WS_EX_NOACTIVATE = 0x08000000 168 | //#endif /* WIN32WINNT >= 0x0500 */ 169 | 170 | } 171 | 172 | 173 | } 174 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/kernel32/Interop.FreeLibrary.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System; 6 | using System.Runtime.InteropServices; 7 | 8 | internal partial class Interop 9 | { 10 | internal partial class Kernel32 11 | { 12 | [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] 13 | public static extern BOOL FreeLibrary(IntPtr hModule); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/kernel32/Interop.GetModuleHandle.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | using System; 7 | internal partial class Interop 8 | { 9 | internal partial class Kernel32 10 | { 11 | [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] 12 | public static extern IntPtr GetModuleHandleW(string moduleName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/kernel32/Interop.LoadLibrary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | 5 | 6 | internal partial class Interop 7 | { 8 | internal partial class Kernel32 9 | { 10 | 11 | private const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002; 12 | 13 | [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] 14 | private static extern IntPtr LoadLibraryExW(string lpModuleName, IntPtr hFile, uint dwFlags); 15 | 16 | public static IntPtr LoadLibraryAsDataFile(string libraryName) 17 | { 18 | IntPtr kernel32 = GetModuleHandleW(Libraries.Kernel32); 19 | if (kernel32 == IntPtr.Zero) 20 | { 21 | return IntPtr.Zero; 22 | } 23 | 24 | // LOAD_LIBRARY_SEARCH_SYSTEM32 was introduced in KB2533623. Check for its presence 25 | // to preserve compat with Windows 7 SP1 without this patch. 26 | IntPtr result = LoadLibraryExW(libraryName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); 27 | if (result != IntPtr.Zero) 28 | { 29 | return result; 30 | } 31 | 32 | // Load without this flag. 33 | if (Marshal.GetLastWin32Error() != ERROR.INVALID_PARAMETER) 34 | { 35 | return IntPtr.Zero; 36 | } 37 | 38 | return LoadLibraryExW(libraryName, IntPtr.Zero, 0); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Interop/kernel32/Interop.LoadLibraryFlags.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the.NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | using System; 5 | internal static partial class Interop 6 | { 7 | internal static partial class kernel32 8 | { 9 | /// 10 | /// The action to be taken when loading the module. If no flags are specified, the behavior of this function is identical to that of the function. 11 | /// 12 | [Flags] 13 | public enum LoadLibraryFlags : uint 14 | { 15 | None = 0, 16 | /// 17 | /// If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module. 18 | /// 19 | DONT_RESOLVE_DLL_REFERENCES = 0x00000001, 20 | /// 21 | /// If this value is used, the system does not check AppLocker rules or apply Software Restriction Policies for the DLL. This action applies only to the DLL being loaded and not to its dependencies. This value is recommended for use in setup programs that must run extracted DLLs during installation. 22 | /// 23 | LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, 24 | /// 25 | /// If this value is used, the system maps the file into the calling process's virtual address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. 26 | /// 27 | LOAD_LIBRARY_AS_DATAFILE = 0x00000002, 28 | /// 29 | /// Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file is opened with exclusive write access for the calling process. Other processes cannot open the DLL file for write access while it is in use. However, the DLL can still be opened by other processes. 30 | /// 31 | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, 32 | /// 33 | /// If this value is used, the system maps the file into the process's virtual address space as an image file. However, the loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a DLL only to extract messages or resources from it. 34 | /// 35 | LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, 36 | /// 37 | /// If this value is used, the application's installation directory is searched for the DLL and its dependencies. Directories in the standard search path are not searched 38 | /// 39 | LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200, 40 | /// 41 | /// This value is a combination of LOAD_LIBRARY_SEARCH_APPLICATION_DIR, LOAD_LIBRARY_SEARCH_SYSTEM32, and LOAD_LIBRARY_SEARCH_USER_DIRS. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. 42 | /// 43 | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000, 44 | /// 45 | /// If this value is used, the directory that contains the DLL is temporarily added to the beginning of the list of directories that are searched for the DLL's dependencies. Directories in the standard search path are not searched. 46 | /// 47 | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100, 48 | /// 49 | /// If this value is used, %windows%\system32 is searched for the DLL and its dependencies. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. 50 | /// 51 | LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800, 52 | /// 53 | /// If this value is used, directories added using the AddDllDirectory or the SetDllDirectory function are searched for the DLL and its dependencies. If more than one directory has been added, the order in which the directories are searched is unspecified. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. 54 | /// 55 | LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400, 56 | /// 57 | /// If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path, the behavior is undefined. 58 | /// 59 | LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SkinFramWorkCore/MdiNativeWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | using static Interop; 5 | using static Interop.Gdi32; 6 | using static Interop.User32; 7 | namespace SkinFramWorkCore 8 | { 9 | internal class MdiNativeWindow:NativeWindow 10 | { 11 | private MdiClient _mdiClient; 12 | 13 | public MdiNativeWindow(MdiClient mdiClient) 14 | { 15 | _mdiClient = mdiClient; 16 | ReleaseHandle(); 17 | AssignHandle(_mdiClient.Handle); 18 | _mdiClient.HandleDestroyed += delegate { ReleaseHandle(); }; 19 | } 20 | 21 | protected override void WndProc(ref Message m) 22 | { 23 | switch ((WindowsMessages)m.Msg) 24 | { 25 | case WindowsMessages.PAINT: 26 | PAINTSTRUCT paintStruct = new PAINTSTRUCT(); 27 | var screenHdc = BeginPaint(m.HWnd, ref paintStruct); 28 | UxTheme.BP_PAINTPARAMS paintParams = new UxTheme.BP_PAINTPARAMS(UxTheme.BPPF.Erase| UxTheme.BPPF.NoClip); 29 | RECT clientRect = new RECT(); 30 | GetClientRect(_mdiClient.Handle, ref clientRect); 31 | UxTheme.HPAINTBUFFER bufferedPaint = UxTheme.BeginBufferedPaint(screenHdc, ref clientRect, UxTheme.BP_BUFFERFORMAT.CompatibleBitmap, ref paintParams, out screenHdc); 32 | using (Graphics g = Graphics.FromHdcInternal(screenHdc.Handle)) 33 | { 34 | 35 | if (_mdiClient.BackgroundImage != null) 36 | { 37 | g.DrawBackgroundImage(_mdiClient.BackgroundImage, _mdiClient.BackColor, _mdiClient.BackgroundImageLayout, clientRect, clientRect, Point.Empty,_mdiClient.RightToLeft); 38 | } 39 | else 40 | g.Clear(SystemColors.AppWorkspace); 41 | } 42 | UxTheme.EndBufferedPaint(bufferedPaint, true); 43 | 44 | EndPaint(m.HWnd, ref paintStruct); 45 | break; 46 | case WindowsMessages.ERASEBKGND: 47 | 48 | if (((int)User32.GetWindowLong(_mdiClient.Handle, User32.GWLIndex.GWL_EXSTYLE) & (int)WindowStyles.WS_EX_COMPOSITED) == (int)WindowStyles.WS_EX_COMPOSITED) 49 | { 50 | _mdiClient.Invalidate(); 51 | } 52 | 53 | break; 54 | 55 | default: 56 | base.WndProc(ref m); 57 | break; 58 | } 59 | 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Resources/atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memoarfaa/SkinFormCore/1c589d6df614e1c9374f53000334fdd7b5a31b1a/SkinFramWorkCore/Resources/atlas.png -------------------------------------------------------------------------------- /SkinFramWorkCore/SkinExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the LICENSE file in the project root for more information. 4 | 5 | using System.Diagnostics; 6 | using System.Drawing; 7 | using System.Drawing.Drawing2D; 8 | using System.Drawing.Imaging; 9 | using System.Runtime.InteropServices; 10 | using Microsoft.Win32; 11 | using static Interop; 12 | using System; 13 | using System.IO; 14 | using System.Linq; 15 | using System.Windows.Forms; 16 | 17 | namespace SkinFramWorkCore 18 | { 19 | internal static class SkinExtensions 20 | { 21 | internal static IntPtr hTheme; 22 | internal enum SkinPlatform 23 | { 24 | Vista, 25 | Win7, 26 | Win8, 27 | Win81, 28 | Win10, 29 | Win11 30 | } 31 | 32 | internal enum DwmButtonState 33 | { 34 | Normal = 1, 35 | Hot = 2, 36 | Pressed = 3, 37 | Disabled = 4 38 | } 39 | 40 | 41 | internal static Bitmap GetImageAtlasFromTheme() 42 | { 43 | hTheme = UxTheme.OpenThemeData(IntPtr.Zero, "DWMWINDOW"); 44 | var path = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", string.Empty)?.ToString(); 45 | if (path == null) 46 | return new Bitmap(1, 1); 47 | var hInstance = Kernel32.LoadLibraryAsDataFile(path); 48 | try 49 | { 50 | IntPtr themeStream; 51 | uint streamSize; 52 | UxTheme.GetThemeStream(hTheme, 0, 0, 213, out themeStream, out streamSize, hInstance); 53 | var bufferStream = new byte[streamSize]; 54 | Marshal.Copy(themeStream, bufferStream, 0, bufferStream.Length); 55 | using (var ms = new MemoryStream(bufferStream)) 56 | { 57 | return new Bitmap(Image.FromStream(ms)); 58 | } 59 | } 60 | 61 | catch (Exception ex) 62 | { 63 | //ignore 64 | Debug.WriteLine(ex); 65 | if (hTheme != IntPtr.Zero) 66 | UxTheme.CloseThemeData(hTheme); 67 | return new Bitmap(1, 1); 68 | } 69 | 70 | finally 71 | { 72 | Kernel32.FreeLibrary(hInstance); 73 | if (hTheme != IntPtr.Zero) 74 | UxTheme.CloseThemeData(hTheme); 75 | } 76 | } 77 | 78 | static SkinExtensions() 79 | { 80 | MsStylePlatform = GetMsstylePlatform(); 81 | } 82 | 83 | internal static SkinPlatform MsStylePlatform { get; private set; } 84 | 85 | internal static SkinPlatform GetMsstylePlatform() 86 | { 87 | var currentMsstylePath = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", string.Empty)?.ToString(); 88 | if (string.IsNullOrEmpty(currentMsstylePath)) 89 | return SkinPlatform.Win10; 90 | var fileVersionInfo = FileVersionInfo.GetVersionInfo(currentMsstylePath); 91 | var fileVersion = fileVersionInfo.FileVersion; 92 | if (fileVersion == null) 93 | return SkinPlatform.Win10; 94 | var versionToken = fileVersion.Split('.'); 95 | if (versionToken.Length > 0) 96 | { 97 | switch (versionToken[0]) 98 | { 99 | case "6": 100 | switch (versionToken[1]) 101 | { 102 | case "0": 103 | return SkinPlatform.Vista; 104 | case "1": 105 | return SkinPlatform.Win7; 106 | case "2": 107 | return SkinPlatform.Win8; 108 | case "3": 109 | return SkinPlatform.Win81; 110 | } 111 | 112 | break; 113 | case "10": 114 | return int.Parse(versionToken[2]) < 22000 ? SkinPlatform.Win10 : SkinPlatform.Win11; 115 | 116 | default: 117 | return SkinPlatform.Win10; 118 | } 119 | } 120 | 121 | return SkinPlatform.Win10; 122 | } 123 | 124 | internal static DwmWindowCaption WindowCaption 125 | { 126 | get 127 | { 128 | switch (MsStylePlatform) 129 | { 130 | case SkinPlatform.Vista: 131 | case SkinPlatform.Win7: 132 | case SkinPlatform.Win81: 133 | case SkinPlatform.Win8: 134 | return new Windows8Caption(); 135 | case SkinPlatform.Win10: 136 | case SkinPlatform.Win11: 137 | return new Windows10Caption(); 138 | default: 139 | return new Windows10Caption(); 140 | } 141 | } 142 | } 143 | 144 | internal static Bitmap Slice(this Bitmap original, Point loc, Size size) 145 | { 146 | return original.Clone(new Rectangle(loc, size), original.PixelFormat); 147 | } 148 | 149 | internal static Bitmap GetDwmWindowButton(int button, int state) 150 | { 151 | try 152 | { 153 | hTheme = UxTheme.OpenThemeData(IntPtr.Zero, "DWMWINDOW"); 154 | const int tmtAtlasrect = 8002; 155 | const int tmtImagecount = 2401; 156 | var atlas = GetImageAtlasFromTheme(); 157 | 158 | if (atlas.IsEmpty()) 159 | return new Bitmap(1, 1); 160 | UxTheme.GetThemeRect(hTheme, button, state, tmtAtlasrect, out RECT rect); 161 | 162 | var result = Slice(atlas, new Point(rect.X, rect.Y), rect.Size); 163 | if (state == 0) 164 | return result; 165 | int count = 0; 166 | UxTheme.GetThemeInt(hTheme, button, state, tmtImagecount, ref count); 167 | var buttonSize = rect.Height / count; 168 | var startPoint = Point.Empty; 169 | var btnSize = new Size(rect.Width, buttonSize); 170 | startPoint.Offset(0, buttonSize * (state - 1)); 171 | var buttonRect = new Rectangle(startPoint, btnSize); 172 | buttonRect.Inflate(-1, -1); 173 | result = Slice(result, buttonRect.Location, buttonRect.Size); 174 | return result; 175 | } 176 | catch 177 | { 178 | if (hTheme != IntPtr.Zero) 179 | UxTheme.CloseThemeData(hTheme); 180 | return new Bitmap(0, 0); 181 | } 182 | 183 | finally 184 | { 185 | if (hTheme != IntPtr.Zero) 186 | UxTheme.CloseThemeData(hTheme); 187 | } 188 | } 189 | 190 | internal static bool IsEmpty(this Bitmap image) 191 | { 192 | var data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), 193 | ImageLockMode.ReadOnly, image.PixelFormat); 194 | var bytes = new byte[data.Height * data.Stride]; 195 | Marshal.Copy(data.Scan0, bytes, 0, bytes.Length); 196 | image.UnlockBits(data); 197 | return bytes.All(x => x == 0); 198 | } 199 | 200 | internal static GraphicsPath RoundedRect(Rectangle bounds, int radius) 201 | { 202 | var diameter = radius * 2; 203 | var size = new Size(diameter, diameter); 204 | var arc = new Rectangle(bounds.Location, size); 205 | var path = new GraphicsPath(); 206 | 207 | if (radius == 0) 208 | { 209 | path.AddRectangle(bounds); 210 | return path; 211 | } 212 | 213 | // top left arc 214 | path.AddArc(arc, 180, 90); 215 | 216 | // top right arc 217 | arc.X = bounds.Right - diameter; 218 | path.AddArc(arc, 270, 90); 219 | 220 | // bottom right arc 221 | arc.Y = bounds.Bottom /*- diameter*/; 222 | path.AddArc(arc, 0, 90); 223 | 224 | // bottom left arc 225 | arc.X = bounds.Left; 226 | path.AddArc(arc, 90, 90); 227 | 228 | path.CloseFigure(); 229 | return path; 230 | } 231 | 232 | internal static Color ContrastColor(this Color iColor) 233 | { 234 | // Calculate the perceptive luminance (aka luma) - human eye favors green color... 235 | double luma = ((0.299 * iColor.R) + (0.587 * iColor.G) + (0.114 * iColor.B)) / 255; 236 | // Return black for bright colors, white for dark colors 237 | return luma > 0.5 ? Color.Black : Color.White; 238 | } 239 | internal static bool isDarkColor(this Color iColor) 240 | { 241 | // Calculate the perceptive luminance (aka luma) - human eye favors green color... 242 | double luma = ((0.299 * iColor.R) + (0.587 * iColor.G) + (0.114 * iColor.B)) / 255; 243 | // Return black for bright colors, white for dark colors 244 | return luma <= 0.5; 245 | } 246 | internal static void DrawCloseButton(Graphics graphics, Rectangle rect, int state, bool active,bool isDark = false) 247 | { 248 | var backgroundImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECLOSE : WindowCaption.BUTTONINACTIVECLOSE, state); 249 | int BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH96; 250 | switch (graphics.DpiX) 251 | { 252 | case 96: 253 | BUTTONCLOSEGLYPH = isDark ? WindowCaption.BUTTONCLOSEGLYPH96DARK : WindowCaption.BUTTONCLOSEGLYPH96; 254 | break; 255 | case 120: 256 | BUTTONCLOSEGLYPH = isDark ? WindowCaption.BUTTONCLOSEGLYPH120DARK : WindowCaption.BUTTONCLOSEGLYPH120; 257 | break; 258 | case 144: 259 | BUTTONCLOSEGLYPH = isDark ? WindowCaption.BUTTONCLOSEGLYPH144DARK : WindowCaption.BUTTONCLOSEGLYPH144; 260 | break; 261 | case 168: 262 | case 192: 263 | BUTTONCLOSEGLYPH = isDark ? WindowCaption.BUTTONCLOSEGLYPH192DARK : WindowCaption.BUTTONCLOSEGLYPH192; 264 | break; 265 | } 266 | var image = GetDwmWindowButton(BUTTONCLOSEGLYPH, active ? state : (int)DwmButtonState.Disabled); 267 | if (backgroundImage == null || image == null) 268 | return; 269 | graphics.DrawImage(backgroundImage, rect); 270 | var boundRect = new Rectangle((rect.Width - image.Width) / 2, (rect.Height - image.Height) / 2, image.Width, image.Height); 271 | boundRect.Offset(rect.Location); 272 | graphics.DrawImage(image, boundRect); 273 | } 274 | 275 | internal static void DrawMinimizeButton(Graphics graphics, Rectangle rect, int state, bool active, bool isDark = false) 276 | { 277 | var backgroundImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); 278 | int BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH96; 279 | switch (graphics.DpiX) 280 | { 281 | case 96: 282 | BUTTONMINGLYPH = isDark ? WindowCaption.BUTTONMINGLYPH96DARK : WindowCaption.BUTTONMINGLYPH96; 283 | break; 284 | case 120: 285 | BUTTONMINGLYPH = isDark ? WindowCaption.BUTTONMINGLYPH120DARK : WindowCaption.BUTTONMINGLYPH120; 286 | break; 287 | case 144: 288 | BUTTONMINGLYPH = isDark ? WindowCaption.BUTTONMINGLYPH144DARK : WindowCaption.BUTTONMINGLYPH144; 289 | break; 290 | case 168: 291 | case 192: 292 | BUTTONMINGLYPH = isDark ? WindowCaption.BUTTONMINGLYPH192DARK : WindowCaption.BUTTONMINGLYPH192; 293 | break; 294 | } 295 | 296 | var image = GetDwmWindowButton(BUTTONMINGLYPH, active ? state : (int)DwmButtonState.Disabled); 297 | if (backgroundImage == null || image == null) 298 | return; 299 | graphics.DrawImage(backgroundImage, rect); 300 | var boundRect = new Rectangle((rect.Width - image.Width) / 2, (rect.Height - image.Height) / 2, image.Width, image.Height); 301 | boundRect.Offset(rect.Location); 302 | graphics.DrawImage(image, boundRect); 303 | } 304 | 305 | internal static void DrawMaximizeButton(Graphics graphics, Rectangle rect, int state, bool active, bool isDark = false) 306 | { 307 | var backgroundImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); 308 | int BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH96; 309 | switch (graphics.DpiX) 310 | { 311 | case 96: 312 | BUTTONMAXGLYPH = isDark ? WindowCaption.BUTTONMAXGLYPH96DARK : WindowCaption.BUTTONMAXGLYPH96; 313 | break; 314 | case 120: 315 | BUTTONMAXGLYPH = isDark ? WindowCaption.BUTTONMAXGLYPH120DARK : WindowCaption.BUTTONMAXGLYPH120; 316 | break; 317 | case 144: 318 | BUTTONMAXGLYPH = isDark ? WindowCaption.BUTTONMAXGLYPH144DARK : WindowCaption.BUTTONMAXGLYPH144; 319 | break; 320 | case 168: 321 | case 192: 322 | BUTTONMAXGLYPH = isDark ? WindowCaption.BUTTONMAXGLYPH192DARK : WindowCaption.BUTTONMAXGLYPH192; 323 | break; 324 | } 325 | 326 | var image = GetDwmWindowButton(BUTTONMAXGLYPH, active ? state : (int)DwmButtonState.Disabled); 327 | if (backgroundImage == null || image == null) 328 | return; 329 | graphics.DrawImage(backgroundImage, rect); 330 | var boundRect = new Rectangle((rect.Width - image.Width) / 2, (rect.Height - image.Height) / 2, image.Width, image.Height); 331 | boundRect.Offset(rect.Location); 332 | graphics.DrawImage(image, boundRect); 333 | } 334 | 335 | 336 | 337 | internal static void DrawRestorButton(Graphics graphics, Rectangle rect, int state, bool active, bool isDark) 338 | { 339 | var backgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); 340 | int BUTTONRESTOREGLYPH = WindowCaption.BUTTONRESTOREGLYPH96; 341 | switch (graphics.DpiX) 342 | { 343 | case 96: 344 | BUTTONRESTOREGLYPH = isDark ? WindowCaption.BUTTONRESTOREGLYPH96DARK : WindowCaption.BUTTONRESTOREGLYPH96; 345 | break; 346 | case 120: 347 | BUTTONRESTOREGLYPH = isDark ? WindowCaption.BUTTONRESTOREGLYPH120DARK : WindowCaption.BUTTONMAXGLYPH120; 348 | break; 349 | case 144: 350 | BUTTONRESTOREGLYPH = isDark ? WindowCaption.BUTTONRESTOREGLYPH144DARK : WindowCaption.BUTTONMAXGLYPH144; 351 | break; 352 | case 168: 353 | case 192: 354 | BUTTONRESTOREGLYPH = isDark ? WindowCaption.BUTTONRESTOREGLYPH192DARK : WindowCaption.BUTTONMAXGLYPH192; 355 | break; 356 | } 357 | var image = GetDwmWindowButton(BUTTONRESTOREGLYPH, active ? state : (int)DwmButtonState.Disabled); 358 | if (backgrounImage == null || image == null) 359 | return; 360 | graphics.DrawImage(backgrounImage, rect); 361 | var boundRect = new Rectangle((rect.Width - image.Width) / 2, (rect.Height - image.Height) / 2, image.Width, image.Height); 362 | boundRect.Offset(rect.Location); 363 | graphics.DrawImage(image, boundRect); 364 | } 365 | 366 | internal static Rectangle RtlRectangle(this Rectangle rectangle, int width) 367 | { 368 | return new Rectangle(width - rectangle.Width - rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); 369 | } 370 | 371 | internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout) 372 | { 373 | var rectangle = bounds; 374 | if (backgroundImage != null) 375 | { 376 | switch (imageLayout) 377 | { 378 | case ImageLayout.None: 379 | rectangle.Size = backgroundImage.Size; 380 | break; 381 | case ImageLayout.Center: 382 | rectangle.Size = backgroundImage.Size; 383 | var size1 = bounds.Size; 384 | if (size1.Width > rectangle.Width) 385 | rectangle.X = (size1.Width - rectangle.Width) / 2; 386 | if (size1.Height > rectangle.Height) 387 | { 388 | rectangle.Y = (size1.Height - rectangle.Height) / 2; 389 | } 390 | break; 391 | case ImageLayout.Stretch: 392 | rectangle.Size = bounds.Size; 393 | break; 394 | case ImageLayout.Zoom: 395 | var size2 = backgroundImage.Size; 396 | var num1 = bounds.Width / (float)size2.Width; 397 | var num2 = bounds.Height / (float)size2.Height; 398 | if (num1 < (double)num2) 399 | { 400 | rectangle.Width = bounds.Width; 401 | rectangle.Height = (int)(size2.Height * (double)num1 + 0.5); 402 | if (bounds.Y >= 0) 403 | { 404 | rectangle.Y = (bounds.Height - rectangle.Height) / 2; 405 | } 406 | break; 407 | } 408 | rectangle.Height = bounds.Height; 409 | rectangle.Width = (int)(size2.Width * (double)num2 + 0.5); 410 | if (bounds.X >= 0) 411 | { 412 | rectangle.X = (bounds.Width - rectangle.Width) / 2; 413 | } 414 | break; 415 | } 416 | } 417 | return rectangle; 418 | } 419 | 420 | public static void DrawBackgroundImage(this Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft) 421 | { 422 | if (g == null) 423 | throw new ArgumentNullException("g"); 424 | 425 | if (backgroundImageLayout == ImageLayout.Tile) 426 | { 427 | using (var textureBrush = new TextureBrush(backgroundImage, WrapMode.Tile)) 428 | { 429 | if (scrollOffset != Point.Empty) 430 | { 431 | var transform = textureBrush.Transform; 432 | transform.Translate(scrollOffset.X, scrollOffset.Y); 433 | textureBrush.Transform = transform; 434 | } 435 | g.FillRectangle(textureBrush, clipRect); 436 | } 437 | } 438 | else 439 | { 440 | var backgroundImageRectangle = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout); 441 | if (rightToLeft == RightToLeft.Yes && backgroundImageLayout == ImageLayout.None) 442 | backgroundImageRectangle.X += clipRect.Width - backgroundImageRectangle.Width; 443 | if (rightToLeft == RightToLeft.Yes) 444 | { 445 | g.Transform = new Matrix(-1, 0, 0, 1, bounds.Width, 0); 446 | 447 | } 448 | if (!clipRect.Contains(backgroundImageRectangle)) 449 | { 450 | switch (backgroundImageLayout) 451 | { 452 | case ImageLayout.Stretch: 453 | case ImageLayout.Zoom: 454 | backgroundImageRectangle.Intersect(clipRect); 455 | g.DrawImage(backgroundImage, clipRect); 456 | break; 457 | case ImageLayout.None: 458 | { 459 | backgroundImageRectangle.Offset(clipRect.Location); 460 | var destRect = backgroundImageRectangle; 461 | destRect.Intersect(clipRect); 462 | var rectangle = new Rectangle(Point.Empty, destRect.Size); 463 | g.DrawImage(backgroundImage, destRect, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel); 464 | } 465 | break; 466 | default: 467 | { 468 | var destRect = backgroundImageRectangle; 469 | destRect.Intersect(clipRect); 470 | var rectangle = new Rectangle(new Point(destRect.X - backgroundImageRectangle.X, destRect.Y - backgroundImageRectangle.Y), destRect.Size); 471 | g.DrawImage(backgroundImage, destRect, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, GraphicsUnit.Pixel); 472 | } 473 | break; 474 | } 475 | } 476 | else 477 | { 478 | var imageAttr = new ImageAttributes(); 479 | imageAttr.SetWrapMode(WrapMode.TileFlipXY); 480 | g.DrawImage(backgroundImage, backgroundImageRectangle, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr); 481 | imageAttr.Dispose(); 482 | } 483 | } 484 | } 485 | 486 | 487 | internal static void DrawCaptionButton(this Graphics graphics, Rectangle rect, CaptionButton captionButton, DwmButtonState state, bool active,bool isDark =false) 488 | { 489 | switch (captionButton) 490 | { 491 | case CaptionButton.Close: 492 | DrawCloseButton(graphics, rect, (int)state, active,isDark); 493 | break; 494 | case CaptionButton.Minimize: 495 | DrawMinimizeButton(graphics, rect, (int)state, active,isDark); 496 | break; 497 | case CaptionButton.Maximize: 498 | DrawMaximizeButton(graphics, rect, (int)state, active, isDark); 499 | break; 500 | case CaptionButton.Restore: 501 | DrawRestorButton(graphics, rect, (int)state, active,isDark); 502 | break; 503 | case CaptionButton.Help: 504 | break; 505 | } 506 | } 507 | 508 | internal static bool IsDrawMaximizeBox(this Form form) 509 | { 510 | return form.MaximizeBox && form.FormBorderStyle != FormBorderStyle.SizableToolWindow && 511 | form.FormBorderStyle != FormBorderStyle.FixedToolWindow; 512 | } 513 | 514 | internal static bool IsDrawMinimizeBox(this Form form) 515 | { 516 | return form.MinimizeBox && form.FormBorderStyle != FormBorderStyle.SizableToolWindow && 517 | form.FormBorderStyle != FormBorderStyle.FixedToolWindow; 518 | } 519 | } 520 | } 521 | -------------------------------------------------------------------------------- /SkinFramWorkCore/SkinForm.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace SkinFramWorkCore 3 | { 4 | partial class SkinForm 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.components = new System.ComponentModel.Container(); 33 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 34 | this.ClientSize = new System.Drawing.Size(800, 450); 35 | this.Text = "Form2"; 36 | } 37 | 38 | #endregion 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SkinFramWorkCore/SkinForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | -------------------------------------------------------------------------------- /SkinFramWorkCore/SkinFramWorkCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0-windows;net6.0-windows;net5.0-windows;netcoreapp3.1 5 | disable 6 | enable 7 | true 8 | True 9 | 1.2.0 10 | memoarfaa 11 | https://github.com/memoarfaa/SkinFormCore 12 | https://github.com/memoarfaa/SkinFormCore 13 | git 14 | LICENSE.txt 15 | NonClient area Theme Form for .Net Core 16 | AnyCPU 17 | False 18 | True 19 | false 20 | 21 | 22 | 3 23 | 24 | 25 | 3 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Windows10Caption.cs: -------------------------------------------------------------------------------- 1 | namespace SkinFramWorkCore 2 | { 3 | public class Windows10Caption : DwmWindowCaption 4 | { 5 | public override int BUTTONACTIVECAPTION { get; set; } = 3; 6 | public override int BUTTONINACTIVECAPTION { get; set; } = 4; 7 | public override int BUTTONACTIVECLOSE { get; set; } = 7; 8 | public override int BUTTONINACTIVECLOSE { get; set; } = 8; 9 | public override int BUTTONCLOSEGLYPH96 { get; set; } = 11; 10 | public override int BUTTONCLOSEGLYPH120 { get; set; } = 12; 11 | public override int BUTTONCLOSEGLYPH144 { get; set; } = 13; 12 | public override int BUTTONCLOSEGLYPH192 { get; set; } = 15; 13 | public override int BUTTONMAXGLYPH96 { get; set; } = 19; 14 | public override int BUTTONMAXGLYPH120 { get; set; } = 20; 15 | public override int BUTTONMAXGLYPH144 { get; set; } = 21; 16 | public override int BUTTONMAXGLYPH192 { get; set; } = 22; 17 | public override int BUTTONMINGLYPH96 { get; set; } = 23; 18 | public override int BUTTONMINGLYPH120 { get; set; } = 24; 19 | public override int BUTTONMINGLYPH144 { get; set; } = 25; 20 | public override int BUTTONMINGLYPH192 { get; set; } = 26; 21 | public override int BUTTONRESTOREGLYPH96 { get; set; } = 27; 22 | public override int BUTTONRESTOREGLYPH120 { get; set; } = 28; 23 | public override int BUTTONRESTOREGLYPH144 { get; set; } = 29; 24 | public override int BUTTONRESTOREGLYPH192 { get; set; } = 30; 25 | public override int BUTTONCLOSEGLYPH96DARK { get; set; } = 64; 26 | public override int BUTTONCLOSEGLYPH120DARK { get; set; } = 65; 27 | public override int BUTTONCLOSEGLYPH144DARK { get; set; } = 66; 28 | public override int BUTTONCLOSEGLYPH192DARK { get; set; } = 67; 29 | public override int BUTTONMAXGLYPH96DARK { get; set; } = 72; 30 | public override int BUTTONMAXGLYPH120DARK { get; set; } = 73; 31 | public override int BUTTONMAXGLYPH144DARK { get; set; } = 74; 32 | public override int BUTTONMAXGLYPH192DARK { get; set; } = 75; 33 | public override int BUTTONMINGLYPH96DARK { get; set; } = 76; 34 | public override int BUTTONMINGLYPH120DARK { get; set; } = 77; 35 | public override int BUTTONMINGLYPH144DARK { get; set; } = 78; 36 | public override int BUTTONMINGLYPH192DARK { get; set; } = 79; 37 | public override int BUTTONRESTOREGLYPH96DARK { get; set; } = 80; 38 | public override int BUTTONRESTOREGLYPH120DARK { get; set; } = 81; 39 | public override int BUTTONRESTOREGLYPH144DARK { get; set; } = 82; 40 | public override int BUTTONRESTOREGLYPH192DARK { get; set; } = 83; 41 | 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SkinFramWorkCore/Windows8Caption.cs: -------------------------------------------------------------------------------- 1 | namespace SkinFramWorkCore 2 | { 3 | public class Windows8Caption : DwmWindowCaption 4 | { 5 | public override int BUTTONACTIVECAPTION { get; set; } = 3; 6 | public override int BUTTONINACTIVECAPTION { get; set; } = 4; 7 | public override int BUTTONACTIVECLOSE { get; set; } = 7; 8 | public override int BUTTONINACTIVECLOSE { get; set; } = 8; 9 | public override int BUTTONCLOSEGLYPH96 { get; set; } = 12; 10 | public override int BUTTONCLOSEGLYPH120 { get; set; } = 13; 11 | public override int BUTTONCLOSEGLYPH144 { get; set; } = 14; 12 | public override int BUTTONCLOSEGLYPH192 { get; set; } = 15; 13 | public override int BUTTONMAXGLYPH96 { get; set; } = 20; 14 | public override int BUTTONMAXGLYPH120 { get; set; } = 21; 15 | public override int BUTTONMAXGLYPH144 { get; set; } = 22; 16 | public override int BUTTONMAXGLYPH192 { get; set; } = 23; 17 | public override int BUTTONMINGLYPH96 { get; set; } = 24; 18 | public override int BUTTONMINGLYPH120 { get; set; } = 25; 19 | public override int BUTTONMINGLYPH144 { get; set; } = 26; 20 | public override int BUTTONMINGLYPH192 { get; set; } = 27; 21 | public override int BUTTONRESTOREGLYPH96 { get; set; } = 28; 22 | public override int BUTTONRESTOREGLYPH120 { get; set; } = 29; 23 | public override int BUTTONRESTOREGLYPH144 { get; set; } = 30; 24 | public override int BUTTONRESTOREGLYPH192 { get; set; } = 31; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TestApp1/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | en-US 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /TestApp1/MDIParent1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace TestApp1 2 | { 3 | partial class MDIParent1 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.components = new System.ComponentModel.Container(); 32 | this.statusStrip = new System.Windows.Forms.StatusStrip(); 33 | this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); 34 | this.toolTip = new System.Windows.Forms.ToolTip(this.components); 35 | this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 36 | this.borderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.borderWidthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.borderRadiusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.borderOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.activeBorederColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 41 | this.inactiveBorederColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.captionHeightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.desktopBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.imageLayoutTileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 45 | this.imageLayoutCenterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | this.imageLayoutStretchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 47 | this.imageLayoutZoomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 48 | this.removeBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 49 | this.formsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 50 | this.newFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 | this.newChildFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 52 | this.layoutMdiCascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 | this.layoutMdiVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 54 | this.layoutMdiHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 55 | this.directionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 56 | this.leftToRightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 57 | this.rightToLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 58 | this.statusStrip.SuspendLayout(); 59 | this.menuStrip1.SuspendLayout(); 60 | this.SuspendLayout(); 61 | // 62 | // statusStrip 63 | // 64 | this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 65 | this.toolStripStatusLabel}); 66 | this.statusStrip.Location = new System.Drawing.Point(0, 707); 67 | this.statusStrip.Name = "statusStrip"; 68 | this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); 69 | this.statusStrip.Size = new System.Drawing.Size(1008, 22); 70 | this.statusStrip.TabIndex = 2; 71 | this.statusStrip.Text = "StatusStrip"; 72 | // 73 | // toolStripStatusLabel 74 | // 75 | this.toolStripStatusLabel.Name = "toolStripStatusLabel"; 76 | this.toolStripStatusLabel.Size = new System.Drawing.Size(39, 17); 77 | this.toolStripStatusLabel.Text = "Status"; 78 | // 79 | // menuStrip1 80 | // 81 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 82 | this.borderToolStripMenuItem, 83 | this.desktopBackgroundToolStripMenuItem, 84 | this.formsToolStripMenuItem, 85 | this.directionToolStripMenuItem}); 86 | this.menuStrip1.Location = new System.Drawing.Point(0, 0); 87 | this.menuStrip1.Name = "menuStrip1"; 88 | this.menuStrip1.Size = new System.Drawing.Size(1008, 24); 89 | this.menuStrip1.TabIndex = 4; 90 | this.menuStrip1.Text = "menuStrip1"; 91 | // 92 | // borderToolStripMenuItem 93 | // 94 | this.borderToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 95 | this.borderWidthToolStripMenuItem, 96 | this.borderRadiusToolStripMenuItem, 97 | this.borderOpacityToolStripMenuItem, 98 | this.activeBorederColorToolStripMenuItem, 99 | this.inactiveBorederColorToolStripMenuItem, 100 | this.captionHeightToolStripMenuItem}); 101 | this.borderToolStripMenuItem.Name = "borderToolStripMenuItem"; 102 | this.borderToolStripMenuItem.Size = new System.Drawing.Size(54, 20); 103 | this.borderToolStripMenuItem.Text = "Border"; 104 | // 105 | // borderWidthToolStripMenuItem 106 | // 107 | this.borderWidthToolStripMenuItem.Name = "borderWidthToolStripMenuItem"; 108 | this.borderWidthToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 109 | this.borderWidthToolStripMenuItem.Text = "Border Width"; 110 | this.borderWidthToolStripMenuItem.Click += new System.EventHandler(this.borderWidthToolStripMenuItem_Click); 111 | // 112 | // borderRadiusToolStripMenuItem 113 | // 114 | this.borderRadiusToolStripMenuItem.Name = "borderRadiusToolStripMenuItem"; 115 | this.borderRadiusToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 116 | this.borderRadiusToolStripMenuItem.Text = "Border Radius"; 117 | this.borderRadiusToolStripMenuItem.Click += new System.EventHandler(this.borderRadiusToolStripMenuItem_Click); 118 | // 119 | // borderOpacityToolStripMenuItem 120 | // 121 | this.borderOpacityToolStripMenuItem.Name = "borderOpacityToolStripMenuItem"; 122 | this.borderOpacityToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 123 | this.borderOpacityToolStripMenuItem.Text = "Border Opacity"; 124 | this.borderOpacityToolStripMenuItem.Click += new System.EventHandler(this.borderOpacityToolStripMenuItem_Click); 125 | // 126 | // activeBorederColorToolStripMenuItem 127 | // 128 | this.activeBorederColorToolStripMenuItem.Name = "activeBorederColorToolStripMenuItem"; 129 | this.activeBorederColorToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 130 | this.activeBorederColorToolStripMenuItem.Text = "Active Border Color"; 131 | this.activeBorederColorToolStripMenuItem.Click += new System.EventHandler(this.activeBorederColorToolStripMenuItem_Click); 132 | // 133 | // inactiveBorederColorToolStripMenuItem 134 | // 135 | this.inactiveBorederColorToolStripMenuItem.Name = "inactiveBorederColorToolStripMenuItem"; 136 | this.inactiveBorederColorToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 137 | this.inactiveBorederColorToolStripMenuItem.Text = "Inactive Border Color"; 138 | this.inactiveBorederColorToolStripMenuItem.Click += new System.EventHandler(this.inactiveBorederColorToolStripMenuItem_Click); 139 | // 140 | // captionHeightToolStripMenuItem 141 | // 142 | this.captionHeightToolStripMenuItem.Name = "captionHeightToolStripMenuItem"; 143 | this.captionHeightToolStripMenuItem.Size = new System.Drawing.Size(191, 22); 144 | this.captionHeightToolStripMenuItem.Text = "Caption Height"; 145 | this.captionHeightToolStripMenuItem.Click += new System.EventHandler(this.CaptionHieghtToolStripMenuItem_Click); 146 | // 147 | // desktopBackgroundToolStripMenuItem 148 | // 149 | this.desktopBackgroundToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 150 | this.imageLayoutTileToolStripMenuItem, 151 | this.imageLayoutCenterToolStripMenuItem, 152 | this.imageLayoutStretchToolStripMenuItem, 153 | this.imageLayoutZoomToolStripMenuItem, 154 | this.removeBackgroundToolStripMenuItem}); 155 | this.desktopBackgroundToolStripMenuItem.Name = "desktopBackgroundToolStripMenuItem"; 156 | this.desktopBackgroundToolStripMenuItem.Size = new System.Drawing.Size(129, 20); 157 | this.desktopBackgroundToolStripMenuItem.Text = "Desktop Background"; 158 | // 159 | // imageLayoutTileToolStripMenuItem 160 | // 161 | this.imageLayoutTileToolStripMenuItem.Name = "imageLayoutTileToolStripMenuItem"; 162 | this.imageLayoutTileToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 163 | this.imageLayoutTileToolStripMenuItem.Text = "Image Layout Tile"; 164 | this.imageLayoutTileToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutTileToolStripMenuItem_Click); 165 | // 166 | // imageLayoutCenterToolStripMenuItem 167 | // 168 | this.imageLayoutCenterToolStripMenuItem.Name = "imageLayoutCenterToolStripMenuItem"; 169 | this.imageLayoutCenterToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 170 | this.imageLayoutCenterToolStripMenuItem.Text = "Image Layout Center"; 171 | this.imageLayoutCenterToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutCenterToolStripMenuItem_Click); 172 | // 173 | // imageLayoutStretchToolStripMenuItem 174 | // 175 | this.imageLayoutStretchToolStripMenuItem.Name = "imageLayoutStretchToolStripMenuItem"; 176 | this.imageLayoutStretchToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 177 | this.imageLayoutStretchToolStripMenuItem.Text = "Image Layout Stretch"; 178 | this.imageLayoutStretchToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutStretchToolStripMenuItem_Click); 179 | // 180 | // imageLayoutZoomToolStripMenuItem 181 | // 182 | this.imageLayoutZoomToolStripMenuItem.Name = "imageLayoutZoomToolStripMenuItem"; 183 | this.imageLayoutZoomToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 184 | this.imageLayoutZoomToolStripMenuItem.Text = "Image Layout Zoom"; 185 | this.imageLayoutZoomToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutZoomToolStripMenuItem_Click); 186 | // 187 | // removeBackgroundToolStripMenuItem 188 | // 189 | this.removeBackgroundToolStripMenuItem.Name = "removeBackgroundToolStripMenuItem"; 190 | this.removeBackgroundToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 191 | this.removeBackgroundToolStripMenuItem.Text = "Remove Background"; 192 | this.removeBackgroundToolStripMenuItem.Click += new System.EventHandler(this.removeBackgroundToolStripMenuItem_Click); 193 | // 194 | // formsToolStripMenuItem 195 | // 196 | this.formsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 197 | this.newFormToolStripMenuItem, 198 | this.newChildFormToolStripMenuItem, 199 | this.layoutMdiCascadeToolStripMenuItem, 200 | this.layoutMdiVerticalToolStripMenuItem, 201 | this.layoutMdiHorizontalToolStripMenuItem}); 202 | this.formsToolStripMenuItem.Name = "formsToolStripMenuItem"; 203 | this.formsToolStripMenuItem.Size = new System.Drawing.Size(52, 20); 204 | this.formsToolStripMenuItem.Text = "Forms"; 205 | // 206 | // newFormToolStripMenuItem 207 | // 208 | this.newFormToolStripMenuItem.Name = "newFormToolStripMenuItem"; 209 | this.newFormToolStripMenuItem.Size = new System.Drawing.Size(192, 22); 210 | this.newFormToolStripMenuItem.Text = "New Form"; 211 | this.newFormToolStripMenuItem.Click += new System.EventHandler(this.newFormToolStripMenuItem_Click); 212 | // 213 | // newChildFormToolStripMenuItem 214 | // 215 | this.newChildFormToolStripMenuItem.Name = "newChildFormToolStripMenuItem"; 216 | this.newChildFormToolStripMenuItem.Size = new System.Drawing.Size(192, 22); 217 | this.newChildFormToolStripMenuItem.Text = "New Child Form"; 218 | this.newChildFormToolStripMenuItem.Click += new System.EventHandler(this.newChildFormToolStripMenuItem_Click); 219 | // 220 | // layoutMdiCascadeToolStripMenuItem 221 | // 222 | this.layoutMdiCascadeToolStripMenuItem.Name = "layoutMdiCascadeToolStripMenuItem"; 223 | this.layoutMdiCascadeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); 224 | this.layoutMdiCascadeToolStripMenuItem.Text = "Layout Mdi Cascade"; 225 | this.layoutMdiCascadeToolStripMenuItem.Click += new System.EventHandler(this.CascadeToolStripMenuItem_Click); 226 | // 227 | // layoutMdiVerticalToolStripMenuItem 228 | // 229 | this.layoutMdiVerticalToolStripMenuItem.Name = "layoutMdiVerticalToolStripMenuItem"; 230 | this.layoutMdiVerticalToolStripMenuItem.Size = new System.Drawing.Size(192, 22); 231 | this.layoutMdiVerticalToolStripMenuItem.Text = "Layout Mdi Vertical"; 232 | this.layoutMdiVerticalToolStripMenuItem.Click += new System.EventHandler(this.TileVerticalToolStripMenuItem_Click); 233 | // 234 | // layoutMdiHorizontalToolStripMenuItem 235 | // 236 | this.layoutMdiHorizontalToolStripMenuItem.Name = "layoutMdiHorizontalToolStripMenuItem"; 237 | this.layoutMdiHorizontalToolStripMenuItem.Size = new System.Drawing.Size(192, 22); 238 | this.layoutMdiHorizontalToolStripMenuItem.Text = "Layout Mdi Horizontal"; 239 | this.layoutMdiHorizontalToolStripMenuItem.Click += new System.EventHandler(this.TileHorizontalToolStripMenuItem_Click); 240 | // 241 | // directionToolStripMenuItem 242 | // 243 | this.directionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 244 | this.leftToRightToolStripMenuItem, 245 | this.rightToLeftToolStripMenuItem}); 246 | this.directionToolStripMenuItem.Name = "directionToolStripMenuItem"; 247 | this.directionToolStripMenuItem.Size = new System.Drawing.Size(67, 20); 248 | this.directionToolStripMenuItem.Text = "Direction"; 249 | // 250 | // leftToRightToolStripMenuItem 251 | // 252 | this.leftToRightToolStripMenuItem.Name = "leftToRightToolStripMenuItem"; 253 | this.leftToRightToolStripMenuItem.Size = new System.Drawing.Size(139, 22); 254 | this.leftToRightToolStripMenuItem.Text = "Left to Right"; 255 | this.leftToRightToolStripMenuItem.Click += new System.EventHandler(this.leftToRightToolStripMenuItem_Click); 256 | // 257 | // rightToLeftToolStripMenuItem 258 | // 259 | this.rightToLeftToolStripMenuItem.Name = "rightToLeftToolStripMenuItem"; 260 | this.rightToLeftToolStripMenuItem.Size = new System.Drawing.Size(139, 22); 261 | this.rightToLeftToolStripMenuItem.Text = "Right to Left"; 262 | this.rightToLeftToolStripMenuItem.Click += new System.EventHandler(this.rightToLeftToolStripMenuItem_Click); 263 | // 264 | // MDIParent1 265 | // 266 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 267 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 268 | this.ClientSize = new System.Drawing.Size(1008, 729); 269 | this.Controls.Add(this.statusStrip); 270 | this.Controls.Add(this.menuStrip1); 271 | this.IsMdiContainer = true; 272 | this.MainMenuStrip = this.menuStrip1; 273 | this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); 274 | this.Name = "MDIParent1"; 275 | this.Text = "MDIParent1"; 276 | this.statusStrip.ResumeLayout(false); 277 | this.statusStrip.PerformLayout(); 278 | this.menuStrip1.ResumeLayout(false); 279 | this.menuStrip1.PerformLayout(); 280 | this.ResumeLayout(false); 281 | this.PerformLayout(); 282 | 283 | } 284 | #endregion 285 | 286 | private System.Windows.Forms.StatusStrip statusStrip; 287 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel; 288 | private System.Windows.Forms.ToolTip toolTip; 289 | private MenuStrip menuStrip1; 290 | private ToolStripMenuItem borderToolStripMenuItem; 291 | private ToolStripMenuItem borderWidthToolStripMenuItem; 292 | private ToolStripMenuItem borderRadiusToolStripMenuItem; 293 | private ToolStripMenuItem borderOpacityToolStripMenuItem; 294 | private ToolStripMenuItem desktopBackgroundToolStripMenuItem; 295 | private ToolStripMenuItem formsToolStripMenuItem; 296 | private ToolStripMenuItem directionToolStripMenuItem; 297 | private ToolStripMenuItem activeBorederColorToolStripMenuItem; 298 | private ToolStripMenuItem inactiveBorederColorToolStripMenuItem; 299 | private ToolStripMenuItem captionHeightToolStripMenuItem; 300 | private ToolStripMenuItem imageLayoutTileToolStripMenuItem; 301 | private ToolStripMenuItem imageLayoutCenterToolStripMenuItem; 302 | private ToolStripMenuItem imageLayoutStretchToolStripMenuItem; 303 | private ToolStripMenuItem imageLayoutZoomToolStripMenuItem; 304 | private ToolStripMenuItem removeBackgroundToolStripMenuItem; 305 | private ToolStripMenuItem newFormToolStripMenuItem; 306 | private ToolStripMenuItem newChildFormToolStripMenuItem; 307 | private ToolStripMenuItem layoutMdiCascadeToolStripMenuItem; 308 | private ToolStripMenuItem layoutMdiVerticalToolStripMenuItem; 309 | private ToolStripMenuItem layoutMdiHorizontalToolStripMenuItem; 310 | private ToolStripMenuItem leftToRightToolStripMenuItem; 311 | private ToolStripMenuItem rightToLeftToolStripMenuItem; 312 | } 313 | } 314 | 315 | 316 | 317 | -------------------------------------------------------------------------------- /TestApp1/MDIParent1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Globalization; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | using SkinFramWorkCore; 13 | using TestApp1.Properties; 14 | 15 | namespace TestApp1 16 | { 17 | public partial class MDIParent1 : SkinForm 18 | { 19 | private int childFormNumber = 0; 20 | private TextBox txtBorders; 21 | private Button submitButton; 22 | private Button btnToggleMenuStrip; 23 | private Label labelBorders; 24 | private SkinForm frmSubmit; 25 | private SkinForm frmChild; 26 | 27 | public MDIParent1() 28 | { 29 | InitializeComponent(); 30 | RightToLeft = Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; 31 | RightToLeftLayout = Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft; 32 | frmSubmit = new SkinForm { RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "Window", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterParent, AllowNcTransparency = AllowNcTransparency, Size = new Size(240, 200) }; 33 | txtBorders = new TextBox(); 34 | txtBorders.Location = new Point(50, 60); 35 | txtBorders.Size = new Size(120, 23); 36 | frmSubmit.Controls.Add(txtBorders); 37 | submitButton = new Button(); 38 | submitButton.Location = new Point(50, 110); 39 | submitButton.Size = new Size(120, 30); 40 | submitButton.Text = "Submit"; 41 | submitButton.UseVisualStyleBackColor = true; 42 | submitButton.Click += SubmitButton_Click; 43 | frmSubmit.Controls.Add(submitButton); 44 | labelBorders = new Label(); 45 | labelBorders.AutoSize = true; 46 | labelBorders.Location = new Point(35, 25); 47 | labelBorders.Size = new Size(155, 15); 48 | frmSubmit.Controls.Add(labelBorders); 49 | frmChild = new SkinForm { MdiParent = this, RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "frmChild", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterScreen, AllowNcTransparency = AllowNcTransparency }; 50 | 51 | btnToggleMenuStrip = new Button { Text = "Toggle MenuStrip", Size = new Size(160, 30) }; 52 | btnToggleMenuStrip.Click += BtnToggleMenuStrip_Click; 53 | frmChild.Controls.Add(btnToggleMenuStrip); 54 | Load += MDIParent1_Load; 55 | } 56 | 57 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 58 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "")] 59 | public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); 60 | 61 | [DllImport("user32.dll", SetLastError = true)] 62 | [return: MarshalAs(UnmanagedType.Bool)] 63 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "")] 64 | public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); 65 | 66 | [Flags] 67 | internal enum SWPFlags 68 | { 69 | 70 | SWP_NOSIZE = 0x0001, 71 | SWP_NOMOVE = 0x0002, 72 | SWP_NOZORDER = 0x0004, 73 | SWP_NOREDRAW = 0x0008, 74 | SWP_NOACTIVATE = 0x0010, 75 | SWP_FRAMECHANGED = 0x0020, 76 | } 77 | 78 | private void MDIParent1_Load(object? sender, EventArgs e) 79 | { 80 | frmChild.Show(); 81 | if (GetDeskTopWallpaper != null) 82 | { 83 | BackgroundImage = GetDeskTopWallpaper(); 84 | BackgroundImageLayout = ImageLayout.Stretch; 85 | } 86 | } 87 | private void InvalidateForm(Form form) 88 | { 89 | if (!form.IsDisposed && form.IsHandleCreated) 90 | { 91 | SetWindowPos(form.Handle, IntPtr.Zero, 0, 0, 0, 0, 92 | (int)(SWPFlags.SWP_NOACTIVATE | SWPFlags.SWP_NOMOVE | SWPFlags.SWP_NOSIZE | 93 | SWPFlags.SWP_NOZORDER | SWPFlags.SWP_FRAMECHANGED)); 94 | } 95 | } 96 | 97 | private void BtnToggleMenuStrip_Click(object? sender, EventArgs e) 98 | { 99 | if (MainMenuStrip is null) 100 | { 101 | MainMenuStrip = menuStrip1; 102 | Controls.Add(menuStrip1); 103 | } 104 | 105 | else 106 | { 107 | Controls.Remove(menuStrip1); 108 | MainMenuStrip = null; 109 | } 110 | } 111 | 112 | 113 | private Image? GetDeskTopWallpaper() 114 | { 115 | int SPI_GETDESKWALLPAPER = 0x73; 116 | int MAX_PATH = 260; 117 | string wallpaper = new string('\0', (int)MAX_PATH); 118 | SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaper, 0); 119 | 120 | wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0')); 121 | return !string.IsNullOrEmpty(wallpaper) ? new Bitmap(Image.FromFile(wallpaper)) : null; 122 | } 123 | 124 | 125 | private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) 126 | { 127 | LayoutMdi(MdiLayout.Cascade); 128 | } 129 | 130 | private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) 131 | { 132 | LayoutMdi(MdiLayout.TileVertical); 133 | } 134 | 135 | private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) 136 | { 137 | LayoutMdi(MdiLayout.TileHorizontal); 138 | } 139 | 140 | private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) 141 | { 142 | LayoutMdi(MdiLayout.ArrangeIcons); 143 | } 144 | 145 | private void rightToLeftToolStripMenuItem_Click(object sender, EventArgs e) 146 | { 147 | 148 | Settings settings = Settings.Default; 149 | if (settings.Culture == "ar-EG") return; 150 | settings.Culture = "ar-EG"; 151 | settings.Save(); 152 | Application.Restart(); 153 | } 154 | 155 | private void leftToRightToolStripMenuItem_Click(object sender, EventArgs e) 156 | { 157 | Settings settings = Settings.Default; 158 | if (settings.Culture == "en-US") return; 159 | settings.Culture = "en-US"; 160 | settings.Save(); 161 | Application.Restart(); 162 | } 163 | 164 | 165 | private void borderWidthToolStripMenuItem_Click(object sender, EventArgs e) 166 | { 167 | labelBorders.Text = "Insert Border Width"; 168 | frmSubmit.ShowDialog(this); 169 | } 170 | 171 | private void newFormToolStripMenuItem_Click(object sender, EventArgs e) 172 | { 173 | SkinForm form = new SkinForm { RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "Form1", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterParent, AllowNcTransparency = AllowNcTransparency, Size = new Size(1024, 768), BackgroundImage = BackgroundImage, BackgroundImageLayout = BackgroundImageLayout , ActiveCaptionColor = ActiveCaptionColor, InActiveCaptionColor = InActiveCaptionColor }; 174 | 175 | WindowState = FormWindowState.Minimized; 176 | form.Closing += delegate { WindowState = FormWindowState.Maximized; }; 177 | form.Show(); 178 | form.Activate(); 179 | } 180 | 181 | private void newChildFormToolStripMenuItem_Click(object sender, EventArgs e) 182 | { 183 | SkinForm frmChild = new SkinForm { MdiParent = this, RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "frmChild " + childFormNumber++, BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, BackgroundImage = BackgroundImage, BackgroundImageLayout = BackgroundImageLayout, AllowNcTransparency = AllowNcTransparency,ActiveCaptionColor = ActiveCaptionColor,InActiveCaptionColor = InActiveCaptionColor }; 184 | frmChild.Show(); 185 | } 186 | 187 | private void imageLayoutTileToolStripMenuItem_Click(object sender, EventArgs e) 188 | { 189 | if (GetDeskTopWallpaper != null) 190 | { 191 | BackgroundImage = GetDeskTopWallpaper(); 192 | BackgroundImageLayout = ImageLayout.Tile; 193 | } 194 | 195 | 196 | } 197 | 198 | private void imageLayoutCenterToolStripMenuItem_Click(object sender, EventArgs e) 199 | { 200 | if (GetDeskTopWallpaper != null) 201 | { 202 | BackgroundImage = GetDeskTopWallpaper(); 203 | BackgroundImageLayout = ImageLayout.Center; 204 | } 205 | 206 | 207 | } 208 | 209 | private void imageLayoutStretchToolStripMenuItem_Click(object sender, EventArgs e) 210 | { 211 | if (GetDeskTopWallpaper != null) 212 | { 213 | BackgroundImage = GetDeskTopWallpaper(); 214 | BackgroundImageLayout = ImageLayout.Stretch; 215 | } 216 | } 217 | 218 | private void imageLayoutZoomToolStripMenuItem_Click(object sender, EventArgs e) 219 | { 220 | if (GetDeskTopWallpaper != null) 221 | { 222 | BackgroundImage = GetDeskTopWallpaper(); 223 | BackgroundImageLayout = ImageLayout.Zoom; 224 | } 225 | } 226 | 227 | private void removeBackgroundToolStripMenuItem_Click(object sender, EventArgs e) 228 | { 229 | BackgroundImage = null; 230 | } 231 | 232 | private void borderRadiusToolStripMenuItem_Click(object sender, EventArgs e) 233 | { 234 | labelBorders.Text = "Insert Border Radius"; 235 | frmSubmit.ShowDialog(this); 236 | } 237 | 238 | private void borderOpacityToolStripMenuItem_Click(object sender, EventArgs e) 239 | { 240 | labelBorders.Text = "Insert Border Opacity"; 241 | frmSubmit.ShowDialog(this); 242 | } 243 | private void CaptionHieghtToolStripMenuItem_Click(object sender, EventArgs e) 244 | { 245 | labelBorders.Text = "Insert Caption Height"; 246 | frmSubmit.ShowDialog(this); 247 | } 248 | private void SubmitButton_Click(object? sender, EventArgs e) 249 | { 250 | switch (labelBorders.Text) 251 | { 252 | case "Insert Border Width": 253 | { 254 | if (txtBorders.Text.Length > 0) 255 | { 256 | int borderWidth; 257 | bool isnumber = int.TryParse(txtBorders.Text, out borderWidth); 258 | if (isnumber && borderWidth > 0) 259 | { 260 | BorderWidth = frmChild.BorderWidth = frmSubmit.BorderWidth = borderWidth; 261 | InvalidateForm(this); 262 | InvalidateForm(frmChild); 263 | InvalidateForm(frmSubmit); 264 | MdiChildren.ToList().ForEach(child => 265 | { 266 | ((SkinForm)child).BorderWidth = borderWidth; 267 | InvalidateForm(child); 268 | }); 269 | } 270 | } 271 | } 272 | 273 | break; 274 | 275 | case "Insert Border Radius": 276 | { 277 | if (txtBorders.Text.Length > 0) 278 | { 279 | int borderRadius; 280 | bool isnumber = int.TryParse(txtBorders.Text, out borderRadius); 281 | if (isnumber && borderRadius > 0) 282 | { 283 | BorderRadius = frmChild.BorderRadius = frmSubmit.BorderRadius = borderRadius; 284 | InvalidateForm(this); 285 | InvalidateForm(frmChild); 286 | InvalidateForm(frmSubmit); 287 | MdiChildren.ToList().ForEach(child => 288 | { 289 | ((SkinForm)child).BorderRadius = borderRadius; 290 | InvalidateForm(child); 291 | }); 292 | } 293 | } 294 | } 295 | 296 | break; 297 | case "Insert Border Opacity": 298 | { 299 | if (txtBorders.Text.Length > 0) 300 | { 301 | int ncOpacity; 302 | bool isnumber = int.TryParse(txtBorders.Text, out ncOpacity); 303 | if (isnumber && ncOpacity > 0) 304 | { 305 | NcOpacity = frmChild.NcOpacity = frmSubmit.NcOpacity = ncOpacity; 306 | InvalidateForm(this); 307 | InvalidateForm(frmChild); 308 | InvalidateForm(frmSubmit); 309 | MdiChildren.ToList().ForEach(child => 310 | { 311 | ((SkinForm)child).NcOpacity = ncOpacity; 312 | InvalidateForm(child); 313 | }); 314 | } 315 | } 316 | } 317 | 318 | break; 319 | 320 | case "Insert Caption Height": 321 | { 322 | if (txtBorders.Text.Length > 0) 323 | { 324 | int captionHieght; 325 | bool isnumber = int.TryParse(txtBorders.Text, out captionHieght); 326 | if (isnumber && captionHieght > 0) 327 | { 328 | CaptionHieght = frmChild.CaptionHieght = frmSubmit.CaptionHieght = captionHieght; 329 | InvalidateForm(this); 330 | InvalidateForm(frmChild); 331 | InvalidateForm(frmSubmit); 332 | MdiChildren.ToList().ForEach(child => 333 | { 334 | ((SkinForm)child).CaptionHieght = captionHieght; 335 | InvalidateForm(child); 336 | }); 337 | } 338 | } 339 | } 340 | 341 | break; 342 | } 343 | 344 | frmSubmit.Close(); 345 | } 346 | 347 | private void activeBorederColorToolStripMenuItem_Click(object sender, EventArgs e) 348 | { 349 | ColorDialog colorDialog = new ColorDialog(); 350 | if (colorDialog.ShowDialog() == DialogResult.OK) 351 | { 352 | ActiveCaptionColor = frmChild.ActiveCaptionColor = frmSubmit.ActiveCaptionColor = colorDialog.Color; 353 | InvalidateForm(this); 354 | InvalidateForm(frmChild); 355 | InvalidateForm(frmSubmit); 356 | MdiChildren.ToList().ForEach(child => 357 | { 358 | 359 | InvalidateForm(child); 360 | }); 361 | } 362 | } 363 | 364 | private void inactiveBorederColorToolStripMenuItem_Click(object sender, EventArgs e) 365 | { 366 | ColorDialog colorDialog = new ColorDialog(); 367 | if (colorDialog.ShowDialog() == DialogResult.OK) 368 | { 369 | InActiveCaptionColor = frmChild.InActiveCaptionColor = frmSubmit.InActiveCaptionColor = colorDialog.Color; 370 | InvalidateForm(this); 371 | InvalidateForm(frmChild); 372 | InvalidateForm(frmSubmit); 373 | MdiChildren.ToList().ForEach(child => 374 | { 375 | 376 | InvalidateForm(child); 377 | }); 378 | } 379 | } 380 | } 381 | } 382 | -------------------------------------------------------------------------------- /TestApp1/MDIParent1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | 61 | 223, 17 62 | 63 | 64 | 332, 17 65 | 66 | 67 | 422, 17 68 | 69 | 70 | 51 71 | 72 | -------------------------------------------------------------------------------- /TestApp1/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace TestApp1 4 | { 5 | internal static class Program 6 | { 7 | /// 8 | /// The main entry point for the application. 9 | /// 10 | [STAThread] 11 | static void Main() 12 | { 13 | // To customize application configuration such as set high DPI settings or default font, 14 | // see https://aka.ms/applicationconfiguration. 15 | ApplicationConfiguration.Initialize(); 16 | Properties.Settings settings = Properties.Settings.Default; 17 | Thread.CurrentThread.CurrentCulture = new CultureInfo( settings.Culture); 18 | Thread.CurrentThread.CurrentUICulture = new CultureInfo( settings.Culture); 19 | Application.Run(new MDIParent1()); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TestApp1/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 TestApp1.Properties { 12 | using System; 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", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestApp1.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap _4475e73c885921925f61fcf123c7c8c1f93e1c0c { 67 | get { 68 | object obj = ResourceManager.GetObject("4475e73c885921925f61fcf123c7c8c1f93e1c0c", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /TestApp1/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 | 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 | 121 | 122 | ..\Resources\4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /TestApp1/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 TestApp1.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("en-US")] 29 | public string Culture { 30 | get { 31 | return ((string)(this["Culture"])); 32 | } 33 | set { 34 | this["Culture"] = value; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /TestApp1/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | en-US 7 | 8 | 9 | -------------------------------------------------------------------------------- /TestApp1/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memoarfaa/SkinFormCore/1c589d6df614e1c9374f53000334fdd7b5a31b1a/TestApp1/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg -------------------------------------------------------------------------------- /TestApp1/TestApp1.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | True 18 | True 19 | Resources.resx 20 | 21 | 22 | True 23 | True 24 | Settings.settings 25 | 26 | 27 | 28 | 29 | 30 | ResXFileCodeGenerator 31 | Resources.Designer.cs 32 | 33 | 34 | 35 | 36 | 37 | SettingsSingleFileGenerator 38 | Settings.Designer.cs 39 | 40 | 41 | 42 | --------------------------------------------------------------------------------