├── .gitattributes ├── .gitignore ├── ColorWheelIcon.PNG ├── LICENSE ├── MaterialColorWheelDemo.sln ├── MaterialColorWheelDemo.sln.DotSettings ├── MaterialColorWheelDemo ├── App.config ├── App.xaml ├── App.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── MainWindowViewModel.cs ├── MaterialColorWheelDemo.csproj ├── Properties │ ├── Annotations.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── MaterialDesignAddon.nuspec ├── MaterialDesignAddon ├── Controls │ ├── MaterialColorWheel.cs │ ├── MaterialStatusBar.cs │ └── SimpleMaterialWindow.cs ├── Helpers │ └── VisualTreeHelper.cs ├── MaterialDesignAddon.csproj ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Themes │ ├── Generic.xaml │ ├── MaterialColorWheel.xaml │ ├── MaterialStatusBar.xaml │ └── SimpleMaterialWindow.xaml └── packages.config └── Readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Windows Store app package directory 170 | AppPackages/ 171 | BundleArtifacts/ 172 | 173 | # Visual Studio cache files 174 | # files ending in .cache can be ignored 175 | *.[Cc]ache 176 | # but keep track of directories ending in .cache 177 | !*.[Cc]ache/ 178 | 179 | # Others 180 | ClientBin/ 181 | [Ss]tyle[Cc]op.* 182 | ~$* 183 | *~ 184 | *.dbmdl 185 | *.dbproj.schemaview 186 | *.pfx 187 | *.publishsettings 188 | node_modules/ 189 | orleans.codegen.cs 190 | 191 | # RIA/Silverlight projects 192 | Generated_Code/ 193 | 194 | # Backup & report files from converting an old project file 195 | # to a newer Visual Studio version. Backup files are not needed, 196 | # because we have git ;-) 197 | _UpgradeReport_Files/ 198 | Backup*/ 199 | UpgradeLog*.XML 200 | UpgradeLog*.htm 201 | 202 | # SQL Server files 203 | *.mdf 204 | *.ldf 205 | 206 | # Business Intelligence projects 207 | *.rdl.data 208 | *.bim.layout 209 | *.bim_*.settings 210 | 211 | # Microsoft Fakes 212 | FakesAssemblies/ 213 | 214 | # GhostDoc plugin setting file 215 | *.GhostDoc.xml 216 | 217 | # Node.js Tools for Visual Studio 218 | .ntvs_analysis.dat 219 | 220 | # Visual Studio 6 build log 221 | *.plg 222 | 223 | # Visual Studio 6 workspace options file 224 | *.opt 225 | 226 | # Visual Studio LightSwitch build output 227 | **/*.HTMLClient/GeneratedArtifacts 228 | **/*.DesktopClient/GeneratedArtifacts 229 | **/*.DesktopClient/ModelManifest.xml 230 | **/*.Server/GeneratedArtifacts 231 | **/*.Server/ModelManifest.xml 232 | _Pvt_Extensions 233 | 234 | # LightSwitch generated files 235 | GeneratedArtifacts/ 236 | ModelManifest.xml 237 | 238 | # Paket dependency manager 239 | .paket/paket.exe 240 | 241 | # FAKE - F# Make 242 | .fake/ 243 | -------------------------------------------------------------------------------- /ColorWheelIcon.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tstephansen/MaterialColorWheelDemo/cb10110911591b8b3803dfe3af6706a892cf4e19/ColorWheelIcon.PNG -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /MaterialColorWheelDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialColorWheelDemo", "MaterialColorWheelDemo\MaterialColorWheelDemo.csproj", "{D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialDesignAddon", "MaterialDesignAddon\MaterialDesignAddon.csproj", "{2306B263-506A-4030-A360-EDF57125EC0C}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BE36B6B1-D1D8-49AB-A511-D58F9EE0A5D1}" 11 | ProjectSection(SolutionItems) = preProject 12 | MaterialDesignAddon.nuspec = MaterialDesignAddon.nuspec 13 | Readme.md = Readme.md 14 | EndProjectSection 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2306B263-506A-4030-A360-EDF57125EC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2306B263-506A-4030-A360-EDF57125EC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2306B263-506A-4030-A360-EDF57125EC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2306B263-506A-4030-A360-EDF57125EC0C}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(CodealikeProperties) = postSolution 35 | SolutionGuid = 0788a22c-a5cb-4975-b993-962f7b6e0545 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True -------------------------------------------------------------------------------- /MaterialColorWheelDemo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace MaterialColorWheelDemo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 43 | 51 | 59 | 67 | 75 | 83 | 91 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 118 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace MaterialColorWheelDemo 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | using System.Runtime.CompilerServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Threading; 9 | 10 | namespace MaterialColorWheelDemo 11 | { 12 | public class MainWindowViewModel : INotifyPropertyChanged 13 | { 14 | public MainWindowViewModel() 15 | { 16 | TimeText = DateTime.Now.ToShortTimeString(); 17 | var statusTimer = new DispatcherTimer(); 18 | statusTimer.Tick += DispatcherTimer_Tick; 19 | statusTimer.Interval = new TimeSpan(0, 0, 1); 20 | statusTimer.Start(); 21 | SetStatusBarText(""); 22 | } 23 | 24 | private void DispatcherTimer_Tick(object sender, EventArgs eventArgs) 25 | { 26 | TimeText = DateTime.Now.ToShortTimeString(); 27 | } 28 | 29 | private void SetStatusBarText(string text) 30 | { 31 | StatusBarText = text; 32 | } 33 | 34 | private string _statusBarText; 35 | 36 | /// 37 | /// Gets or sets the status bar text. 38 | /// 39 | /// The status bar text. 40 | public string StatusBarText 41 | { 42 | get { return _statusBarText; } 43 | set 44 | { 45 | if (_statusBarText != value) 46 | { 47 | _statusBarText = value; 48 | OnPropertyChanged(); 49 | } 50 | } 51 | } 52 | 53 | private string _timeText; 54 | 55 | /// 56 | /// Gets or sets the time text. 57 | /// 58 | /// The time text. 59 | public string TimeText 60 | { 61 | get { return _timeText; } 62 | set 63 | { 64 | if (_timeText != value) 65 | { 66 | _timeText = value; 67 | OnPropertyChanged(); 68 | } 69 | } 70 | } 71 | 72 | #region INPC 73 | public event PropertyChangedEventHandler PropertyChanged; 74 | 75 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 76 | { 77 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 78 | } 79 | #endregion 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/MaterialColorWheelDemo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D2E4BF91-DBAF-4D64-AFDD-2749B78BCF41} 8 | WinExe 9 | Properties 10 | MaterialColorWheelDemo 11 | MaterialColorWheelDemo 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | true 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Dragablz.0.0.3.182\lib\net45\Dragablz.dll 41 | True 42 | 43 | 44 | ..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll 45 | True 46 | 47 | 48 | ..\packages\MaterialDesignThemes.2.2.1.750\lib\net45\MaterialDesignThemes.Wpf.dll 49 | True 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 4.0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | MSBuild:Compile 69 | Designer 70 | 71 | 72 | MSBuild:Compile 73 | Designer 74 | 75 | 76 | App.xaml 77 | Code 78 | 79 | 80 | MainWindow.xaml 81 | Code 82 | 83 | 84 | 85 | 86 | 87 | Code 88 | 89 | 90 | True 91 | True 92 | Resources.resx 93 | 94 | 95 | True 96 | Settings.settings 97 | True 98 | 99 | 100 | ResXFileCodeGenerator 101 | Resources.Designer.cs 102 | 103 | 104 | 105 | SettingsSingleFileGenerator 106 | Settings.Designer.cs 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | {2306b263-506a-4030-a360-edf57125ec0c} 116 | MaterialDesignAddon 117 | 118 | 119 | 120 | 127 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/Annotations.cs: -------------------------------------------------------------------------------- 1 | /* MIT License 2 | 3 | Copyright (c) 2016 JetBrains http://www.jetbrains.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. */ 22 | 23 | using System; 24 | 25 | #pragma warning disable 1591 26 | // ReSharper disable UnusedMember.Global 27 | // ReSharper disable MemberCanBePrivate.Global 28 | // ReSharper disable UnusedAutoPropertyAccessor.Global 29 | // ReSharper disable IntroduceOptionalParameters.Global 30 | // ReSharper disable MemberCanBeProtected.Global 31 | // ReSharper disable InconsistentNaming 32 | 33 | namespace MaterialColorWheelDemo.Annotations 34 | { 35 | /// 36 | /// Indicates that the value of the marked element could be null sometimes, 37 | /// so the check for null is necessary before its usage. 38 | /// 39 | /// 40 | /// [CanBeNull] object Test() => null; 41 | /// 42 | /// void UseTest() { 43 | /// var p = Test(); 44 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' 45 | /// } 46 | /// 47 | [AttributeUsage( 48 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 49 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | 50 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] 51 | public sealed class CanBeNullAttribute : Attribute { } 52 | 53 | /// 54 | /// Indicates that the value of the marked element could never be null. 55 | /// 56 | /// 57 | /// [NotNull] object Foo() { 58 | /// return null; // Warning: Possible 'null' assignment 59 | /// } 60 | /// 61 | [AttributeUsage( 62 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 63 | AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | 64 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] 65 | public sealed class NotNullAttribute : Attribute { } 66 | 67 | /// 68 | /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task 69 | /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property 70 | /// or of the Lazy.Value property can never be null. 71 | /// 72 | [AttributeUsage( 73 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 74 | AttributeTargets.Delegate | AttributeTargets.Field)] 75 | public sealed class ItemNotNullAttribute : Attribute { } 76 | 77 | /// 78 | /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task 79 | /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property 80 | /// or of the Lazy.Value property can be null. 81 | /// 82 | [AttributeUsage( 83 | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | 84 | AttributeTargets.Delegate | AttributeTargets.Field)] 85 | public sealed class ItemCanBeNullAttribute : Attribute { } 86 | 87 | /// 88 | /// Indicates that the marked method builds string by format pattern and (optional) arguments. 89 | /// Parameter, which contains format string, should be given in constructor. The format string 90 | /// should be in -like form. 91 | /// 92 | /// 93 | /// [StringFormatMethod("message")] 94 | /// void ShowError(string message, params object[] args) { /* do something */ } 95 | /// 96 | /// void Foo() { 97 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string 98 | /// } 99 | /// 100 | [AttributeUsage( 101 | AttributeTargets.Constructor | AttributeTargets.Method | 102 | AttributeTargets.Property | AttributeTargets.Delegate)] 103 | public sealed class StringFormatMethodAttribute : Attribute 104 | { 105 | /// 106 | /// Specifies which parameter of an annotated method should be treated as format-string 107 | /// 108 | public StringFormatMethodAttribute([NotNull] string formatParameterName) 109 | { 110 | FormatParameterName = formatParameterName; 111 | } 112 | 113 | [NotNull] public string FormatParameterName { get; private set; } 114 | } 115 | 116 | /// 117 | /// For a parameter that is expected to be one of the limited set of values. 118 | /// Specify fields of which type should be used as values for this parameter. 119 | /// 120 | [AttributeUsage( 121 | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, 122 | AllowMultiple = true)] 123 | public sealed class ValueProviderAttribute : Attribute 124 | { 125 | public ValueProviderAttribute([NotNull] string name) 126 | { 127 | Name = name; 128 | } 129 | 130 | [NotNull] public string Name { get; private set; } 131 | } 132 | 133 | /// 134 | /// Indicates that the function argument should be string literal and match one 135 | /// of the parameters of the caller function. For example, ReSharper annotates 136 | /// the parameter of . 137 | /// 138 | /// 139 | /// void Foo(string param) { 140 | /// if (param == null) 141 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol 142 | /// } 143 | /// 144 | [AttributeUsage(AttributeTargets.Parameter)] 145 | public sealed class InvokerParameterNameAttribute : Attribute { } 146 | 147 | /// 148 | /// Indicates that the method is contained in a type that implements 149 | /// System.ComponentModel.INotifyPropertyChanged interface and this method 150 | /// is used to notify that some property value changed. 151 | /// 152 | /// 153 | /// The method should be non-static and conform to one of the supported signatures: 154 | /// 155 | /// NotifyChanged(string) 156 | /// NotifyChanged(params string[]) 157 | /// NotifyChanged{T}(Expression{Func{T}}) 158 | /// NotifyChanged{T,U}(Expression{Func{T,U}}) 159 | /// SetProperty{T}(ref T, T, string) 160 | /// 161 | /// 162 | /// 163 | /// public class Foo : INotifyPropertyChanged { 164 | /// public event PropertyChangedEventHandler PropertyChanged; 165 | /// 166 | /// [NotifyPropertyChangedInvocator] 167 | /// protected virtual void NotifyChanged(string propertyName) { ... } 168 | /// 169 | /// string _name; 170 | /// 171 | /// public string Name { 172 | /// get { return _name; } 173 | /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } 174 | /// } 175 | /// } 176 | /// 177 | /// Examples of generated notifications: 178 | /// 179 | /// NotifyChanged("Property") 180 | /// NotifyChanged(() => Property) 181 | /// NotifyChanged((VM x) => x.Property) 182 | /// SetProperty(ref myField, value, "Property") 183 | /// 184 | /// 185 | [AttributeUsage(AttributeTargets.Method)] 186 | public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute 187 | { 188 | public NotifyPropertyChangedInvocatorAttribute() { } 189 | public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) 190 | { 191 | ParameterName = parameterName; 192 | } 193 | 194 | [CanBeNull] public string ParameterName { get; private set; } 195 | } 196 | 197 | /// 198 | /// Describes dependency between method input and output. 199 | /// 200 | /// 201 | ///

Function Definition Table syntax:

