├── .gitattributes ├── .gitignore ├── Mica.sln ├── Mica ├── App.xaml ├── App.xaml.cs ├── Assets │ ├── LargeTile.scale-100.png │ ├── LargeTile.scale-125.png │ ├── LargeTile.scale-150.png │ ├── LargeTile.scale-200.png │ ├── LockScreenLogo.scale-200.png │ ├── SmallTile.scale-100.png │ ├── SmallTile.scale-125.png │ ├── SmallTile.scale-150.png │ ├── SmallTile.scale-200.png │ ├── SmallTile.scale-400.png │ ├── SplashScreen.scale-100.png │ ├── SplashScreen.scale-125.png │ ├── SplashScreen.scale-150.png │ ├── SplashScreen.scale-200.png │ ├── SplashScreen.scale-400.png │ ├── Square150x150Logo.scale-100.png │ ├── Square150x150Logo.scale-125.png │ ├── Square150x150Logo.scale-150.png │ ├── Square150x150Logo.scale-200.png │ ├── Square150x150Logo.scale-400.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-16.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-24.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-256.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-32.png │ ├── Square44x44Logo.altform-lightunplated_targetsize-48.png │ ├── Square44x44Logo.altform-unplated_targetsize-16.png │ ├── Square44x44Logo.altform-unplated_targetsize-256.png │ ├── Square44x44Logo.altform-unplated_targetsize-32.png │ ├── Square44x44Logo.altform-unplated_targetsize-48.png │ ├── Square44x44Logo.scale-100.png │ ├── Square44x44Logo.scale-125.png │ ├── Square44x44Logo.scale-150.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.scale-400.png │ ├── Square44x44Logo.targetsize-16.png │ ├── Square44x44Logo.targetsize-24.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── Square44x44Logo.targetsize-256.png │ ├── Square44x44Logo.targetsize-32.png │ ├── Square44x44Logo.targetsize-48.png │ ├── StoreLogo.backup.png │ ├── StoreLogo.scale-100.png │ ├── StoreLogo.scale-125.png │ ├── StoreLogo.scale-150.png │ ├── StoreLogo.scale-200.png │ ├── StoreLogo.scale-400.png │ ├── Wide310x150Logo.scale-100.png │ ├── Wide310x150Logo.scale-125.png │ ├── Wide310x150Logo.scale-150.png │ ├── Wide310x150Logo.scale-200.png │ └── Wide310x150Logo.scale-400.png ├── Brushes │ ├── BackdropKind.cs │ └── MicaAltBrush.cs ├── Helpers │ └── ColorHelper.cs ├── LICENSE ├── MainPage.xaml ├── MainPage.xaml.cs ├── Materials │ ├── AuroraLite.xaml │ ├── AuroraLite.xaml.cs │ ├── Bloom.html │ ├── BloomView.xaml │ ├── BloomView.xaml.cs │ ├── RedBloom.html │ ├── RedBloomView.xaml │ └── RedBloomView.xaml.cs ├── Mica.csproj ├── Package.appxmanifest ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml └── SettingsControls │ ├── Converters.cs │ ├── SettingsBlockControl.xaml │ ├── SettingsBlockControl.xaml.cs │ ├── SettingsDisplayControl.xaml │ └── SettingsDisplayControl.xaml.cs └── TenMica ├── DwmThumbnail.h ├── TenMica.vcxproj ├── TenMica.vcxproj.filters ├── TenMicaBrush.cpp ├── TenMicaBrush.h ├── packages.config ├── pch.cpp └── pch.h /.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 -------------------------------------------------------------------------------- /Mica.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33205.214 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mica", "Mica\Mica.csproj", "{C54D8977-3DA3-4273-AF12-51B3AC5F6F35}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TenMica", "TenMica\TenMica.vcxproj", "{9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|ARM = Debug|ARM 13 | Debug|ARM64 = Debug|ARM64 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|ARM = Release|ARM 17 | Release|ARM64 = Release|ARM64 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM.ActiveCfg = Debug|ARM 23 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM.Build.0 = Debug|ARM 24 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM.Deploy.0 = Debug|ARM 25 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM64.ActiveCfg = Debug|ARM64 26 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM64.Build.0 = Debug|ARM64 27 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|ARM64.Deploy.0 = Debug|ARM64 28 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x64.ActiveCfg = Debug|x64 29 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x64.Build.0 = Debug|x64 30 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x64.Deploy.0 = Debug|x64 31 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x86.ActiveCfg = Debug|x86 32 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x86.Build.0 = Debug|x86 33 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Debug|x86.Deploy.0 = Debug|x86 34 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM.ActiveCfg = Release|ARM 35 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM.Build.0 = Release|ARM 36 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM.Deploy.0 = Release|ARM 37 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM64.ActiveCfg = Release|ARM64 38 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM64.Build.0 = Release|ARM64 39 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|ARM64.Deploy.0 = Release|ARM64 40 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x64.ActiveCfg = Release|x64 41 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x64.Build.0 = Release|x64 42 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x64.Deploy.0 = Release|x64 43 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x86.ActiveCfg = Release|x86 44 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x86.Build.0 = Release|x86 45 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35}.Release|x86.Deploy.0 = Release|x86 46 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|ARM.ActiveCfg = Debug|ARM 47 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|ARM.Build.0 = Debug|ARM 48 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|ARM64.ActiveCfg = Debug|ARM64 49 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|ARM64.Build.0 = Debug|ARM64 50 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|x64.ActiveCfg = Debug|x64 51 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|x64.Build.0 = Debug|x64 52 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|x86.ActiveCfg = Debug|Win32 53 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Debug|x86.Build.0 = Debug|Win32 54 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|ARM.ActiveCfg = Release|ARM 55 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|ARM.Build.0 = Release|ARM 56 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|ARM64.ActiveCfg = Release|ARM64 57 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|ARM64.Build.0 = Release|ARM64 58 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|x64.ActiveCfg = Release|x64 59 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|x64.Build.0 = Release|x64 60 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|x86.ActiveCfg = Release|Win32 61 | {9BCE64F0-F93A-4EA1-BC2F-7E6D2667AEBA}.Release|x86.Build.0 = Release|Win32 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | GlobalSection(ExtensibilityGlobals) = postSolution 67 | SolutionGuid = {A33CCA4C-A367-480F-BAE3-27906C364A8D} 68 | EndGlobalSection 69 | EndGlobal 70 | -------------------------------------------------------------------------------- /Mica/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.ExceptionServices; 6 | using System.Runtime.InteropServices.WindowsRuntime; 7 | using System.Threading.Tasks; 8 | using Windows.ApplicationModel; 9 | using Windows.ApplicationModel.Activation; 10 | using Windows.Foundation; 11 | using Windows.Foundation.Collections; 12 | using Windows.Foundation.Metadata; 13 | using Windows.UI.ViewManagement; 14 | using Windows.UI.WindowManagement; 15 | using Windows.UI.Xaml; 16 | using Windows.UI.Xaml.Controls; 17 | using Windows.UI.Xaml.Controls.Primitives; 18 | using Windows.UI.Xaml.Data; 19 | using Windows.UI.Xaml.Hosting; 20 | using Windows.UI.Xaml.Input; 21 | using Windows.UI.Xaml.Media; 22 | using Windows.UI.Xaml.Navigation; 23 | 24 | namespace Mica 25 | { 26 | /// 27 | /// Provides application-specific behavior to supplement the default Application class. 28 | /// 29 | sealed partial class App : Application 30 | { 31 | /// 32 | /// Initializes the singleton application object. This is the first line of authored code 33 | /// executed, and as such is the logical equivalent of main() or WinMain(). 34 | /// 35 | public App() 36 | { 37 | this.InitializeComponent(); 38 | this.Suspending += OnSuspending; 39 | UnhandledException += OnUnhandledException; 40 | 41 | TaskScheduler.UnobservedTaskException += OnUnobservedException; 42 | AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; 43 | } 44 | private static void OnUnobservedException(object sender, UnobservedTaskExceptionEventArgs e) 45 | { 46 | // Occurs when an exception is not handled on a background thread. 47 | // ie. A task is fired and forgotten Task.Run(() => {...}) 48 | 49 | 50 | // suppress and handle it manually. 51 | e.SetObserved(); 52 | } 53 | 54 | private static void OnUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) 55 | { 56 | e.Handled = true; 57 | } 58 | 59 | private void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) 60 | { 61 | 62 | } 63 | /// 64 | /// Invoked when the application is launched normally by the end user. Other entry points 65 | /// will be used such as when the application is launched to open a specific file. 66 | /// 67 | /// Details about the launch request and process. 68 | protected override void OnLaunched(LaunchActivatedEventArgs e) 69 | { 70 | // StartApp(); 71 | Frame rootFrame = Window.Current.Content as Frame; 72 | 73 | // Do not repeat app initialization when the Window already has content, 74 | // just ensure that the window is active 75 | if (rootFrame == null) 76 | { 77 | // Create a Frame to act as the navigation context and navigate to the first page 78 | rootFrame = new Frame(); 79 | 80 | rootFrame.NavigationFailed += OnNavigationFailed; 81 | 82 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) 83 | { 84 | //TODO: Load state from previously suspended application 85 | } 86 | 87 | // Place the frame in the current Window 88 | Window.Current.Content = rootFrame; 89 | } 90 | 91 | if (e.PrelaunchActivated == false) 92 | { 93 | if (rootFrame.Content == null) 94 | { 95 | // When the navigation stack isn't restored navigate to the first page, 96 | // configuring the new page by passing required information as a navigation 97 | // parameter 98 | rootFrame.Navigate(typeof(MainPage), e.Arguments); 99 | } 100 | // Ensure the current window is active 101 | Window.Current.Activate(); 102 | } 103 | } 104 | 105 | protected override void OnActivated(IActivatedEventArgs args) 106 | { 107 | if (args.Kind == ActivationKind.Protocol) 108 | { 109 | ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs; 110 | // TODO: Handle URI activation 111 | // The received URI is eventArgs.Uri.AbsoluteUri 112 | Frame rootFrame = Window.Current.Content as Frame; 113 | 114 | // Do not repeat app initialization when the Window already has content, 115 | // just ensure that the window is active 116 | if (rootFrame == null) 117 | { 118 | // Create a Frame to act as the navigation context and navigate to the first page 119 | rootFrame = new Frame(); 120 | 121 | rootFrame.NavigationFailed += OnNavigationFailed; 122 | 123 | // Place the frame in the current Window 124 | Window.Current.Content = rootFrame; 125 | } 126 | if (rootFrame.Content == null) 127 | { 128 | // When the navigation stack isn't restored navigate to the first page, 129 | // configuring the new page by passing required information as a navigation 130 | // parameter 131 | rootFrame.Navigate(typeof(MainPage)); 132 | } 133 | // Ensure the current window is active 134 | Window.Current.Activate(); 135 | } 136 | } 137 | 138 | /// 139 | /// Invoked when Navigation to a certain page fails 140 | /// 141 | /// The Frame which failed navigation 142 | /// Details about the navigation failure 143 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e) 144 | { 145 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName); 146 | } 147 | 148 | /// 149 | /// Invoked when application execution is being suspended. Application state is saved 150 | /// without knowing whether the application will be terminated or resumed with the contents 151 | /// of memory still intact. 152 | /// 153 | /// The source of the suspend request. 154 | /// Details about the suspend request. 155 | private void OnSuspending(object sender, SuspendingEventArgs e) 156 | { 157 | var deferral = e.SuspendingOperation.GetDeferral(); 158 | //TODO: Save application state and stop any background activity 159 | deferral.Complete(); 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Mica/Assets/LargeTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/LargeTile.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/LargeTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/LargeTile.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/LargeTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/LargeTile.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/LargeTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/LargeTile.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/SmallTile.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SmallTile.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/SmallTile.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SmallTile.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/SmallTile.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SmallTile.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/SmallTile.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SmallTile.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/SmallTile.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SmallTile.scale-400.png -------------------------------------------------------------------------------- /Mica/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/SplashScreen.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SplashScreen.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/SplashScreen.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SplashScreen.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/SplashScreen.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/SplashScreen.scale-400.png -------------------------------------------------------------------------------- /Mica/Assets/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/Square150x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square150x150Logo.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/Square150x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square150x150Logo.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/Square150x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square150x150Logo.scale-400.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-unplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-unplated_targetsize-16.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-unplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-unplated_targetsize-256.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-unplated_targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-unplated_targetsize-32.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.altform-unplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.altform-unplated_targetsize-48.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.scale-400.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-16.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-24.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-256.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-32.png -------------------------------------------------------------------------------- /Mica/Assets/Square44x44Logo.targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Square44x44Logo.targetsize-48.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.backup.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/StoreLogo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/StoreLogo.scale-400.png -------------------------------------------------------------------------------- /Mica/Assets/Wide310x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Wide310x150Logo.scale-100.png -------------------------------------------------------------------------------- /Mica/Assets/Wide310x150Logo.scale-125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Wide310x150Logo.scale-125.png -------------------------------------------------------------------------------- /Mica/Assets/Wide310x150Logo.scale-150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Wide310x150Logo.scale-150.png -------------------------------------------------------------------------------- /Mica/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /Mica/Assets/Wide310x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FireCubeStudios/Mica-App/6d23981d48006a828450861ea11bfe26d2b6a58d/Mica/Assets/Wide310x150Logo.scale-400.png -------------------------------------------------------------------------------- /Mica/Brushes/BackdropKind.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Mica.Brushes 8 | { 9 | public enum BackdropKind 10 | { 11 | Base = 0, 12 | BaseAlt = 1, 13 | Custom = 2 14 | } 15 | } -------------------------------------------------------------------------------- /Mica/Brushes/MicaAltBrush.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using Microsoft.Graphics.Canvas.Effects; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Runtime.CompilerServices; 7 | using Windows.ApplicationModel; 8 | using Windows.UI; 9 | using Windows.UI.Composition; 10 | using Windows.UI.Xaml; 11 | using Windows.UI.Xaml.Media; 12 | 13 | namespace Mica.Brushes 14 | { 15 | public class MicaAltBrush : XamlCompositionBrushBase, INotifyPropertyChanged 16 | { 17 | private double tintOpacity; 18 | 19 | public double TintOpacity 20 | { 21 | get => tintOpacity; 22 | set => tintOpacity = value; 23 | } 24 | 25 | private double luminosityOpacity; 26 | 27 | public double LuminosityOpacity 28 | { 29 | get => luminosityOpacity; 30 | set => luminosityOpacity = value; 31 | } 32 | 33 | private Color tintColor; 34 | 35 | public Color TintColor 36 | { 37 | get => tintColor; 38 | set => tintColor = value; 39 | } 40 | 41 | private Color luminosityColor; 42 | 43 | public Color LuminosityColor 44 | { 45 | get => luminosityColor; 46 | set => luminosityColor = value; 47 | } 48 | 49 | private ElementTheme _theme; 50 | 51 | public ElementTheme Theme 52 | { 53 | get => _theme; 54 | set 55 | { 56 | _theme = value; 57 | UpdateTheme(); 58 | } 59 | } 60 | 61 | private BackdropKind _kind; 62 | 63 | public int Kind 64 | { 65 | get => (int)_kind; 66 | set 67 | { 68 | _kind = (BackdropKind)value; 69 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsKindCustom))); 70 | UpdateTheme(); 71 | } 72 | } 73 | 74 | public bool IsKindCustom => _kind == BackdropKind.Custom; 75 | 76 | private void UpdateTheme() 77 | { 78 | switch (_kind) 79 | { 80 | case BackdropKind.Custom: 81 | return; 82 | case BackdropKind.Base: 83 | switch (Theme) 84 | { 85 | case ElementTheme.Light: 86 | tintColor = luminosityColor = Color.FromArgb(255, 243, 243, 243); 87 | tintOpacity = 50; 88 | luminosityOpacity = 100; 89 | break; 90 | case ElementTheme.Dark: 91 | tintColor = luminosityColor = Color.FromArgb(255, 32, 32, 32); 92 | tintOpacity = 80; 93 | luminosityOpacity = 100; 94 | break; 95 | } 96 | break; 97 | case BackdropKind.BaseAlt: 98 | switch (Theme) 99 | { 100 | case ElementTheme.Light: 101 | tintColor = luminosityColor = Color.FromArgb(255, 218, 218, 218); 102 | tintOpacity = 50; 103 | luminosityOpacity = 100; 104 | break; 105 | case ElementTheme.Dark: 106 | tintColor = luminosityColor = Color.FromArgb(255, 10, 10, 10); 107 | tintOpacity = 0; 108 | luminosityOpacity = 100; 109 | break; 110 | } 111 | break; 112 | } 113 | 114 | UpdateBrush(); 115 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TintColor))); 116 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TintOpacity))); 117 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LuminosityColor))); 118 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LuminosityOpacity))); 119 | } 120 | 121 | public event PropertyChangedEventHandler PropertyChanged; 122 | private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 123 | 124 | public static CompositionBrush BuildMicaEffectBrush(Compositor compositor, Color tintColor, float tintOpacity, Color luminosityColor, float luminosityOpacity) 125 | { 126 | // Tint Color. 127 | 128 | var tintColorEffect = new ColorSourceEffect(); 129 | tintColorEffect.Name = "TintColor"; 130 | tintColorEffect.Color = tintColor; 131 | 132 | // OpacityEffect applied to Tint. 133 | var tintOpacityEffect = new OpacityEffect(); 134 | tintOpacityEffect.Name = "TintOpacity"; 135 | tintOpacityEffect.Opacity = tintOpacity; 136 | tintOpacityEffect.Source = tintColorEffect; 137 | 138 | // Apply Luminosity: 139 | 140 | // Luminosity Color. 141 | var luminosityColorEffect = new ColorSourceEffect(); 142 | luminosityColorEffect.Color = luminosityColor; 143 | 144 | // OpacityEffect applied to Luminosity. 145 | var luminosityOpacityEffect = new OpacityEffect(); 146 | luminosityOpacityEffect.Name = "LuminosityOpacity"; 147 | luminosityOpacityEffect.Opacity = luminosityOpacity; 148 | luminosityOpacityEffect.Source = luminosityColorEffect; 149 | 150 | // Luminosity Blend. 151 | // NOTE: There is currently a bug where the names of BlendEffectMode::Luminosity and BlendEffectMode::Color are flipped. 152 | var luminosityBlendEffect = new BlendEffect(); 153 | luminosityBlendEffect.Mode = BlendEffectMode.Color; 154 | luminosityBlendEffect.Background = new CompositionEffectSourceParameter("BlurredWallpaperBackdrop"); 155 | luminosityBlendEffect.Foreground = luminosityOpacityEffect; 156 | 157 | // Apply Tint: 158 | 159 | // Color Blend. 160 | // NOTE: There is currently a bug where the names of BlendEffectMode::Luminosity and BlendEffectMode::Color are flipped. 161 | var colorBlendEffect = new BlendEffect(); 162 | colorBlendEffect.Mode = BlendEffectMode.Luminosity; 163 | colorBlendEffect.Background = luminosityBlendEffect; 164 | colorBlendEffect.Foreground = tintOpacityEffect; 165 | 166 | CompositionEffectBrush micaEffectBrush = compositor.CreateEffectFactory(colorBlendEffect).CreateBrush(); 167 | //var blurredWallpaperBackdropBrush = (ICompositorWithBlurredWallpaperBackdropBrush)((object)compositor); // Code for < 22000 SDK 168 | //micaEffectBrush.SetSourceParameter("BlurredWallpaperBackdrop", blurredWallpaperBackdropBrush.TryCreateBlurredWallpaperBackdropBrush()); 169 | micaEffectBrush.SetSourceParameter("BlurredWallpaperBackdrop", compositor.TryCreateBlurredWallpaperBackdropBrush()); 170 | 171 | return micaEffectBrush; 172 | } 173 | 174 | private CompositionBrush CreateCrossFadeEffectBrush(Compositor compositor, CompositionBrush from, CompositionBrush to) 175 | { 176 | var crossFadeEffect = new CrossFadeEffect(); 177 | crossFadeEffect.Name = "Crossfade"; // Name to reference when starting the animation. 178 | crossFadeEffect.Source1 = new CompositionEffectSourceParameter("source1"); 179 | crossFadeEffect.Source2 = new CompositionEffectSourceParameter("source2"); 180 | crossFadeEffect.CrossFade = 0; 181 | 182 | CompositionEffectBrush crossFadeEffectBrush = compositor.CreateEffectFactory(crossFadeEffect, new List() { "Crossfade.CrossFade" }).CreateBrush(); 183 | crossFadeEffectBrush.Comment = "Crossfade"; 184 | // The inputs have to be swapped here to work correctly... 185 | crossFadeEffectBrush.SetSourceParameter("source1", to); 186 | crossFadeEffectBrush.SetSourceParameter("source2", from); 187 | return crossFadeEffectBrush; 188 | } 189 | 190 | private ScalarKeyFrameAnimation CreateCrossFadeAnimation(Compositor compositor) 191 | { 192 | ScalarKeyFrameAnimation animation = compositor.CreateScalarKeyFrameAnimation(); 193 | LinearEasingFunction linearEasing = compositor.CreateLinearEasingFunction(); 194 | animation.InsertKeyFrame(0.0f, 0.0f, linearEasing); 195 | animation.InsertKeyFrame(1.0f, 1.0f, linearEasing); 196 | animation.Duration = TimeSpan.FromMilliseconds(250); 197 | return animation; 198 | } 199 | 200 | private void UpdateBrush() 201 | { 202 | Compositor compositor = Window.Current.Compositor; 203 | 204 | CompositionBrush newBrush = BuildMicaEffectBrush(compositor, TintColor, (float)(TintOpacity / 100), LuminosityColor, (float)(LuminosityOpacity / 100)); 205 | 206 | CompositionBrush oldBrush = CompositionBrush; 207 | 208 | if (oldBrush == null || CompositionBrush.Comment == "Crossfade" || Kind == (int)BackdropKind.Custom) 209 | { 210 | // Set new brush directly 211 | if (oldBrush != null) 212 | { 213 | oldBrush.Dispose(); 214 | } 215 | this.CompositionBrush = newBrush; 216 | } 217 | else 218 | { 219 | // Crossfade 220 | CompositionBrush crossFadeBrush = CreateCrossFadeEffectBrush(compositor, oldBrush, newBrush); 221 | ScalarKeyFrameAnimation animation = CreateCrossFadeAnimation(compositor); 222 | CompositionBrush = crossFadeBrush; 223 | 224 | var crossFadeAnimationBatch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation); 225 | crossFadeBrush.StartAnimation("CrossFade.CrossFade", animation); 226 | crossFadeAnimationBatch.End(); 227 | 228 | crossFadeAnimationBatch.Completed += (o, a) => 229 | { 230 | crossFadeBrush.Dispose(); 231 | oldBrush.Dispose(); 232 | this.CompositionBrush = newBrush; 233 | }; 234 | } 235 | } 236 | 237 | protected override void OnConnected() 238 | { 239 | if (DesignMode.DesignModeEnabled) 240 | { 241 | CompositionBrush = Window.Current.Compositor.CreateColorBrush(Color.FromArgb(255, 243, 243, 243)); 242 | return; 243 | } 244 | 245 | UpdateBrush(); 246 | } 247 | } 248 | } -------------------------------------------------------------------------------- /Mica/Helpers/ColorHelper.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI; 2 | 3 | namespace Mica.Helpers 4 | { 5 | class ColorHelper 6 | { 7 | private static 8 | ( 9 | Color SystemAccentColorLight3, 10 | Color SystemAccentColorLight2, 11 | Color SystemAccentColorLight1, 12 | Color SystemAccentColor, 13 | Color SystemAccentColorDark1, 14 | Color SystemAccentColorDark2, 15 | Color SystemAccentColorDark3 16 | ) 17 | GetColorPalette(Color c) 18 | { 19 | return 20 | ( 21 | ChangeColorBrightness(c, 0.51f), 22 | ChangeColorBrightness(c, 0.25f), 23 | ChangeColorBrightness(c, 0.02f), 24 | c, 25 | ChangeColorBrightness(c, -0.19f), 26 | ChangeColorBrightness(c, -0.40f), 27 | ChangeColorBrightness(c, -0.68f) 28 | ); 29 | } 30 | public static Color ChangeColorBrightness(Color color, double correctionFactor) 31 | { 32 | double red = color.R; 33 | double green = color.G; 34 | double blue = color.B; 35 | 36 | if (correctionFactor < 0) 37 | { 38 | correctionFactor = 1 + correctionFactor; 39 | red *= correctionFactor; 40 | green *= correctionFactor; 41 | blue *= correctionFactor; 42 | } 43 | else 44 | { 45 | red = (255 - red) * correctionFactor + red; 46 | green = (255 - green) * correctionFactor + green; 47 | blue = (255 - blue) * correctionFactor + blue; 48 | } 49 | 50 | return Color.FromArgb(color.A, (byte)red, (byte)green, (byte)blue); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Mica/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Mica/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 23 | 32 | 33 | 34 | 35 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | Effects personalization 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | About this app 117 | Mica™️ 2.0.x.0 118 | Developed by FireCubeStudios 119 | Icon by josephbeattiee 120 | 10Mica by Ahmed Walid 121 | Follow me on Twitter 122 | Join FireCubeStudios server 123 | GitHub repository 124 | 125 | Get Acrylic™️ 126 | Get Tabbed™️ 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /Mica/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Toolkit.Uwp.Helpers; 2 | using System; 3 | using Windows.ApplicationModel.Core; 4 | using Windows.System; 5 | using Windows.UI; 6 | using Windows.UI.ViewManagement; 7 | using Windows.UI.Xaml; 8 | using Windows.UI.Xaml.Controls; 9 | using Windows.UI.Xaml.Input; 10 | 11 | namespace Mica 12 | { 13 | public sealed partial class MainPage : Page 14 | { 15 | public MainPage() 16 | { 17 | this.InitializeComponent(); 18 | ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; 19 | titleBar.ButtonBackgroundColor = Colors.Transparent; 20 | titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; 21 | CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; 22 | coreTitleBar.ExtendViewIntoTitleBar = true; 23 | Window.Current.SetTitleBar(AppTitleBar); 24 | Tip.IsOpen = SystemInformation.Instance.IsFirstRun ? true : false; 25 | InfiniteMicaSetting.Visibility = IsWin11() ? Visibility.Visible : Visibility.Collapsed; 26 | } 27 | 28 | private void ThemeSwitch_Toggled(object sender, RoutedEventArgs e) 29 | { 30 | if (Window.Current.Content is FrameworkElement frameworkElement) 31 | { 32 | frameworkElement.RequestedTheme = ThemeSwitch.IsOn ? ElementTheme.Dark : ElementTheme.Light; 33 | if(Mica10 is not null) 34 | Mica10.ForcedTheme = ThemeSwitch.IsOn ? ApplicationTheme.Dark : ApplicationTheme.Light; 35 | } 36 | } 37 | 38 | private void Page_SizeChanged(object sender, SizeChangedEventArgs e) 39 | { 40 | if (Window.Current.Bounds.Width < 800) 41 | { 42 | AboutPanel.Visibility = Visibility.Collapsed; 43 | CloseButton.Margin = new Thickness(50, 54, 50, 100); 44 | SettingsGrid.Margin = new Thickness(50, 50, 50, 100); 45 | } 46 | else 47 | { 48 | AboutPanel.Visibility = Visibility.Visible; 49 | CloseButton.Margin = new Thickness(100, 54, 300, 100); 50 | SettingsGrid.Margin = new Thickness(100, 50, 300, 100); 51 | } 52 | } 53 | 54 | private void Button_Click(object sender, RoutedEventArgs e) => Tip.IsOpen = true; 55 | 56 | private void Grid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) => SettingsPanel.Visibility = Visibility.Visible; 57 | 58 | private void Grid_RightTapped(object sender, RightTappedRoutedEventArgs e) => SettingsPanel.Visibility = Visibility.Visible; 59 | 60 | private void CloseButton_Click(object sender, RoutedEventArgs e) => SettingsPanel.Visibility = Visibility.Collapsed; 61 | 62 | private void Tip_ActionButtonClick(Microsoft.UI.Xaml.Controls.TeachingTip sender, object args) => SettingsPanel.Visibility = ((sender.IsOpen = false) is false) ? Visibility.Visible : Visibility.Visible; 63 | 64 | private void ColorPicker_ColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args) 65 | { 66 | Gs2.Color = Helpers.ColorHelper.ChangeColorBrightness(sender.Color, 0.51f); 67 | Gs1.Color = Helpers.ColorHelper.ChangeColorBrightness(sender.Color, 0.25f); 68 | Gs0.Color = Helpers.ColorHelper.ChangeColorBrightness(sender.Color, 0.02f); 69 | Glow.Color = sender.Color; 70 | } 71 | 72 | private async void NewMica_Click(object sender, RoutedEventArgs e) => await Launcher.LaunchUriAsync(new Uri("mica:")); 73 | 74 | public bool IsWin11() => (Environment.OSVersion.Version.Build >= 22000); 75 | 76 | private void InfiniteSwitch_Toggled(object sender, RoutedEventArgs e) 77 | { 78 | if (Mica is not null) 79 | Mica.Visibility = InfiniteSwitch.IsOn ? Visibility.Visible : Visibility.Collapsed; 80 | if (Window.Current.Content is FrameworkElement frameworkElement) 81 | { 82 | frameworkElement.RequestedTheme = ThemeSwitch.IsOn ? ElementTheme.Dark : ElementTheme.Light; 83 | if (Mica10 is not null) 84 | Mica10.ForcedTheme = ThemeSwitch.IsOn ? ApplicationTheme.Dark : ApplicationTheme.Light; 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Mica/Materials/AuroraLite.xaml: -------------------------------------------------------------------------------- 1 |  9 | 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 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 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 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | -------------------------------------------------------------------------------- /Mica/Materials/AuroraLite.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml.Controls; 2 | 3 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 4 | 5 | namespace Mica.Materials 6 | { 7 | public sealed partial class AuroraLite : UserControl 8 | { 9 | public AuroraLite() 10 | { 11 | this.InitializeComponent(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Mica/Materials/BloomView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Mica/Materials/BloomView.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Windows.UI.Xaml.Controls; 3 | 4 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 5 | 6 | namespace Mica.Materials 7 | { 8 | public sealed partial class BloomView : UserControl 9 | { 10 | public BloomView() 11 | { 12 | this.InitializeComponent(); 13 | BloomWebView.Height = Window.Current.Bounds.Height; 14 | BloomWebView.Width = Window.Current.Bounds.Width; 15 | } 16 | 17 | private void Bloom_SizeChanged(object sender, SizeChangedEventArgs e) 18 | { 19 | BloomWebView.Height = Window.Current.Bounds.Height; 20 | BloomWebView.Width = Window.Current.Bounds.Width; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Mica/Materials/RedBloomView.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Mica/Materials/RedBloomView.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Windows.UI.Xaml.Controls; 3 | 4 | // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 5 | 6 | namespace Mica.Materials 7 | { 8 | public sealed partial class RedBloomView : UserControl 9 | { 10 | public RedBloomView() 11 | { 12 | this.InitializeComponent(); 13 | BloomWebView.Height = Window.Current.Bounds.Height; 14 | BloomWebView.Width = Window.Current.Bounds.Width; 15 | } 16 | 17 | private void Bloom_SizeChanged(object sender, SizeChangedEventArgs e) 18 | { 19 | BloomWebView.Height = Window.Current.Bounds.Height; 20 | BloomWebView.Width = Window.Current.Bounds.Width; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Mica/Mica.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | {C54D8977-3DA3-4273-AF12-51B3AC5F6F35} 8 | AppContainerExe 9 | Properties 10 | Mica 11 | Mica 12 | en-US 13 | UAP 14 | 9.0 15 | 10.0.22000.0 16 | 10.0.18362.0 17 | 14 18 | 512 19 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 20 | true 21 | True 22 | 0853A17B687504FA4C247CCCAB8E3B33BE0E4B9F 23 | 24 | False 25 | SHA256 26 | True 27 | True 28 | Always 29 | x86|x64|arm64 30 | 0 31 | 32 | 33 | true 34 | bin\x86\Debug\ 35 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 36 | ;2008 37 | full 38 | x86 39 | false 40 | prompt 41 | true 42 | 43 | 44 | bin\x86\Release\ 45 | TRACE;NETFX_CORE;WINDOWS_UWP 46 | true 47 | ;2008 48 | pdbonly 49 | x86 50 | false 51 | prompt 52 | true 53 | true 54 | 55 | 56 | true 57 | bin\ARM\Debug\ 58 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 59 | ;2008 60 | full 61 | ARM 62 | false 63 | prompt 64 | true 65 | 66 | 67 | bin\ARM\Release\ 68 | TRACE;NETFX_CORE;WINDOWS_UWP 69 | true 70 | ;2008 71 | pdbonly 72 | ARM 73 | false 74 | prompt 75 | true 76 | true 77 | 78 | 79 | true 80 | bin\ARM64\Debug\ 81 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 82 | ;2008 83 | full 84 | ARM64 85 | false 86 | prompt 87 | true 88 | true 89 | 90 | 91 | bin\ARM64\Release\ 92 | TRACE;NETFX_CORE;WINDOWS_UWP 93 | true 94 | ;2008 95 | pdbonly 96 | ARM64 97 | false 98 | prompt 99 | true 100 | true 101 | 102 | 103 | true 104 | bin\x64\Debug\ 105 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP 106 | ;2008 107 | full 108 | x64 109 | false 110 | prompt 111 | true 112 | 113 | 114 | bin\x64\Release\ 115 | TRACE;NETFX_CORE;WINDOWS_UWP 116 | true 117 | ;2008 118 | pdbonly 119 | x64 120 | false 121 | prompt 122 | true 123 | true 124 | 125 | 126 | PackageReference 127 | 128 | 129 | 130 | App.xaml 131 | 132 | 133 | 134 | 135 | 136 | MainPage.xaml 137 | 138 | 139 | AuroraLite.xaml 140 | 141 | 142 | RedBloomView.xaml 143 | 144 | 145 | BloomView.xaml 146 | 147 | 148 | 149 | 150 | SettingsBlockControl.xaml 151 | 152 | 153 | SettingsDisplayControl.xaml 154 | 155 | 156 | 157 | 158 | Designer 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | MSBuild:Compile 221 | Designer 222 | 223 | 224 | MSBuild:Compile 225 | Designer 226 | 227 | 228 | Designer 229 | MSBuild:Compile 230 | 231 | 232 | MSBuild:Compile 233 | Designer 234 | 235 | 236 | Designer 237 | MSBuild:Compile 238 | 239 | 240 | MSBuild:Compile 241 | Designer 242 | 243 | 244 | MSBuild:Compile 245 | Designer 246 | 247 | 248 | 249 | 250 | 8.2.0 251 | 252 | 253 | 1.1.110 254 | 255 | 256 | 0.1.9 257 | 258 | 259 | 6.2.14 260 | 261 | 262 | 7.1.2 263 | 264 | 265 | 7.1.3 266 | 267 | 268 | 2.7.0 269 | 270 | 271 | 272 | 273 | {9bce64f0-f93a-4ea1-bc2f-7e6d2667aeba} 274 | TenMica 275 | 276 | 277 | 278 | 14.0 279 | 280 | 281 | 288 | -------------------------------------------------------------------------------- /Mica/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | Mica™️ 20 | FireCubeStudios 21 | Assets\StoreLogo.png 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | Mica 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Mica/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Mica")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Mica")] 13 | [assembly: AssemblyCopyright("Copyright © 2022")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Mica/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Mica/SettingsControls/Converters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | using Windows.UI.Xaml.Data; 4 | 5 | #nullable enable 6 | 7 | namespace Mica.SettingsControls 8 | { 9 | /// 10 | /// The generic base implementation of a value converter. 11 | /// 12 | /// The source type. 13 | /// The target type. 14 | public abstract class ValueConverter 15 | : IValueConverter 16 | { 17 | /// 18 | /// Converts a source value to the target type. 19 | /// 20 | /// 21 | /// 22 | public TTarget? Convert(TSource? value) 23 | { 24 | return Convert(value, null, null); 25 | } 26 | 27 | /// 28 | /// Converts a target value back to the source type. 29 | /// 30 | /// 31 | /// 32 | public TSource? ConvertBack(TTarget? value) 33 | { 34 | return ConvertBack(value, null, null); 35 | } 36 | 37 | /// 38 | /// Modifies the source data before passing it to the target for display in the UI. 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | /// 45 | public object? Convert(object? value, Type? targetType, object? parameter, string? language) 46 | { 47 | // CastExceptions will occur when invalid value, or target type provided. 48 | return Convert((TSource?)value, parameter, language); 49 | } 50 | 51 | /// 52 | /// Modifies the target data before passing it to the source object. This method is called only in TwoWay bindings. 53 | /// 54 | /// 55 | /// 56 | /// 57 | /// 58 | /// 59 | public object? ConvertBack(object? value, Type? targetType, object? parameter, string? language) 60 | { 61 | // CastExceptions will occur when invalid value, or target type provided. 62 | return ConvertBack((TTarget?)value, parameter, language); 63 | } 64 | 65 | /// 66 | /// Converts a source value to the target type. 67 | /// 68 | /// 69 | /// 70 | /// 71 | /// 72 | protected virtual TTarget? Convert(TSource? value, object? parameter, string? language) 73 | { 74 | throw new NotSupportedException(); 75 | } 76 | 77 | /// 78 | /// Converts a target value back to the source type. 79 | /// 80 | /// 81 | /// 82 | /// 83 | /// 84 | protected virtual TSource? ConvertBack(TTarget? value, object? parameter, string? language) 85 | { 86 | throw new NotSupportedException(); 87 | } 88 | } 89 | 90 | /// 91 | /// The base class for converting instances of type T to object and vice versa. 92 | /// 93 | public abstract class ToObjectConverter 94 | : ValueConverter 95 | { 96 | /// 97 | /// Converts a source value to the target type. 98 | /// 99 | /// 100 | /// 101 | /// 102 | /// 103 | protected override object? Convert(T? value, object? parameter, string? language) 104 | { 105 | return value; 106 | } 107 | 108 | /// 109 | /// Converts a target value back to the source type. 110 | /// 111 | /// 112 | /// 113 | /// 114 | /// 115 | protected override T? ConvertBack(object? value, object? parameter, string? language) 116 | { 117 | return (T?)value; 118 | } 119 | } 120 | 121 | /// 122 | /// Converts a boolean to and from a visibility value. 123 | /// 124 | public class InverseBooleanConverter 125 | : ValueConverter 126 | { 127 | /// 128 | /// Converts a source value to the target type. 129 | /// 130 | /// 131 | /// 132 | /// 133 | /// 134 | protected override bool Convert(bool value, object? parameter, string? language) 135 | { 136 | return !value; 137 | } 138 | 139 | /// 140 | /// Converts a target value back to the source type. 141 | /// 142 | /// 143 | /// 144 | /// 145 | /// 146 | protected override bool ConvertBack(bool value, object? parameter, string? language) 147 | { 148 | return !value; 149 | } 150 | } 151 | 152 | public class NullToTrueConverter 153 | : ValueConverter 154 | { 155 | /// 156 | /// Determines whether an inverse conversion should take place. 157 | /// 158 | /// If set, the value True results in , and false in . 159 | public bool Inverse { get; set; } 160 | 161 | /// 162 | /// Converts a source value to the target type. 163 | /// 164 | /// 165 | /// 166 | /// 167 | /// 168 | protected override bool Convert(object? value, object? parameter, string? language) 169 | { 170 | return Inverse ? value != null : value == null; 171 | } 172 | 173 | /// 174 | /// Converts a target value back to the source type. 175 | /// 176 | /// 177 | /// 178 | /// 179 | /// 180 | protected override object? ConvertBack(bool value, object? parameter, string? language) 181 | { 182 | return null; 183 | } 184 | } 185 | 186 | public class StringNullOrWhiteSpaceToTrueConverter 187 | : ValueConverter 188 | { 189 | /// 190 | /// Determines whether an inverse conversion should take place. 191 | /// 192 | /// If set, the value True results in , and false in . 193 | public bool Inverse { get; set; } 194 | 195 | /// 196 | /// Converts a source value to the target type. 197 | /// 198 | /// 199 | /// 200 | /// 201 | /// 202 | protected override bool Convert(string? value, object? parameter, string? language) 203 | { 204 | return Inverse ? !string.IsNullOrWhiteSpace(value) : string.IsNullOrWhiteSpace(value); 205 | } 206 | 207 | /// 208 | /// Converts a target value back to the source type. 209 | /// 210 | /// 211 | /// 212 | /// 213 | /// 214 | protected override string ConvertBack(bool value, object? parameter, string? language) 215 | { 216 | return string.Empty; 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /Mica/SettingsControls/SettingsBlockControl.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 36 | 37 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 77 | 78 | 79 | 80 | 81 | 82 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /Mica/SettingsControls/SettingsBlockControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Windows.UI.Xaml.Controls; 3 | using Windows.UI.Xaml.Markup; 4 | 5 | namespace Mica.SettingsControls 6 | { 7 | [ContentProperty(Name = nameof(SettingsActionableElement))] 8 | public sealed partial class SettingsBlockControl : UserControl 9 | { 10 | public FrameworkElement SettingsActionableElement { get; set; } 11 | 12 | public static readonly DependencyProperty ExpandableContentProperty = DependencyProperty.Register( 13 | "ExpandableContent", 14 | typeof(FrameworkElement), 15 | typeof(SettingsBlockControl), 16 | new PropertyMetadata(null) 17 | ); 18 | 19 | public FrameworkElement ExpandableContent 20 | { 21 | get => (FrameworkElement)GetValue(ExpandableContentProperty); 22 | set => SetValue(ExpandableContentProperty, value); 23 | } 24 | 25 | public static readonly DependencyProperty AdditionalDescriptionContentProperty = DependencyProperty.Register( 26 | "AdditionalDescriptionContent", 27 | typeof(FrameworkElement), 28 | typeof(SettingsBlockControl), 29 | new PropertyMetadata(null) 30 | ); 31 | 32 | public FrameworkElement AdditionalDescriptionContent 33 | { 34 | get => (FrameworkElement)GetValue(AdditionalDescriptionContentProperty); 35 | set => SetValue(AdditionalDescriptionContentProperty, value); 36 | } 37 | 38 | public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( 39 | "Title", 40 | typeof(string), 41 | typeof(SettingsBlockControl), 42 | new PropertyMetadata(null) 43 | ); 44 | 45 | public string Title 46 | { 47 | get => (string)GetValue(TitleProperty); 48 | set => SetValue(TitleProperty, value); 49 | } 50 | 51 | public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register( 52 | "Description", 53 | typeof(string), 54 | typeof(SettingsBlockControl), 55 | new PropertyMetadata(null) 56 | ); 57 | 58 | public string Description 59 | { 60 | get => (string)GetValue(DescriptionProperty); 61 | set => SetValue(DescriptionProperty, value); 62 | } 63 | 64 | public static readonly DependencyProperty IconProperty = DependencyProperty.Register( 65 | "Icon", 66 | typeof(IconElement), 67 | typeof(SettingsBlockControl), 68 | new PropertyMetadata(null) 69 | ); 70 | 71 | public IconElement Icon 72 | { 73 | get => (IconElement)GetValue(IconProperty); 74 | set => SetValue(IconProperty, value); 75 | } 76 | 77 | public static readonly DependencyProperty IsClickableProperty = DependencyProperty.Register( 78 | "IsClickable", 79 | typeof(bool), 80 | typeof(SettingsBlockControl), 81 | new PropertyMetadata(false) 82 | ); 83 | 84 | public bool IsClickable 85 | { 86 | get => (bool)GetValue(IsClickableProperty); 87 | set => SetValue(IsClickableProperty, value); 88 | } 89 | 90 | // 91 | // Summary: 92 | // Occurs when a button control is clicked. 93 | public event RoutedEventHandler Click; 94 | 95 | public SettingsBlockControl() 96 | { 97 | this.InitializeComponent(); 98 | } 99 | 100 | private void ActionableButton_Click(object sender, RoutedEventArgs e) 101 | { 102 | Click?.Invoke(this, e); 103 | } 104 | 105 | private void Expander_Expanding(Microsoft.UI.Xaml.Controls.Expander sender, Microsoft.UI.Xaml.Controls.ExpanderExpandingEventArgs args) 106 | { 107 | Click?.Invoke(this, new RoutedEventArgs()); 108 | } 109 | 110 | private void Expander_Collapsed(Microsoft.UI.Xaml.Controls.Expander sender, Microsoft.UI.Xaml.Controls.ExpanderCollapsedEventArgs args) 111 | { 112 | Click?.Invoke(this, new RoutedEventArgs()); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Mica/SettingsControls/SettingsDisplayControl.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 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 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 62 | 63 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 77 | 78 | 83 | 84 | 88 | 89 | 90 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Mica/SettingsControls/SettingsDisplayControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Windows.UI.Xaml.Controls; 3 | using Windows.UI.Xaml.Markup; 4 | 5 | namespace Mica.SettingsControls 6 | { 7 | [ContentProperty(Name = nameof(SettingsActionableElement))] 8 | public sealed partial class SettingsDisplayControl : UserControl 9 | { 10 | public FrameworkElement SettingsActionableElement { get; set; } 11 | 12 | public static readonly DependencyProperty AdditionalDescriptionContentProperty = DependencyProperty.Register( 13 | "AdditionalDescriptionContent", 14 | typeof(FrameworkElement), 15 | typeof(SettingsDisplayControl), 16 | new PropertyMetadata(null) 17 | ); 18 | 19 | public FrameworkElement AdditionalDescriptionContent 20 | { 21 | get => (FrameworkElement)GetValue(AdditionalDescriptionContentProperty); 22 | set => SetValue(AdditionalDescriptionContentProperty, value); 23 | } 24 | 25 | public static readonly DependencyProperty TitleProperty = DependencyProperty.Register( 26 | "Title", 27 | typeof(string), 28 | typeof(SettingsDisplayControl), 29 | new PropertyMetadata(null) 30 | ); 31 | 32 | public string Title 33 | { 34 | get => (string)GetValue(TitleProperty); 35 | set => SetValue(TitleProperty, value); 36 | } 37 | 38 | public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register( 39 | "Description", 40 | typeof(string), 41 | typeof(SettingsDisplayControl), 42 | new PropertyMetadata(null) 43 | ); 44 | 45 | public string Description 46 | { 47 | get => (string)GetValue(DescriptionProperty); 48 | set => SetValue(DescriptionProperty, value); 49 | } 50 | 51 | public static readonly DependencyProperty IconProperty = DependencyProperty.Register( 52 | "Icon", 53 | typeof(IconElement), 54 | typeof(SettingsDisplayControl), 55 | new PropertyMetadata(null) 56 | ); 57 | 58 | public IconElement Icon 59 | { 60 | get => (IconElement)GetValue(IconProperty); 61 | set => SetValue(IconProperty, value); 62 | } 63 | 64 | public SettingsDisplayControl() 65 | { 66 | this.InitializeComponent(); 67 | VisualStateManager.GoToState(this, "NormalState", false); 68 | } 69 | 70 | private void MainPanel_SizeChanged(object sender, SizeChangedEventArgs e) 71 | { 72 | if (e.NewSize.Width == e.PreviousSize.Width || ActionableElement == null) 73 | return; 74 | 75 | if (ActionableElement.ActualWidth > e.NewSize.Width / 3) 76 | { 77 | VisualStateManager.GoToState(this, "CompactState", false); 78 | } 79 | else 80 | { 81 | VisualStateManager.GoToState(this, "NormalState", false); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /TenMica/DwmThumbnail.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | enum THUMBNAIL_TYPE 7 | { 8 | TT_DEFAULT = 0x0, 9 | TT_SNAPSHOT = 0x1, 10 | TT_ICONIC = 0x2, 11 | TT_BITMAPPENDING = 0x3, 12 | TT_BITMAP = 0x4 13 | }; 14 | 15 | typedef struct _DWM_THUMBNAIL_PROPERTIES 16 | { 17 | DWORD dwFlags; // Specifies which members of this struct have been specified 18 | RECT rcDestination; // The area in the destination window where the thumbnail will be rendered 19 | RECT rcSource; // The region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail 20 | BYTE opacity; // The opacity with which to render the thumbnail. 0 is fully transparent, while 255 is fully opaque. The default value is 255 21 | BOOL fVisible; // Whether the thumbnail should be visible. The default is FALSE 22 | BOOL fSourceClientAreaOnly; // Whether only the client area of the source window should be included in the thumbnail. The default is FALSE 23 | } DWM_THUMBNAIL_PROPERTIES, * PDWM_THUMBNAIL_PROPERTIES; 24 | 25 | typedef HANDLE HTHUMBNAIL; 26 | typedef HTHUMBNAIL* PHTHUMBNAIL; 27 | 28 | typedef HRESULT(WINAPI* DwmpCreateSharedThumbnailVisual)( 29 | IN HWND hwndDestination, 30 | IN HWND hwndSource, 31 | IN DWORD dwThumbnailFlags, 32 | IN DWM_THUMBNAIL_PROPERTIES* pThumbnailProperties, 33 | IN VOID* pDCompDevice, 34 | OUT VOID** ppVisual, 35 | OUT PHTHUMBNAIL phThumbnailId); 36 | 37 | typedef HRESULT(WINAPI* DwmpQueryWindowThumbnailSourceSize)( 38 | IN HWND hwndSource, 39 | IN BOOL fSourceClientAreaOnly, 40 | OUT SIZE* pSize); 41 | 42 | typedef HRESULT(WINAPI* DwmpQueryThumbnailType)( 43 | IN HTHUMBNAIL hThumbnailId, 44 | OUT THUMBNAIL_TYPE* thumbType); 45 | 46 | #define DWM_TNP_FREEZE 0x100000 47 | #define DWM_TNP_ENABLE3D 0x4000000 48 | #define DWM_TNP_DISABLE3D 0x8000000 49 | #define DWM_TNP_FORCECVI 0x40000000 50 | #define DWM_TNP_DISABLEFORCECVI 0x80000000 51 | 52 | #pragma region Flags for DWM_THUMBNAIL_PROPERTIES 53 | #define DWM_TNP_RECTDESTINATION 0x00000001 // A value for the "rcDestination" member has been specified. 54 | #define DWM_TNP_RECTSOURCE 0x00000002 // A value for the "rcSource" member has been specified. 55 | #define DWM_TNP_OPACITY 0x00000004 // A value for the "opacity" member has been specified. 56 | #define DWM_TNP_VISIBLE 0x00000008 // A value for the "fVisible" member has been specified. 57 | #define DWM_TNP_SOURCECLIENTAREAONLY 0x00000010 // A value for the "fSourceClientAreaOnly" member has been specified. 58 | #pragma endregion 59 | 60 | typedef LRESULT(CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); 61 | 62 | typedef struct tagWNDCLASSW { 63 | UINT style; 64 | WNDPROC lpfnWndProc; 65 | int cbClsExtra; 66 | int cbWndExtra; 67 | HINSTANCE hInstance; 68 | HICON hIcon; 69 | HCURSOR hCursor; 70 | HBRUSH hbrBackground; 71 | LPCWSTR lpszMenuName; 72 | LPCWSTR lpszClassName; 73 | } WNDCLASSW, * PWNDCLASSW, NEAR* NPWNDCLASSW, FAR* LPWNDCLASSW, WNDCLASS; 74 | 75 | MIDL_INTERFACE("45D64A29-A63E-4CB6-B498-5781D298CB4F") 76 | ICoreWindowInterop : public IUnknown 77 | { 78 | public: 79 | virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_WindowHandle( 80 | /* [retval][out] */ __RPC__deref_out_opt HWND * hwnd) = 0; 81 | 82 | virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_MessageHandled( 83 | /* [in] */ boolean value) = 0; 84 | 85 | }; 86 | 87 | DECLARE_INTERFACE_IID_(IDCompositionDevice, IUnknown, "C37EA93A-E7AA-450D-B16F-9746CB0407F3") 88 | { 89 | //DUMMY 90 | }; 91 | 92 | DECLARE_INTERFACE_IID_(IDCompositionVisual, IUnknown, "4d93059d-097b-4651-9a60-f0f25116e2f3") 93 | { 94 | //DUMMY 95 | }; 96 | 97 | DECLARE_INTERFACE_IID_(IDCompositionVisual2, IDCompositionVisual, "E8DE1639-4331-4B26-BC5F-6A321D347A85") 98 | { 99 | //DUMMY 100 | }; 101 | 102 | typedef HWND 103 | (WINAPI* 104 | FindWindowWProto)( 105 | _In_opt_ LPCWSTR lpClassName, 106 | _In_opt_ LPCWSTR lpWindowName); 107 | 108 | typedef BOOL 109 | (WINAPI* 110 | GetWindowRectProto)( 111 | _In_ HWND hWnd, 112 | _Out_ LPRECT lpRect); 113 | 114 | typedef HWND 115 | (WINAPI* 116 | GetParentProto)( 117 | _In_ HWND hWnd); 118 | 119 | enum WINDOWCOMPOSITIONATTRIB 120 | { 121 | WCA_UNDEFINED = 0x0, 122 | WCA_NCRENDERING_ENABLED = 0x1, 123 | WCA_NCRENDERING_POLICY = 0x2, 124 | WCA_TRANSITIONS_FORCEDISABLED = 0x3, 125 | WCA_ALLOW_NCPAINT = 0x4, 126 | WCA_CAPTION_BUTTON_BOUNDS = 0x5, 127 | WCA_NONCLIENT_RTL_LAYOUT = 0x6, 128 | WCA_FORCE_ICONIC_REPRESENTATION = 0x7, 129 | WCA_EXTENDED_FRAME_BOUNDS = 0x8, 130 | WCA_HAS_ICONIC_BITMAP = 0x9, 131 | WCA_THEME_ATTRIBUTES = 0xA, 132 | WCA_NCRENDERING_EXILED = 0xB, 133 | WCA_NCADORNMENTINFO = 0xC, 134 | WCA_EXCLUDED_FROM_LIVEPREVIEW = 0xD, 135 | WCA_VIDEO_OVERLAY_ACTIVE = 0xE, 136 | WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 0xF, 137 | WCA_DISALLOW_PEEK = 0x10, 138 | WCA_CLOAK = 0x11, 139 | WCA_CLOAKED = 0x12, 140 | WCA_ACCENT_POLICY = 0x13, 141 | WCA_FREEZE_REPRESENTATION = 0x14, 142 | WCA_EVER_UNCLOAKED = 0x15, 143 | WCA_VISUAL_OWNER = 0x16, 144 | WCA_HOLOGRAPHIC = 0x17, 145 | WCA_EXCLUDED_FROM_DDA = 0x18, 146 | WCA_PASSIVEUPDATEMODE = 0x19, 147 | WCA_LAST = 0x1A, 148 | }; 149 | 150 | typedef struct WINDOWCOMPOSITIONATTRIBDATA 151 | { 152 | WINDOWCOMPOSITIONATTRIB Attrib; 153 | void* pvData; 154 | DWORD cbData; 155 | }; 156 | 157 | typedef BOOL(WINAPI* SetWindowCompositionAttribute)( 158 | IN HWND hwnd, 159 | IN WINDOWCOMPOSITIONATTRIBDATA* pwcad); -------------------------------------------------------------------------------- /TenMica/TenMica.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | ARM 7 | 8 | 9 | Debug 10 | ARM64 11 | 12 | 13 | Debug 14 | Win32 15 | 16 | 17 | Debug 18 | x64 19 | 20 | 21 | Release 22 | ARM 23 | 24 | 25 | Release 26 | ARM64 27 | 28 | 29 | Release 30 | Win32 31 | 32 | 33 | Release 34 | x64 35 | 36 | 37 | 38 | {9bce64f0-f93a-4ea1-bc2f-7e6d2667aeba} 39 | WindowsRuntimeComponent 40 | TenMica 41 | en-US 42 | 14.0 43 | true 44 | Windows Store 45 | 10.0.19041.0 46 | 10.0.15063.0 47 | 10.0 48 | 49 | 50 | 51 | DynamicLibrary 52 | true 53 | v143 54 | 55 | 56 | DynamicLibrary 57 | true 58 | v143 59 | 60 | 61 | DynamicLibrary 62 | true 63 | v143 64 | 65 | 66 | DynamicLibrary 67 | true 68 | v143 69 | 70 | 71 | DynamicLibrary 72 | false 73 | true 74 | v143 75 | 76 | 77 | DynamicLibrary 78 | false 79 | true 80 | v143 81 | 82 | 83 | DynamicLibrary 84 | false 85 | true 86 | v143 87 | 88 | 89 | DynamicLibrary 90 | false 91 | true 92 | v143 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | false 127 | 128 | 129 | false 130 | 131 | 132 | false 133 | 134 | 135 | false 136 | $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ 137 | $(Platform)\$(Configuration)\ 138 | 139 | 140 | false 141 | 142 | 143 | false 144 | 145 | 146 | false 147 | 148 | 149 | false 150 | 151 | 152 | 153 | Use 154 | _WINRT_DLL;%(PreprocessorDefinitions) 155 | pch.h 156 | $(IntDir)pch.pch 157 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 158 | /bigobj %(AdditionalOptions) 159 | 28204 160 | 161 | 162 | Console 163 | false 164 | 165 | 166 | 167 | 168 | Use 169 | _WINRT_DLL;%(PreprocessorDefinitions) 170 | pch.h 171 | $(IntDir)pch.pch 172 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 173 | /bigobj %(AdditionalOptions) 174 | 28204 175 | 176 | 177 | Console 178 | false 179 | 180 | 181 | 182 | 183 | Use 184 | _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) 185 | pch.h 186 | $(IntDir)pch.pch 187 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 188 | /bigobj %(AdditionalOptions) 189 | 28204 190 | 191 | 192 | Console 193 | false 194 | 195 | 196 | 197 | 198 | Use 199 | _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) 200 | pch.h 201 | $(IntDir)pch.pch 202 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 203 | 28204 204 | stdcpp17 205 | /bigobj %(AdditionalOptions) 206 | 207 | 208 | Console 209 | false 210 | 211 | 212 | 213 | 214 | Use 215 | _WINRT_DLL;%(PreprocessorDefinitions) 216 | pch.h 217 | $(IntDir)pch.pch 218 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 219 | /bigobj %(AdditionalOptions) 220 | 28204 221 | 222 | 223 | Console 224 | false 225 | 226 | 227 | 228 | 229 | Use 230 | _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) 231 | pch.h 232 | $(IntDir)pch.pch 233 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 234 | /bigobj %(AdditionalOptions) 235 | 28204 236 | 237 | 238 | Console 239 | false 240 | 241 | 242 | 243 | 244 | Use 245 | _WINRT_DLL;%(PreprocessorDefinitions) 246 | pch.h 247 | $(IntDir)pch.pch 248 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 249 | /bigobj %(AdditionalOptions) 250 | 28204 251 | 252 | 253 | Console 254 | false 255 | User32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) 256 | 257 | 258 | 259 | 260 | Use 261 | _WINRT_DLL;NDEBUG;%(PreprocessorDefinitions) 262 | pch.h 263 | $(IntDir)pch.pch 264 | $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) 265 | /bigobj %(AdditionalOptions) 266 | 28204 267 | 268 | 269 | Console 270 | false 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | Create 281 | Create 282 | Create 283 | Create 284 | Create 285 | Create 286 | Create 287 | Create 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 301 | 302 | 303 | 304 | -------------------------------------------------------------------------------- /TenMica/TenMica.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 47d959a8-716b-479e-b919-bcb4cb29cf73 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /TenMica/TenMicaBrush.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TenMicaBrush.h" 3 | using namespace Windows::ApplicationModel; 4 | using namespace Windows::System::Power; 5 | 6 | using namespace TenMica; 7 | using namespace Platform; 8 | 9 | TenMicaBrush::TenMicaBrush() { Init(); } 10 | 11 | TenMicaBrush::TenMicaBrush(ApplicationTheme ForcedTheme) : forcedTheme(ForcedTheme), isThemeForced(true) { Init(); } 12 | 13 | void TenMicaBrush::Init() 14 | { 15 | auto dwmapiLib = LoadLibrary("dwmapi.dll"); 16 | 17 | lDwmpQueryThumbnailType = (DwmpQueryThumbnailType)GetProcAddress(dwmapiLib, MAKEINTRESOURCEA(114)); 18 | lDwmpCreateSharedThumbnailVisual = (DwmpCreateSharedThumbnailVisual)GetProcAddress(dwmapiLib, MAKEINTRESOURCEA(147)); 19 | lDwmpQueryWindowThumbnailSourceSize = (DwmpQueryWindowThumbnailSourceSize)GetProcAddress(dwmapiLib, MAKEINTRESOURCEA(162)); 20 | 21 | GetWindowRect = (GetWindowRectProto)GetProcAddress("user32.dll", "GetWindowRect"); 22 | FindWindow = (FindWindowWProto)GetProcAddress("user32.dll", "FindWindowW"); 23 | GetParent = (GetParentProto)GetProcAddress("user32.dll", "GetParent"); 24 | //lSetWindowCompositionAttribute = (SetWindowCompositionAttribute)GetProcAddress("user32.dll", "SetWindowCompositionAttribute"); 25 | } 26 | 27 | ::CompositionBrush^ TenMicaBrush::BuildMicaEffectBrush(Compositor^ compositor, Visual^ src, Color tintColor, float tintOpacity, float luminosityOpacity, SIZE size) 28 | { 29 | // Tint Color. 30 | 31 | var tintColorEffect = ref new ColorSourceEffect(); 32 | tintColorEffect->Name = "TintColor"; 33 | tintColorEffect->Color = tintColor; 34 | 35 | // OpacityEffect applied to Tint. 36 | var tintOpacityEffect = ref new OpacityEffect(); 37 | tintOpacityEffect->Name = "TintOpacity"; 38 | tintOpacityEffect->Opacity = tintOpacity; 39 | tintOpacityEffect->Source = tintColorEffect; 40 | 41 | // Apply Luminosity: 42 | 43 | // Luminosity Color. 44 | var luminosityColorEffect = ref new ColorSourceEffect(); 45 | luminosityColorEffect->Color = tintColor; 46 | 47 | // OpacityEffect applied to Luminosity. 48 | var luminosityOpacityEffect = ref new OpacityEffect(); 49 | luminosityOpacityEffect->Name = "LuminosityOpacity"; 50 | luminosityOpacityEffect->Opacity = luminosityOpacity; 51 | luminosityOpacityEffect->Source = luminosityColorEffect; 52 | 53 | // Luminosity Blend. 54 | var luminosityBlendEffect = ref new BlendEffect(); 55 | luminosityBlendEffect->Mode = BlendEffectMode::Color; 56 | luminosityBlendEffect->Background = ref new CompositionEffectSourceParameter("BlurredWallpaperBackdrop"); 57 | luminosityBlendEffect->Foreground = luminosityOpacityEffect; 58 | 59 | // Apply Tint: 60 | 61 | // Color Blend. 62 | var colorBlendEffect = ref new BlendEffect(); 63 | colorBlendEffect->Mode = BlendEffectMode::Luminosity; 64 | colorBlendEffect->Background = luminosityBlendEffect; 65 | colorBlendEffect->Foreground = tintOpacityEffect; 66 | 67 | CompositionEffectBrush^ micaEffectBrush = compositor->CreateEffectFactory(colorBlendEffect)->CreateBrush(); 68 | 69 | var srcSize = Windows::Foundation::Numerics::float2::float2(size.cx, size.cy); 70 | 71 | if (surface != nullptr) 72 | { 73 | try 74 | { 75 | Visual^ visual; 76 | visual = surface->SourceVisual; 77 | 78 | surface->SourceVisual = nullptr; 79 | delete surface; 80 | surface = nullptr; 81 | delete visual; 82 | visual = nullptr; 83 | } catch (...) { } 84 | } 85 | 86 | surface = compositor->CreateVisualSurface(); 87 | surface->SourceVisual = src; 88 | surface->SourceSize = srcSize; 89 | 90 | var brushRaw = compositor->CreateSurfaceBrush(surface); 91 | brushRaw->Stretch = CompositionStretch::None; 92 | 93 | 94 | // Blur 95 | var blurEffect = ref new GaussianBlurEffect(); 96 | blurEffect->Name = "Blur"; 97 | blurEffect->BlurAmount = 140.0f; 98 | blurEffect->Source = ref new CompositionEffectSourceParameter("src"); 99 | 100 | var brush = compositor->CreateEffectFactory(blurEffect)->CreateBrush(); 101 | brush->SetSourceParameter("src", brushRaw); 102 | 103 | micaEffectBrush->SetSourceParameter("BlurredWallpaperBackdrop", brush); 104 | 105 | return micaEffectBrush; 106 | } 107 | 108 | // Ugly hack, basically 109 | void TenMicaBrush::UpdateVisual(RECT rect) 110 | { 111 | surface->SourceSize = Windows::Foundation::Numerics::float2::float2(rect.right - rect.left, rect.bottom - rect.top); 112 | surface->SourceOffset = Windows::Foundation::Numerics::float2::float2(rect.left, rect.top); 113 | } 114 | 115 | /*LRESULT CALLBACK HlprWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 116 | { 117 | switch (message) 118 | { 119 | case WM_CLOSE: 120 | //PostQuitMessage(0); 121 | break; 122 | default: 123 | break; 124 | } 125 | return DefWindowProcW(hwnd, message, wParam, lParam); 126 | }*/ 127 | 128 | #define null nullptr 129 | 130 | void TenMicaBrush::OnConnected() 131 | { 132 | if (CompositionBrush != nullptr) return; 133 | 134 | if (DesignMode::DesignModeEnabled) return; 135 | 136 | cWindow = CoreWindow::GetForCurrentThread(); // Assuming we use CoreWindow 137 | CoreWindow^ coreWnd = cWindow; 138 | 139 | if (uiSettings == null) 140 | { 141 | uiSettings = ref new UISettings(); 142 | } 143 | 144 | if (accessibilitySettings == null) 145 | { 146 | accessibilitySettings = ref new AccessibilitySettings(); 147 | } 148 | 149 | fastEffects = CompositionCapabilities::GetForCurrentView()->AreEffectsFast(); 150 | 151 | energySaver = PowerManager::EnergySaverStatus == EnergySaverStatus::On; 152 | 153 | windowActivated = coreWnd->ActivationMode == CoreWindowActivationMode::ActivatedInForeground 154 | || (enableInActivatedNotForeground && coreWnd->ActivationMode == CoreWindowActivationMode::ActivatedNotForeground); 155 | 156 | ComPtr coreWndRaw; 157 | coreWndRaw = reinterpret_cast(coreWnd); 158 | 159 | // Getting our HWND 160 | ComPtr interop; 161 | coreWndRaw.As(&interop); 162 | interop->get_WindowHandle(&cHwnd); 163 | 164 | // TEMP HACK-y WORKAROUND 165 | 166 | /*HINSTANCE hInstance = GetModuleHandle3(); 167 | 168 | WNDCLASS wc = {}; 169 | wc.lpfnWndProc = HlprWndProc; 170 | wc.hInstance = hInstance; 171 | wc.cbWndExtra = 0; 172 | wc.lpszClassName = L"TenMicaHelperWindow"; 173 | 174 | RegisterClassW(&wc); 175 | 176 | hwndHelper = CreateWindowExW(WS_EX_NOREDIRECTIONBITMAP | WS_EX_LAYERED | WS_EX_TRANSPARENT, L"TenMicaHelperWindow", L"TenMicaHelperWindow", 177 | NULL, CW_USEDEFAULT, CW_USEDEFAULT, 1, 1, 178 | nullptr, nullptr, hInstance, NULL); 179 | 180 | BOOL enable = TRUE; 181 | WINDOWCOMPOSITIONATTRIBDATA wData{}; 182 | wData.Attrib = WCA_CLOAK; 183 | wData.pvData = &enable; 184 | wData.cbData = sizeof(BOOL); 185 | lSetWindowCompositionAttribute(hwndHelper, &wData); 186 | 187 | ShowWindow(hwndHelper, SW_SHOWNA);*/ 188 | 189 | UpdateBrush(); 190 | 191 | OnActivatedCookie = coreWnd->Activated += ref new Windows::Foundation::TypedEventHandler(this, &TenMica::TenMicaBrush::OnActivated); 192 | 193 | OnColorValuesChangedCookie = uiSettings->ColorValuesChanged += ref new Windows::Foundation::TypedEventHandler(this, &TenMica::TenMicaBrush::OnColorValuesChanged); 194 | OnHighContrastChangedCookie = accessibilitySettings->HighContrastChanged += ref new Windows::Foundation::TypedEventHandler(this, &TenMica::TenMicaBrush::OnHighContrastChanged); 195 | OnCompositionCapabilitiesChangedCookie = CompositionCapabilities::GetForCurrentView()->Changed += ref new Windows::Foundation::TypedEventHandler(this, &TenMica::TenMicaBrush::OnCompositionCapabilitiesChanged); 196 | OnEnergySaverStatusChangedCookie = PowerManager::EnergySaverStatusChanged += ref new Windows::Foundation::EventHandler(this, &TenMica::TenMicaBrush::OnEnergySaverStatusChanged); 197 | 198 | IInternalCoreWindow2^ internalW = (IInternalCoreWindow2^)coreWnd; // Pure black magic 199 | 200 | // Syncing!! 201 | OnWindowPositionChangedCookie = internalW->WindowPositionChanged += ref new TypedEventHandler(this, &TenMicaBrush::OnWindowPositionChanged); 202 | 203 | IInternalCoreWindow^ internalW1 = (IInternalCoreWindow^)coreWnd; // Pure blue magic 204 | OnDisplayChangedCookie = internalW1->DisplayChanged += ref new Windows::Foundation::TypedEventHandler(this, &TenMica::TenMicaBrush::OnDisplayChanged); 205 | } 206 | 207 | void TenMicaBrush::OnDisplayChanged(Windows::UI::Core::CoreWindow^ sender, Platform::Object^ args) 208 | { 209 | sender->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 210 | { 211 | UpdateBrush(); 212 | })); 213 | } 214 | 215 | void TenMicaBrush::OnWindowPositionChanged(IInternalCoreWindow2^ window, Platform::Object^ args) 216 | { 217 | if (surface != nullptr) 218 | { 219 | RECT rect; 220 | GetWindowRect(cHwnd, &rect); 221 | UpdateVisual(rect); 222 | } 223 | } 224 | 225 | void TenMicaBrush::OnColorValuesChanged(UISettings^ sender, Object^ args) 226 | { 227 | cWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 228 | { 229 | UpdateBrush(); 230 | })); 231 | } 232 | 233 | void TenMicaBrush::OnHighContrastChanged(AccessibilitySettings^ sender, Platform::Object^ args) 234 | { 235 | cWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 236 | { 237 | UpdateBrush(); 238 | })); 239 | } 240 | 241 | void TenMicaBrush::OnEnergySaverStatusChanged(Platform::Object^ sender, Platform::Object^ e) 242 | { 243 | cWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 244 | { 245 | energySaver = PowerManager::EnergySaverStatus == EnergySaverStatus::On; 246 | UpdateBrush(); 247 | })); 248 | } 249 | 250 | void TenMicaBrush::OnCompositionCapabilitiesChanged(CompositionCapabilities^ sender, Platform::Object^ args) 251 | { 252 | cWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 253 | { 254 | fastEffects = CompositionCapabilities::GetForCurrentView()->AreEffectsFast(); 255 | UpdateBrush(); 256 | })); 257 | } 258 | 259 | void TenMicaBrush::OnActivated(CoreWindow^ sender, WindowActivatedEventArgs^ args) 260 | { 261 | sender->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, sender]() 262 | { 263 | var activated = sender->ActivationMode == CoreWindowActivationMode::ActivatedInForeground 264 | || (enableInActivatedNotForeground && (sender->ActivationMode == CoreWindowActivationMode::ActivatedNotForeground || sender->Visible)); 265 | if (windowActivated && activated == windowActivated) 266 | { 267 | return; 268 | } 269 | windowActivated = activated; 270 | UpdateBrush(); 271 | })); 272 | } 273 | 274 | ::CompositionBrush^ TenMicaBrush::CreateCrossFadeEffectBrush(Compositor^ compositor, ::CompositionBrush^ from, ::CompositionBrush^ to) 275 | { 276 | var crossFadeEffect = ref new CrossFadeEffect(); 277 | crossFadeEffect->Name = "Crossfade"; // Name to reference when starting the animation. 278 | crossFadeEffect->Source1 = ref new CompositionEffectSourceParameter("source1"); 279 | crossFadeEffect->Source2 = ref new CompositionEffectSourceParameter("source2"); 280 | crossFadeEffect->CrossFade = 0; 281 | 282 | auto list = ref new Platform::Collections::Vector(); 283 | list->Append("Crossfade.CrossFade"); 284 | 285 | CompositionEffectBrush^ crossFadeEffectBrush = compositor->CreateEffectFactory(crossFadeEffect, list)->CreateBrush(); 286 | crossFadeEffectBrush->Comment = "Crossfade"; 287 | // The inputs have to be swapped here to work correctly... 288 | crossFadeEffectBrush->SetSourceParameter("source1", to); 289 | crossFadeEffectBrush->SetSourceParameter("source2", from); 290 | return crossFadeEffectBrush; 291 | } 292 | 293 | ScalarKeyFrameAnimation^ TenMicaBrush::CreateCrossFadeAnimation(Compositor^ compositor) 294 | { 295 | ScalarKeyFrameAnimation^ animation = compositor->CreateScalarKeyFrameAnimation(); 296 | LinearEasingFunction^ linearEasing = compositor->CreateLinearEasingFunction(); 297 | animation->InsertKeyFrame(0.0f, 0.0f, linearEasing); 298 | animation->InsertKeyFrame(1.0f, 1.0f, linearEasing); 299 | animation->Duration = TimeSpan{ 2500000 }; 300 | return animation; 301 | } 302 | 303 | void TenMicaBrush::UpdateBrush() 304 | { 305 | if (uiSettings == nullptr || accessibilitySettings == nullptr) 306 | { 307 | return; 308 | } 309 | 310 | bool useSolidColorFallback = !windowActivated || fastEffects == false || energySaver == true || !uiSettings->AdvancedEffectsEnabled; 311 | 312 | var compositor = Window::Current->Compositor; 313 | 314 | var isLightMode = isThemeForced ? ForcedTheme == ApplicationTheme::Light : Application::Current->RequestedTheme == ApplicationTheme::Light; 315 | Color tintColor = isLightMode ? Color{ 255, 243, 243, 243 } : Color{ 255, 32, 32, 32 }; 316 | float tintOpacity = isLightMode ? 0.5f : 0.8f; 317 | 318 | if (accessibilitySettings->HighContrast) 319 | { 320 | tintColor = uiSettings->GetColorValue(UIColorType::Background); 321 | useSolidColorFallback = true; 322 | } 323 | 324 | FallbackColor = tintColor; 325 | 326 | ::CompositionBrush^ newBrush; 327 | 328 | if (useSolidColorFallback) 329 | { 330 | newBrush = compositor->CreateColorBrush(tintColor); 331 | } 332 | else 333 | { 334 | CoreWindow^ coreWnd = cWindow; // Assuming we use CoreWindow 335 | 336 | HWND targetWindow = (HWND)FindWindow(L"Progman", NULL); // Progman is still the name of the Desktop window :)))) 337 | 338 | SIZE windowSize{}; 339 | lDwmpQueryWindowThumbnailSourceSize(targetWindow, FALSE, &windowSize); 340 | 341 | // Officially documented 342 | DWM_THUMBNAIL_PROPERTIES thumb{}; 343 | thumb.dwFlags = DWM_TNP_SOURCECLIENTAREAONLY | DWM_TNP_VISIBLE | DWM_TNP_RECTDESTINATION | DWM_TNP_RECTSOURCE | DWM_TNP_OPACITY | DWM_TNP_ENABLE3D; 344 | thumb.opacity = 255; 345 | thumb.fVisible = TRUE; 346 | thumb.fSourceClientAreaOnly = TRUE; 347 | thumb.rcDestination = RECT{ 0, 0, windowSize.cx, windowSize.cy }; 348 | thumb.rcSource = RECT{ 0, 0, windowSize.cx, windowSize.cy }; 349 | 350 | HTHUMBNAIL hThumbWindow; 351 | ComPtr windowVisual; 352 | 353 | //TODO: check if comp implements IDCompositionDevice before calling, it doesn't implement it if we aren't running under XAML or having no InteropCompositor 354 | auto result = lDwmpCreateSharedThumbnailVisual(GetParent(cHwnd), targetWindow, 2, &thumb, (IDCompositionDevice*)compositor, (void**)windowVisual.GetAddressOf(), &hThumbWindow); 355 | 356 | // you can cast directly but this is safer, like in case we don't have an InteropCompositor 357 | ComPtr visualRaw; 358 | windowVisual.As(&visualRaw); 359 | //TODO: check if visualRaw isn't nullptr before casting 360 | auto visual = reinterpret_cast(visualRaw.Get()); 361 | 362 | newBrush = BuildMicaEffectBrush(compositor, visual, tintColor, tintOpacity, 1.0f, windowSize); 363 | 364 | RECT rect; 365 | GetWindowRect(cHwnd, &rect); 366 | UpdateVisual(rect); 367 | } 368 | 369 | ::CompositionBrush^ oldBrush = CompositionBrush; 370 | 371 | if (oldBrush == nullptr || (CompositionBrush->Comment == "Crossfade") || (dynamic_cast(oldBrush) != nullptr && dynamic_cast(newBrush) != nullptr)) 372 | { 373 | // Set new brush directly 374 | if (oldBrush != nullptr) 375 | { 376 | delete oldBrush; 377 | } 378 | CompositionBrush = newBrush; 379 | } 380 | else 381 | { 382 | // Crossfade 383 | ::CompositionBrush^ crossFadeBrush = CreateCrossFadeEffectBrush(compositor, oldBrush, newBrush); 384 | ScalarKeyFrameAnimation^ animation = CreateCrossFadeAnimation(compositor); 385 | CompositionBrush = crossFadeBrush; 386 | 387 | var crossFadeAnimationBatch = compositor->CreateScopedBatch(CompositionBatchTypes::Animation); 388 | crossFadeBrush->StartAnimation("CrossFade.CrossFade", animation); 389 | crossFadeAnimationBatch->End(); 390 | 391 | crossFadeAnimationBatch->Completed += ref new TypedEventHandler([this, crossFadeBrush, oldBrush, newBrush](Platform::Object^, CompositionBatchCompletedEventArgs^) 392 | { 393 | delete crossFadeBrush; 394 | delete oldBrush; 395 | this->CompositionBrush = newBrush; 396 | }); 397 | } 398 | } 399 | 400 | void TenMicaBrush::OnDisconnected() 401 | { 402 | //TODO: do proper disposing 403 | if (CompositionBrush != nullptr) 404 | { 405 | try 406 | { 407 | delete CompositionBrush; 408 | CompositionBrush = null; 409 | 410 | if (cWindow != null) 411 | { 412 | cWindow->Activated -= OnActivatedCookie; 413 | IInternalCoreWindow2^ internalW = (IInternalCoreWindow2^)cWindow; 414 | internalW->WindowPositionChanged -= OnWindowPositionChangedCookie; 415 | 416 | IInternalCoreWindow^ internalW1 = (IInternalCoreWindow^)cWindow; 417 | internalW1->DisplayChanged -= OnDisplayChangedCookie; 418 | 419 | cWindow = null; 420 | } 421 | 422 | if (uiSettings != null) 423 | { 424 | uiSettings->ColorValuesChanged -= OnColorValuesChangedCookie; 425 | uiSettings = null; 426 | } 427 | 428 | if (accessibilitySettings != null) 429 | { 430 | accessibilitySettings->HighContrastChanged -= OnHighContrastChangedCookie; 431 | accessibilitySettings = null; 432 | } 433 | 434 | CompositionCapabilities::GetForCurrentView()->Changed -= OnCompositionCapabilitiesChangedCookie; 435 | PowerManager::EnergySaverStatusChanged -= OnEnergySaverStatusChangedCookie; 436 | 437 | Visual^ visual; 438 | visual = surface->SourceVisual; 439 | 440 | surface->SourceVisual = null; 441 | delete surface; 442 | surface = null; 443 | //delete visual; 444 | visual = null; 445 | } catch (...) { } 446 | } 447 | } 448 | 449 | ApplicationTheme TenMicaBrush::ForcedTheme::get() { return forcedTheme; } 450 | 451 | void TenMicaBrush::ForcedTheme::set(ApplicationTheme value) 452 | { 453 | forcedTheme = value; 454 | isThemeForced = true; 455 | 456 | UpdateBrush(); 457 | } 458 | 459 | bool TenMicaBrush::IsThemeForced::get() { return isThemeForced; } 460 | 461 | void TenMicaBrush::IsThemeForced::set(bool value) 462 | { 463 | isThemeForced = value; 464 | UpdateBrush(); 465 | } 466 | 467 | bool TenMicaBrush::EnabledInActivatedNotForeground::get() { return enableInActivatedNotForeground; } 468 | 469 | void TenMicaBrush::EnabledInActivatedNotForeground::set(bool value) 470 | { 471 | enableInActivatedNotForeground = value; 472 | UpdateBrush(); 473 | } -------------------------------------------------------------------------------- /TenMica/TenMicaBrush.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace Platform; 17 | using namespace Microsoft::WRL; 18 | using namespace Windows::Foundation; 19 | using namespace Windows::Foundation::Collections; 20 | using namespace Windows::Devices::Input; 21 | using namespace Windows::UI::Xaml; 22 | using namespace Windows::UI::Core; 23 | using namespace Windows::UI; 24 | using namespace Windows::UI::Input; 25 | using namespace Windows::UI::Composition; 26 | using namespace Windows::UI::Xaml::Controls; 27 | using namespace Windows::UI::Xaml::Controls::Primitives; 28 | using namespace Windows::UI::Xaml::Data; 29 | using namespace Windows::UI::Xaml::Input; 30 | using namespace Windows::UI::Xaml::Media; 31 | using namespace Windows::UI::Xaml::Navigation; 32 | using namespace Microsoft::Graphics::Canvas::Effects; 33 | using namespace Windows::UI::ViewManagement; 34 | 35 | #define var auto 36 | 37 | #pragma pack (8) // C++/CX is stupid and won't allow us to compile on x86/Win32 without this... 38 | 39 | namespace TenMica 40 | { 41 | private enum class FullScreenType //FULL_SCREEN_TYPE 42 | { 43 | Standard = 0x0, 44 | Minimal = 0x1, 45 | SuppressSystemOverlays = 0x2, 46 | None = 0x3, 47 | }; 48 | 49 | [uuid("42a17e3d-7171-439a-b1fa-a31b7b957489")] 50 | private interface class IInternalCoreWindow 51 | { 52 | property MouseDevice^ MouseDevice { ::MouseDevice^ get(); } 53 | property int ApplicationViewState { int get(); } 54 | property int ApplicationViewOrientation { int get(); } 55 | property int AdjacentDisplayEdges { int get(); } 56 | property bool IsOnLockScreen{ bool get(); } 57 | property PointerVisualizationSettings^ PointerVisualizationSettings { ::PointerVisualizationSettings^ get(); } 58 | property CoreWindowResizeManager^ CoreWindowResizeManager { ::CoreWindowResizeManager^ get(); } 59 | property bool IsScreenCaptureEnabled; 60 | property FullScreenType SuppressSystemOverlays; 61 | event TypedEventHandler^ ThemeChanged; 62 | event TypedEventHandler^ ContextMenuRequested; 63 | event TypedEventHandler^ DisplayChanged; 64 | event TypedEventHandler^ Consolidated; 65 | }; 66 | 67 | [uuid("c12779d8-85d2-43e5-901a-95dd4f8ecba3")] 68 | private interface class IInternalCoreWindow2 69 | { 70 | property Rect LayoutBounds { Rect get(); } 71 | property Rect VisibleBounds { Rect get(); } 72 | property ApplicationViewBoundsMode DesiredBoundsMode { ApplicationViewBoundsMode get(); } 73 | bool SetDesiredBoundsMode(ApplicationViewBoundsMode mode); 74 | void OnVisibleBoundsChange(); 75 | event TypedEventHandler^ LayoutBoundsChanged; 76 | event TypedEventHandler^ VisibleBoundsChanged; 77 | event TypedEventHandler^ SysKeyDown; 78 | event TypedEventHandler^ SysKeyUp; 79 | event TypedEventHandler^ WindowPositionChanged; 80 | event TypedEventHandler^ SettingChanged; 81 | event TypedEventHandler^ ViewStateChanged; 82 | event TypedEventHandler^ Destroying; 83 | }; 84 | 85 | //TODO: inherit from IXamlCompositionBrushBaseOverridesPrivate to support non-full-window Mica scenarios 86 | //TODO: add support for AppWindow, do not assume CoreWindow 87 | //TODO: add multi-monitor support 88 | //TODO: handle theming properly 89 | 90 | public ref class TenMicaBrush sealed : XamlCompositionBrushBase 91 | { 92 | private: 93 | DwmpQueryThumbnailType lDwmpQueryThumbnailType; 94 | DwmpCreateSharedThumbnailVisual lDwmpCreateSharedThumbnailVisual; 95 | DwmpQueryWindowThumbnailSourceSize lDwmpQueryWindowThumbnailSourceSize; 96 | GetWindowRectProto GetWindowRect; 97 | FindWindowWProto FindWindow; 98 | GetParentProto GetParent; 99 | SetWindowCompositionAttribute lSetWindowCompositionAttribute; 100 | 101 | ApplicationTheme forcedTheme; 102 | bool isThemeForced = false; 103 | bool fastEffects; 104 | bool energySaver; 105 | UISettings^ uiSettings; 106 | AccessibilitySettings^ accessibilitySettings; 107 | bool windowActivated; 108 | bool enableInActivatedNotForeground = false; 109 | HWND hwndHelper; 110 | 111 | CompositionVisualSurface^ surface; 112 | CoreWindow^ cWindow; 113 | HWND cHwnd; 114 | 115 | Windows::Foundation::EventRegistrationToken OnActivatedCookie; 116 | Windows::Foundation::EventRegistrationToken OnColorValuesChangedCookie; 117 | Windows::Foundation::EventRegistrationToken OnHighContrastChangedCookie; 118 | Windows::Foundation::EventRegistrationToken OnEnergySaverStatusChangedCookie; 119 | Windows::Foundation::EventRegistrationToken OnCompositionCapabilitiesChangedCookie; 120 | Windows::Foundation::EventRegistrationToken OnWindowPositionChangedCookie; 121 | Windows::Foundation::EventRegistrationToken OnDisplayChangedCookie; 122 | 123 | void Init(); 124 | ::CompositionBrush^ BuildMicaEffectBrush(Compositor^ compositor, Visual^ src, Color tintColor, float tintOpacity, float luminosityOpacity, SIZE size); 125 | void UpdateVisual(RECT rect); 126 | ::CompositionBrush^ CreateCrossFadeEffectBrush(Compositor^ compositor, ::CompositionBrush^ from, ::CompositionBrush^ to); 127 | ScalarKeyFrameAnimation^ CreateCrossFadeAnimation(Compositor^ compositor); 128 | void UpdateBrush(); 129 | void OnActivated(CoreWindow^ sender, WindowActivatedEventArgs^ args); 130 | void OnColorValuesChanged(UISettings^ sender, Object^ args); 131 | void OnHighContrastChanged(AccessibilitySettings^ sender, Platform::Object^ args); 132 | void OnEnergySaverStatusChanged(Platform::Object^ sender, Platform::Object^ e); 133 | void OnCompositionCapabilitiesChanged(CompositionCapabilities^ sender, Platform::Object^ args); 134 | void OnWindowPositionChanged(IInternalCoreWindow2^ window, Platform::Object^ args); 135 | void OnDisplayChanged(Windows::UI::Core::CoreWindow^ sender, Platform::Object^ args); 136 | public: 137 | TenMicaBrush(); 138 | TenMicaBrush(ApplicationTheme ForcedTheme); 139 | 140 | property bool IsThemeForced { bool get(); void set(bool value); } 141 | property bool EnabledInActivatedNotForeground { bool get(); void set(bool value); } 142 | property ApplicationTheme ForcedTheme { ApplicationTheme get(); void set(ApplicationTheme value); } 143 | protected: 144 | virtual void OnConnected() override; 145 | virtual void OnDisconnected() override; 146 | }; 147 | } 148 | -------------------------------------------------------------------------------- /TenMica/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /TenMica/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /TenMica/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /* 7 | MIT License 8 | Copyright (c) 2019 Gustave Monce - @gus33000 - gus33000.me 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 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. 24 | */ 25 | 26 | #undef WINAPI_PARTITION_SYSTEM 27 | #define WINAPI_PARTITION_SYSTEM 1 28 | #include 29 | #undef WINAPI_PARTITION_SYSTEM 30 | #define WINAPI_PARTITION_SYSTEM 0 31 | 32 | // Redefine PEB structures. The structure definitions in winternl.h are incomplete. 33 | typedef struct _MY_PEB_LDR_DATA { 34 | ULONG Length; 35 | BOOL Initialized; 36 | PVOID SsHandle; 37 | LIST_ENTRY InLoadOrderModuleList; 38 | LIST_ENTRY InMemoryOrderModuleList; 39 | LIST_ENTRY InInitializationOrderModuleList; 40 | } MY_PEB_LDR_DATA, * PMY_PEB_LDR_DATA; 41 | 42 | typedef struct _MY_LDR_DATA_TABLE_ENTRY 43 | { 44 | LIST_ENTRY InLoadOrderLinks; 45 | LIST_ENTRY InMemoryOrderLinks; 46 | LIST_ENTRY InInitializationOrderLinks; 47 | PVOID DllBase; 48 | PVOID EntryPoint; 49 | ULONG SizeOfImage; 50 | UNICODE_STRING FullDllName; 51 | UNICODE_STRING BaseDllName; 52 | } MY_LDR_DATA_TABLE_ENTRY, * PMY_LDR_DATA_TABLE_ENTRY; 53 | 54 | using namespace Platform; 55 | 56 | #include 57 | 58 | inline String^ Str(UNICODE_STRING US) { 59 | wchar_t* str = (wchar_t*)malloc(US.Length + sizeof(wchar_t)); 60 | memcpy(str, US.Buffer, US.Length); 61 | str[US.Length / sizeof(wchar_t)] = 0; 62 | String^ ret = ref new String(str); 63 | free(str); 64 | return ret; 65 | } 66 | 67 | inline String^ Str(const char* char_array) { 68 | std::string s_str = std::string(char_array); 69 | std::wstring wid_str = std::wstring(s_str.begin(), s_str.end()); 70 | const wchar_t* w_char = wid_str.c_str(); 71 | return ref new String(w_char); 72 | } 73 | 74 | inline String^ ToLower(String^ str) { 75 | std::wstring wid_str = str->Data(); 76 | std::transform(wid_str.begin(), wid_str.end(), wid_str.begin(), ::tolower); 77 | return ref new String(wid_str.c_str()); 78 | } 79 | 80 | inline PEB* NtCurrentPeb() { 81 | #ifdef _M_X64 82 | return (PEB*)(__readgsqword(0x60)); 83 | #elif _M_IX86 84 | return (PEB*)(__readfsdword(0x30)); 85 | #elif _M_ARM 86 | return *(PEB**)(_MoveFromCoprocessor(15, 0, 13, 0, 2) + 0x30); 87 | #elif _M_ARM64 88 | return *(PEB**)(__getReg(18) + 0x60); // TEB in x18 89 | #elif _M_IA64 90 | return *(PEB**)(_rdteb() + 0x60); 91 | #elif _M_ALPHA 92 | return *(PEB**)(_rdteb() + 0x30); 93 | #elif _M_MIPS 94 | return *(PEB**)((*(char**)(0x7ffff030)) + 0x30); 95 | #elif _M_PPC 96 | // winnt.h of the period uses __builtin_get_gpr13() or __gregister_get(13) depending on _MSC_VER 97 | return *(PEB**)(__gregister_get(13) + 0x30); 98 | #else 99 | #error "This architecture is currently unsupported" 100 | #endif 101 | }; 102 | 103 | inline FARPROC GetProcAddress(String^ dll, String^ func) { 104 | dll = ToLower(dll); 105 | func = ToLower(func); 106 | auto Ldr = (PMY_PEB_LDR_DATA)(NtCurrentPeb()->Ldr); 107 | auto NextModule = Ldr->InLoadOrderModuleList.Flink; 108 | auto TableEntry = (PMY_LDR_DATA_TABLE_ENTRY)NextModule; 109 | while (TableEntry->DllBase != NULL) { 110 | PVOID base = TableEntry->DllBase; 111 | String^ dllName = ToLower(Str(TableEntry->BaseDllName)); 112 | auto PE = (PIMAGE_NT_HEADERS)((ULONG_PTR)base + ((PIMAGE_DOS_HEADER)base)->e_lfanew); 113 | auto exportdirRVA = PE->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; 114 | TableEntry = (PMY_LDR_DATA_TABLE_ENTRY)TableEntry->InLoadOrderLinks.Flink; 115 | 116 | if (exportdirRVA == 0) continue; 117 | if (dllName != dll) continue; 118 | 119 | auto Exports = (PIMAGE_EXPORT_DIRECTORY)((ULONG_PTR)base + exportdirRVA); 120 | auto Names = (PDWORD)((PCHAR)base + Exports->AddressOfNames); 121 | auto Ordinals = (PUSHORT)((ULONG_PTR)base + Exports->AddressOfNameOrdinals); 122 | auto Functions = (PDWORD)((ULONG_PTR)base + Exports->AddressOfFunctions); 123 | 124 | for (uint32 iterator = 0; iterator < Exports->NumberOfNames; iterator++) { 125 | String^ funcName = ToLower(Str((PCSTR)(Names[iterator] + (ULONG_PTR)base))); 126 | 127 | if (funcName != func) continue; 128 | 129 | USHORT ordTblIndex = Ordinals[iterator]; 130 | return (FARPROC)((ULONG_PTR)base + Functions[ordTblIndex]); 131 | } 132 | } 133 | return NULL; 134 | } 135 | 136 | inline HMODULE GetModuleHandle2(String^ dll) { 137 | dll = ToLower(dll); 138 | auto Ldr = (PMY_PEB_LDR_DATA)(NtCurrentPeb()->Ldr); 139 | auto NextModule = Ldr->InLoadOrderModuleList.Flink; 140 | auto TableEntry = (PMY_LDR_DATA_TABLE_ENTRY)NextModule; 141 | while (TableEntry->DllBase != NULL) { 142 | PVOID base = TableEntry->DllBase; 143 | String^ dllName = ToLower(Str(TableEntry->BaseDllName)); 144 | auto PE = (PIMAGE_NT_HEADERS)((ULONG_PTR)base + ((PIMAGE_DOS_HEADER)base)->e_lfanew); 145 | auto exportdirRVA = PE->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; 146 | TableEntry = (PMY_LDR_DATA_TABLE_ENTRY)TableEntry->InLoadOrderLinks.Flink; 147 | 148 | if (exportdirRVA == 0) continue; 149 | if (dllName != dll) continue; 150 | 151 | return (HMODULE)base; 152 | } 153 | return NULL; 154 | } 155 | 156 | inline HMODULE GetModuleHandle3() { 157 | auto Ldr = (PMY_PEB_LDR_DATA)(NtCurrentPeb()->Ldr); 158 | auto NextModule = Ldr->InLoadOrderModuleList.Flink; 159 | auto TableEntry = (PMY_LDR_DATA_TABLE_ENTRY)NextModule; 160 | return (HMODULE)TableEntry->DllBase; 161 | } 162 | 163 | inline HMODULE LoadLibrary(String^ dll) 164 | { 165 | typedef HMODULE(WINAPI* LoadLibraryProto)(_In_ LPCTSTR); 166 | auto LoadLibraryW = (LoadLibraryProto)(GetProcAddress(GetModuleHandle2("kernel32.dll"), "LoadLibraryW")); 167 | 168 | return LoadLibraryW(dll->Data()); 169 | } --------------------------------------------------------------------------------