202 | /// 203 | /// FDT ::= FDTRow [;FDTRow]* 204 | /// FDTRow ::= Input => Output | Output <= Input 205 | /// Input ::= ParameterName: Value [, Input]* 206 | /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} 207 | /// Value ::= true | false | null | notnull | canbenull 208 | /// 209 | /// If method has single input parameter, it's name could be omitted.
210 | /// Using halt (or void/nothing, which is the same) for method output 211 | /// means that the methos doesn't return normally (throws or terminates the process).
212 | /// Value canbenull is only applicable for output parameters.
213 | /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute 214 | /// with rows separated by semicolon. There is no notion of order rows, all rows are checked 215 | /// for applicability and applied per each program state tracked by R# analysis.
216 | ///
217 | /// 218 | /// 219 | /// [ContractAnnotation("=> halt")] 220 | /// public void TerminationMethod() 221 | /// 222 | /// 223 | /// [ContractAnnotation("halt <= condition: false")] 224 | /// public void Assert(bool condition, string text) // regular assertion method 225 | /// 226 | /// 227 | /// [ContractAnnotation("s:null => true")] 228 | /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() 229 | /// 230 | /// 231 | /// // A method that returns null if the parameter is null, 232 | /// // and not null if the parameter is not null 233 | /// [ContractAnnotation("null => null; notnull => notnull")] 234 | /// public object Transform(object data) 235 | /// 236 | /// 237 | /// [ContractAnnotation("=> true, result: notnull; => false, result: null")] 238 | /// public bool TryParse(string s, out Person result) 239 | /// 240 | /// 241 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 242 | public sealed class ContractAnnotationAttribute : Attribute 243 | { 244 | public ContractAnnotationAttribute([NotNull] string contract) 245 | : this(contract, false) { } 246 | 247 | public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) 248 | { 249 | Contract = contract; 250 | ForceFullStates = forceFullStates; 251 | } 252 | 253 | [NotNull] public string Contract { get; private set; } 254 | 255 | public bool ForceFullStates { get; private set; } 256 | } 257 | 258 | /// 259 | /// Indicates that marked element should be localized or not. 260 | /// 261 | /// 262 | /// [LocalizationRequiredAttribute(true)] 263 | /// class Foo { 264 | /// string str = "my string"; // Warning: Localizable string 265 | /// } 266 | /// 267 | [AttributeUsage(AttributeTargets.All)] 268 | public sealed class LocalizationRequiredAttribute : Attribute 269 | { 270 | public LocalizationRequiredAttribute() : this(true) { } 271 | 272 | public LocalizationRequiredAttribute(bool required) 273 | { 274 | Required = required; 275 | } 276 | 277 | public bool Required { get; private set; } 278 | } 279 | 280 | /// 281 | /// Indicates that the value of the marked type (or its derivatives) 282 | /// cannot be compared using '==' or '!=' operators and Equals() 283 | /// should be used instead. However, using '==' or '!=' for comparison 284 | /// with null is always permitted. 285 | /// 286 | /// 287 | /// [CannotApplyEqualityOperator] 288 | /// class NoEquality { } 289 | /// 290 | /// class UsesNoEquality { 291 | /// void Test() { 292 | /// var ca1 = new NoEquality(); 293 | /// var ca2 = new NoEquality(); 294 | /// if (ca1 != null) { // OK 295 | /// bool condition = ca1 == ca2; // Warning 296 | /// } 297 | /// } 298 | /// } 299 | /// 300 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] 301 | public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } 302 | 303 | /// 304 | /// When applied to a target attribute, specifies a requirement for any type marked 305 | /// with the target attribute to implement or inherit specific type or types. 306 | /// 307 | /// 308 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement 309 | /// class ComponentAttribute : Attribute { } 310 | /// 311 | /// [Component] // ComponentAttribute requires implementing IComponent interface 312 | /// class MyComponent : IComponent { } 313 | /// 314 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 315 | [BaseTypeRequired(typeof(Attribute))] 316 | public sealed class BaseTypeRequiredAttribute : Attribute 317 | { 318 | public BaseTypeRequiredAttribute([NotNull] Type baseType) 319 | { 320 | BaseType = baseType; 321 | } 322 | 323 | [NotNull] public Type BaseType { get; private set; } 324 | } 325 | 326 | /// 327 | /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), 328 | /// so this symbol will not be marked as unused (as well as by other usage inspections). 329 | /// 330 | [AttributeUsage(AttributeTargets.All)] 331 | public sealed class UsedImplicitlyAttribute : Attribute 332 | { 333 | public UsedImplicitlyAttribute() 334 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 335 | 336 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) 337 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 338 | 339 | public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) 340 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 341 | 342 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 343 | { 344 | UseKindFlags = useKindFlags; 345 | TargetFlags = targetFlags; 346 | } 347 | 348 | public ImplicitUseKindFlags UseKindFlags { get; private set; } 349 | 350 | public ImplicitUseTargetFlags TargetFlags { get; private set; } 351 | } 352 | 353 | /// 354 | /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes 355 | /// as unused (as well as by other usage inspections) 356 | /// 357 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] 358 | public sealed class MeansImplicitUseAttribute : Attribute 359 | { 360 | public MeansImplicitUseAttribute() 361 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 362 | 363 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) 364 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 365 | 366 | public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) 367 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 368 | 369 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 370 | { 371 | UseKindFlags = useKindFlags; 372 | TargetFlags = targetFlags; 373 | } 374 | 375 | [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } 376 | 377 | [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } 378 | } 379 | 380 | [Flags] 381 | public enum ImplicitUseKindFlags 382 | { 383 | Default = Access | Assign | InstantiatedWithFixedConstructorSignature, 384 | /// Only entity marked with attribute considered used. 385 | Access = 1, 386 | /// Indicates implicit assignment to a member. 387 | Assign = 2, 388 | /// 389 | /// Indicates implicit instantiation of a type with fixed constructor signature. 390 | /// That means any unused constructor parameters won't be reported as such. 391 | /// 392 | InstantiatedWithFixedConstructorSignature = 4, 393 | /// Indicates implicit instantiation of a type. 394 | InstantiatedNoFixedConstructorSignature = 8, 395 | } 396 | 397 | /// 398 | /// Specify what is considered used implicitly when marked 399 | /// with or . 400 | /// 401 | [Flags] 402 | public enum ImplicitUseTargetFlags 403 | { 404 | Default = Itself, 405 | Itself = 1, 406 | /// Members of entity marked with attribute are considered used. 407 | Members = 2, 408 | /// Entity marked with attribute and all its members considered used. 409 | WithMembers = Itself | Members 410 | } 411 | 412 | /// 413 | /// This attribute is intended to mark publicly available API 414 | /// which should not be removed and so is treated as used. 415 | /// 416 | [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] 417 | public sealed class PublicAPIAttribute : Attribute 418 | { 419 | public PublicAPIAttribute() { } 420 | 421 | public PublicAPIAttribute([NotNull] string comment) 422 | { 423 | Comment = comment; 424 | } 425 | 426 | [CanBeNull] public string Comment { get; private set; } 427 | } 428 | 429 | /// 430 | /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. 431 | /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. 432 | /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. 433 | /// 434 | [AttributeUsage(AttributeTargets.Parameter)] 435 | public sealed class InstantHandleAttribute : Attribute { } 436 | 437 | /// 438 | /// Indicates that a method does not make any observable state changes. 439 | /// The same as System.Diagnostics.Contracts.PureAttribute. 440 | /// 441 | /// 442 | /// [Pure] int Multiply(int x, int y) => x * y; 443 | /// 444 | /// void M() { 445 | /// Multiply(123, 42); // Waring: Return value of pure method is not used 446 | /// } 447 | /// 448 | [AttributeUsage(AttributeTargets.Method)] 449 | public sealed class PureAttribute : Attribute { } 450 | 451 | /// 452 | /// Indicates that the return value of method invocation must be used. 453 | /// 454 | [AttributeUsage(AttributeTargets.Method)] 455 | public sealed class MustUseReturnValueAttribute : Attribute 456 | { 457 | public MustUseReturnValueAttribute() { } 458 | 459 | public MustUseReturnValueAttribute([NotNull] string justification) 460 | { 461 | Justification = justification; 462 | } 463 | 464 | [CanBeNull] public string Justification { get; private set; } 465 | } 466 | 467 | /// 468 | /// Indicates the type member or parameter of some type, that should be used instead of all other ways 469 | /// to get the value that type. This annotation is useful when you have some "context" value evaluated 470 | /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. 471 | /// 472 | /// 473 | /// class Foo { 474 | /// [ProvidesContext] IBarService _barService = ...; 475 | /// 476 | /// void ProcessNode(INode node) { 477 | /// DoSomething(node, node.GetGlobalServices().Bar); 478 | /// // ^ Warning: use value of '_barService' field 479 | /// } 480 | /// } 481 | /// 482 | [AttributeUsage( 483 | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | 484 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] 485 | public sealed class ProvidesContextAttribute : Attribute { } 486 | 487 | /// 488 | /// Indicates that a parameter is a path to a file or a folder within a web project. 489 | /// Path can be relative or absolute, starting from web root (~). 490 | /// 491 | [AttributeUsage(AttributeTargets.Parameter)] 492 | public sealed class PathReferenceAttribute : Attribute 493 | { 494 | public PathReferenceAttribute() { } 495 | 496 | public PathReferenceAttribute([NotNull, PathReference] string basePath) 497 | { 498 | BasePath = basePath; 499 | } 500 | 501 | [CanBeNull] public string BasePath { get; private set; } 502 | } 503 | 504 | /// 505 | /// An extension method marked with this attribute is processed by ReSharper code completion 506 | /// as a 'Source Template'. When extension method is completed over some expression, it's source code 507 | /// is automatically expanded like a template at call site. 508 | /// 509 | /// 510 | /// Template method body can contain valid source code and/or special comments starting with '$'. 511 | /// Text inside these comments is added as source code when the template is applied. Template parameters 512 | /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. 513 | /// Use the attribute to specify macros for parameters. 514 | /// 515 | /// 516 | /// In this example, the 'forEach' method is a source template available over all values 517 | /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: 518 | /// 519 | /// [SourceTemplate] 520 | /// public static void forEach<T>(this IEnumerable<T> xs) { 521 | /// foreach (var x in xs) { 522 | /// //$ $END$ 523 | /// } 524 | /// } 525 | /// 526 | /// 527 | [AttributeUsage(AttributeTargets.Method)] 528 | public sealed class SourceTemplateAttribute : Attribute { } 529 | 530 | /// 531 | /// Allows specifying a macro for a parameter of a source template. 532 | /// 533 | /// 534 | /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression 535 | /// is defined in the property. When applied on a method, the target 536 | /// template parameter is defined in the property. To apply the macro silently 537 | /// for the parameter, set the property value = -1. 538 | /// 539 | /// 540 | /// Applying the attribute on a source template method: 541 | /// 542 | /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] 543 | /// public static void forEach<T>(this IEnumerable<T> collection) { 544 | /// foreach (var item in collection) { 545 | /// //$ $END$ 546 | /// } 547 | /// } 548 | /// 549 | /// Applying the attribute on a template method parameter: 550 | /// 551 | /// [SourceTemplate] 552 | /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { 553 | /// /*$ var $x$Id = "$newguid$" + x.ToString(); 554 | /// x.DoSomething($x$Id); */ 555 | /// } 556 | /// 557 | /// 558 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] 559 | public sealed class MacroAttribute : Attribute 560 | { 561 | /// 562 | /// Allows specifying a macro that will be executed for a source template 563 | /// parameter when the template is expanded. 564 | /// 565 | [CanBeNull] public string Expression { get; set; } 566 | 567 | /// 568 | /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. 569 | /// 570 | /// 571 | /// If the target parameter is used several times in the template, only one occurrence becomes editable; 572 | /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, 573 | /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. 574 | /// > 575 | public int Editable { get; set; } 576 | 577 | /// 578 | /// Identifies the target parameter of a source template if the 579 | /// is applied on a template method. 580 | /// 581 | [CanBeNull] public string Target { get; set; } 582 | } 583 | 584 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 585 | public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute 586 | { 587 | public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) 588 | { 589 | Format = format; 590 | } 591 | 592 | [NotNull] public string Format { get; private set; } 593 | } 594 | 595 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 596 | public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute 597 | { 598 | public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) 599 | { 600 | Format = format; 601 | } 602 | 603 | [NotNull] public string Format { get; private set; } 604 | } 605 | 606 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 607 | public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute 608 | { 609 | public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) 610 | { 611 | Format = format; 612 | } 613 | 614 | [NotNull] public string Format { get; private set; } 615 | } 616 | 617 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 618 | public sealed class AspMvcMasterLocationFormatAttribute : Attribute 619 | { 620 | public AspMvcMasterLocationFormatAttribute([NotNull] string format) 621 | { 622 | Format = format; 623 | } 624 | 625 | [NotNull] public string Format { get; private set; } 626 | } 627 | 628 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 629 | public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute 630 | { 631 | public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) 632 | { 633 | Format = format; 634 | } 635 | 636 | [NotNull] public string Format { get; private set; } 637 | } 638 | 639 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 640 | public sealed class AspMvcViewLocationFormatAttribute : Attribute 641 | { 642 | public AspMvcViewLocationFormatAttribute([NotNull] string format) 643 | { 644 | Format = format; 645 | } 646 | 647 | [NotNull] public string Format { get; private set; } 648 | } 649 | 650 | /// 651 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 652 | /// is an MVC action. If applied to a method, the MVC action name is calculated 653 | /// implicitly from the context. Use this attribute for custom wrappers similar to 654 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 655 | /// 656 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 657 | public sealed class AspMvcActionAttribute : Attribute 658 | { 659 | public AspMvcActionAttribute() { } 660 | 661 | public AspMvcActionAttribute([NotNull] string anonymousProperty) 662 | { 663 | AnonymousProperty = anonymousProperty; 664 | } 665 | 666 | [CanBeNull] public string AnonymousProperty { get; private set; } 667 | } 668 | 669 | /// 670 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. 671 | /// Use this attribute for custom wrappers similar to 672 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). 673 | /// 674 | [AttributeUsage(AttributeTargets.Parameter)] 675 | public sealed class AspMvcAreaAttribute : Attribute 676 | { 677 | public AspMvcAreaAttribute() { } 678 | 679 | public AspMvcAreaAttribute([NotNull] string anonymousProperty) 680 | { 681 | AnonymousProperty = anonymousProperty; 682 | } 683 | 684 | [CanBeNull] public string AnonymousProperty { get; private set; } 685 | } 686 | 687 | /// 688 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is 689 | /// an MVC controller. If applied to a method, the MVC controller name is calculated 690 | /// implicitly from the context. Use this attribute for custom wrappers similar to 691 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). 692 | /// 693 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 694 | public sealed class AspMvcControllerAttribute : Attribute 695 | { 696 | public AspMvcControllerAttribute() { } 697 | 698 | public AspMvcControllerAttribute([NotNull] string anonymousProperty) 699 | { 700 | AnonymousProperty = anonymousProperty; 701 | } 702 | 703 | [CanBeNull] public string AnonymousProperty { get; private set; } 704 | } 705 | 706 | /// 707 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute 708 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). 709 | /// 710 | [AttributeUsage(AttributeTargets.Parameter)] 711 | public sealed class AspMvcMasterAttribute : Attribute { } 712 | 713 | /// 714 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute 715 | /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). 716 | /// 717 | [AttributeUsage(AttributeTargets.Parameter)] 718 | public sealed class AspMvcModelTypeAttribute : Attribute { } 719 | 720 | /// 721 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC 722 | /// partial view. If applied to a method, the MVC partial view name is calculated implicitly 723 | /// from the context. Use this attribute for custom wrappers similar to 724 | /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). 725 | /// 726 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 727 | public sealed class AspMvcPartialViewAttribute : Attribute { } 728 | 729 | /// 730 | /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. 731 | /// 732 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 733 | public sealed class AspMvcSuppressViewErrorAttribute : Attribute { } 734 | 735 | /// 736 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. 737 | /// Use this attribute for custom wrappers similar to 738 | /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). 739 | /// 740 | [AttributeUsage(AttributeTargets.Parameter)] 741 | public sealed class AspMvcDisplayTemplateAttribute : Attribute { } 742 | 743 | /// 744 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. 745 | /// Use this attribute for custom wrappers similar to 746 | /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). 747 | /// 748 | [AttributeUsage(AttributeTargets.Parameter)] 749 | public sealed class AspMvcEditorTemplateAttribute : Attribute { } 750 | 751 | /// 752 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. 753 | /// Use this attribute for custom wrappers similar to 754 | /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). 755 | /// 756 | [AttributeUsage(AttributeTargets.Parameter)] 757 | public sealed class AspMvcTemplateAttribute : Attribute { } 758 | 759 | /// 760 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 761 | /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly 762 | /// from the context. Use this attribute for custom wrappers similar to 763 | /// System.Web.Mvc.Controller.View(Object). 764 | /// 765 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 766 | public sealed class AspMvcViewAttribute : Attribute { } 767 | 768 | /// 769 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 770 | /// is an MVC view component name. 771 | /// 772 | [AttributeUsage(AttributeTargets.Parameter)] 773 | public sealed class AspMvcViewComponentAttribute : Attribute { } 774 | 775 | /// 776 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 777 | /// is an MVC view component view. If applied to a method, the MVC view component view name is default. 778 | /// 779 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 780 | public sealed class AspMvcViewComponentViewAttribute : Attribute { } 781 | 782 | /// 783 | /// ASP.NET MVC attribute. When applied to a parameter of an attribute, 784 | /// indicates that this parameter is an MVC action name. 785 | /// 786 | /// 787 | /// [ActionName("Foo")] 788 | /// public ActionResult Login(string returnUrl) { 789 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK 790 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action 791 | /// } 792 | /// 793 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] 794 | public sealed class AspMvcActionSelectorAttribute : Attribute { } 795 | 796 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] 797 | public sealed class HtmlElementAttributesAttribute : Attribute 798 | { 799 | public HtmlElementAttributesAttribute() { } 800 | 801 | public HtmlElementAttributesAttribute([NotNull] string name) 802 | { 803 | Name = name; 804 | } 805 | 806 | [CanBeNull] public string Name { get; private set; } 807 | } 808 | 809 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] 810 | public sealed class HtmlAttributeValueAttribute : Attribute 811 | { 812 | public HtmlAttributeValueAttribute([NotNull] string name) 813 | { 814 | Name = name; 815 | } 816 | 817 | [NotNull] public string Name { get; private set; } 818 | } 819 | 820 | /// 821 | /// Razor attribute. Indicates that a parameter or a method is a Razor section. 822 | /// Use this attribute for custom wrappers similar to 823 | /// System.Web.WebPages.WebPageBase.RenderSection(String). 824 | /// 825 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 826 | public sealed class RazorSectionAttribute : Attribute { } 827 | 828 | /// 829 | /// Indicates how method, constructor invocation or property access 830 | /// over collection type affects content of the collection. 831 | /// 832 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] 833 | public sealed class CollectionAccessAttribute : Attribute 834 | { 835 | public CollectionAccessAttribute(CollectionAccessType collectionAccessType) 836 | { 837 | CollectionAccessType = collectionAccessType; 838 | } 839 | 840 | public CollectionAccessType CollectionAccessType { get; private set; } 841 | } 842 | 843 | [Flags] 844 | public enum CollectionAccessType 845 | { 846 | /// Method does not use or modify content of the collection. 847 | None = 0, 848 | /// Method only reads content of the collection but does not modify it. 849 | Read = 1, 850 | /// Method can change content of the collection but does not add new elements. 851 | ModifyExistingContent = 2, 852 | /// Method can add new elements to the collection. 853 | UpdatedContent = ModifyExistingContent | 4 854 | } 855 | 856 | /// 857 | /// Indicates that the marked method is assertion method, i.e. it halts control flow if 858 | /// one of the conditions is satisfied. To set the condition, mark one of the parameters with 859 | /// attribute. 860 | /// 861 | [AttributeUsage(AttributeTargets.Method)] 862 | public sealed class AssertionMethodAttribute : Attribute { } 863 | 864 | /// 865 | /// Indicates the condition parameter of the assertion method. The method itself should be 866 | /// marked by attribute. The mandatory argument of 867 | /// the attribute is the assertion type. 868 | /// 869 | [AttributeUsage(AttributeTargets.Parameter)] 870 | public sealed class AssertionConditionAttribute : Attribute 871 | { 872 | public AssertionConditionAttribute(AssertionConditionType conditionType) 873 | { 874 | ConditionType = conditionType; 875 | } 876 | 877 | public AssertionConditionType ConditionType { get; private set; } 878 | } 879 | 880 | /// 881 | /// Specifies assertion type. If the assertion method argument satisfies the condition, 882 | /// then the execution continues. Otherwise, execution is assumed to be halted. 883 | /// 884 | public enum AssertionConditionType 885 | { 886 | /// Marked parameter should be evaluated to true. 887 | IS_TRUE = 0, 888 | /// Marked parameter should be evaluated to false. 889 | IS_FALSE = 1, 890 | /// Marked parameter should be evaluated to null value. 891 | IS_NULL = 2, 892 | /// Marked parameter should be evaluated to not null value. 893 | IS_NOT_NULL = 3, 894 | } 895 | 896 | /// 897 | /// Indicates that the marked method unconditionally terminates control flow execution. 898 | /// For example, it could unconditionally throw exception. 899 | /// 900 | [Obsolete("Use [ContractAnnotation('=> halt')] instead")] 901 | [AttributeUsage(AttributeTargets.Method)] 902 | public sealed class TerminatesProgramAttribute : Attribute { } 903 | 904 | /// 905 | /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, 906 | /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters 907 | /// of delegate type by analyzing LINQ method chains. 908 | /// 909 | [AttributeUsage(AttributeTargets.Method)] 910 | public sealed class LinqTunnelAttribute : Attribute { } 911 | 912 | /// 913 | /// Indicates that IEnumerable, passed as parameter, is not enumerated. 914 | /// 915 | [AttributeUsage(AttributeTargets.Parameter)] 916 | public sealed class NoEnumerationAttribute : Attribute { } 917 | 918 | /// 919 | /// Indicates that parameter is regular expression pattern. 920 | /// 921 | [AttributeUsage(AttributeTargets.Parameter)] 922 | public sealed class RegexPatternAttribute : Attribute { } 923 | 924 | /// 925 | /// Prevents the Member Reordering feature from tossing members of the marked class. 926 | /// 927 | /// 928 | /// The attribute must be mentioned in your member reordering patterns 929 | /// 930 | [AttributeUsage( 931 | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] 932 | public sealed class NoReorderAttribute : Attribute { } 933 | 934 | /// 935 | /// XAML attribute. Indicates the type that has ItemsSource property and should be treated 936 | /// as ItemsControl-derived type, to enable inner items DataContext type resolve. 937 | /// 938 | [AttributeUsage(AttributeTargets.Class)] 939 | public sealed class XamlItemsControlAttribute : Attribute { } 940 | 941 | /// 942 | /// XAML attribute. Indicates the property of some BindingBase-derived type, that 943 | /// is used to bind some item of ItemsControl-derived type. This annotation will 944 | /// enable the DataContext type resolve for XAML bindings for such properties. 945 | /// 946 | /// 947 | /// Property should have the tree ancestor of the ItemsControl type or 948 | /// marked with the attribute. 949 | /// 950 | [AttributeUsage(AttributeTargets.Property)] 951 | public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } 952 | 953 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 954 | public sealed class AspChildControlTypeAttribute : Attribute 955 | { 956 | public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) 957 | { 958 | TagName = tagName; 959 | ControlType = controlType; 960 | } 961 | 962 | [NotNull] public string TagName { get; private set; } 963 | 964 | [NotNull] public Type ControlType { get; private set; } 965 | } 966 | 967 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 968 | public sealed class AspDataFieldAttribute : Attribute { } 969 | 970 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] 971 | public sealed class AspDataFieldsAttribute : Attribute { } 972 | 973 | [AttributeUsage(AttributeTargets.Property)] 974 | public sealed class AspMethodPropertyAttribute : Attribute { } 975 | 976 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 977 | public sealed class AspRequiredAttributeAttribute : Attribute 978 | { 979 | public AspRequiredAttributeAttribute([NotNull] string attribute) 980 | { 981 | Attribute = attribute; 982 | } 983 | 984 | [NotNull] public string Attribute { get; private set; } 985 | } 986 | 987 | [AttributeUsage(AttributeTargets.Property)] 988 | public sealed class AspTypePropertyAttribute : Attribute 989 | { 990 | public bool CreateConstructorReferences { get; private set; } 991 | 992 | public AspTypePropertyAttribute(bool createConstructorReferences) 993 | { 994 | CreateConstructorReferences = createConstructorReferences; 995 | } 996 | } 997 | 998 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 999 | public sealed class RazorImportNamespaceAttribute : Attribute 1000 | { 1001 | public RazorImportNamespaceAttribute([NotNull] string name) 1002 | { 1003 | Name = name; 1004 | } 1005 | 1006 | [NotNull] public string Name { get; private set; } 1007 | } 1008 | 1009 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 1010 | public sealed class RazorInjectionAttribute : Attribute 1011 | { 1012 | public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) 1013 | { 1014 | Type = type; 1015 | FieldName = fieldName; 1016 | } 1017 | 1018 | [NotNull] public string Type { get; private set; } 1019 | 1020 | [NotNull] public string FieldName { get; private set; } 1021 | } 1022 | 1023 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 1024 | public sealed class RazorDirectiveAttribute : Attribute 1025 | { 1026 | public RazorDirectiveAttribute([NotNull] string directive) 1027 | { 1028 | Directive = directive; 1029 | } 1030 | 1031 | [NotNull] public string Directive { get; private set; } 1032 | } 1033 | 1034 | [AttributeUsage(AttributeTargets.Method)] 1035 | public sealed class RazorHelperCommonAttribute : Attribute { } 1036 | 1037 | [AttributeUsage(AttributeTargets.Property)] 1038 | public sealed class RazorLayoutAttribute : Attribute { } 1039 | 1040 | [AttributeUsage(AttributeTargets.Method)] 1041 | public sealed class RazorWriteLiteralMethodAttribute : Attribute { } 1042 | 1043 | [AttributeUsage(AttributeTargets.Method)] 1044 | public sealed class RazorWriteMethodAttribute : Attribute { } 1045 | 1046 | [AttributeUsage(AttributeTargets.Parameter)] 1047 | public sealed class RazorWriteMethodParameterAttribute : Attribute { } 1048 | } -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("MaterialColorWheelDemo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("MaterialColorWheelDemo")] 15 | [assembly: AssemblyCopyright("Copyright © 2017")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialColorWheelDemo.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MaterialColorWheelDemo.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialColorWheelDemo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MaterialColorWheelDemo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MaterialDesignAddon.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MaterialDesignAddon 5 | 1.0.3 6 | Material Color Wheel Addon 7 | Tim Stephansen 8 | Tim Stephansen 9 | https://opensource.org/licenses/Apache-2.0 10 | https://github.com/tstephansen/MaterialColorWheelDemo 11 | https://raw.githubusercontent.com/tstephansen/MaterialColorWheelDemo/master/ColorWheelIcon.PNG 12 | false 13 | Added a button to switch between dark and light themes. 14 | A color wheel for the Material Design in XAML Toolkit that is modeled after Google's Material Design Lite CSS Customizer. 15 | Copyright ©2017 Tim Stephansen 16 | 17 | material design color wheel xaml theme google 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Controls/MaterialColorWheel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Input; 7 | using System.Windows.Media; 8 | using System.Windows.Media.Effects; 9 | using System.Windows.Shapes; 10 | using MaterialDesignAddon.Helpers; 11 | using MaterialDesignColors; 12 | using MaterialDesignThemes.Wpf; 13 | using System.Windows.Media.Animation; 14 | 15 | namespace MaterialDesignAddon.Controls 16 | { 17 | /// 18 | /// A color picker designed after Google's customizer. 19 | /// The first click sets the primary color and the second click sets the accent color. 20 | /// The credit for the design of this control goes to Google and the original can be found 21 | /// at https://getmdl.io/customize/index.html. I took their SVG file and created a XAML control 22 | /// based on that file. 23 | /// 24 | /// 25 | [TemplatePart(Name = PART_CyanCanvas, Type = typeof(Canvas))] 26 | [TemplatePart(Name = PART_TealCanvas, Type = typeof(Canvas))] 27 | [TemplatePart(Name = PART_GreenCanvas, Type = typeof(Canvas))] 28 | [TemplatePart(Name = PART_LightGreenCanvas, Type = typeof(Canvas))] 29 | [TemplatePart(Name = PART_LimeCanvas, Type = typeof(Canvas))] 30 | [TemplatePart(Name = PART_YellowCanvas, Type = typeof(Canvas))] 31 | [TemplatePart(Name = PART_AmberCanvas, Type = typeof(Canvas))] 32 | [TemplatePart(Name = PART_OrangeCanvas, Type = typeof(Canvas))] 33 | [TemplatePart(Name = PART_BrownCanvas, Type = typeof(Canvas))] 34 | [TemplatePart(Name = PART_BlueGreyCanvas, Type = typeof(Canvas))] 35 | [TemplatePart(Name = PART_GreyCanvas, Type = typeof(Canvas))] 36 | [TemplatePart(Name = PART_DeepOrangeCanvas, Type = typeof(Canvas))] 37 | [TemplatePart(Name = PART_RedCanvas, Type = typeof(Canvas))] 38 | [TemplatePart(Name = PART_PurpleCanvas, Type = typeof(Canvas))] 39 | [TemplatePart(Name = PART_DeepPurpleCanvas, Type = typeof(Canvas))] 40 | [TemplatePart(Name = PART_BlueCanvas, Type = typeof(Canvas))] 41 | [TemplatePart(Name = PART_LightBlueCanvas, Type = typeof(Canvas))] 42 | [TemplatePart(Name = PART_IndigoCanvas, Type = typeof(Canvas))] 43 | [TemplatePart(Name = PART_PinkCanvas, Type = typeof(Canvas))] 44 | [TemplatePart(Name = PART_CyanSelector, Type = typeof(Path))] 45 | [TemplatePart(Name = PART_TealSelector, Type = typeof(Path))] 46 | [TemplatePart(Name = PART_GreenSelector, Type = typeof(Path))] 47 | [TemplatePart(Name = PART_LightGreenSelector, Type = typeof(Path))] 48 | [TemplatePart(Name = PART_LimeSelector, Type = typeof(Path))] 49 | [TemplatePart(Name = PART_YellowSelector, Type = typeof(Path))] 50 | [TemplatePart(Name = PART_AmberSelector, Type = typeof(Path))] 51 | [TemplatePart(Name = PART_OrangeSelector, Type = typeof(Path))] 52 | [TemplatePart(Name = PART_BrownSelector, Type = typeof(Path))] 53 | [TemplatePart(Name = PART_BlueGreySelector, Type = typeof(Path))] 54 | [TemplatePart(Name = PART_GreySelector, Type = typeof(Path))] 55 | [TemplatePart(Name = PART_DeepOrangeSelector, Type = typeof(Path))] 56 | [TemplatePart(Name = PART_RedSelector, Type = typeof(Path))] 57 | [TemplatePart(Name = PART_PurpleSelector, Type = typeof(Path))] 58 | [TemplatePart(Name = PART_DeepPurpleSelector, Type = typeof(Path))] 59 | [TemplatePart(Name = PART_BlueSelector, Type = typeof(Path))] 60 | [TemplatePart(Name = PART_LightBlueSelector, Type = typeof(Path))] 61 | [TemplatePart(Name = PART_IndigoSelector, Type = typeof(Path))] 62 | [TemplatePart(Name = PART_PinkSelector, Type = typeof(Path))] 63 | [TemplatePart(Name = PART_Cyan1Canvas, Type = typeof(Canvas))] 64 | [TemplatePart(Name = PART_Teal1Canvas, Type = typeof(Canvas))] 65 | [TemplatePart(Name = PART_Green1Canvas, Type = typeof(Canvas))] 66 | [TemplatePart(Name = PART_LightGreen1Canvas, Type = typeof(Canvas))] 67 | [TemplatePart(Name = PART_Lime1Canvas, Type = typeof(Canvas))] 68 | [TemplatePart(Name = PART_Yellow1Canvas, Type = typeof(Canvas))] 69 | [TemplatePart(Name = PART_Amber1Canvas, Type = typeof(Canvas))] 70 | [TemplatePart(Name = PART_Orange1Canvas, Type = typeof(Canvas))] 71 | [TemplatePart(Name = PART_Brown1Canvas, Type = typeof(Canvas))] 72 | [TemplatePart(Name = PART_BlueGrey1Canvas, Type = typeof(Canvas))] 73 | [TemplatePart(Name = PART_Grey1Canvas, Type = typeof(Canvas))] 74 | [TemplatePart(Name = PART_DeepOrange1Canvas, Type = typeof(Canvas))] 75 | [TemplatePart(Name = PART_Red1Canvas, Type = typeof(Canvas))] 76 | [TemplatePart(Name = PART_Purple1Canvas, Type = typeof(Canvas))] 77 | [TemplatePart(Name = PART_DeepPurple1Canvas, Type = typeof(Canvas))] 78 | [TemplatePart(Name = PART_Blue1Canvas, Type = typeof(Canvas))] 79 | [TemplatePart(Name = PART_LightBlue1Canvas, Type = typeof(Canvas))] 80 | [TemplatePart(Name = PART_Indigo1Canvas, Type = typeof(Canvas))] 81 | [TemplatePart(Name = PART_Pink1Canvas, Type = typeof(Canvas))] 82 | [TemplatePart(Name = PART_Cyan2Canvas, Type = typeof(Canvas))] 83 | [TemplatePart(Name = PART_Teal2Canvas, Type = typeof(Canvas))] 84 | [TemplatePart(Name = PART_Green2Canvas, Type = typeof(Canvas))] 85 | [TemplatePart(Name = PART_LightGreen2Canvas, Type = typeof(Canvas))] 86 | [TemplatePart(Name = PART_Lime2Canvas, Type = typeof(Canvas))] 87 | [TemplatePart(Name = PART_Yellow2Canvas, Type = typeof(Canvas))] 88 | [TemplatePart(Name = PART_Amber2Canvas, Type = typeof(Canvas))] 89 | [TemplatePart(Name = PART_Orange2Canvas, Type = typeof(Canvas))] 90 | [TemplatePart(Name = PART_Brown2Canvas, Type = typeof(Canvas))] 91 | [TemplatePart(Name = PART_BlueGrey2Canvas, Type = typeof(Canvas))] 92 | [TemplatePart(Name = PART_Grey2Canvas, Type = typeof(Canvas))] 93 | [TemplatePart(Name = PART_DeepOrange2Canvas, Type = typeof(Canvas))] 94 | [TemplatePart(Name = PART_Red2Canvas, Type = typeof(Canvas))] 95 | [TemplatePart(Name = PART_Purple2Canvas, Type = typeof(Canvas))] 96 | [TemplatePart(Name = PART_DeepPurple2Canvas, Type = typeof(Canvas))] 97 | [TemplatePart(Name = PART_Blue2Canvas, Type = typeof(Canvas))] 98 | [TemplatePart(Name = PART_LightBlue2Canvas, Type = typeof(Canvas))] 99 | [TemplatePart(Name = PART_Indigo2Canvas, Type = typeof(Canvas))] 100 | [TemplatePart(Name = PART_Pink2Canvas, Type = typeof(Canvas))] 101 | [TemplatePart(Name = PART_CyanPolys, Type = typeof(Canvas))] 102 | [TemplatePart(Name = PART_TealPolys, Type = typeof(Canvas))] 103 | [TemplatePart(Name = PART_GreenPolys, Type = typeof(Canvas))] 104 | [TemplatePart(Name = PART_LightGreenPolys, Type = typeof(Canvas))] 105 | [TemplatePart(Name = PART_LimePolys, Type = typeof(Canvas))] 106 | [TemplatePart(Name = PART_YellowPolys, Type = typeof(Canvas))] 107 | [TemplatePart(Name = PART_AmberPolys, Type = typeof(Canvas))] 108 | [TemplatePart(Name = PART_OrangePolys, Type = typeof(Canvas))] 109 | [TemplatePart(Name = PART_BrownPolys, Type = typeof(Canvas))] 110 | [TemplatePart(Name = PART_BlueGreyPolys, Type = typeof(Canvas))] 111 | [TemplatePart(Name = PART_GreyPolys, Type = typeof(Canvas))] 112 | [TemplatePart(Name = PART_DeepOrangePolys, Type = typeof(Canvas))] 113 | [TemplatePart(Name = PART_RedPolys, Type = typeof(Canvas))] 114 | [TemplatePart(Name = PART_PurplePolys, Type = typeof(Canvas))] 115 | [TemplatePart(Name = PART_DeepPurplePolys, Type = typeof(Canvas))] 116 | [TemplatePart(Name = PART_BluePolys, Type = typeof(Canvas))] 117 | [TemplatePart(Name = PART_LightBluePolys, Type = typeof(Canvas))] 118 | [TemplatePart(Name = PART_IndigoPolys, Type = typeof(Canvas))] 119 | [TemplatePart(Name = PART_PinkPolys, Type = typeof(Canvas))] 120 | [TemplatePart(Name = PART_DarkLightButton, Type = typeof(Button))] 121 | public class MaterialColorWheel : Control 122 | { 123 | #region Initialization and Template 124 | /// 125 | /// Initializes static members of the class. 126 | /// 127 | static MaterialColorWheel() 128 | { 129 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialColorWheel), new FrameworkPropertyMetadata(typeof(MaterialColorWheel))); 130 | } 131 | 132 | /// 133 | /// Initializes a new instance of the class. 134 | /// 135 | public MaterialColorWheel() 136 | { 137 | _swatches = new SwatchesProvider().Swatches; 138 | } 139 | 140 | /// 141 | /// When overridden in a derived class, is invoked whenever application code or internal processes call 142 | /// . 143 | /// 144 | public override void OnApplyTemplate() 145 | { 146 | base.OnApplyTemplate(); 147 | _cyanCanvas = GetTemplateChild(PART_CyanCanvas) as Canvas; 148 | _tealCanvas = GetTemplateChild(PART_TealCanvas) as Canvas; 149 | _greenCanvas = GetTemplateChild(PART_GreenCanvas) as Canvas; 150 | _lightGreenCanvas = GetTemplateChild(PART_LightGreenCanvas) as Canvas; 151 | _limeCanvas = GetTemplateChild(PART_LimeCanvas) as Canvas; 152 | _yellowCanvas = GetTemplateChild(PART_YellowCanvas) as Canvas; 153 | _amberCanvas = GetTemplateChild(PART_AmberCanvas) as Canvas; 154 | _orangeCanvas = GetTemplateChild(PART_OrangeCanvas) as Canvas; 155 | _brownCanvas = GetTemplateChild(PART_BrownCanvas) as Canvas; 156 | _blueGreyCanvas = GetTemplateChild(PART_BlueGreyCanvas) as Canvas; 157 | _greyCanvas = GetTemplateChild(PART_GreyCanvas) as Canvas; 158 | _deepOrangeCanvas = GetTemplateChild(PART_DeepOrangeCanvas) as Canvas; 159 | _redCanvas = GetTemplateChild(PART_RedCanvas) as Canvas; 160 | _purpleCanvas = GetTemplateChild(PART_PurpleCanvas) as Canvas; 161 | _deepPurpleCanvas = GetTemplateChild(PART_DeepPurpleCanvas) as Canvas; 162 | _blueCanvas = GetTemplateChild(PART_BlueCanvas) as Canvas; 163 | _lightBlueCanvas = GetTemplateChild(PART_LightBlueCanvas) as Canvas; 164 | _indigoCanvas = GetTemplateChild(PART_IndigoCanvas) as Canvas; 165 | _pinkCanvas = GetTemplateChild(PART_PinkCanvas) as Canvas; 166 | _cyanSelector = GetTemplateChild(PART_CyanSelector) as Path; 167 | _tealSelector = GetTemplateChild(PART_TealSelector) as Path; 168 | _greenSelector = GetTemplateChild(PART_GreenSelector) as Path; 169 | _lightGreenSelector = GetTemplateChild(PART_LightGreenSelector) as Path; 170 | _limeSelector = GetTemplateChild(PART_LimeSelector) as Path; 171 | _yellowSelector = GetTemplateChild(PART_YellowSelector) as Path; 172 | _amberSelector = GetTemplateChild(PART_AmberSelector) as Path; 173 | _orangeSelector = GetTemplateChild(PART_OrangeSelector) as Path; 174 | _brownSelector = GetTemplateChild(PART_BrownSelector) as Path; 175 | _blueGreySelector = GetTemplateChild(PART_BlueGreySelector) as Path; 176 | _greySelector = GetTemplateChild(PART_GreySelector) as Path; 177 | _deepOrangeSelector = GetTemplateChild(PART_DeepOrangeSelector) as Path; 178 | _redSelector = GetTemplateChild(PART_RedSelector) as Path; 179 | _purpleSelector = GetTemplateChild(PART_PurpleSelector) as Path; 180 | _deepPurpleSelector = GetTemplateChild(PART_DeepPurpleSelector) as Path; 181 | _blueSelector = GetTemplateChild(PART_BlueSelector) as Path; 182 | _lightBlueSelector = GetTemplateChild(PART_LightBlueSelector) as Path; 183 | _indigoSelector = GetTemplateChild(PART_IndigoSelector) as Path; 184 | _pinkSelector = GetTemplateChild(PART_PinkSelector) as Path; 185 | _cyan1Canvas = GetTemplateChild(PART_Cyan1Canvas) as Canvas; 186 | _teal1Canvas = GetTemplateChild(PART_Teal1Canvas) as Canvas; 187 | _green1Canvas = GetTemplateChild(PART_Green1Canvas) as Canvas; 188 | _lightGreen1Canvas = GetTemplateChild(PART_LightGreen1Canvas) as Canvas; 189 | _lime1Canvas = GetTemplateChild(PART_Lime1Canvas) as Canvas; 190 | _yellow1Canvas = GetTemplateChild(PART_Yellow1Canvas) as Canvas; 191 | _amber1Canvas = GetTemplateChild(PART_Amber1Canvas) as Canvas; 192 | _orange1Canvas = GetTemplateChild(PART_Orange1Canvas) as Canvas; 193 | _brown1Canvas = GetTemplateChild(PART_Brown1Canvas) as Canvas; 194 | _blueGrey1Canvas = GetTemplateChild(PART_BlueGrey1Canvas) as Canvas; 195 | _grey1Canvas = GetTemplateChild(PART_Grey1Canvas) as Canvas; 196 | _deepOrange1Canvas = GetTemplateChild(PART_DeepOrange1Canvas) as Canvas; 197 | _red1Canvas = GetTemplateChild(PART_Red1Canvas) as Canvas; 198 | _purple1Canvas = GetTemplateChild(PART_Purple1Canvas) as Canvas; 199 | _deepPurple1Canvas = GetTemplateChild(PART_DeepPurple1Canvas) as Canvas; 200 | _blue1Canvas = GetTemplateChild(PART_Blue1Canvas) as Canvas; 201 | _lightBlue1Canvas = GetTemplateChild(PART_LightBlue1Canvas) as Canvas; 202 | _indigo1Canvas = GetTemplateChild(PART_Indigo1Canvas) as Canvas; 203 | _pink1Canvas = GetTemplateChild(PART_Pink1Canvas) as Canvas; 204 | _cyan2Canvas = GetTemplateChild(PART_Cyan2Canvas) as Canvas; 205 | _teal2Canvas = GetTemplateChild(PART_Teal2Canvas) as Canvas; 206 | _green2Canvas = GetTemplateChild(PART_Green2Canvas) as Canvas; 207 | _lightGreen2Canvas = GetTemplateChild(PART_LightGreen2Canvas) as Canvas; 208 | _lime2Canvas = GetTemplateChild(PART_Lime2Canvas) as Canvas; 209 | _yellow2Canvas = GetTemplateChild(PART_Yellow2Canvas) as Canvas; 210 | _amber2Canvas = GetTemplateChild(PART_Amber2Canvas) as Canvas; 211 | _orange2Canvas = GetTemplateChild(PART_Orange2Canvas) as Canvas; 212 | _brown2Canvas = GetTemplateChild(PART_Brown2Canvas) as Canvas; 213 | _blueGrey2Canvas = GetTemplateChild(PART_BlueGrey2Canvas) as Canvas; 214 | _grey2Canvas = GetTemplateChild(PART_Grey2Canvas) as Canvas; 215 | _deepOrange2Canvas = GetTemplateChild(PART_DeepOrange2Canvas) as Canvas; 216 | _red2Canvas = GetTemplateChild(PART_Red2Canvas) as Canvas; 217 | _purple2Canvas = GetTemplateChild(PART_Purple2Canvas) as Canvas; 218 | _deepPurple2Canvas = GetTemplateChild(PART_DeepPurple2Canvas) as Canvas; 219 | _blue2Canvas = GetTemplateChild(PART_Blue2Canvas) as Canvas; 220 | _lightBlue2Canvas = GetTemplateChild(PART_LightBlue2Canvas) as Canvas; 221 | _indigo2Canvas = GetTemplateChild(PART_Indigo2Canvas) as Canvas; 222 | _pink2Canvas = GetTemplateChild(PART_Pink2Canvas) as Canvas; 223 | _cyanPolys = GetTemplateChild(PART_CyanPolys) as Canvas; 224 | _tealPolys = GetTemplateChild(PART_TealPolys) as Canvas; 225 | _greenPolys = GetTemplateChild(PART_GreenPolys) as Canvas; 226 | _lightGreenPolys = GetTemplateChild(PART_LightGreenPolys) as Canvas; 227 | _limePolys = GetTemplateChild(PART_LimePolys) as Canvas; 228 | _yellowPolys = GetTemplateChild(PART_YellowPolys) as Canvas; 229 | _amberPolys = GetTemplateChild(PART_AmberPolys) as Canvas; 230 | _orangePolys = GetTemplateChild(PART_OrangePolys) as Canvas; 231 | _brownPolys = GetTemplateChild(PART_BrownPolys) as Canvas; 232 | _blueGreyPolys = GetTemplateChild(PART_BlueGreyPolys) as Canvas; 233 | _greyPolys = GetTemplateChild(PART_GreyPolys) as Canvas; 234 | _deepOrangePolys = GetTemplateChild(PART_DeepOrangePolys) as Canvas; 235 | _redPolys = GetTemplateChild(PART_RedPolys) as Canvas; 236 | _purplePolys = GetTemplateChild(PART_PurplePolys) as Canvas; 237 | _deepPurplePolys = GetTemplateChild(PART_DeepPurplePolys) as Canvas; 238 | _bluePolys = GetTemplateChild(PART_BluePolys) as Canvas; 239 | _lightBluePolys = GetTemplateChild(PART_LightBluePolys) as Canvas; 240 | _indigoPolys = GetTemplateChild(PART_IndigoPolys) as Canvas; 241 | _pinkPolys = GetTemplateChild(PART_PinkPolys) as Canvas; 242 | _darkLightButton = GetTemplateChild(PART_DarkLightButton) as Button; 243 | _colorCanvases = new Dictionary 244 | { 245 | {"Cyan", _cyanCanvas}, 246 | {"Teal", _tealCanvas}, 247 | {"Green", _greenCanvas}, 248 | {"LightGreen", _lightGreenCanvas}, 249 | {"Lime", _limeCanvas}, 250 | {"Yellow", _yellowCanvas}, 251 | {"Amber", _amberCanvas}, 252 | {"Orange", _orangeCanvas}, 253 | {"Brown", _brownCanvas}, 254 | {"BlueGrey", _blueGreyCanvas}, 255 | {"Grey", _greyCanvas}, 256 | {"DeepOrange", _deepOrangeCanvas}, 257 | {"Red", _redCanvas}, 258 | {"Purple", _purpleCanvas}, 259 | {"DeepPurple", _deepPurpleCanvas}, 260 | {"Blue", _blueCanvas}, 261 | {"LightBlue", _lightBlueCanvas}, 262 | {"Indigo", _indigoCanvas}, 263 | {"Pink", _pinkCanvas} 264 | }; 265 | _selectors = new Dictionary 266 | { 267 | {"Cyan", _cyanSelector}, 268 | {"Teal", _tealSelector}, 269 | {"Green", _greenSelector}, 270 | {"LightGreen", _lightGreenSelector}, 271 | {"Lime", _limeSelector}, 272 | {"Yellow", _yellowSelector}, 273 | {"Amber", _amberSelector}, 274 | {"Orange", _orangeSelector}, 275 | {"Brown", _brownSelector}, 276 | {"BlueGrey", _blueGreySelector}, 277 | {"Grey", _greySelector}, 278 | {"DeepOrange", _deepOrangeSelector}, 279 | {"Red", _redSelector}, 280 | {"Purple", _purpleSelector}, 281 | {"DeepPurple", _deepPurpleSelector}, 282 | {"Blue", _blueSelector}, 283 | {"LightBlue", _lightBlueSelector}, 284 | {"Indigo", _indigoSelector}, 285 | {"Pink", _pinkSelector} 286 | }; 287 | _polygons = new Dictionary 288 | { 289 | {"Cyan", _cyanPolys}, 290 | {"Teal", _tealPolys}, 291 | {"Green", _greenPolys}, 292 | {"LightGreen", _lightGreenPolys}, 293 | {"Lime", _limePolys}, 294 | {"Yellow", _yellowPolys}, 295 | {"Amber", _amberPolys}, 296 | {"Orange", _orangePolys}, 297 | {"Brown", _brownPolys}, 298 | {"BlueGrey", _blueGreyPolys}, 299 | {"Grey", _greyPolys}, 300 | {"DeepOrange", _deepOrangePolys}, 301 | {"Red", _redPolys}, 302 | {"Purple", _purplePolys}, 303 | {"DeepPurple", _deepPurplePolys}, 304 | {"Blue", _bluePolys}, 305 | {"LightBlue", _lightBluePolys}, 306 | {"Indigo", _indigoPolys}, 307 | {"Pink", _pinkPolys} 308 | }; 309 | if (_cyanCanvas != null) 310 | _cyanCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 311 | if (_tealCanvas != null) 312 | _tealCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 313 | if (_greenCanvas != null) 314 | _greenCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 315 | if (_lightGreenCanvas != null) 316 | _lightGreenCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 317 | if (_limeCanvas != null) 318 | _limeCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 319 | if (_yellowCanvas != null) 320 | _yellowCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 321 | if (_amberCanvas != null) 322 | _amberCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 323 | if (_orangeCanvas != null) 324 | _orangeCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 325 | if (_brownCanvas != null) 326 | _brownCanvas.PreviewMouseLeftButtonUp += RestrictedColorCanvas_PreviewMouseLeftButtonUp; 327 | if (_blueGreyCanvas != null) 328 | _blueGreyCanvas.PreviewMouseLeftButtonUp += RestrictedColorCanvas_PreviewMouseLeftButtonUp; 329 | if (_greyCanvas != null) 330 | _greyCanvas.PreviewMouseLeftButtonUp += RestrictedColorCanvas_PreviewMouseLeftButtonUp; 331 | if (_deepOrangeCanvas != null) 332 | _deepOrangeCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 333 | if (_redCanvas != null) 334 | _redCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 335 | if (_purpleCanvas != null) 336 | _purpleCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 337 | if (_deepPurpleCanvas != null) 338 | _deepPurpleCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 339 | if (_blueCanvas != null) 340 | _blueCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 341 | if (_lightBlueCanvas != null) 342 | _lightBlueCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 343 | if (_indigoCanvas != null) 344 | _indigoCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 345 | if (_pinkCanvas != null) 346 | _pinkCanvas.PreviewMouseLeftButtonUp += UnrestrictedColorCanvas_PreviewMouseLeftButtonUp; 347 | if (_darkLightButton != null) 348 | _darkLightButton.Click += (s, e) => 349 | { 350 | var btn = (Button)s; 351 | if (btn == null) 352 | return; 353 | ToggleDarkLight(); 354 | if (IsDark) 355 | { 356 | IsDark = false; 357 | new PaletteHelper().SetLightDark(false); 358 | CenterButtonFontColor = new SolidColorBrush(Color.FromArgb(221, 0, 0, 0)); 359 | CenterButtonText = "Light"; 360 | } 361 | else 362 | { 363 | IsDark = true; 364 | new PaletteHelper().SetLightDark(true); 365 | CenterButtonFontColor = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); 366 | CenterButtonText = "Dark"; 367 | } 368 | }; 369 | } 370 | #endregion 371 | 372 | #region Event Methods 373 | /// 374 | /// Fired when a canvas that is not grey, blue grey, or brown is clicked. This changes 375 | /// the primary or accent color depending on which selection is being processed. 376 | /// 377 | /// The canvas. 378 | /// The event arguments 379 | private void UnrestrictedColorCanvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) 380 | { 381 | var canvas = (Canvas)sender; 382 | if (canvas == null) 383 | throw new InvalidOperationException("Canvas can't be found."); 384 | var upperColorName = canvas.Name.Replace("PART_", "").Replace("Canvas", ""); 385 | var colorName = upperColorName.ToLower(CultureInfo.InvariantCulture); 386 | var selectorName = $"PART_{upperColorName}Selector"; 387 | var numberOneName = $"PART_{upperColorName}1Canvas"; 388 | var numberTwoName = $"PART_{upperColorName}2Canvas"; 389 | if (_isSecondColorSelected) 390 | { 391 | ClearAllSelections(); 392 | _isFirstColorSelected = false; 393 | _isSecondColorSelected = false; 394 | } 395 | if (!_isFirstColorSelected) 396 | { 397 | PrimaryName = upperColorName; 398 | DisableAllEffects(); 399 | var selector = canvas.FindChild(selectorName); 400 | if (selector != null) 401 | selector.Visibility = Visibility.Visible; 402 | var numberOneCanvas = canvas.FindChild(numberOneName); 403 | if (numberOneCanvas != null) 404 | numberOneCanvas.Visibility = Visibility.Visible; 405 | _isFirstColorSelected = true; 406 | new PaletteHelper().ReplacePrimaryColor(colorName); 407 | if (upperColorName == "Grey") 408 | _greySelected = true; 409 | if (upperColorName == "BlueGrey") 410 | _blueGreySelected = true; 411 | if (upperColorName == "Brown") 412 | _brownSelected = true; 413 | ApplyDropShadowEffect(upperColorName); 414 | DisableInvalidColorChoices(upperColorName); 415 | } 416 | else 417 | { 418 | AccentName = upperColorName; 419 | var numberOneCanvas = canvas.FindChild(numberOneName); 420 | if (numberOneCanvas?.Visibility == Visibility.Visible) 421 | return; 422 | var selector = canvas.FindChild(selectorName); 423 | if (selector != null) 424 | selector.Visibility = Visibility.Visible; 425 | var numberTwoCanvas = canvas.FindChild(numberTwoName); 426 | if (numberTwoCanvas != null) 427 | numberTwoCanvas.Visibility = Visibility.Visible; 428 | _isSecondColorSelected = true; 429 | ApplyDropShadowEffect(upperColorName); 430 | new PaletteHelper().ReplaceAccentColor(colorName); 431 | EnableDisabledColorChoices(); 432 | } 433 | } 434 | 435 | /// 436 | /// Fired when a canvas that is grey, blue grey, or brown is clicked. This changes 437 | /// the primary color only because these colors are not allowed to be selected as 438 | /// accent colors. 439 | /// 440 | /// The canvas. 441 | /// The event arguments 442 | private void RestrictedColorCanvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) 443 | { 444 | var canvas = (Canvas)sender; 445 | if (canvas == null) 446 | throw new InvalidOperationException("Canvas can't be found."); 447 | var upperColorName = canvas.Name.Replace("PART_", "").Replace("Canvas", ""); 448 | var colorName = upperColorName.ToLower(CultureInfo.InvariantCulture); 449 | var selectorName = $"PART_{upperColorName}Selector"; 450 | var numberOneName = $"PART_{upperColorName}1Canvas"; 451 | var numberTwoName = $"PART_{upperColorName}2Canvas"; 452 | if (_isSecondColorSelected) 453 | { 454 | ClearAllSelections(); 455 | _isFirstColorSelected = false; 456 | _isSecondColorSelected = false; 457 | } 458 | if (!_isFirstColorSelected) 459 | { 460 | PrimaryName = upperColorName; 461 | DisableAllEffects(); 462 | var selector = canvas.FindChild(selectorName); 463 | if (selector != null) 464 | selector.Visibility = Visibility.Visible; 465 | // Disabled this until I can figure out a way to fix the font size inside the viewbox. 466 | var numberOneCanvas = canvas.FindChild(numberOneName); 467 | if (numberOneCanvas != null) 468 | numberOneCanvas.Visibility = Visibility.Visible; 469 | _isFirstColorSelected = true; 470 | new PaletteHelper().ReplacePrimaryColor(colorName); 471 | if (upperColorName == "Grey") 472 | _greySelected = true; 473 | if (upperColorName == "BlueGrey") 474 | _blueGreySelected = true; 475 | if (upperColorName == "Brown") 476 | _brownSelected = true; 477 | ApplyDropShadowEffect(upperColorName); 478 | DisableInvalidColorChoices(upperColorName); 479 | } 480 | } 481 | #endregion 482 | 483 | #region Helpers 484 | /// 485 | /// Keeps grey, brown, and blue grey from being selected as an accent color. 486 | /// 487 | /// The color. 488 | private void DisableInvalidColorChoices(string color) 489 | { 490 | DisableGrey(); 491 | DisableBlueGrey(); 492 | DisableBrown(); 493 | DisableCurrentColor(color); 494 | } 495 | 496 | /// 497 | /// Gets the canvas of the specified color. 498 | /// 499 | /// The color. 500 | /// Canvas. 501 | private Canvas GetColorCanvas(string color) 502 | { 503 | Canvas canvas; 504 | _colorCanvases.TryGetValue(color, out canvas); 505 | return canvas; 506 | } 507 | 508 | /// 509 | /// Disables the currently selected primary color. 510 | /// 511 | /// The color. 512 | private void DisableCurrentColor(string color) 513 | { 514 | var canvas = GetColorCanvas(color); 515 | if (canvas != null) 516 | canvas.IsEnabled = false; 517 | } 518 | 519 | /// 520 | /// Keeps grey from being selected as an accent color. 521 | /// 522 | private void DisableGrey() 523 | { 524 | if (_greySelected) 525 | return; 526 | _greyCanvas.IsEnabled = false; 527 | var greyOuter = _greyPolys.FindChild("GreyOuter"); 528 | if (greyOuter != null) 529 | greyOuter.Fill = new SolidColorBrush(Color.FromRgb(239, 239, 239)); 530 | var greyInner = _greyPolys.FindChild("GreyInner"); 531 | if (greyInner != null) 532 | greyInner.Fill = new SolidColorBrush(Color.FromRgb(232, 232, 232)); 533 | } 534 | 535 | /// 536 | /// Keeps blue grey from being selected as an accent color. 537 | /// 538 | private void DisableBlueGrey() 539 | { 540 | if (_blueGreySelected) 541 | return; 542 | _blueGreyCanvas.IsEnabled = false; 543 | var greyOuter = _blueGreyPolys.FindChild("BlueGreyOuter"); 544 | if (greyOuter != null) 545 | greyOuter.Fill = new SolidColorBrush(Color.FromRgb(232, 235, 237)); 546 | var greyInner = _blueGreyPolys.FindChild("BlueGreyInner"); 547 | if (greyInner != null) 548 | greyInner.Fill = new SolidColorBrush(Color.FromRgb(228, 231, 232)); 549 | } 550 | 551 | /// 552 | /// Keeps brown from being selected as an accent color. 553 | /// 554 | private void DisableBrown() 555 | { 556 | if (_brownSelected) 557 | return; 558 | _brownCanvas.IsEnabled = false; 559 | var brownOuter = _brownPolys.FindChild("BrownOuter"); 560 | if (brownOuter != null) 561 | brownOuter.Fill = new SolidColorBrush(Color.FromRgb(235, 230, 229)); 562 | var brownInner = _brownPolys.FindChild("BrownInner"); 563 | if (brownInner != null) 564 | brownInner.Fill = new SolidColorBrush(Color.FromRgb(231, 228, 227)); 565 | } 566 | 567 | /// 568 | /// Enables blue grey, grey, and brown to be selected as a primary color. 569 | /// 570 | private void EnableDisabledColorChoices() 571 | { 572 | EnableGrey(); 573 | EnableBlueGrey(); 574 | EnableBrown(); 575 | EnableAllColors(); 576 | } 577 | 578 | /// 579 | /// Enables all colors. 580 | /// 581 | private void EnableAllColors() 582 | { 583 | foreach (var o in _colorCanvases) 584 | o.Value.IsEnabled = true; 585 | } 586 | 587 | /// 588 | /// Disables all effects. 589 | /// 590 | private void DisableAllEffects() 591 | { 592 | foreach (var o in _polygons) 593 | o.Value.Effect = null; 594 | } 595 | 596 | /// 597 | /// Enables grey to be selected. 598 | /// 599 | private void EnableGrey() 600 | { 601 | _greyCanvas.IsEnabled = true; 602 | var greyOuter = _greyPolys.FindChild("GreyOuter"); 603 | if (greyOuter != null) 604 | greyOuter.Fill = new SolidColorBrush(Color.FromRgb(158, 158, 158)); 605 | var greyInner = _greyPolys.FindChild("GreyInner"); 606 | if (greyInner != null) 607 | greyInner.Fill = new SolidColorBrush(Color.FromRgb(97, 97, 97)); 608 | } 609 | 610 | /// 611 | /// Enables blue grey to be selected. 612 | /// 613 | private void EnableBlueGrey() 614 | { 615 | _blueGreyCanvas.IsEnabled = true; 616 | var blueGreyOuter = _blueGreyPolys.FindChild("BlueGreyOuter"); 617 | if (blueGreyOuter != null) 618 | blueGreyOuter.Fill = new SolidColorBrush(Color.FromRgb(96, 125, 139)); 619 | var blueGreyInner = _blueGreyPolys.FindChild("BlueGreyInner"); 620 | if (blueGreyInner != null) 621 | blueGreyInner.Fill = new SolidColorBrush(Color.FromRgb(69, 90, 100)); 622 | } 623 | 624 | /// 625 | /// Enables brown to be selected. 626 | /// 627 | private void EnableBrown() 628 | { 629 | _brownCanvas.IsEnabled = true; 630 | var brownOuter = _brownPolys.FindChild("BrownOuter"); 631 | if (brownOuter != null) 632 | brownOuter.Fill = new SolidColorBrush(Color.FromRgb(121, 85, 72)); 633 | var brownInner = _brownPolys.FindChild("BrownInner"); 634 | if (brownInner != null) 635 | brownInner.Fill = new SolidColorBrush(Color.FromRgb(93, 64, 55)); 636 | } 637 | 638 | /// 639 | /// Sets the visibility to collapsed for all of the selectors and indicators. 640 | /// 641 | private void ClearAllSelections() 642 | { 643 | ClearTextIcons(); 644 | ClearSelectionIcons(); 645 | _greySelected = false; 646 | _blueGreySelected = false; 647 | _brownSelected = false; 648 | } 649 | 650 | /// 651 | /// Sets the visibility of all the selector to collapsed. 652 | /// 653 | private void ClearSelectionIcons() 654 | { 655 | foreach (var o in _selectors) 656 | o.Value.Visibility = Visibility.Collapsed; 657 | } 658 | 659 | /// 660 | /// Sets the visibility of all of the that specify 661 | /// whether the selection is primary or accent to collapsed. 662 | /// 663 | private void ClearTextIcons() 664 | { 665 | _cyan1Canvas.Visibility = Visibility.Collapsed; 666 | _teal1Canvas.Visibility = Visibility.Collapsed; 667 | _green1Canvas.Visibility = Visibility.Collapsed; 668 | _lightGreen1Canvas.Visibility = Visibility.Collapsed; 669 | _lime1Canvas.Visibility = Visibility.Collapsed; 670 | _yellow1Canvas.Visibility = Visibility.Collapsed; 671 | _amber1Canvas.Visibility = Visibility.Collapsed; 672 | _orange1Canvas.Visibility = Visibility.Collapsed; 673 | _brown1Canvas.Visibility = Visibility.Collapsed; 674 | _blueGrey1Canvas.Visibility = Visibility.Collapsed; 675 | _grey1Canvas.Visibility = Visibility.Collapsed; 676 | _deepOrange1Canvas.Visibility = Visibility.Collapsed; 677 | _red1Canvas.Visibility = Visibility.Collapsed; 678 | _purple1Canvas.Visibility = Visibility.Collapsed; 679 | _deepPurple1Canvas.Visibility = Visibility.Collapsed; 680 | _blue1Canvas.Visibility = Visibility.Collapsed; 681 | _lightBlue1Canvas.Visibility = Visibility.Collapsed; 682 | _indigo1Canvas.Visibility = Visibility.Collapsed; 683 | _pink1Canvas.Visibility = Visibility.Collapsed; 684 | _cyan2Canvas.Visibility = Visibility.Collapsed; 685 | _teal2Canvas.Visibility = Visibility.Collapsed; 686 | _green2Canvas.Visibility = Visibility.Collapsed; 687 | _lightGreen2Canvas.Visibility = Visibility.Collapsed; 688 | _lime2Canvas.Visibility = Visibility.Collapsed; 689 | _yellow2Canvas.Visibility = Visibility.Collapsed; 690 | _amber2Canvas.Visibility = Visibility.Collapsed; 691 | _orange2Canvas.Visibility = Visibility.Collapsed; 692 | _brown2Canvas.Visibility = Visibility.Collapsed; 693 | _blueGrey2Canvas.Visibility = Visibility.Collapsed; 694 | _grey2Canvas.Visibility = Visibility.Collapsed; 695 | _deepOrange2Canvas.Visibility = Visibility.Collapsed; 696 | _red2Canvas.Visibility = Visibility.Collapsed; 697 | _purple2Canvas.Visibility = Visibility.Collapsed; 698 | _deepPurple2Canvas.Visibility = Visibility.Collapsed; 699 | _blue2Canvas.Visibility = Visibility.Collapsed; 700 | _lightBlue2Canvas.Visibility = Visibility.Collapsed; 701 | _indigo2Canvas.Visibility = Visibility.Collapsed; 702 | _pink2Canvas.Visibility = Visibility.Collapsed; 703 | } 704 | 705 | /// 706 | /// Returns the canvas that contains the polygons for the 707 | /// selected color. 708 | /// 709 | /// 710 | /// 711 | private Canvas GetPolygons(string color) 712 | { 713 | Canvas canvas; 714 | _polygons.TryGetValue(color, out canvas); 715 | return canvas; 716 | } 717 | 718 | /// 719 | /// Applies a drop shadow effect to the canvas that contains the polygons 720 | /// for the selected color. 721 | /// 722 | /// 723 | private void ApplyDropShadowEffect(string color) 724 | { 725 | var canvas = GetPolygons(color); 726 | canvas.Effect = new DropShadowEffect 727 | { 728 | BlurRadius = 14, 729 | Color = Color.FromArgb(153, 0, 0, 0), 730 | Direction = 270, 731 | Opacity = 0.42, 732 | RenderingBias = RenderingBias.Performance, 733 | ShadowDepth = 4.5 734 | }; 735 | } 736 | 737 | /// 738 | /// Toggles the theme between dark and light. 739 | /// 740 | public virtual void ToggleDarkLight() 741 | { 742 | ReplaceEntry("MaterialDesignUserControlBackground", 743 | IsDark ? new SolidColorBrush(Color.FromRgb(224, 224, 224)) : new SolidColorBrush(Color.FromRgb(55, 71, 79))); 744 | } 745 | 746 | /// 747 | /// Replaces a certain entry anywhere in the parent dictionary and its merged dictionaries. 748 | /// This was taken from the Material Design In XAML Toolkit. James gets the credit for this. 749 | /// 750 | /// The entry to replace 751 | /// The new entry value 752 | /// The root dictionary to start searching at. Null means using Application.Current.Resources 753 | private static void ReplaceEntry(object entryName, object newValue, ResourceDictionary parentDictionary = null) 754 | { 755 | if (parentDictionary == null) 756 | parentDictionary = Application.Current.Resources; 757 | 758 | if (parentDictionary.Contains(entryName)) 759 | { 760 | var brush = parentDictionary[entryName] as SolidColorBrush; 761 | if (brush != null && !brush.IsFrozen) 762 | { 763 | var animation = new ColorAnimation 764 | { 765 | From = ((SolidColorBrush)parentDictionary[entryName]).Color, 766 | To = ((SolidColorBrush)newValue).Color, 767 | Duration = new Duration(TimeSpan.FromMilliseconds(300)) 768 | }; 769 | brush.BeginAnimation(SolidColorBrush.ColorProperty, animation); 770 | } 771 | else 772 | parentDictionary[entryName] = newValue; 773 | } 774 | 775 | foreach (var dictionary in parentDictionary.MergedDictionaries) 776 | ReplaceEntry(entryName, newValue, dictionary); 777 | } 778 | #endregion 779 | 780 | #region Dependency Properties 781 | /// 782 | /// The selector color property 783 | /// 784 | public static readonly DependencyProperty SelectorColorProperty = DependencyProperty.Register( 785 | "SelectorColor", typeof(SolidColorBrush), typeof(MaterialColorWheel), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(158, 158, 158)))); 786 | 787 | /// 788 | /// Gets or sets the color of the selector. 789 | /// 790 | /// The color of the selector. 791 | public SolidColorBrush SelectorColor 792 | { 793 | get { return (SolidColorBrush)GetValue(SelectorColorProperty); } 794 | set { SetValue(SelectorColorProperty, value); } 795 | } 796 | 797 | /// 798 | /// The selector foreground color property 799 | /// 800 | public static readonly DependencyProperty SelectorForegroundColorProperty = DependencyProperty.Register( 801 | "SelectorForegroundColor", typeof(SolidColorBrush), typeof(MaterialColorWheel), 802 | new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 255, 255)))); 803 | 804 | /// 805 | /// Gets or sets the color of the selector foreground. 806 | /// 807 | /// The color of the selector foreground. 808 | public SolidColorBrush SelectorForegroundColor 809 | { 810 | get { return (SolidColorBrush)GetValue(SelectorForegroundColorProperty); } 811 | set { SetValue(SelectorForegroundColorProperty, value); } 812 | } 813 | 814 | /// 815 | /// The stretch property 816 | /// 817 | public static readonly DependencyProperty StretchProperty = DependencyProperty.Register( 818 | "Stretch", typeof(Stretch), typeof(MaterialColorWheel), new PropertyMetadata(default(Stretch))); 819 | 820 | /// 821 | /// Gets or sets the stretch. 822 | /// 823 | /// The stretch. 824 | public Stretch Stretch 825 | { 826 | get { return (Stretch)GetValue(StretchProperty); } 827 | set { SetValue(StretchProperty, value); } 828 | } 829 | 830 | /// 831 | /// The center button text property 832 | /// 833 | public static readonly DependencyProperty CenterButtonTextProperty = DependencyProperty.Register( 834 | "CenterButtonText", typeof(string), typeof(MaterialColorWheel), new FrameworkPropertyMetadata("Light")); 835 | 836 | /// 837 | /// Gets or sets the center button text. 838 | /// 839 | /// The center button text. 840 | public string CenterButtonText 841 | { 842 | get { return (string)GetValue(CenterButtonTextProperty); } 843 | set { SetValue(CenterButtonTextProperty, value); } 844 | } 845 | 846 | /// 847 | /// The button width property 848 | /// 849 | public static readonly DependencyProperty ButtonWidthProperty = DependencyProperty.Register( 850 | "ButtonWidth", typeof(double), typeof(MaterialColorWheel), new PropertyMetadata(default(double))); 851 | 852 | /// 853 | /// Gets or sets the width of the button. 854 | /// 855 | /// The width of the button. 856 | public double ButtonWidth 857 | { 858 | get { return (double)GetValue(ButtonWidthProperty); } 859 | set { SetValue(ButtonWidthProperty, value); } 860 | } 861 | 862 | /// 863 | /// The button height property 864 | /// 865 | public static readonly DependencyProperty ButtonHeightProperty = DependencyProperty.Register( 866 | "ButtonHeight", typeof(double), typeof(MaterialColorWheel), new PropertyMetadata(default(double))); 867 | 868 | /// 869 | /// Gets or sets the height of the button. 870 | /// 871 | /// The height of the button. 872 | public double ButtonHeight 873 | { 874 | get { return (double)GetValue(ButtonHeightProperty); } 875 | set { SetValue(ButtonHeightProperty, value); } 876 | } 877 | 878 | /// 879 | /// The center button font color property 880 | /// 881 | public static readonly DependencyProperty CenterButtonFontColorProperty = DependencyProperty.Register( 882 | "CenterButtonFontColor", typeof(SolidColorBrush), typeof(MaterialColorWheel), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(221, 0, 0, 0)))); 883 | 884 | /// 885 | /// Gets or sets the color of the center button font. 886 | /// 887 | /// The color of the center button font. 888 | public SolidColorBrush CenterButtonFontColor 889 | { 890 | get { return (SolidColorBrush)GetValue(CenterButtonFontColorProperty); } 891 | set { SetValue(CenterButtonFontColorProperty, value); } 892 | } 893 | #endregion 894 | 895 | #region Template Properties 896 | // ReSharper disable once InconsistentNaming 897 | private const string PART_DarkLightButton = "PART_DarkLightButton"; 898 | private Button _darkLightButton; 899 | // ReSharper disable InconsistentNaming 900 | private const string PART_CyanCanvas = "PART_CyanCanvas"; 901 | private const string PART_TealCanvas = "PART_TealCanvas"; 902 | private const string PART_GreenCanvas = "PART_GreenCanvas"; 903 | private const string PART_LightGreenCanvas = "PART_LightGreenCanvas"; 904 | private const string PART_LimeCanvas = "PART_LimeCanvas"; 905 | private const string PART_YellowCanvas = "PART_YellowCanvas"; 906 | private const string PART_AmberCanvas = "PART_AmberCanvas"; 907 | private const string PART_OrangeCanvas = "PART_OrangeCanvas"; 908 | private const string PART_BrownCanvas = "PART_BrownCanvas"; 909 | private const string PART_BlueGreyCanvas = "PART_BlueGreyCanvas"; 910 | private const string PART_GreyCanvas = "PART_GreyCanvas"; 911 | private const string PART_DeepOrangeCanvas = "PART_DeepOrangeCanvas"; 912 | private const string PART_RedCanvas = "PART_RedCanvas"; 913 | private const string PART_PurpleCanvas = "PART_PurpleCanvas"; 914 | private const string PART_DeepPurpleCanvas = "PART_DeepPurpleCanvas"; 915 | private const string PART_BlueCanvas = "PART_BlueCanvas"; 916 | private const string PART_LightBlueCanvas = "PART_LightBlueCanvas"; 917 | private const string PART_IndigoCanvas = "PART_IndigoCanvas"; 918 | private const string PART_PinkCanvas = "PART_PinkCanvas"; 919 | // ReSharper restore InconsistentNaming 920 | private Canvas _cyanCanvas; 921 | private Canvas _tealCanvas; 922 | private Canvas _greenCanvas; 923 | private Canvas _lightGreenCanvas; 924 | private Canvas _limeCanvas; 925 | private Canvas _yellowCanvas; 926 | private Canvas _amberCanvas; 927 | private Canvas _orangeCanvas; 928 | private Canvas _brownCanvas; 929 | private Canvas _blueGreyCanvas; 930 | private Canvas _greyCanvas; 931 | private Canvas _deepOrangeCanvas; 932 | private Canvas _redCanvas; 933 | private Canvas _purpleCanvas; 934 | private Canvas _deepPurpleCanvas; 935 | private Canvas _blueCanvas; 936 | private Canvas _lightBlueCanvas; 937 | private Canvas _indigoCanvas; 938 | private Canvas _pinkCanvas; 939 | // ReSharper disable InconsistentNaming 940 | private const string PART_CyanSelector = "PART_CyanSelector"; 941 | private const string PART_TealSelector = "PART_TealSelector"; 942 | private const string PART_GreenSelector = "PART_GreenSelector"; 943 | private const string PART_LightGreenSelector = "PART_LightGreenSelector"; 944 | private const string PART_LimeSelector = "PART_LimeSelector"; 945 | private const string PART_YellowSelector = "PART_YellowSelector"; 946 | private const string PART_AmberSelector = "PART_AmberSelector"; 947 | private const string PART_OrangeSelector = "PART_OrangeSelector"; 948 | private const string PART_BrownSelector = "PART_BrownSelector"; 949 | private const string PART_BlueGreySelector = "PART_BlueGreySelector"; 950 | private const string PART_GreySelector = "PART_GreySelector"; 951 | private const string PART_DeepOrangeSelector = "PART_DeepOrangeSelector"; 952 | private const string PART_RedSelector = "PART_RedSelector"; 953 | private const string PART_PurpleSelector = "PART_PurpleSelector"; 954 | private const string PART_DeepPurpleSelector = "PART_DeepPurpleSelector"; 955 | private const string PART_BlueSelector = "PART_BlueSelector"; 956 | private const string PART_LightBlueSelector = "PART_LightBlueSelector"; 957 | private const string PART_IndigoSelector = "PART_IndigoSelector"; 958 | private const string PART_PinkSelector = "PART_PinkSelector"; 959 | // ReSharper restore InconsistentNaming 960 | private Path _cyanSelector; 961 | private Path _tealSelector; 962 | private Path _greenSelector; 963 | private Path _lightGreenSelector; 964 | private Path _limeSelector; 965 | private Path _yellowSelector; 966 | private Path _amberSelector; 967 | private Path _orangeSelector; 968 | private Path _brownSelector; 969 | private Path _blueGreySelector; 970 | private Path _greySelector; 971 | private Path _deepOrangeSelector; 972 | private Path _redSelector; 973 | private Path _purpleSelector; 974 | private Path _deepPurpleSelector; 975 | private Path _blueSelector; 976 | private Path _lightBlueSelector; 977 | private Path _indigoSelector; 978 | private Path _pinkSelector; 979 | // ReSharper disable InconsistentNaming 980 | private const string PART_Cyan1Canvas = "PART_Cyan1Canvas"; 981 | private const string PART_Teal1Canvas = "PART_Teal1Canvas"; 982 | private const string PART_Green1Canvas = "PART_Green1Canvas"; 983 | private const string PART_LightGreen1Canvas = "PART_LightGreen1Canvas"; 984 | private const string PART_Lime1Canvas = "PART_Lime1Canvas"; 985 | private const string PART_Yellow1Canvas = "PART_Yellow1Canvas"; 986 | private const string PART_Amber1Canvas = "PART_Amber1Canvas"; 987 | private const string PART_Orange1Canvas = "PART_Orange1Canvas"; 988 | private const string PART_Brown1Canvas = "PART_Brown1Canvas"; 989 | private const string PART_BlueGrey1Canvas = "PART_BlueGrey1Canvas"; 990 | private const string PART_Grey1Canvas = "PART_Grey1Canvas"; 991 | private const string PART_DeepOrange1Canvas = "PART_DeepOrange1Canvas"; 992 | private const string PART_Red1Canvas = "PART_Red1Canvas"; 993 | private const string PART_Purple1Canvas = "PART_Purple1Canvas"; 994 | private const string PART_DeepPurple1Canvas = "PART_DeepPurple1Canvas"; 995 | private const string PART_Blue1Canvas = "PART_Blue1Canvas"; 996 | private const string PART_LightBlue1Canvas = "PART_LightBlue1Canvas"; 997 | private const string PART_Indigo1Canvas = "PART_Indigo1Canvas"; 998 | private const string PART_Pink1Canvas = "PART_Pink1Canvas"; 999 | private const string PART_Cyan2Canvas = "PART_Cyan2Canvas"; 1000 | private const string PART_Teal2Canvas = "PART_Teal2Canvas"; 1001 | private const string PART_Green2Canvas = "PART_Green2Canvas"; 1002 | private const string PART_LightGreen2Canvas = "PART_LightGreen2Canvas"; 1003 | private const string PART_Lime2Canvas = "PART_Lime2Canvas"; 1004 | private const string PART_Yellow2Canvas = "PART_Yellow2Canvas"; 1005 | private const string PART_Amber2Canvas = "PART_Amber2Canvas"; 1006 | private const string PART_Orange2Canvas = "PART_Orange2Canvas"; 1007 | private const string PART_Brown2Canvas = "PART_Brown2Canvas"; 1008 | private const string PART_BlueGrey2Canvas = "PART_BlueGrey2Canvas"; 1009 | private const string PART_Grey2Canvas = "PART_Grey2Canvas"; 1010 | private const string PART_DeepOrange2Canvas = "PART_DeepOrange2Canvas"; 1011 | private const string PART_Red2Canvas = "PART_Red2Canvas"; 1012 | private const string PART_Purple2Canvas = "PART_Purple2Canvas"; 1013 | private const string PART_DeepPurple2Canvas = "PART_DeepPurple2Canvas"; 1014 | private const string PART_Blue2Canvas = "PART_Blue2Canvas"; 1015 | private const string PART_LightBlue2Canvas = "PART_LightBlue2Canvas"; 1016 | private const string PART_Indigo2Canvas = "PART_Indigo2Canvas"; 1017 | private const string PART_Pink2Canvas = "PART_Pink2Canvas"; 1018 | // ReSharper restore InconsistentNaming 1019 | private Canvas _cyan1Canvas; 1020 | private Canvas _teal1Canvas; 1021 | private Canvas _green1Canvas; 1022 | private Canvas _lightGreen1Canvas; 1023 | private Canvas _lime1Canvas; 1024 | private Canvas _yellow1Canvas; 1025 | private Canvas _amber1Canvas; 1026 | private Canvas _orange1Canvas; 1027 | private Canvas _brown1Canvas; 1028 | private Canvas _blueGrey1Canvas; 1029 | private Canvas _grey1Canvas; 1030 | private Canvas _deepOrange1Canvas; 1031 | private Canvas _red1Canvas; 1032 | private Canvas _purple1Canvas; 1033 | private Canvas _deepPurple1Canvas; 1034 | private Canvas _blue1Canvas; 1035 | private Canvas _lightBlue1Canvas; 1036 | private Canvas _indigo1Canvas; 1037 | private Canvas _pink1Canvas; 1038 | private Canvas _cyan2Canvas; 1039 | private Canvas _teal2Canvas; 1040 | private Canvas _green2Canvas; 1041 | private Canvas _lightGreen2Canvas; 1042 | private Canvas _lime2Canvas; 1043 | private Canvas _yellow2Canvas; 1044 | private Canvas _amber2Canvas; 1045 | private Canvas _orange2Canvas; 1046 | private Canvas _brown2Canvas; 1047 | private Canvas _blueGrey2Canvas; 1048 | private Canvas _grey2Canvas; 1049 | private Canvas _deepOrange2Canvas; 1050 | private Canvas _red2Canvas; 1051 | private Canvas _purple2Canvas; 1052 | private Canvas _deepPurple2Canvas; 1053 | private Canvas _blue2Canvas; 1054 | private Canvas _lightBlue2Canvas; 1055 | private Canvas _indigo2Canvas; 1056 | private Canvas _pink2Canvas; 1057 | private bool _isFirstColorSelected; 1058 | private bool _isSecondColorSelected; 1059 | private bool _brownSelected; 1060 | private bool _greySelected; 1061 | private bool _blueGreySelected; 1062 | private readonly IEnumerable _swatches; 1063 | private Dictionary _colorCanvases; 1064 | private Dictionary _selectors; 1065 | private Dictionary _polygons; 1066 | // ReSharper disable InconsistentNaming 1067 | private const string PART_CyanPolys = "PART_CyanPolys"; 1068 | private const string PART_TealPolys = "PART_TealPolys"; 1069 | private const string PART_GreenPolys = "PART_GreenPolys"; 1070 | private const string PART_LightGreenPolys = "PART_LightGreenPolys"; 1071 | private const string PART_LimePolys = "PART_LimePolys"; 1072 | private const string PART_YellowPolys = "PART_YellowPolys"; 1073 | private const string PART_AmberPolys = "PART_AmberPolys"; 1074 | private const string PART_OrangePolys = "PART_OrangePolys"; 1075 | private const string PART_BrownPolys = "PART_BrownPolys"; 1076 | private const string PART_BlueGreyPolys = "PART_BlueGreyPolys"; 1077 | private const string PART_GreyPolys = "PART_GreyPolys"; 1078 | private const string PART_DeepOrangePolys = "PART_DeepOrangePolys"; 1079 | private const string PART_RedPolys = "PART_RedPolys"; 1080 | private const string PART_PurplePolys = "PART_PurplePolys"; 1081 | private const string PART_DeepPurplePolys = "PART_DeepPurplePolys"; 1082 | private const string PART_BluePolys = "PART_BluePolys"; 1083 | private const string PART_LightBluePolys = "PART_LightBluePolys"; 1084 | private const string PART_IndigoPolys = "PART_IndigoPolys"; 1085 | private const string PART_PinkPolys = "PART_PinkPolys"; 1086 | // ReSharper restore InconsistentNaming 1087 | private Canvas _cyanPolys; 1088 | private Canvas _tealPolys; 1089 | private Canvas _greenPolys; 1090 | private Canvas _lightGreenPolys; 1091 | private Canvas _limePolys; 1092 | private Canvas _yellowPolys; 1093 | private Canvas _amberPolys; 1094 | private Canvas _orangePolys; 1095 | private Canvas _brownPolys; 1096 | private Canvas _blueGreyPolys; 1097 | private Canvas _greyPolys; 1098 | private Canvas _deepOrangePolys; 1099 | private Canvas _redPolys; 1100 | private Canvas _purplePolys; 1101 | private Canvas _deepPurplePolys; 1102 | private Canvas _bluePolys; 1103 | private Canvas _lightBluePolys; 1104 | private Canvas _indigoPolys; 1105 | private Canvas _pinkPolys; 1106 | /// 1107 | /// Gets or sets the name of the primary color. 1108 | /// 1109 | /// The name of the primary color. 1110 | public string PrimaryName { get; set; } 1111 | /// 1112 | /// Gets or sets the name of the accent color. 1113 | /// 1114 | /// The name of the accent color. 1115 | public string AccentName { get; set; } 1116 | /// 1117 | /// Gets or sets a value indicating whether this instance is dark. 1118 | /// 1119 | /// true if this instance is dark; otherwise, false. 1120 | public bool IsDark { get; set; } 1121 | #endregion 1122 | } 1123 | } -------------------------------------------------------------------------------- /MaterialDesignAddon/Controls/MaterialStatusBar.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace MaterialDesignAddon.Controls 5 | { 6 | public class MaterialStatusBar : ContentControl 7 | { 8 | static MaterialStatusBar() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaterialStatusBar), 11 | new FrameworkPropertyMetadata(typeof(MaterialStatusBar))); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Controls/SimpleMaterialWindow.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | 4 | namespace MaterialDesignAddon.Controls 5 | { 6 | public class SimpleMaterialWindow : Window 7 | { 8 | static SimpleMaterialWindow() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SimpleMaterialWindow), 11 | new FrameworkPropertyMetadata(typeof(SimpleMaterialWindow))); 12 | } 13 | 14 | public SimpleMaterialWindow() 15 | { 16 | CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, CloseWindow)); 17 | CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, MaximizeWindow, 18 | CanResizeWindow)); 19 | CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, MinimizeWindow, 20 | CanMinimizeWindow)); 21 | CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, RestoreWindow, 22 | CanResizeWindow)); 23 | } 24 | 25 | public static readonly DependencyProperty StatusBarItemsProperty = DependencyProperty.Register( 26 | "StatusBarItems", typeof(MaterialStatusBar), typeof(SimpleMaterialWindow), 27 | new PropertyMetadata(default(MaterialStatusBar))); 28 | 29 | public MaterialStatusBar StatusBarItems 30 | { 31 | get { return (MaterialStatusBar)GetValue(StatusBarItemsProperty); } 32 | set { SetValue(StatusBarItemsProperty, value); } 33 | } 34 | 35 | #region Window Commands 36 | private void CanResizeWindow(object sender, CanExecuteRoutedEventArgs e) 37 | { 38 | e.CanExecute = ResizeMode == ResizeMode.CanResize || ResizeMode == ResizeMode.CanResizeWithGrip; 39 | } 40 | 41 | private void CanMinimizeWindow(object sender, CanExecuteRoutedEventArgs e) 42 | { 43 | e.CanExecute = ResizeMode != ResizeMode.NoResize; 44 | } 45 | 46 | private void CloseWindow(object sender, ExecutedRoutedEventArgs e) 47 | { 48 | SystemCommands.CloseWindow(this); 49 | } 50 | 51 | private void MaximizeWindow(object sender, ExecutedRoutedEventArgs e) 52 | { 53 | SystemCommands.MaximizeWindow(this); 54 | } 55 | 56 | private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e) 57 | { 58 | SystemCommands.MinimizeWindow(this); 59 | } 60 | 61 | private void RestoreWindow(object sender, ExecutedRoutedEventArgs e) 62 | { 63 | SystemCommands.RestoreWindow(this); 64 | } 65 | #endregion 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Helpers/VisualTreeHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace MaterialDesignAddon.Helpers 5 | { 6 | /// 7 | /// Helper methods for UI-related tasks. 8 | /// I, Tim Stephansen, take no credit for this class whatsoever. 9 | /// This class was obtained from Philip Sumi (a fellow WPF Disciples blog) 10 | /// http://www.hardcodet.net/uploads/2009/06/UIHelper.cs 11 | /// 12 | public static class VisualTreeHelper 13 | { 14 | /// 15 | /// Finds a parent of a given item on the visual tree. 16 | /// 17 | /// The type of the queried item. 18 | /// A direct or indirect child of the 19 | /// queried item. 20 | /// The first parent item that matches the submitted 21 | /// type parameter. If not matching item can be found, a null 22 | /// reference is being returned. 23 | public static T TryFindParent(this DependencyObject child) 24 | where T : DependencyObject 25 | { 26 | //get parent item 27 | DependencyObject parentObject = GetParentObject(child); 28 | 29 | //we've reached the end of the tree 30 | if (parentObject == null) 31 | return null; 32 | 33 | //check if the parent matches the type we're looking for 34 | T parent = parentObject as T; 35 | return parent ?? TryFindParent(parentObject); 36 | } 37 | 38 | /// 39 | /// Finds a Child of a given item in the visual tree. 40 | /// 41 | /// A direct parent of the queried item. 42 | /// The type of the queried item. 43 | /// x:Name or Name of child. 44 | /// The first parent item that matches the submitted type parameter. 45 | /// If not matching item can be found, 46 | /// a null parent is being returned. 47 | public static T FindChild(this DependencyObject parent, string childName) 48 | where T : DependencyObject 49 | { 50 | // Confirm parent and childName are valid. 51 | if (parent == null) 52 | return null; 53 | 54 | T foundChild = null; 55 | 56 | int childrenCount = System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); 57 | for (int i = 0; i < childrenCount; i++) 58 | { 59 | var child = System.Windows.Media.VisualTreeHelper.GetChild(parent, i); 60 | // If the child is not of the request child type child 61 | T childType = child as T; 62 | if (childType == null) 63 | { 64 | // recursively drill down the tree 65 | foundChild = FindChild(child, childName); 66 | 67 | // If the child is found, break so we do not overwrite the found child. 68 | if (foundChild != null) 69 | break; 70 | } 71 | else if (!string.IsNullOrEmpty(childName)) 72 | { 73 | var frameworkElement = child as FrameworkElement; 74 | // If the child's name is set for search 75 | if (frameworkElement != null && frameworkElement.Name == childName) 76 | { 77 | // if the child's name is of the request name 78 | foundChild = (T)child; 79 | break; 80 | } 81 | } 82 | else 83 | { 84 | // child element found. 85 | foundChild = (T)child; 86 | break; 87 | } 88 | } 89 | 90 | return foundChild; 91 | } 92 | 93 | /// 94 | /// This method is an alternative to WPF's 95 | /// method, which also 96 | /// supports content elements. Keep in mind that for content element, 97 | /// this method falls back to the logical tree of the element! 98 | /// 99 | /// The item to be processed. 100 | /// The submitted item's parent, if available. Otherwise 101 | /// null. 102 | public static DependencyObject GetParentObject(this DependencyObject child) 103 | { 104 | if (child == null) 105 | return null; 106 | 107 | //handle content elements separately 108 | var contentElement = child as ContentElement; 109 | if (contentElement != null) 110 | { 111 | DependencyObject parent = ContentOperations.GetParent(contentElement); 112 | if (parent != null) 113 | return parent; 114 | 115 | var fce = contentElement as FrameworkContentElement; 116 | return fce != null ? fce.Parent : null; 117 | } 118 | 119 | //also try searching for parent in framework elements (such as DockPanel, etc) 120 | var frameworkElement = child as FrameworkElement; 121 | if (frameworkElement != null) 122 | { 123 | DependencyObject parent = frameworkElement.Parent; 124 | if (parent != null) 125 | return parent; 126 | } 127 | 128 | //if it's not a ContentElement/FrameworkElement, rely on VisualTreeHelper 129 | return System.Windows.Media.VisualTreeHelper.GetParent(child); 130 | } 131 | 132 | /// 133 | /// Analyzes both visual and logical tree in order to find all elements of a given 134 | /// type that are descendants of the item. 135 | /// 136 | /// The type of the queried items. 137 | /// The root element that marks the source of the search. If the 138 | /// source is already of the requested type, it will not be included in the result. 139 | /// Sometimes it's better to search in the VisualTree (e.g. in tests) 140 | /// All descendants of that match the requested type. 141 | public static IEnumerable FindChildren(this DependencyObject source, bool forceUsingTheVisualTreeHelper = false) where T : DependencyObject 142 | { 143 | if (source != null) 144 | { 145 | var childs = GetChildObjects(source, forceUsingTheVisualTreeHelper); 146 | foreach (DependencyObject child in childs) 147 | { 148 | //analyze if children match the requested type 149 | if (child != null && child is T) 150 | { 151 | yield return (T)child; 152 | } 153 | 154 | //recurse tree 155 | foreach (T descendant in FindChildren(child)) 156 | { 157 | yield return descendant; 158 | } 159 | } 160 | } 161 | } 162 | 163 | /// 164 | /// This method is an alternative to WPF's 165 | /// method, which also 166 | /// supports content elements. Keep in mind that for content elements, 167 | /// this method falls back to the logical tree of the element. 168 | /// 169 | /// The item to be processed. 170 | /// Sometimes it's better to search in the VisualTree (e.g. in tests) 171 | /// The submitted item's child elements, if available. 172 | public static IEnumerable GetChildObjects(this DependencyObject parent, bool forceUsingTheVisualTreeHelper = false) 173 | { 174 | if (parent == null) 175 | yield break; 176 | 177 | if (!forceUsingTheVisualTreeHelper && (parent is ContentElement || parent is FrameworkElement)) 178 | { 179 | //use the logical tree for content / framework elements 180 | foreach (object obj in LogicalTreeHelper.GetChildren(parent)) 181 | { 182 | var depObj = obj as DependencyObject; 183 | if (depObj != null) 184 | yield return (DependencyObject)obj; 185 | } 186 | } 187 | else 188 | { 189 | //use the visual tree per default 190 | int count = System.Windows.Media.VisualTreeHelper.GetChildrenCount(parent); 191 | for (int i = 0; i < count; i++) 192 | { 193 | yield return System.Windows.Media.VisualTreeHelper.GetChild(parent, i); 194 | } 195 | } 196 | } 197 | 198 | /// 199 | /// Tries to locate a given item within the visual tree, 200 | /// starting with the dependency object at a given position. 201 | /// 202 | /// The type of the element to be found 203 | /// on the visual tree of the element at the given location. 204 | /// The main element which is used to perform 205 | /// hit testing. 206 | /// The position to be evaluated on the origin. 207 | public static T TryFindFromPoint(UIElement reference, Point point) 208 | where T : DependencyObject 209 | { 210 | var element = reference.InputHitTest(point) as DependencyObject; 211 | 212 | if (element == null) 213 | return null; 214 | if (element is T) 215 | return (T)element; 216 | return TryFindParent(element); 217 | } 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /MaterialDesignAddon/MaterialDesignAddon.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2306B263-506A-4030-A360-EDF57125EC0C} 8 | library 9 | Properties 10 | MaterialDesignAddon 11 | MaterialDesignAddon 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | bin\Release\MaterialDesignAddon.XML 35 | 36 | 37 | 38 | ..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll 39 | True 40 | 41 | 42 | ..\packages\MaterialDesignThemes.2.2.1.750\lib\net45\MaterialDesignThemes.Wpf.dll 43 | True 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 4.0 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | MSBuild:Compile 63 | Designer 64 | 65 | 66 | 67 | 68 | 69 | Code 70 | 71 | 72 | Designer 73 | MSBuild:Compile 74 | 75 | 76 | Designer 77 | MSBuild:Compile 78 | 79 | 80 | Designer 81 | MSBuild:Compile 82 | 83 | 84 | 85 | 86 | Code 87 | 88 | 89 | True 90 | True 91 | Resources.resx 92 | 93 | 94 | True 95 | Settings.settings 96 | True 97 | 98 | 99 | ResXFileCodeGenerator 100 | Resources.Designer.cs 101 | 102 | 103 | 104 | SettingsSingleFileGenerator 105 | Settings.Designer.cs 106 | 107 | 108 | 109 | 110 | 117 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using System.Windows.Markup; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("MaterialDesignAddon")] 12 | [assembly: AssemblyDescription("Material Design Color Wheel for the Material Design in XAML Toolkit")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("LandmarkDevs")] 15 | [assembly: AssemblyProduct("MaterialDesignAddon")] 16 | [assembly: AssemblyCopyright("Copyright © 2017")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | [assembly: XmlnsDefinition("http://schemas.landmarkdevs.com/xaml", "MaterialDesignAddon.Controls")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | //In order to begin building localizable applications, set 27 | //CultureYouAreCodingWith in your .csproj file 28 | //inside a . For example, if you are using US english 29 | //in your source files, set the to en-US. Then uncomment 30 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 31 | //the line below to match the UICulture setting in the project file. 32 | 33 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 34 | 35 | 36 | [assembly:ThemeInfo( 37 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 38 | //(used if a resource is not found in the page, 39 | // or application resource dictionaries) 40 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 41 | //(used if a resource is not found in the page, 42 | // app, or any theme specific resource dictionaries) 43 | )] 44 | 45 | 46 | // Version information for an assembly consists of the following four values: 47 | // 48 | // Major Version 49 | // Minor Version 50 | // Build Number 51 | // Revision 52 | // 53 | // You can specify all the values or you can default the Build and Revision Numbers 54 | // by using the '*' as shown below: 55 | // [assembly: AssemblyVersion("1.0.*")] 56 | [assembly: AssemblyVersion("1.0.0.0")] 57 | [assembly: AssemblyFileVersion("1.0.0.0")] 58 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialDesignAddon.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MaterialDesignAddon.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialDesignAddon.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Themes/MaterialStatusBar.xaml: -------------------------------------------------------------------------------- 1 |  4 | 13 | -------------------------------------------------------------------------------- /MaterialDesignAddon/Themes/SimpleMaterialWindow.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 8 | 17 | 26 | 27 | 28 | 31 | 40 | 49 | 50 | 51 | 54 | 62 | 63 | 64 | 67 | 76 | 77 | 78 | 109 | 110 | 123 | 124 | 165 | 166 | 167 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 185 | 186 | 187 | 188 | 189 | 192 | 201 | 209 |