├── .gitignore ├── LICENSE ├── README.md ├── docs └── assets │ ├── create_component_demo.gif │ ├── demo.gif │ ├── generate_code_behind_demo.gif │ ├── wrap_in_component_demo.gif │ └── wrap_in_tag_demo.gif └── src ├── AntDesignToolbox.sln └── AntDesignToolbox ├── AntDesignToolbox.csproj ├── AntDesignToolboxPackage.cs ├── Commands ├── AddComponentCommand.cs ├── AddCrudPageCommand.cs ├── ControlToolboxCommand.cs ├── CreateCodeBehindCommand.cs ├── SurroundWithComponentCommand.cs └── SurroundWithTagCommand.cs ├── Commons ├── FileHelper.cs ├── ProjectHelper.cs ├── ViewModelHelper.cs └── XmlHelpers.cs ├── Converters ├── BooleanToHiddenConverter.cs └── InverseBooleanConverter.cs ├── Definitions └── Components.xml ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs └── Resources.resx ├── Resources └── Icon.png ├── Styles ├── GridStyles.xaml ├── LabelStyles.xaml ├── OptionItemStyles.xaml ├── StyleUtilities.xaml └── TextboxStyles.xaml ├── TextTemplates ├── BaseTemplate.cs ├── BaseTemplate.tt ├── CodeBehindTemplate.cs ├── CodeBehindTemplate.tt ├── CssTemplate.cs ├── CssTemplate.tt ├── RazorComponentTemplate.cs └── RazorComponentTemplate.tt ├── ToolWindows ├── ControlToolboxControl.xaml ├── ControlToolboxControl.xaml.cs ├── ControlToolboxWindow.cs ├── Controls │ ├── ComponentTreeItemControl.xaml │ └── ComponentTreeItemControl.xaml.cs └── ViewModels │ ├── ComponentViewModel.cs │ ├── ControlToolboxViewModel.cs │ ├── EnumOptions │ ├── ButtonSize.cs │ ├── ButtonType.cs │ ├── DefaultAttribute.cs │ ├── Direction.cs │ ├── MenuMode.cs │ ├── MenuTheme.cs │ ├── NavLinkMatch.cs │ ├── Placement.cs │ ├── Size.cs │ ├── StringValueAttribute.cs │ ├── TitleLevel.cs │ └── TypographyType.cs │ ├── PropertyCategory.cs │ ├── PropertyImplementations │ ├── BooleanPropertyViewModel.cs │ ├── ContainsElementPropertyViewModel.cs │ ├── IconTypePropertyViewModel.cs │ ├── IntegerOrIteratorPropertyViewModel.cs │ ├── IntegerPropertyViewModel.cs │ ├── OptionsPropertyViewModel.cs │ ├── StringOptionItemViewModel.cs │ ├── StringOptionsViewModel.cs │ └── StringPropertyViewModel.cs │ ├── PropertyItemViewModel.cs │ ├── TreeItemViewModel.cs │ └── ViewModelSourceHelper.cs ├── VSCommandTable.cs ├── VSCommandTable.vsct ├── ViewModels ├── AddComponentViewModel.cs ├── CreateCodeBehindViewModel.cs ├── SurroundWithComponentViewModel.cs └── SurroundWithTagViewModel.cs ├── Views ├── AddComponentWindow.xaml ├── AddComponentWindow.xaml.cs ├── CreateCodeBehindWindow.xaml ├── CreateCodeBehindWindow.xaml.cs ├── SurroundWithComponentWindow.xaml ├── SurroundWithComponentWindow.xaml.cs ├── SurroundWithTagWindow.xaml └── SurroundWithTagWindow.xaml.cs ├── source.extension.cs └── source.extension.vsixmanifest /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Bin Dong 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ant Design Blazor Toolbox 2 | 3 | Your companion for developing Blazor with Ant Design Blazor 4 | 5 | ## Supported Version 6 | 7 | **Requires Visual Studio 2022 or newer** 8 | 9 | ## Features (WIP) 10 | 11 | 1. Drag and Drop control from toolbox to razor file. 12 | 3. Generate boilerplate razor component for specific scenarios. 13 | 4. Customize and export code snippets. 14 | 15 | ## Demo 16 | 17 | * Drag Ant Design Blazor components to razor file 18 | 19 | ![demo](/docs/assets/demo.gif) 20 | 21 | * Create Razor component with code behind or stylesheet 22 | 23 | ![demo](/docs/assets/create_component_demo.gif) 24 | 25 | * Generate code behind and stylesheet for existing components 26 | 27 | ![demo](/docs/assets/generate_code_behind_demo.gif) 28 | 29 | * Surround component with tag 30 | 31 | ![demo](/docs/assets/wrap_in_tag_demo.gif) 32 | 33 | * Surround component with component 34 | 35 | ![demo](/docs/assets/wrap_in_component_demo.gif) 36 | -------------------------------------------------------------------------------- /docs/assets/create_component_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/docs/assets/create_component_demo.gif -------------------------------------------------------------------------------- /docs/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/docs/assets/demo.gif -------------------------------------------------------------------------------- /docs/assets/generate_code_behind_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/docs/assets/generate_code_behind_demo.gif -------------------------------------------------------------------------------- /docs/assets/wrap_in_component_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/docs/assets/wrap_in_component_demo.gif -------------------------------------------------------------------------------- /docs/assets/wrap_in_tag_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/docs/assets/wrap_in_tag_demo.gif -------------------------------------------------------------------------------- /src/AntDesignToolbox.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32616.157 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AntDesignToolbox", "AntDesignToolbox\AntDesignToolbox.csproj", "{23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x86 = Debug|x86 12 | Release|Any CPU = Release|Any CPU 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Debug|x86.ActiveCfg = Debug|x86 19 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Debug|x86.Build.0 = Debug|x86 20 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Release|x86.ActiveCfg = Release|x86 23 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C}.Release|x86.Build.0 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {284B9320-01E5-415C-9A7F-4940C62AA8D1} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/AntDesignToolbox.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 5 | latest 6 | 7 | 8 | 9 | 10 | Debug 11 | AnyCPU 12 | 2.0 13 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | {23FEB5A4-A6D0-492B-91F7-7FDF3E53969C} 15 | Library 16 | Properties 17 | AntDesignToolbox 18 | AntDesignToolbox 19 | v4.8 20 | true 21 | true 22 | true 23 | true 24 | false 25 | true 26 | true 27 | Program 28 | $(DevEnvDir)devenv.exe 29 | /rootsuffix Exp 30 | 31 | 32 | true 33 | full 34 | false 35 | bin\Debug\ 36 | DEBUG;TRACE 37 | prompt 38 | 4 39 | True 40 | 41 | 42 | pdbonly 43 | true 44 | bin\Release\ 45 | TRACE 46 | prompt 47 | 4 48 | True 49 | False 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | True 68 | True 69 | Resources.resx 70 | 71 | 72 | True 73 | True 74 | source.extension.vsixmanifest 75 | 76 | 77 | True 78 | True 79 | BaseTemplate.tt 80 | 81 | 82 | True 83 | True 84 | CodeBehindTemplate.tt 85 | 86 | 87 | True 88 | True 89 | RazorComponentTemplate.tt 90 | 91 | 92 | True 93 | True 94 | CssTemplate.tt 95 | 96 | 97 | ComponentTreeItemControl.xaml 98 | 99 | 100 | ControlToolboxControl.xaml 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | AddComponentWindow.xaml 136 | 137 | 138 | CreateCodeBehindWindow.xaml 139 | 140 | 141 | SurroundWithComponentWindow.xaml 142 | 143 | 144 | SurroundWithTagWindow.xaml 145 | 146 | 147 | True 148 | True 149 | VSCommandTable.vsct 150 | 151 | 152 | 153 | 154 | TextTemplatingFilePreprocessor 155 | BaseTemplate.cs 156 | 157 | 158 | TextTemplatingFilePreprocessor 159 | CodeBehindTemplate.cs 160 | 161 | 162 | TextTemplatingFilePreprocessor 163 | RazorComponentTemplate.cs 164 | 165 | 166 | TextTemplatingFilePreprocessor 167 | CssTemplate.cs 168 | 169 | 170 | Designer 171 | VsixManifestGenerator 172 | source.extension.cs 173 | 174 | 175 | 176 | PreserveNewest 177 | true 178 | 179 | 180 | 181 | 182 | Menus.ctmenu 183 | VsctGenerator 184 | VSCommandTable.cs 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | compile; build; native; contentfiles; analyzers; buildtransitive 202 | 203 | 204 | 4.2.0 205 | 206 | 207 | 4.2.0 208 | 209 | 210 | 4.2.0 211 | 212 | 213 | 4.2.0 214 | 215 | 216 | 17.2.32505.113 217 | 218 | 219 | 4.2.0 220 | 221 | 222 | 17.2.32505.113 223 | 224 | 225 | runtime; build; native; contentfiles; analyzers; buildtransitive 226 | all 227 | 228 | 229 | 8.1.97 230 | 231 | 232 | 5.0.0 233 | 234 | 235 | 236 | 237 | Designer 238 | MSBuild:Compile 239 | 240 | 241 | Designer 242 | MSBuild:Compile 243 | 244 | 245 | Designer 246 | MSBuild:Compile 247 | 248 | 249 | Designer 250 | MSBuild:Compile 251 | 252 | 253 | Designer 254 | MSBuild:Compile 255 | 256 | 257 | Designer 258 | MSBuild:Compile 259 | 260 | 261 | MSBuild:Compile 262 | Designer 263 | 264 | 265 | Designer 266 | MSBuild:Compile 267 | 268 | 269 | Designer 270 | MSBuild:Compile 271 | 272 | 273 | Designer 274 | MSBuild:Compile 275 | 276 | 277 | Designer 278 | MSBuild:Compile 279 | 280 | 281 | 282 | 283 | ResXFileCodeGenerator 284 | Resources.Designer.cs 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 302 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/AntDesignToolboxPackage.cs: -------------------------------------------------------------------------------- 1 | global using Community.VisualStudio.Toolkit; 2 | global using Microsoft.VisualStudio.Shell; 3 | global using System; 4 | global using Task = System.Threading.Tasks.Task; 5 | using EnvDTE; 6 | using EnvDTE80; 7 | using Microsoft.VisualStudio; 8 | using System.Runtime.InteropServices; 9 | using System.Threading; 10 | 11 | namespace AntDesignToolbox 12 | { 13 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] 14 | [InstalledProductRegistration(Vsix.Name, Vsix.Description, Vsix.Version)] 15 | [ProvideToolWindow(typeof(ControlToolboxWindow.Pane), Style = VsDockStyle.Tabbed, Window = WindowGuids.Toolbox)] 16 | [ProvideToolWindowVisibility(typeof(ControlToolboxWindow), VSConstants.UICONTEXT.SolutionExists_string)] 17 | [ProvideMenuResource("Menus.ctmenu", 1)] 18 | [Guid(PackageGuids.AntDesignToolboxString)] 19 | public sealed class AntDesignToolboxPackage : ToolkitPackage 20 | { 21 | public static DTE2 DTE { get; private set; } 22 | 23 | protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) 24 | { 25 | DTE = (DTE2)await GetServiceAsync(typeof(DTE)); 26 | await this.RegisterCommandsAsync(); 27 | this.RegisterToolWindows(); 28 | 29 | } 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/AddComponentCommand.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.Views; 2 | using System.Linq; 3 | 4 | namespace AntDesignToolbox 5 | { 6 | [Command(PackageGuids.AntDesignToolboxString, PackageIds.AddComponentCommand)] 7 | internal sealed class AddComponentCommand : BaseCommand 8 | { 9 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 10 | { 11 | var solutionItems = (await VS.Solutions.GetActiveItemsAsync())?.ToList(); 12 | if (solutionItems is null || solutionItems.Count != 1) 13 | { 14 | await VS.MessageBox.ShowErrorAsync("Cannot determine where to add this component. Please select only one folder. "); 15 | return; 16 | } 17 | await VS.Windows.ShowDialogAsync(new AddComponentWindow()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/AddCrudPageCommand.cs: -------------------------------------------------------------------------------- 1 | namespace AntDesignToolbox 2 | { 3 | [Command(PackageGuids.AntDesignToolboxString, PackageIds.AddCrudPageCommand)] 4 | internal sealed class AddCrudPageCommand : BaseCommand 5 | { 6 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 7 | { 8 | await VS.MessageBox.ShowWarningAsync("AddCrudPageCommand", "Button clicked"); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/ControlToolboxCommand.cs: -------------------------------------------------------------------------------- 1 | namespace AntDesignToolbox 2 | { 3 | [Command(PackageIds.ControlToolboxCommand)] 4 | internal sealed class ControlToolboxCommand : BaseCommand 5 | { 6 | protected override Task ExecuteAsync(OleMenuCmdEventArgs e) 7 | { 8 | return ControlToolboxWindow.ShowAsync(); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/CreateCodeBehindCommand.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.Views; 2 | using System.Collections.Generic; 3 | 4 | namespace AntDesignToolbox 5 | { 6 | [Command(PackageGuids.AntDesignToolboxString, PackageIds.CreateCodeBehindCommand)] 7 | internal sealed class CreateCodeBehindCommand : BaseCommand 8 | { 9 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 10 | { 11 | await VS.Windows.ShowDialogAsync(new CreateCodeBehindWindow()); 12 | } 13 | 14 | protected override void BeforeQueryStatus(EventArgs e) 15 | { 16 | IEnumerable solutionItems = ThreadHelper.JoinableTaskFactory.Run(VS.Solutions.GetActiveItemsAsync); 17 | bool enable = true; 18 | foreach(var item in solutionItems) 19 | { 20 | if(item.Type != SolutionItemType.PhysicalFile) 21 | { 22 | enable = false; 23 | } 24 | } 25 | this.Command.Enabled = enable; 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/SurroundWithComponentCommand.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.Views; 2 | 3 | namespace AntDesignToolbox 4 | { 5 | [Command(PackageGuids.AntDesignToolboxString, PackageIds.SurroundWithComponentCommand)] 6 | internal sealed class SurroundWithComponentCommand : BaseCommand 7 | { 8 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 9 | { 10 | // await VS.MessageBox.ShowWarningAsync("SurroundWithComponentCommand", "Button clicked"); 11 | await VS.Windows.ShowDialogAsync(new SurroundWithComponentWindow()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commands/SurroundWithTagCommand.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.Views; 2 | using EnvDTE; 3 | using Microsoft.VisualStudio.Threading; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace AntDesignToolbox 8 | { 9 | [Command(PackageGuids.AntDesignToolboxString, PackageIds.SurroundWithTagCommand)] 10 | internal sealed class SurroundWithTagCommand : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | //Execute(); 15 | await VS.Windows.ShowDialogAsync(new SurroundWithTagWindow()); 16 | } 17 | 18 | protected override void BeforeQueryStatus(EventArgs e) 19 | { 20 | ThreadHelper.ThrowIfNotOnUIThread(); 21 | var activeDocument = AntDesignToolboxPackage.DTE.ActiveDocument.Object("TextDocument") as TextDocument; 22 | var language = activeDocument.Language; 23 | this.Command.Enabled = (language=="Razor"); 24 | } 25 | 26 | private void Execute() 27 | { 28 | ThreadHelper.ThrowIfNotOnUIThread(); 29 | var activeDocument = AntDesignToolboxPackage.DTE.ActiveDocument.Object("TextDocument") as TextDocument; 30 | TextSelection selection = activeDocument.Selection; 31 | var text = selection.Text; 32 | var lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 33 | var newText = GetNewText(lines); 34 | selection.ReplaceText(text, newText); 35 | } 36 | 37 | private Tuple GetIndent(string[] lines) 38 | { 39 | if (lines is null || lines.Length == 0) return new Tuple(' ', 0); 40 | string line = lines.FirstOrDefault(a=>a.Length>0); 41 | if(line is null) return new Tuple(' ', 0); 42 | if (line.StartsWith("\t")) 43 | { 44 | int count = 0; 45 | foreach(char c in line) 46 | { 47 | if (c == '\t') 48 | { 49 | count++; 50 | } 51 | else 52 | { 53 | break; 54 | } 55 | } 56 | return new Tuple('\t', count); 57 | } 58 | else if(line.StartsWith(" ")) 59 | { 60 | int count = 0; 61 | foreach (char c in line) 62 | { 63 | if (c == ' ') 64 | { 65 | count++; 66 | } 67 | else 68 | { 69 | break; 70 | } 71 | } 72 | return new Tuple(' ', count); 73 | } 74 | return new Tuple(' ', 0); 75 | } 76 | 77 | private string GetNewText(string[] lines) 78 | { 79 | var tuple = GetIndent(lines); 80 | string indent = tuple.Item1 == ' ' ? " " : "\t"; 81 | string divIndent = new string(Enumerable.Repeat(tuple.Item1, tuple.Item2).ToArray()); 82 | StringBuilder builder = new StringBuilder(); 83 | builder.AppendLine(divIndent + "
"); 84 | foreach(var line in lines) 85 | { 86 | if (line.Length == 0) 87 | { 88 | builder.AppendLine(line); 89 | } 90 | else{ 91 | builder.AppendLine(indent + line); 92 | } 93 | } 94 | builder.AppendLine(divIndent + "
"); 95 | return builder.ToString(); 96 | } 97 | 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commons/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.Commons 9 | { 10 | internal static class FileHelper 11 | { 12 | public static async Task CreateTextFileAsync(string path, string content) 13 | { 14 | using var stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, bufferSize: 4096, useAsync: true); 15 | using StreamWriter sw = new(stream); 16 | await sw.WriteAsync(content); 17 | } 18 | 19 | public static async Task ThrowIfExistAsync(string path) 20 | { 21 | if (File.Exists(path)) 22 | { 23 | await VS.MessageBox.ShowErrorAsync("File already exists. "); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commons/ProjectHelper.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE80; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace AntDesignToolbox.Commons 10 | { 11 | internal static class ProjectHelper 12 | { 13 | private static readonly DTE2 _dte = AntDesignToolboxPackage.DTE; 14 | 15 | public static async Task GetRootNamespaceAsync(this Project project) 16 | { 17 | if (project is null) return null; 18 | string @namespace = project.Name ?? string.Empty; 19 | try 20 | { 21 | @namespace = await project.GetAttributeAsync("RootNamespace"); 22 | } 23 | catch { } 24 | return @namespace; 25 | } 26 | 27 | public static async Task GetNamespaceAsync(SolutionItem item) 28 | { 29 | Project project = null; 30 | if (item is Project p) 31 | { 32 | project = p; 33 | } 34 | else 35 | { 36 | project = item.FindParent(SolutionItemType.Project) as Project; 37 | } 38 | var rootNamespace = await GetRootNamespaceAsync(project); 39 | List sections = new List(); 40 | SolutionItem i = item; 41 | while (i != null && i?.FullPath != project?.FullPath) 42 | { 43 | sections.Add(i.Text); 44 | i = i.Parent; 45 | } 46 | sections.Add(rootNamespace); 47 | sections.Reverse(); 48 | return string.Join(".", sections); 49 | } 50 | 51 | public static DirectoryInfo GetContainingFolder(this SolutionItem project) 52 | { 53 | if (project.Type == SolutionItemType.Project || project.Type == SolutionItemType.PhysicalFile) 54 | { 55 | FileInfo fileInfo = new FileInfo(project.FullPath); 56 | return fileInfo.Directory; 57 | } 58 | else if (project.Type == SolutionItemType.PhysicalFolder) 59 | { 60 | DirectoryInfo info = new DirectoryInfo(project.FullPath); 61 | return info; 62 | } 63 | return null; 64 | } 65 | 66 | public static Project GetContainingProject(this SolutionItem item) 67 | { 68 | if (item is null || item.Type == SolutionItemType.Solution || item.Type == SolutionItemType.SolutionFolder) 69 | { 70 | return null; 71 | } 72 | SolutionItem i = item; 73 | // TODO: optimize code. 74 | //if(i.Parent != null && i.Parent.Type == SolutionItemType.Project) 75 | //{ 76 | // return i.Parent as Project; 77 | //} 78 | //while (i.Parent != null && i.Parent.Type != SolutionItemType.Project) 79 | //{ 80 | // i = i.Parent; 81 | //} 82 | //return i as Project; 83 | while (i != null) 84 | { 85 | if (i.Type == SolutionItemType.Project) 86 | { 87 | return i as Project; 88 | } 89 | else 90 | { 91 | i = i.Parent; 92 | } 93 | } 94 | return null; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commons/ViewModelHelper.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.Collections.ObjectModel; 7 | using AntDesignToolbox.ToolWindows.ViewModels; 8 | 9 | namespace AntDesignToolbox.Commons 10 | { 11 | public static class ViewModelHelper 12 | { 13 | public static T GetProperty( this ObservableCollection collection, string name) where T:PropertyItemViewModel 14 | { 15 | var property = collection.OfType().FirstOrDefault(a => a.PropertyName == name); 16 | return property; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Commons/XmlHelpers.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.Xml.Linq; 7 | 8 | namespace AntDesignToolbox.Commons 9 | { 10 | public static class XmlHelper 11 | { 12 | public static void AddNonNullAttribute(this XElement element, XAttribute attribute) 13 | { 14 | if (attribute is null) return; 15 | element.Add(attribute); 16 | } 17 | 18 | public static void AddNonNullAttributes(this XElement element, IEnumerable attributes) 19 | { 20 | if(attributes is null) return; 21 | foreach(var attribute in attributes) 22 | { 23 | if (attribute is null) return; 24 | element.Add(attribute); 25 | } 26 | } 27 | 28 | public static void AddNonNullNodes(this XElement element, IEnumerable elements) 29 | { 30 | if (elements is null) return; 31 | foreach(var e in elements) 32 | { 33 | if (e is null) return; 34 | element.Add(e); 35 | } 36 | } 37 | 38 | public static void EnsureNotEmpty(this XElement element) 39 | { 40 | if (element.Elements().Count() == 0) 41 | { 42 | element.Add(new XText("\n\n")); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Converters/BooleanToHiddenConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace AntDesignToolbox.Converters 7 | { 8 | internal class BooleanToHiddenConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if(value is bool b) 13 | { 14 | return b ? Visibility.Visible : Visibility.Hidden; 15 | } 16 | return Visibility.Hidden; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace AntDesignToolbox.Converters 7 | { 8 | public class InverseBooleanConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if(value is bool b) 13 | { 14 | return !b; 15 | } 16 | return DependencyProperty.UnsetValue; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Definitions/Components.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Primary]]> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle(Vsix.Name)] 6 | [assembly: AssemblyDescription(Vsix.Description)] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany(Vsix.Author)] 9 | [assembly: AssemblyProduct(Vsix.Name)] 10 | [assembly: AssemblyCopyright(Vsix.Author)] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: AssemblyVersion(Vsix.Version)] 17 | [assembly: AssemblyFileVersion(Vsix.Version)] 18 | 19 | namespace System.Runtime.CompilerServices 20 | { 21 | public class IsExternalInit { } 22 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/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 AntDesignToolbox.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AntDesignToolbox.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 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rabbitism/AntDesignToolbox/0377ab671df67de8fe0776fbe7fbcd1da0555a66/src/AntDesignToolbox/Resources/Icon.png -------------------------------------------------------------------------------- /src/AntDesignToolbox/Styles/GridStyles.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 22 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Styles/LabelStyles.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 11 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Styles/OptionItemStyles.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 33 | 37 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 62 | 67 | 68 | 69 | 70 | 71 | 72 | 75 | 76 | 77 | 87 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 110 | 113 | 114 | 115 | 116 | 117 | 118 | 121 | 122 | 123 | 133 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 147 | 148 | 149 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 187 | 188 | 189 | 199 | 204 | 205 | 206 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 234 | 239 | 240 | 241 | 243 | 244 | 245 | 256 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Styles/StyleUtilities.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 11 | 16 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Styles/TextboxStyles.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 14 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/BaseTemplate.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version: 17.0.0.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | namespace AntDesignToolbox.TextTemplates 11 | { 12 | using System.Linq; 13 | using System.Text; 14 | using System.Collections.Generic; 15 | using System; 16 | 17 | /// 18 | /// Class to produce the template output 19 | /// 20 | 21 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\BaseTemplate.tt" 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] 23 | public partial class BaseTemplate : BaseTemplateBase 24 | { 25 | #line hidden 26 | /// 27 | /// Create the template output 28 | /// 29 | public virtual string TransformText() 30 | { 31 | return this.GenerationEnvironment.ToString(); 32 | } 33 | 34 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\BaseTemplate.tt" 35 | 36 | private string _DummyField; 37 | 38 | /// 39 | /// Access the Dummy parameter of the template. 40 | /// 41 | private string Dummy 42 | { 43 | get 44 | { 45 | return this._DummyField; 46 | } 47 | } 48 | 49 | 50 | /// 51 | /// Initialize the template 52 | /// 53 | public virtual void Initialize() 54 | { 55 | if ((this.Errors.HasErrors == false)) 56 | { 57 | bool DummyValueAcquired = false; 58 | if (this.Session.ContainsKey("Dummy")) 59 | { 60 | this._DummyField = ((string)(this.Session["Dummy"])); 61 | DummyValueAcquired = true; 62 | } 63 | if ((DummyValueAcquired == false)) 64 | { 65 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Dummy"); 66 | if ((data != null)) 67 | { 68 | this._DummyField = ((string)(data)); 69 | } 70 | } 71 | 72 | 73 | } 74 | } 75 | 76 | 77 | 78 | #line default 79 | #line hidden 80 | } 81 | 82 | #line default 83 | #line hidden 84 | #region Base class 85 | /// 86 | /// Base class for this transformation 87 | /// 88 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] 89 | public class BaseTemplateBase 90 | { 91 | #region Fields 92 | private global::System.Text.StringBuilder generationEnvironmentField; 93 | private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField; 94 | private global::System.Collections.Generic.List indentLengthsField; 95 | private string currentIndentField = ""; 96 | private bool endsWithNewline; 97 | private global::System.Collections.Generic.IDictionary sessionField; 98 | #endregion 99 | #region Properties 100 | /// 101 | /// The string builder that generation-time code is using to assemble generated output 102 | /// 103 | protected System.Text.StringBuilder GenerationEnvironment 104 | { 105 | get 106 | { 107 | if ((this.generationEnvironmentField == null)) 108 | { 109 | this.generationEnvironmentField = new global::System.Text.StringBuilder(); 110 | } 111 | return this.generationEnvironmentField; 112 | } 113 | set 114 | { 115 | this.generationEnvironmentField = value; 116 | } 117 | } 118 | /// 119 | /// The error collection for the generation process 120 | /// 121 | public System.CodeDom.Compiler.CompilerErrorCollection Errors 122 | { 123 | get 124 | { 125 | if ((this.errorsField == null)) 126 | { 127 | this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection(); 128 | } 129 | return this.errorsField; 130 | } 131 | } 132 | /// 133 | /// A list of the lengths of each indent that was added with PushIndent 134 | /// 135 | private System.Collections.Generic.List indentLengths 136 | { 137 | get 138 | { 139 | if ((this.indentLengthsField == null)) 140 | { 141 | this.indentLengthsField = new global::System.Collections.Generic.List(); 142 | } 143 | return this.indentLengthsField; 144 | } 145 | } 146 | /// 147 | /// Gets the current indent we use when adding lines to the output 148 | /// 149 | public string CurrentIndent 150 | { 151 | get 152 | { 153 | return this.currentIndentField; 154 | } 155 | } 156 | /// 157 | /// Current transformation session 158 | /// 159 | public virtual global::System.Collections.Generic.IDictionary Session 160 | { 161 | get 162 | { 163 | return this.sessionField; 164 | } 165 | set 166 | { 167 | this.sessionField = value; 168 | } 169 | } 170 | #endregion 171 | #region Transform-time helpers 172 | /// 173 | /// Write text directly into the generated output 174 | /// 175 | public void Write(string textToAppend) 176 | { 177 | if (string.IsNullOrEmpty(textToAppend)) 178 | { 179 | return; 180 | } 181 | // If we're starting off, or if the previous text ended with a newline, 182 | // we have to append the current indent first. 183 | if (((this.GenerationEnvironment.Length == 0) 184 | || this.endsWithNewline)) 185 | { 186 | this.GenerationEnvironment.Append(this.currentIndentField); 187 | this.endsWithNewline = false; 188 | } 189 | // Check if the current text ends with a newline 190 | if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture)) 191 | { 192 | this.endsWithNewline = true; 193 | } 194 | // This is an optimization. If the current indent is "", then we don't have to do any 195 | // of the more complex stuff further down. 196 | if ((this.currentIndentField.Length == 0)) 197 | { 198 | this.GenerationEnvironment.Append(textToAppend); 199 | return; 200 | } 201 | // Everywhere there is a newline in the text, add an indent after it 202 | textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField)); 203 | // If the text ends with a newline, then we should strip off the indent added at the very end 204 | // because the appropriate indent will be added when the next time Write() is called 205 | if (this.endsWithNewline) 206 | { 207 | this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length)); 208 | } 209 | else 210 | { 211 | this.GenerationEnvironment.Append(textToAppend); 212 | } 213 | } 214 | /// 215 | /// Write text directly into the generated output 216 | /// 217 | public void WriteLine(string textToAppend) 218 | { 219 | this.Write(textToAppend); 220 | this.GenerationEnvironment.AppendLine(); 221 | this.endsWithNewline = true; 222 | } 223 | /// 224 | /// Write formatted text directly into the generated output 225 | /// 226 | public void Write(string format, params object[] args) 227 | { 228 | this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); 229 | } 230 | /// 231 | /// Write formatted text directly into the generated output 232 | /// 233 | public void WriteLine(string format, params object[] args) 234 | { 235 | this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args)); 236 | } 237 | /// 238 | /// Raise an error 239 | /// 240 | public void Error(string message) 241 | { 242 | System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); 243 | error.ErrorText = message; 244 | this.Errors.Add(error); 245 | } 246 | /// 247 | /// Raise a warning 248 | /// 249 | public void Warning(string message) 250 | { 251 | System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError(); 252 | error.ErrorText = message; 253 | error.IsWarning = true; 254 | this.Errors.Add(error); 255 | } 256 | /// 257 | /// Increase the indent 258 | /// 259 | public void PushIndent(string indent) 260 | { 261 | if ((indent == null)) 262 | { 263 | throw new global::System.ArgumentNullException("indent"); 264 | } 265 | this.currentIndentField = (this.currentIndentField + indent); 266 | this.indentLengths.Add(indent.Length); 267 | } 268 | /// 269 | /// Remove the last indent that was added with PushIndent 270 | /// 271 | public string PopIndent() 272 | { 273 | string returnValue = ""; 274 | if ((this.indentLengths.Count > 0)) 275 | { 276 | int indentLength = this.indentLengths[(this.indentLengths.Count - 1)]; 277 | this.indentLengths.RemoveAt((this.indentLengths.Count - 1)); 278 | if ((indentLength > 0)) 279 | { 280 | returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength)); 281 | this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength)); 282 | } 283 | } 284 | return returnValue; 285 | } 286 | /// 287 | /// Remove any indentation 288 | /// 289 | public void ClearIndent() 290 | { 291 | this.indentLengths.Clear(); 292 | this.currentIndentField = ""; 293 | } 294 | #endregion 295 | #region ToString Helpers 296 | /// 297 | /// Utility class to produce culture-oriented representation of an object as a string. 298 | /// 299 | public class ToStringInstanceHelper 300 | { 301 | private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture; 302 | /// 303 | /// Gets or sets format provider to be used by ToStringWithCulture method. 304 | /// 305 | public System.IFormatProvider FormatProvider 306 | { 307 | get 308 | { 309 | return this.formatProviderField ; 310 | } 311 | set 312 | { 313 | if ((value != null)) 314 | { 315 | this.formatProviderField = value; 316 | } 317 | } 318 | } 319 | /// 320 | /// This is called from the compile/run appdomain to convert objects within an expression block to a string 321 | /// 322 | public string ToStringWithCulture(object objectToConvert) 323 | { 324 | if ((objectToConvert == null)) 325 | { 326 | throw new global::System.ArgumentNullException("objectToConvert"); 327 | } 328 | System.Type t = objectToConvert.GetType(); 329 | System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] { 330 | typeof(System.IFormatProvider)}); 331 | if ((method == null)) 332 | { 333 | return objectToConvert.ToString(); 334 | } 335 | else 336 | { 337 | return ((string)(method.Invoke(objectToConvert, new object[] { 338 | this.formatProviderField }))); 339 | } 340 | } 341 | } 342 | private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper(); 343 | /// 344 | /// Helper to produce culture-oriented representation of an object as a string 345 | /// 346 | public ToStringInstanceHelper ToStringHelper 347 | { 348 | get 349 | { 350 | return this.toStringHelperField; 351 | } 352 | } 353 | #endregion 354 | } 355 | #endregion 356 | } 357 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/BaseTemplate.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ parameter type="System.String" name="Dummy" #> -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/CodeBehindTemplate.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version: 17.0.0.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | namespace AntDesignToolbox.TextTemplates 11 | { 12 | using System.Linq; 13 | using System.Text; 14 | using System.Collections.Generic; 15 | using System; 16 | 17 | /// 18 | /// Class to produce the template output 19 | /// 20 | 21 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\CodeBehindTemplate.tt" 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] 23 | public partial class CodeBehindTemplate : BaseTemplate 24 | { 25 | #line hidden 26 | /// 27 | /// Create the template output 28 | /// 29 | public override string TransformText() 30 | { 31 | this.Write("using System;\r\nusing System.Collections.Generic;\r\n\r\nnamespace "); 32 | 33 | #line 11 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\CodeBehindTemplate.tt" 34 | this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); 35 | 36 | #line default 37 | #line hidden 38 | this.Write("\r\n{\r\n public partial class "); 39 | 40 | #line 13 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\CodeBehindTemplate.tt" 41 | this.Write(this.ToStringHelper.ToStringWithCulture(Name)); 42 | 43 | #line default 44 | #line hidden 45 | this.Write("\r\n {\r\n\r\n }\r\n}\r\n"); 46 | return this.GenerationEnvironment.ToString(); 47 | } 48 | 49 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\CodeBehindTemplate.tt" 50 | 51 | private string _NameField; 52 | 53 | /// 54 | /// Access the Name parameter of the template. 55 | /// 56 | private string Name 57 | { 58 | get 59 | { 60 | return this._NameField; 61 | } 62 | } 63 | 64 | private string _NamespaceField; 65 | 66 | /// 67 | /// Access the Namespace parameter of the template. 68 | /// 69 | private string Namespace 70 | { 71 | get 72 | { 73 | return this._NamespaceField; 74 | } 75 | } 76 | 77 | 78 | /// 79 | /// Initialize the template 80 | /// 81 | public override void Initialize() 82 | { 83 | base.Initialize(); 84 | if ((this.Errors.HasErrors == false)) 85 | { 86 | bool NameValueAcquired = false; 87 | if (this.Session.ContainsKey("Name")) 88 | { 89 | this._NameField = ((string)(this.Session["Name"])); 90 | NameValueAcquired = true; 91 | } 92 | if ((NameValueAcquired == false)) 93 | { 94 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Name"); 95 | if ((data != null)) 96 | { 97 | this._NameField = ((string)(data)); 98 | } 99 | } 100 | bool NamespaceValueAcquired = false; 101 | if (this.Session.ContainsKey("Namespace")) 102 | { 103 | this._NamespaceField = ((string)(this.Session["Namespace"])); 104 | NamespaceValueAcquired = true; 105 | } 106 | if ((NamespaceValueAcquired == false)) 107 | { 108 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Namespace"); 109 | if ((data != null)) 110 | { 111 | this._NamespaceField = ((string)(data)); 112 | } 113 | } 114 | 115 | 116 | } 117 | } 118 | 119 | 120 | 121 | #line default 122 | #line hidden 123 | } 124 | 125 | #line default 126 | #line hidden 127 | } 128 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/CodeBehindTemplate.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" inherits="BaseTemplate" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ parameter type="System.String" name="Name" #> 7 | <#@ parameter type="System.String" name="Namespace" #> 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace <#=Namespace#> 12 | { 13 | public partial class <#=Name#> 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/CssTemplate.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version: 17.0.0.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | namespace AntDesignToolbox.TextTemplates 11 | { 12 | using System.Linq; 13 | using System.Text; 14 | using System.Collections.Generic; 15 | using System; 16 | 17 | /// 18 | /// Class to produce the template output 19 | /// 20 | 21 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\CssTemplate.tt" 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] 23 | public partial class CssTemplate : BaseTemplate 24 | { 25 | #line hidden 26 | /// 27 | /// Create the template output 28 | /// 29 | public override string TransformText() 30 | { 31 | this.Write("body{\r\n\r\n}"); 32 | return this.GenerationEnvironment.ToString(); 33 | } 34 | } 35 | 36 | #line default 37 | #line hidden 38 | } 39 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/CssTemplate.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" inherits="BaseTemplate" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | body{ 7 | 8 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/RazorComponentTemplate.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version: 17.0.0.0 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | namespace AntDesignToolbox.TextTemplates 11 | { 12 | using System.Linq; 13 | using System.Text; 14 | using System.Collections.Generic; 15 | using System; 16 | 17 | /// 18 | /// Class to produce the template output 19 | /// 20 | 21 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\RazorComponentTemplate.tt" 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] 23 | public partial class RazorComponentTemplate : BaseTemplate 24 | { 25 | #line hidden 26 | /// 27 | /// Create the template output 28 | /// 29 | public override string TransformText() 30 | { 31 | this.Write("

"); 32 | 33 | #line 9 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\RazorComponentTemplate.tt" 34 | this.Write(this.ToStringHelper.ToStringWithCulture(Name)); 35 | 36 | #line default 37 | #line hidden 38 | this.Write("

\r\n"); 39 | 40 | #line 10 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\RazorComponentTemplate.tt" 41 | if(!IndependentCodeBehind) { 42 | 43 | #line default 44 | #line hidden 45 | this.Write("@code {\r\n\r\n}\r\n"); 46 | 47 | #line 14 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\RazorComponentTemplate.tt" 48 | } 49 | 50 | #line default 51 | #line hidden 52 | return this.GenerationEnvironment.ToString(); 53 | } 54 | 55 | #line 1 "C:\Code\Galaxism\AntDesignToolbox\src\AntDesignToolbox\TextTemplates\RazorComponentTemplate.tt" 56 | 57 | private string _NameField; 58 | 59 | /// 60 | /// Access the Name parameter of the template. 61 | /// 62 | private string Name 63 | { 64 | get 65 | { 66 | return this._NameField; 67 | } 68 | } 69 | 70 | private string _NamespaceField; 71 | 72 | /// 73 | /// Access the Namespace parameter of the template. 74 | /// 75 | private string Namespace 76 | { 77 | get 78 | { 79 | return this._NamespaceField; 80 | } 81 | } 82 | 83 | private bool _IndependentCodeBehindField; 84 | 85 | /// 86 | /// Access the IndependentCodeBehind parameter of the template. 87 | /// 88 | private bool IndependentCodeBehind 89 | { 90 | get 91 | { 92 | return this._IndependentCodeBehindField; 93 | } 94 | } 95 | 96 | 97 | /// 98 | /// Initialize the template 99 | /// 100 | public override void Initialize() 101 | { 102 | base.Initialize(); 103 | if ((this.Errors.HasErrors == false)) 104 | { 105 | bool NameValueAcquired = false; 106 | if (this.Session.ContainsKey("Name")) 107 | { 108 | this._NameField = ((string)(this.Session["Name"])); 109 | NameValueAcquired = true; 110 | } 111 | if ((NameValueAcquired == false)) 112 | { 113 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Name"); 114 | if ((data != null)) 115 | { 116 | this._NameField = ((string)(data)); 117 | } 118 | } 119 | bool NamespaceValueAcquired = false; 120 | if (this.Session.ContainsKey("Namespace")) 121 | { 122 | this._NamespaceField = ((string)(this.Session["Namespace"])); 123 | NamespaceValueAcquired = true; 124 | } 125 | if ((NamespaceValueAcquired == false)) 126 | { 127 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("Namespace"); 128 | if ((data != null)) 129 | { 130 | this._NamespaceField = ((string)(data)); 131 | } 132 | } 133 | bool IndependentCodeBehindValueAcquired = false; 134 | if (this.Session.ContainsKey("IndependentCodeBehind")) 135 | { 136 | this._IndependentCodeBehindField = ((bool)(this.Session["IndependentCodeBehind"])); 137 | IndependentCodeBehindValueAcquired = true; 138 | } 139 | if ((IndependentCodeBehindValueAcquired == false)) 140 | { 141 | object data = global::System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("IndependentCodeBehind"); 142 | if ((data != null)) 143 | { 144 | this._IndependentCodeBehindField = ((bool)(data)); 145 | } 146 | } 147 | 148 | 149 | } 150 | } 151 | 152 | 153 | 154 | #line default 155 | #line hidden 156 | } 157 | 158 | #line default 159 | #line hidden 160 | } 161 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/TextTemplates/RazorComponentTemplate.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" inherits="BaseTemplate" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ parameter type="System.String" name="Name" #> 7 | <#@ parameter type="System.String" name="Namespace" #> 8 | <#@ parameter type="System.Boolean" name="IndependentCodeBehind" #> 9 |

<#=Name#>

10 | <# if(!IndependentCodeBehind) { #> 11 | @code { 12 | 13 | } 14 | <# } #> -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ControlToolboxControl.xaml: -------------------------------------------------------------------------------- 1 |  20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 57 | 60 | 61 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 | 75 | 81 | 82 | 83 | 84 | 85 | 86 | 111 | 112 | 118 | 119 | 120 | 121 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ControlToolboxControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Microsoft.CodeAnalysis; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Linq; 8 | using AntDesignToolbox.ToolWindows.ViewModels; 9 | using System.Windows.Media; 10 | using EnvDTE80; 11 | using System.Text; 12 | using Microsoft.VisualStudio.Text.Editor; 13 | using System.Xml.Linq; 14 | using AntDesignToolbox.ToolWindows.Controls; 15 | 16 | namespace AntDesignToolbox 17 | { 18 | public partial class ControlToolboxControl : UserControl 19 | { 20 | public List MyProperty { get; set; } 21 | public ControlToolboxControl() 22 | { 23 | 24 | InitializeComponent(); 25 | this.DataContext = new ControlToolboxViewModel(); 26 | } 27 | 28 | 29 | private void Label_MouseMove_1(object sender, System.Windows.Input.MouseEventArgs e) 30 | { 31 | if(e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) 32 | { 33 | if(sender is Label l) 34 | { 35 | System.Diagnostics.Debug.WriteLine("Dragged"); 36 | if(this.DataContext is ControlToolboxViewModel v && v.SelectedItem!=null) 37 | { 38 | 39 | string s = v.SelectedItem.Component.GetCompiledComponent(); 40 | DragDrop.DoDragDrop(l, s, DragDropEffects.Copy); 41 | } 42 | 43 | } 44 | } 45 | } 46 | 47 | private void Label_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) 48 | { 49 | if (sender is Label) 50 | { 51 | System.Diagnostics.Debug.WriteLine("Dragged"); 52 | if (this.DataContext is ControlToolboxViewModel v && v.SelectedItem != null) 53 | { 54 | 55 | string s = v.SelectedItem.Component.GetCompiledComponent(); 56 | Clipboard.SetText(s); 57 | } 58 | 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ControlToolboxWindow.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Imaging; 2 | using System.Runtime.InteropServices; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Windows; 6 | 7 | namespace AntDesignToolbox 8 | { 9 | public class ControlToolboxWindow : BaseToolWindow 10 | { 11 | public override string GetTitle(int toolWindowId) => "Ant Design Blazor"; 12 | 13 | public override Type PaneType => typeof(Pane); 14 | 15 | public override Task CreateAsync(int toolWindowId, CancellationToken cancellationToken) 16 | { 17 | return Task.FromResult(new ControlToolboxControl()); 18 | } 19 | 20 | [Guid("068cac5e-295a-46c8-bd56-cd45ccf6be60")] 21 | internal class Pane : ToolkitToolWindowPane 22 | { 23 | public Pane() 24 | { 25 | BitmapImageMoniker = KnownMonikers.Blazor; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/Controls/ComponentTreeItemControl.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 18 | 19 | 20 | 21 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/Controls/ComponentTreeItemControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.ToolWindows.ViewModels; 2 | using Microsoft.VisualStudio.Imaging; 3 | using Microsoft.VisualStudio.Imaging.Interop; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | using System.Windows.Navigation; 17 | using System.Windows.Shapes; 18 | 19 | namespace AntDesignToolbox.ToolWindows.Controls 20 | { 21 | /// 22 | /// Interaction logic for ComponentTreeItemControl.xaml 23 | /// 24 | public partial class ComponentTreeItemControl : UserControl 25 | { 26 | public ComponentTreeItemControl() 27 | { 28 | InitializeComponent(); 29 | } 30 | 31 | 32 | public ImageMoniker Moniker 33 | { 34 | get { return (ImageMoniker)GetValue(MonikerProperty); } 35 | set { SetValue(MonikerProperty, value); } 36 | } 37 | public static readonly DependencyProperty MonikerProperty = 38 | DependencyProperty.Register(nameof(Moniker), typeof(ImageMoniker), typeof(ComponentTreeItemControl), new PropertyMetadata(KnownMonikers.None)); 39 | 40 | 41 | public string ComponentName 42 | { 43 | get { return (string)GetValue(ComponentNameProperty); } 44 | set { SetValue(ComponentNameProperty, value); } 45 | } 46 | public static readonly DependencyProperty ComponentNameProperty = 47 | DependencyProperty.Register(nameof(ComponentName), typeof(string), typeof(ComponentTreeItemControl), new PropertyMetadata(string.Empty)); 48 | 49 | private void root_MouseLeave(object sender, MouseEventArgs e) 50 | { 51 | if(e.LeftButton== MouseButtonState.Pressed) 52 | { 53 | if (this.DataContext != null && this.DataContext is TreeItemViewModel vm) 54 | { 55 | DragDrop.DoDragDrop(sender as DependencyObject, vm.Component.DefaultMarkup+"\n", DragDropEffects.Copy); 56 | } 57 | } 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/ComponentViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.VisualStudio.Imaging.Interop; 7 | using Prism.Mvvm; 8 | using System.Collections.ObjectModel; 9 | using System.Xml.Linq; 10 | using System.Windows.Input; 11 | using Prism.Commands; 12 | using AntDesignToolbox.Commons; 13 | 14 | namespace AntDesignToolbox.ToolWindows.ViewModels 15 | { 16 | public class ComponentViewModel: BindableBase 17 | { 18 | public string ControlName { get; set; } 19 | public string ControlDisplayName { get; set; } 20 | public string DefaultMarkup { get; set; } 21 | public ImageMoniker Moniker { get; set; } 22 | public bool AlwaysDefault { get; set; } 23 | 24 | private ObservableCollection _properties; 25 | 26 | public virtual ObservableCollection Properties 27 | { 28 | get { return _properties; } 29 | set { SetProperty(ref _properties, value); } 30 | } 31 | 32 | public ICommand ResetAllCommand { get; set; } 33 | 34 | public ComponentViewModel() 35 | { 36 | Properties = new ObservableCollection(); 37 | ResetAllCommand = new DelegateCommand(ResetAll); 38 | } 39 | 40 | private void ResetAll() 41 | { 42 | foreach(var property in Properties) 43 | { 44 | property.ResetCommand.Execute(null); 45 | } 46 | } 47 | 48 | public virtual string GetCompiledComponent() 49 | { 50 | if (AlwaysDefault) 51 | { 52 | return DefaultMarkup; 53 | } 54 | XElement element = new(ControlName, ""); 55 | foreach(var property in Properties) 56 | { 57 | if (property.IsAttribute) 58 | { 59 | element.AddNonNullAttributes(property.ConvertToAttributes()); 60 | } 61 | else 62 | { 63 | element.AddNonNullNodes(property.ConvertToNodes()); 64 | } 65 | } 66 | 67 | return element.ToString()+"\n"; 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/ControlToolboxViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Imaging; 2 | using Prism.Mvvm; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Windows; 6 | using System.Collections.Generic; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels 9 | { 10 | public class ControlToolboxViewModel : BindableBase 11 | { 12 | #region Properties 13 | private List _allControls; 14 | public ObservableCollection FixedTreeItems { get; set; } 15 | public ObservableCollection TreeItems { get; set; } 16 | private TreeItemViewModel _selectedTreeItem; 17 | 18 | public TreeItemViewModel SelectedItem 19 | { 20 | get { return _selectedTreeItem; } 21 | set 22 | { 23 | SetProperty(ref _selectedTreeItem, value); 24 | } 25 | } 26 | 27 | private string _searchText; 28 | public string SearchText 29 | { 30 | get { return _searchText; } 31 | set 32 | { 33 | SetProperty(ref _searchText, value); 34 | SearchByText(value); 35 | } 36 | } 37 | 38 | #endregion 39 | 40 | 41 | public ControlToolboxViewModel() 42 | { 43 | var items = new List(); 44 | var properties =typeof(ViewModelSourceHelper).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static ); 45 | foreach(var property in properties) 46 | { 47 | if (property.PropertyType == typeof(ComponentViewModel)) 48 | { 49 | ComponentViewModel vm = property.GetValue(null) as ComponentViewModel; 50 | if (vm != null) 51 | { 52 | items.Add(new TreeItemViewModel() { Component = vm }); 53 | } 54 | } 55 | } 56 | 57 | _allControls = items.OrderBy(a=>a.Component.ControlName).ToList(); 58 | 59 | TreeItems = new ObservableCollection(items.OrderBy(a => a.Component.ControlDisplayName)); 60 | } 61 | 62 | 63 | public void DragCompiledComponent(DependencyObject source) 64 | { 65 | DragDrop.DoDragDrop(source, null, DragDropEffects.Copy); 66 | } 67 | 68 | private void SearchByText(string s) 69 | { 70 | if (string.IsNullOrWhiteSpace(s)) 71 | { 72 | TreeItems.Clear(); 73 | foreach(var item in _allControls) 74 | { 75 | TreeItems.Add(item); 76 | } 77 | return; 78 | } 79 | var items = _allControls.Where(a => a.Component.ControlName.ToLower().Contains(s.ToLower())).OrderBy(a => a.Component.ControlDisplayName); 80 | TreeItems.Clear(); 81 | foreach(var item in items) 82 | { 83 | TreeItems.Add(item); 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/ButtonSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum ButtonSize 11 | { 12 | [StringValue("@ButtonSize.Default")] 13 | [Display(Name = "Default")] 14 | [Default] 15 | Default, 16 | [StringValue("@ButtonSize.Large")] 17 | [Display(Name = "Large")] 18 | Large, 19 | [StringValue("@ButtonSize.Small")] 20 | [Display(Name = "Small")] 21 | Small, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/ButtonType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum ButtonType 11 | { 12 | [StringValue("@ButtonType.Default")] 13 | [Display(Name = "Default")] 14 | [Default] 15 | Default, 16 | [StringValue("@ButtonType.Primary")] 17 | [Display(Name = "Primary")] 18 | Primary, 19 | [StringValue("@ButtonType.Dashed")] 20 | [Display(Name = "Dashed")] 21 | Dashed, 22 | [StringValue("@ButtonType.Link")] 23 | [Display(Name = "Link")] 24 | Link, 25 | [StringValue("@ButtonType.Text")] 26 | [Display(Name = "Text")] 27 | Text 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/DefaultAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 8 | { 9 | [System.AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] 10 | sealed class DefaultAttribute : Attribute 11 | { 12 | public bool IsDefault { get; } = true; 13 | // This is a positional argument 14 | public DefaultAttribute() 15 | { 16 | 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/Direction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum Direction 11 | { 12 | [StringValue("@DirectionVHType.Horizontal")] 13 | [Display(Name = "Horizontal")] 14 | Horizontal, 15 | [StringValue("@DirectionVHType.Vertical")] 16 | [Display(Name = "Vertical")] 17 | [Default] 18 | Vertical, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/MenuMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum MenuMode 11 | { 12 | [StringValue("@MenuMode.Vertical")] 13 | [Display(Name = "Vertical")] 14 | [Default] 15 | Vertical, 16 | [StringValue("@MenuMode.Horizontal")] 17 | [Display(Name = "Horizontal")] 18 | Horizontal, 19 | [StringValue("@MenuMode.Inline")] 20 | [Display(Name = "Inline")] 21 | Inline, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/MenuTheme.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum MenuTheme 11 | { 12 | [StringValue("@MenuTheme.Dark")] 13 | [Display(Name = "Dark")] 14 | [Default] 15 | Dark, 16 | [StringValue("@MenuTheme.Light")] 17 | [Display(Name = "Light")] 18 | Light, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/NavLinkMatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum NavLinkMatch 11 | { 12 | [StringValue("@NavLinkMatch.Prefix")] 13 | [Display(Name = "Prefix")] 14 | [Default] 15 | Prefix, 16 | [StringValue("@NavLinkMatch.Prefix")] 17 | [Display(Name = "All")] 18 | [Default] 19 | All 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/Placement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 8 | { 9 | internal enum Placement 10 | { 11 | [StringValue("@Placement.TopLeft")] 12 | [Default] 13 | TopLeft, 14 | [StringValue("@Placement.TopCenter")] 15 | TopCenter, 16 | [StringValue("@Placement.Top")] 17 | Top, 18 | [StringValue("@Placement.TopRight")] 19 | TopRight, 20 | [StringValue("@Placement.Left")] 21 | Left, 22 | [StringValue("@Placement.LeftTop")] 23 | LeftTop, 24 | [StringValue("@Placement.LeftBottom")] 25 | LeftBottom, 26 | [StringValue("@Placement.Right")] 27 | Right, 28 | [StringValue("@Placement.RightTop")] 29 | RightTop, 30 | [StringValue("@Placement.RightBottom")] 31 | RightBottom, 32 | [StringValue("@Placement.BottomLeft")] 33 | BottomLeft, 34 | [StringValue("@Placement.BottomCenter")] 35 | BottomCenter, 36 | [StringValue("@Placement.Bottom")] 37 | Bottom, 38 | [StringValue("@Placement.BottomRight")] 39 | BottomRight 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/Size.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum Size 11 | { 12 | [StringValue("@AntSizeLDSType.Default")] 13 | [Display(Name = "Default")] 14 | [Default] 15 | Default, 16 | [StringValue("@AntSizeLDSType.Large")] 17 | [Display(Name = "Large")] 18 | Large, 19 | [StringValue("@AntSizeLDSType.Small")] 20 | [Display(Name = "Small")] 21 | Small, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/StringValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 8 | { 9 | 10 | [AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] 11 | sealed class StringValueAttribute : Attribute 12 | { 13 | public string StringValue { get; } 14 | 15 | // This is a positional argument 16 | public StringValueAttribute(string stringValue) 17 | { 18 | StringValue = stringValue; 19 | } 20 | 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/TitleLevel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum TitleLevel 11 | { 12 | [StringValue("1")] 13 | [Display(Name = "h1")] 14 | [Default] 15 | H1, 16 | [StringValue("2")] 17 | [Display(Name = "h2")] 18 | H2, 19 | [StringValue("3")] 20 | [Display(Name = "h3")] 21 | H3, 22 | [StringValue("4")] 23 | [Display(Name = "h4")] 24 | H4, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/EnumOptions/TypographyType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels.EnumOptions 9 | { 10 | internal enum TypographyType 11 | { 12 | [StringValue("default")] 13 | [Display(Name = "Default")] 14 | [Default] 15 | None, 16 | [StringValue("@TextElementType.Secondary")] 17 | [Display(Name = "Secondary")] 18 | Secondary, 19 | [StringValue("@TextElementType.Danger")] 20 | [Display(Name = "Danger")] 21 | Danger, 22 | [StringValue("@TextElementType.Warning")] 23 | [Display(Name = "Warning")] 24 | Warning, 25 | [StringValue("success")] 26 | [Display(Name = "Success")] 27 | Success, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyCategory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AntDesignToolbox.ToolWindows.ViewModels 8 | { 9 | public enum PropertyCategory 10 | { 11 | String, 12 | Boolean, 13 | Options, 14 | Number, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/BooleanPropertyViewModel.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.Input; 7 | using System.Xml.Linq; 8 | using Prism.Commands; 9 | 10 | namespace AntDesignToolbox.ToolWindows.ViewModels 11 | { 12 | public class BooleanPropertyViewModel : PropertyItemViewModel 13 | { 14 | public bool? DefaultValue { get; set; } = false; 15 | 16 | private bool? _value; 17 | public bool? Value 18 | { 19 | get { return _value; } 20 | set { SetProperty(ref _value, value); } 21 | } 22 | 23 | public override ICommand ResetCommand { get; set; } 24 | 25 | public BooleanPropertyViewModel() 26 | { 27 | ResetCommand = new DelegateCommand(() => { Value = DefaultValue; }); 28 | Value = false; 29 | } 30 | 31 | public override IEnumerable ConvertToAttributes() 32 | { 33 | if(IgnoreOnDefault && DefaultValue == Value) 34 | { 35 | yield break; 36 | } 37 | if (Value == null) 38 | { 39 | yield break; 40 | } 41 | else 42 | { 43 | yield return new XAttribute(PropertyName, Value.ToString().ToLower()); 44 | } 45 | } 46 | 47 | public override IEnumerable ConvertToNodes() 48 | { 49 | throw new NotImplementedException(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/ContainsElementPropertyViewModel.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.Input; 7 | using System.Xml.Linq; 8 | using Prism.Mvvm; 9 | using Prism.Commands; 10 | 11 | namespace AntDesignToolbox.ToolWindows.ViewModels 12 | { 13 | internal class ContainsElementPropertyViewModel : PropertyItemViewModel 14 | { 15 | #region Properties 16 | public override bool IsAttribute { get; set; } = false; 17 | private bool? _value; 18 | public bool? Value 19 | { 20 | get { return _value; } 21 | set { SetProperty(ref _value, value); } 22 | } 23 | public bool? DefaultValue { get; set; } = false; 24 | 25 | 26 | #endregion 27 | public override ICommand ResetCommand { get; set; } 28 | 29 | public ContainsElementPropertyViewModel() 30 | { 31 | ResetCommand = new DelegateCommand(() => { Value = DefaultValue; }); 32 | Value = false; 33 | } 34 | 35 | public override IEnumerable ConvertToAttributes() 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | 40 | public override IEnumerable ConvertToNodes() 41 | { 42 | if(Value == true) 43 | { 44 | yield return new XElement(PropertyName, PropertyName); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/IntegerOrIteratorPropertyViewModel.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.Input; 7 | using System.Xml.Linq; 8 | using AntDesignToolbox.Commons; 9 | using Prism.Commands; 10 | 11 | namespace AntDesignToolbox.ToolWindows.ViewModels 12 | { 13 | public class IntegerOrIteratorPropertyViewModel : PropertyItemViewModel 14 | { 15 | private uint _count; 16 | public uint Count 17 | { 18 | get { return _count; } 19 | set { SetProperty(ref _count, value); } 20 | } 21 | 22 | public uint DefaultCount { get; set; } 23 | 24 | private bool _iterate; 25 | public bool Iterate 26 | { 27 | get { return _iterate; } 28 | set { SetProperty(ref _iterate, value); } 29 | } 30 | 31 | public override bool IsAttribute { get; set; } = false; 32 | 33 | public string ChildrenTagName { get; set; } 34 | 35 | 36 | public override ICommand ResetCommand { get; set; } 37 | 38 | 39 | public IntegerOrIteratorPropertyViewModel() 40 | { 41 | ResetCommand = new DelegateCommand(Reset); 42 | } 43 | 44 | private void Reset() 45 | { 46 | Count = DefaultCount; 47 | Iterate = false; 48 | } 49 | 50 | public override IEnumerable ConvertToAttributes() 51 | { 52 | throw new NotImplementedException(); 53 | } 54 | 55 | public override IEnumerable ConvertToNodes() 56 | { 57 | if (Iterate) 58 | { 59 | yield return new XText("\n@foreach (var item in collection)\n{\n"); 60 | yield return new XElement(ChildrenTagName, ChildrenTagName); 61 | yield return new XText("\n}\n"); 62 | } 63 | else 64 | { 65 | for (int i = 0; i < Count; i++) 66 | { 67 | yield return new XElement(ChildrenTagName, ChildrenTagName); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/IntegerPropertyViewModel.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.Input; 7 | using System.Xml.Linq; 8 | using Prism.Commands; 9 | 10 | namespace AntDesignToolbox.ToolWindows.ViewModels 11 | { 12 | public class IntegerPropertyViewModel : PropertyItemViewModel 13 | { 14 | public int? DefaultValue { get; set; } 15 | private int? _value; 16 | 17 | public int? Value 18 | { 19 | get { return _value; } 20 | set { SetProperty(ref _value, value); } 21 | } 22 | 23 | public override ICommand ResetCommand { get; set; } 24 | 25 | public IntegerPropertyViewModel() 26 | { 27 | ResetCommand = new DelegateCommand(() => { Value = DefaultValue; }); 28 | } 29 | 30 | public override IEnumerable ConvertToAttributes() 31 | { 32 | if(IgnoreOnDefault && DefaultValue == Value) 33 | { 34 | yield break; 35 | } 36 | if(Value == null) 37 | { 38 | yield break; 39 | } 40 | yield return new XAttribute(PropertyName, Value); 41 | } 42 | 43 | public override IEnumerable ConvertToNodes() 44 | { 45 | throw new NotImplementedException(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/OptionsPropertyViewModel.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.Collections.ObjectModel; 7 | using System.Windows.Input; 8 | using Prism.Commands; 9 | using System.Xml.Linq; 10 | 11 | namespace AntDesignToolbox.ToolWindows.ViewModels 12 | { 13 | public class OptionsPropertyViewModel: PropertyItemViewModel 14 | { 15 | public string DefaultValue { get; set; } 16 | 17 | 18 | private ObservableCollection _options; 19 | public ObservableCollection Options 20 | { 21 | get { return _options; } 22 | set { SetProperty(ref _options, value); } 23 | } 24 | 25 | private string _selectedValue; 26 | public string SelectedValue 27 | { 28 | get { return _selectedValue; } 29 | set { SetProperty(ref _selectedValue, value); } 30 | } 31 | 32 | public override ICommand ResetCommand { get; set; } 33 | 34 | public OptionsPropertyViewModel() 35 | { 36 | ResetCommand = new DelegateCommand(() => { SelectedValue = DefaultValue; }); 37 | } 38 | 39 | public override IEnumerable ConvertToAttributes() 40 | { 41 | if(IgnoreOnDefault && SelectedValue == DefaultValue) 42 | { 43 | yield break; 44 | } 45 | yield return new XAttribute(PropertyName, SelectedValue ?? string.Empty); 46 | } 47 | 48 | public override IEnumerable ConvertToNodes() 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/StringOptionItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Prism.Mvvm; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels 9 | { 10 | /// 11 | /// StringOptionItemViewModel 12 | /// 13 | public class StringOptionItemViewModel : BindableBase 14 | { 15 | public string DisplayName { get; set; } 16 | public string Value { get; set; } 17 | 18 | public StringOptionItemViewModel() 19 | { 20 | 21 | } 22 | 23 | public StringOptionItemViewModel(string displayName, string value) 24 | { 25 | DisplayName = displayName; 26 | Value = value; 27 | } 28 | 29 | #region Equals 30 | public override bool Equals(object obj) 31 | { 32 | if (obj is StringOptionItemViewModel vm) 33 | { 34 | return vm.DisplayName == DisplayName && vm.Value == Value; 35 | } 36 | return false; 37 | } 38 | public override int GetHashCode() 39 | { 40 | return DisplayName.GetHashCode() ^ Value.GetHashCode(); 41 | } 42 | public static bool operator ==(StringOptionItemViewModel v1, StringOptionItemViewModel v2) 43 | { 44 | if (v1 is null) return v2 is null; 45 | return v1.Equals(v2); 46 | } 47 | public static bool operator !=(StringOptionItemViewModel v1, StringOptionItemViewModel v2) 48 | { 49 | return !v1.Equals(v2); 50 | } 51 | #endregion 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/StringOptionsViewModel.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.Input; 7 | using System.Xml.Linq; 8 | using System.Collections.ObjectModel; 9 | 10 | namespace AntDesignToolbox.ToolWindows.ViewModels 11 | { 12 | internal class StringOptionsViewModel : PropertyItemViewModel 13 | { 14 | public StringOptionItemViewModel DefaultValue { get; set; } 15 | 16 | private ObservableCollection _options; 17 | public ObservableCollection Options 18 | { 19 | get { return _options; } 20 | set { SetProperty(ref _options, value); } 21 | } 22 | 23 | private StringOptionItemViewModel _selectedValue; 24 | 25 | public StringOptionItemViewModel SelectedValue 26 | { 27 | get { return _selectedValue; } 28 | set { SetProperty(ref _selectedValue, value); } 29 | } 30 | 31 | 32 | public override ICommand ResetCommand { get; set; } 33 | 34 | public override IEnumerable ConvertToAttributes() 35 | { 36 | if (IgnoreOnDefault && SelectedValue == DefaultValue) 37 | { 38 | yield break; 39 | } 40 | yield return new XAttribute(PropertyName, SelectedValue?.Value ?? string.Empty); 41 | } 42 | 43 | public override IEnumerable ConvertToNodes() 44 | { 45 | throw new NotImplementedException(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyImplementations/StringPropertyViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Input; 4 | using Prism.Mvvm; 5 | using Prism.Commands; 6 | using System.Xml.Linq; 7 | 8 | namespace AntDesignToolbox.ToolWindows.ViewModels 9 | { 10 | public class StringPropertyViewModel : PropertyItemViewModel 11 | { 12 | public string DefaultValue { get; set; } 13 | 14 | private string _value; 15 | public string Value 16 | { 17 | get { return _value; } 18 | set { SetProperty(ref _value, value); } 19 | } 20 | 21 | public override ICommand ResetCommand { get; set; } 22 | 23 | public StringPropertyViewModel() 24 | { 25 | ResetCommand = new DelegateCommand(() => { Value = DefaultValue; }); 26 | } 27 | 28 | public override IEnumerable ConvertToAttributes() 29 | { 30 | if(IgnoreOnDefault && DefaultValue== Value) 31 | { 32 | yield break; 33 | } 34 | yield return new XAttribute(PropertyName, Value ?? string.Empty); 35 | } 36 | 37 | public override IEnumerable ConvertToNodes() 38 | { 39 | yield return new XElement(PropertyName, Value??string.Empty); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/PropertyItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Prism.Mvvm; 7 | using Prism.Commands; 8 | using System.Windows.Input; 9 | using System.Xml.Linq; 10 | 11 | namespace AntDesignToolbox.ToolWindows.ViewModels 12 | { 13 | public abstract class PropertyItemViewModel: BindableBase 14 | { 15 | #region Properties 16 | private string _propertyName; 17 | public string PropertyName 18 | { 19 | get { return _propertyName; } 20 | set { SetProperty(ref _propertyName, value); } 21 | } 22 | 23 | private PropertyCategory _category; 24 | public PropertyCategory Category 25 | { 26 | get { return _category; } 27 | set { SetProperty(ref _category, value); } 28 | } 29 | 30 | private string _propertyDisplayName; 31 | public string PropertyDisplayName 32 | { 33 | get { return _propertyDisplayName; } 34 | set { SetProperty(ref _propertyDisplayName, value); } 35 | } 36 | 37 | 38 | public bool IgnoreOnDefault { get; set; } = true; 39 | public virtual bool IsAttribute { get; set; } = true; 40 | #endregion 41 | 42 | #region Commands 43 | public abstract ICommand ResetCommand { get; set; } 44 | #endregion 45 | 46 | #region XmlSupport 47 | public abstract IEnumerable ConvertToAttributes(); 48 | public abstract IEnumerable ConvertToNodes(); 49 | #endregion 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/TreeItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.Composition; 4 | using Microsoft.VisualStudio.Editor; 5 | using Microsoft.VisualStudio.Text.Editor; 6 | using Microsoft.VisualStudio.TextManager.Interop; 7 | using Microsoft.VisualStudio.Utilities; 8 | using Prism.Mvvm; 9 | using System.Collections.ObjectModel; 10 | using Microsoft.VisualStudio.Imaging.Interop; 11 | using System.Windows.Input; 12 | using Prism.Commands; 13 | 14 | namespace AntDesignToolbox.ToolWindows.ViewModels 15 | { 16 | public class TreeItemViewModel : BindableBase 17 | { 18 | private ComponentViewModel _component; 19 | public ComponentViewModel Component 20 | { 21 | get { return _component; } 22 | set { SetProperty(ref _component, value); } 23 | } 24 | 25 | private ObservableCollection _children; 26 | 27 | public ObservableCollection Children 28 | { 29 | get { return _children; } 30 | set { SetProperty(ref _children, value); } 31 | } 32 | 33 | public TreeItemViewModel() 34 | { 35 | 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ToolWindows/ViewModels/ViewModelSourceHelper.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.ToolWindows.ViewModels.EnumOptions; 2 | using Microsoft.VisualStudio.Imaging; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Linq; 7 | using System.Reflection; 8 | using BP = AntDesignToolbox.ToolWindows.ViewModels.BooleanPropertyViewModel; 9 | using OCP = System.Collections.ObjectModel.ObservableCollection; 10 | using OP = AntDesignToolbox.ToolWindows.ViewModels.OptionsPropertyViewModel; 11 | using SP = AntDesignToolbox.ToolWindows.ViewModels.StringPropertyViewModel; 12 | 13 | namespace AntDesignToolbox.ToolWindows.ViewModels 14 | { 15 | internal static class ViewModelSourceHelper 16 | { 17 | public static ComponentViewModel ButtonViewModel { get; } = new ComponentViewModel() 18 | { 19 | ControlName = "Button", 20 | ControlDisplayName = "Button", 21 | Moniker = KnownMonikers.Button, 22 | DefaultMarkup = @"", 23 | Properties = new OCP 24 | { 25 | EnumOptionHelper.GetOptionsViewModel("Type"), 26 | new SP(){ PropertyName = "Content", DefaultValue = "", Value = "", IsAttribute = false}, 27 | new BP(){ PropertyName = "Danger"}, 28 | new BP(){ PropertyName = "Disabled"}, 29 | new BP(){ PropertyName = "Block"}, 30 | } 31 | }; 32 | public static ComponentViewModel TextViewModel { get; } = new ComponentViewModel() 33 | { 34 | ControlName = "Text", 35 | ControlDisplayName = "Typography - Text", 36 | Moniker = KnownMonikers.TextElement, 37 | DefaultMarkup = @"Ant Design", 38 | Properties = new OCP 39 | { 40 | new BP(){ PropertyName = "Code" }, 41 | new BP(){ PropertyName = "Copyable" }, 42 | new BP(){ PropertyName = "Delete" }, 43 | new BP(){ PropertyName = "Editable" }, 44 | new BP(){ PropertyName = "Ellipsis" }, 45 | new BP(){ PropertyName = "Mark" }, 46 | new BP(){ PropertyName = "Keyboard" }, 47 | new BP(){ PropertyName = "Underline" }, 48 | new BP(){ PropertyName = "Strong" }, 49 | EnumOptionHelper.GetOptionsViewModel("Type", true), 50 | 51 | } 52 | }; 53 | public static ComponentViewModel TitleViewModel { get; } = new ComponentViewModel() 54 | { 55 | ControlName = "Title", 56 | ControlDisplayName = "Typography - Title", 57 | Moniker = KnownMonikers.TextElement, 58 | DefaultMarkup = @"Ant Design", 59 | Properties = new OCP 60 | { 61 | new BP(){ PropertyName = "Code" }, 62 | new BP(){ PropertyName = "Copyable" }, 63 | new BP(){ PropertyName = "Delete" }, 64 | new BP(){ PropertyName = "Editable" }, 65 | new BP(){ PropertyName = "Ellipsis" }, 66 | new BP(){ PropertyName = "Mark" }, 67 | new BP(){ PropertyName = "Keyboard" }, 68 | new BP(){ PropertyName = "Underline" }, 69 | new BP(){ PropertyName = "Strong" }, 70 | EnumOptionHelper.GetOptionsViewModel("Type", true), 71 | EnumOptionHelper.GetOptionsViewModel("Level"), 72 | } 73 | }; 74 | public static ComponentViewModel ParagraphViewModel { get; } = new ComponentViewModel() 75 | { 76 | ControlName = "Paragraph", 77 | ControlDisplayName = "Typography - Paragraph", 78 | Moniker = KnownMonikers.TextElement, 79 | DefaultMarkup = @"Ant Design", 80 | Properties = new OCP 81 | { 82 | new BP(){ PropertyName = "Code" }, 83 | new BP(){ PropertyName = "Copyable" }, 84 | new BP(){ PropertyName = "Delete" }, 85 | new BP(){ PropertyName = "Editable" }, 86 | new BP(){ PropertyName = "Ellipsis" }, 87 | new BP(){ PropertyName = "Mark" }, 88 | new BP(){ PropertyName = "Keyboard" }, 89 | new BP(){ PropertyName = "Underline" }, 90 | new BP(){ PropertyName = "Strong" }, 91 | EnumOptionHelper.GetOptionsViewModel("Type", true), 92 | } 93 | }; 94 | public static ComponentViewModel DividerViewModel { get; } = new ComponentViewModel() 95 | { 96 | ControlName = "Divider", 97 | ControlDisplayName = "Divider", 98 | Moniker = KnownMonikers.Splitter, 99 | DefaultMarkup = @"", 100 | Properties = new OCP() 101 | { 102 | new BP(){ PropertyName = "Dashed" }, 103 | new SP(){ PropertyName = "Content", DefaultValue = "", Value = ""}, 104 | new OP(){ 105 | IgnoreOnDefault=true, 106 | PropertyName = "Orientation", 107 | DefaultValue="", 108 | SelectedValue = "", 109 | Options= new ObservableCollection{"", "DirectionVHType.Vertical" } }, 110 | }, 111 | }; 112 | public static ComponentViewModel SpaceViewModel { get; } = new ComponentViewModel() 113 | { 114 | ControlName = "Space", 115 | ControlDisplayName = "Space", 116 | DefaultMarkup = @" 117 | 118 | Space 119 | 120 | 121 | 122 | 123 | ", 124 | Moniker = KnownMonikers.VisibleBorders, 125 | Properties = new OCP() 126 | { 127 | new IntegerOrIteratorPropertyViewModel(){ PropertyName = "Children", Count = 2, DefaultCount = 2, ChildrenTagName="SpaceItem", Category = PropertyCategory.Number }, 128 | new BP(){ PropertyName = "Split" }, 129 | new OP(){ PropertyName = "Align", DefaultValue = "", SelectedValue = "", 130 | Options = new ObservableCollection{"", "start", "end", "center", "baseline" } }, 131 | EnumOptionHelper.GetOptionsViewModel("Direction"), 132 | EnumOptionHelper.GetOptionsViewModel("Size"), 133 | new BP(){PropertyName = "Wrap" } 134 | } 135 | }; 136 | public static ComponentViewModel LayoutViewModel { get; } = new ComponentViewModel() 137 | { 138 | ControlName = "Layout", 139 | ControlDisplayName = "Layout", 140 | DefaultMarkup = @" 141 |
header
142 | 143 | left sidebar 144 | main content 145 | right sidebar 146 | 147 |
footer
148 |
" 149 | , 150 | Moniker = KnownMonikers.LayoutPanel, 151 | Properties = new OCP 152 | { 153 | new ContainsElementPropertyViewModel(){ PropertyName = "Header", PropertyDisplayName = "Header" }, 154 | new ContainsElementPropertyViewModel(){ PropertyName = "Sider", PropertyDisplayName = "Header" }, 155 | new ContainsElementPropertyViewModel(){ PropertyName = "Content", PropertyDisplayName = "Content" }, 156 | new ContainsElementPropertyViewModel(){ PropertyName = "Footer", PropertyDisplayName = "Footer" }, 157 | } 158 | }; 159 | public static ComponentViewModel BreadcrumbViewModel { get; } = new ComponentViewModel() 160 | { 161 | ControlName = "Breadcrumb", 162 | ControlDisplayName = "Breadcrumb", 163 | Moniker = KnownMonikers.Forwardslash, 164 | DefaultMarkup = @" 165 | Home 166 | Application Center 167 | 168 | ", 169 | Properties = new OCP() 170 | { 171 | new IntegerOrIteratorPropertyViewModel(){ PropertyName = "Count", DefaultCount = 2, Count=2, ChildrenTagName = "BreadcrumbItem" }, 172 | new SP(){ PropertyName = "Separator", DefaultValue = string.Empty, Value = string.Empty } 173 | } 174 | }; 175 | public static ComponentViewModel PageHeaderViewModel { get; } = new ComponentViewModel() 176 | { 177 | ControlName = "PageHeader", 178 | ControlDisplayName = "Page Header", 179 | Moniker = KnownMonikers.PageHeader, 180 | DefaultMarkup = @" 181 | ", 182 | Properties = new OCP() 183 | { 184 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Title", PropertyName="PageHeaderTitle", IsAttribute =false }, 185 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Subtitle",PropertyName="PageHeaderSubtitle", IsAttribute =false }, 186 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Content",PropertyName="PageHeaderContent", IsAttribute =false }, 187 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Footer",PropertyName="PageHeaderFooter", IsAttribute =false }, 188 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Tags",PropertyName="PageHeaderTags", IsAttribute =false }, 189 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Extra",PropertyName="PageHeaderExtra", IsAttribute =false }, 190 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Breadcrumb",PropertyName="PageHeaderBreadcrumb", IsAttribute =false }, 191 | new ContainsElementPropertyViewModel{ PropertyDisplayName = "Avatar",PropertyName="PageHeaderAvatar", IsAttribute =false }, 192 | } 193 | }; 194 | public static ComponentViewModel IconViewModel { get; } = new ComponentViewModel() 195 | { 196 | ControlName= "Icon", 197 | ControlDisplayName = "Icon", 198 | DefaultMarkup = @"", 199 | Moniker = KnownMonikers.ImageIcon, 200 | Properties = new OCP 201 | { 202 | new IconTypePropertyViewModel() { PropertyName = "IconProperty" }, 203 | new BP() { PropertyName = "Spin" }, 204 | new IntegerPropertyViewModel() { PropertyName="Rotate" }, 205 | new SP() { PropertyName = "TwoToneColor" } 206 | } 207 | }; 208 | public static ComponentViewModel DropdownButtonViewModel { get; } = new ComponentViewModel() 209 | { 210 | ControlName = "DropdownButton", 211 | ControlDisplayName = "DropdownButton", 212 | DefaultMarkup = @" 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | ", 221 | Moniker = KnownMonikers.ComboBoxItem, 222 | Properties = new OCP 223 | { 224 | EnumOptionHelper.GetOptionsViewModel("Size"), 225 | EnumOptionHelper.GetOptionsViewModel("Type"), 226 | new BP(){ PropertyName = "Danger" }, 227 | new BP(){ PropertyName = "Ghost" }, 228 | new BP(){ PropertyName = "Loading" }, 229 | new ContainsElementPropertyViewModel(){ PropertyName="Overlay", PropertyDisplayName="Overlay", DefaultValue = true, Value = true, IgnoreOnDefault = false }, 230 | new ContainsElementPropertyViewModel(){ PropertyName="ChildContent", PropertyDisplayName="ChildContent", DefaultValue = true, Value = true, IgnoreOnDefault = false } 231 | } 232 | }; 233 | public static ComponentViewModel DropdownViewModel { get; } = new ComponentViewModel() 234 | { 235 | ControlName = "Dropdown", 236 | ControlDisplayName = "Dropdown", 237 | DefaultMarkup = @" 238 | 239 | 240 | 241 | 242 | 243 | 244 | " 245 | , 246 | Moniker = KnownMonikers.ComboBoxItem, 247 | Properties = new OCP 248 | { 249 | EnumOptionHelper.GetOptionsViewModel("Placement"), 250 | new ContainsElementPropertyViewModel(){ PropertyName="Overlay", PropertyDisplayName="Overlay", DefaultValue = true, Value = true, IgnoreOnDefault = false }, 251 | new ContainsElementPropertyViewModel(){ PropertyName="ChildContent", PropertyDisplayName="ChildContent", DefaultValue = true, Value = true, IgnoreOnDefault = false }, 252 | new BP() { PropertyName = "IsButton" } 253 | } 254 | }; 255 | public static ComponentViewModel MenuViewModel { get; } = new ComponentViewModel() 256 | { 257 | ControlName = "Menu", 258 | ControlDisplayName = "Menu", 259 | DefaultMarkup = @" 260 | Menu 261 | 262 | SubMenuItem 263 | 264 | 265 | ", 266 | Moniker = KnownMonikers.MainMenuControl, 267 | Properties = new OCP 268 | { 269 | EnumOptionHelper.GetOptionsViewModel("Mode"), 270 | EnumOptionHelper.GetOptionsViewModel("Theme"), 271 | new IntegerOrIteratorPropertyViewModel(){ PropertyDisplayName = "Children", PropertyName = "Children", ChildrenTagName = "MenuItem"}, 272 | new BP{ PropertyName="InlineCollapsed" }, 273 | new BP{ PropertyName="Multiple" }, 274 | new BP{ PropertyName="Selectable" } 275 | } 276 | }; 277 | public static ComponentViewModel SubmenuViewModel { get; } = new ComponentViewModel() 278 | { 279 | ControlName = "SubMenu", 280 | ControlDisplayName = "Menu - SubMenu", 281 | DefaultMarkup = @" 282 | Option 1 283 | Option 2 284 | Option 3 285 | Option 4 286 | 287 | ", 288 | Moniker = KnownMonikers.MainMenuControl, 289 | Properties = new OCP 290 | { 291 | new BP{ PropertyName="IsOpen" }, 292 | new BP{ PropertyName="Disabled" }, 293 | new SP{ PropertyName = "Key", IgnoreOnDefault = false }, 294 | new SP{ PropertyName = "Title", IgnoreOnDefault = false }, 295 | } 296 | }; 297 | public static ComponentViewModel MenuItemViewModel { get; } = new ComponentViewModel() 298 | { 299 | ControlName = "SubMenu", 300 | ControlDisplayName = "Menu - MenuItem", 301 | DefaultMarkup = @"SubMenuItem 302 | ", 303 | Moniker = KnownMonikers.MainMenuControl, 304 | Properties = new OCP 305 | { 306 | new BP{ PropertyName="Disabled" }, 307 | new SP{ PropertyName = "Key", IgnoreOnDefault = false}, 308 | new SP{ PropertyName = "Title", IgnoreOnDefault = false}, 309 | new SP{ PropertyName = "RouterLink" }, 310 | EnumOptionHelper.GetOptionsViewModel("RouterMatch"), 311 | } 312 | }; 313 | public static ComponentViewModel PaginationViewModel { get; } = new ComponentViewModel() 314 | { 315 | ControlName = "Pagination", 316 | ControlDisplayName = "Pagination", 317 | DefaultMarkup = @"", 318 | Moniker = KnownMonikers.DottedSplitter, 319 | Properties = new OCP 320 | { 321 | new IntegerPropertyViewModel{ PropertyName="Current", PropertyDisplayName = "Current", DefaultValue = null, Value = null}, 322 | new IntegerPropertyViewModel{ PropertyName="DefaultCurrent", PropertyDisplayName = "Current", DefaultValue = 1, Value = 1}, 323 | new IntegerPropertyViewModel{ PropertyName="Current", PropertyDisplayName = "Current", DefaultValue = 10, Value = 10 }, 324 | new IntegerPropertyViewModel{ PropertyName="PageSize", PropertyDisplayName = "PageSize", DefaultValue = 50, Value = 50 }, 325 | new BP{ PropertyName = "Simple", PropertyDisplayName = "Simple" }, 326 | new BP{ PropertyName = "Disabled", PropertyDisplayName = "Disabled" }, 327 | new BP{ PropertyName = "HideOnSinglePage", PropertyDisplayName = "Hide On Single Page" }, 328 | new BP{ PropertyName = "ShowQuickJumper", PropertyDisplayName = "Show Quick Jumper" }, 329 | new BP{ PropertyName = "ShowSizeChanger", PropertyDisplayName = "Show Size Changer" }, 330 | new IntegerPropertyViewModel{ PropertyName="TotalBoundaryShowSizeChanger", PropertyDisplayName = "TotalBoundaryShowSizeChanger", DefaultValue = 50, Value = 50 }, 331 | new BP{ PropertyName = "ShowTitle", PropertyDisplayName = "Show Title" }, 332 | } 333 | }; 334 | 335 | 336 | private static readonly ComponentViewModel SampleViewModel = new() 337 | { 338 | ControlName = "Sample", 339 | Moniker = KnownMonikers.SamplesFolder, 340 | DefaultMarkup = @"sample", 341 | Properties = new OCP() 342 | { 343 | 344 | }, 345 | }; 346 | 347 | 348 | 349 | } 350 | 351 | internal static class DefaultViewModelSourceHelper 352 | { 353 | public static ComponentViewModel Div = new() 354 | { 355 | ControlName = "
", 356 | Moniker = KnownMonikers.None, 357 | AlwaysDefault = true, 358 | DefaultMarkup = @"
359 | 360 |
361 | ", 362 | }; 363 | public static ComponentViewModel If = new() 364 | { 365 | ControlName = "@if", 366 | Moniker = KnownMonikers.None, 367 | AlwaysDefault = true, 368 | DefaultMarkup = "\n@if( true )\n{\n\n}\n", 369 | }; 370 | public static ComponentViewModel Foreach = new() 371 | { 372 | ControlName = "@foreach", 373 | Moniker = KnownMonikers.None, 374 | AlwaysDefault = true, 375 | DefaultMarkup = "\n@foreach(var item in collection)\n{\n\n}\n", 376 | }; 377 | public static ComponentViewModel CodeBlock = new() 378 | { 379 | ControlName = "@code", 380 | Moniker = KnownMonikers.None, 381 | AlwaysDefault = true, 382 | DefaultMarkup = "\n@code{\n\n}\n", 383 | }; 384 | 385 | } 386 | 387 | internal static class EnumOptionHelper 388 | { 389 | public static StringOptionsViewModel GetOptionsViewModel(string propertyName, bool ignoreOnDefault = false) where T: System.Enum 390 | { 391 | var fields = typeof(T).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); 392 | List list = new(); 393 | StringOptionItemViewModel @default = null; 394 | foreach(var field in fields) 395 | { 396 | var attributes = field.CustomAttributes; 397 | string fieldName = field.Name; 398 | var stringValue = field.GetCustomAttributes(false).FirstOrDefault()?.StringValue ?? fieldName; 399 | var display = field.GetCustomAttributes(false).FirstOrDefault()?.Name ?? fieldName; 400 | var isDefault = field.GetCustomAttributes(false).FirstOrDefault()?.IsDefault ?? false; 401 | StringOptionItemViewModel vm = new(display, stringValue); 402 | if(@default is null && isDefault) 403 | { 404 | @default = vm; 405 | } 406 | list.Add(vm); 407 | } 408 | if(@default is null && list.Count > 0) 409 | { 410 | @default = list[0]; 411 | } 412 | return new StringOptionsViewModel() 413 | { 414 | PropertyName = propertyName, 415 | DefaultValue = @default, 416 | Options = new ObservableCollection(list), 417 | SelectedValue = @default, 418 | IgnoreOnDefault = ignoreOnDefault, 419 | }; 420 | } 421 | } 422 | } 423 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/VSCommandTable.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by VSIX Synchronizer 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace AntDesignToolbox 7 | { 8 | using System; 9 | 10 | /// 11 | /// Helper class that exposes all GUIDs used across VS Package. 12 | /// 13 | internal sealed partial class PackageGuids 14 | { 15 | public const string AntDesignToolboxString = "ebd88e56-07f7-48b1-b706-49ce325a3002"; 16 | public static Guid AntDesignToolbox = new Guid(AntDesignToolboxString); 17 | } 18 | /// 19 | /// Helper class that encapsulates all CommandIDs uses across VS Package. 20 | /// 21 | internal sealed partial class PackageIds 22 | { 23 | public const int ControlToolboxCommand = 0x0100; 24 | public const int AddComponentCommand = 0x0101; 25 | public const int SurroundWithTagCommand = 0x0102; 26 | public const int CreateCodeBehindCommand = 0x0103; 27 | public const int AddCrudPageCommand = 0x0104; 28 | public const int SurroundWithComponentCommand = 0x0105; 29 | public const int AntDesignMenu = 0x0001; 30 | public const int AntDesignMenuGroup = 0x0002; 31 | public const int FolderContextMenuGroup = 0x0003; 32 | public const int FolderContextMenu = 0x0004; 33 | public const int EditorContextMenuGroup = 0x0005; 34 | public const int EditorContextMenu = 0x0006; 35 | public const int EditorContextMenuMainGroup = 0x0007; 36 | public const int ItemNodeContextMenuGroup = 0x0008; 37 | public const int ItemNodeContextMenu = 0x0009; 38 | } 39 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/VSCommandTable.vsct: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Ant Design Blazor 34 | 35 | 36 | 37 | 38 | 39 | Ant Design Blazor 40 | 41 | 42 | 43 | 44 | 45 | Ant Design Blazor 46 | 47 | 48 | 49 | 50 | 51 | Ant Design Blazor 52 | 53 | 54 | 55 | 56 | 57 | 65 | 72 | 80 | 88 | 96 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ViewModels/AddComponentViewModel.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.Commons; 2 | using AntDesignToolbox.TextTemplates; 3 | using Prism.Commands; 4 | using Prism.Mvvm; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Collections.ObjectModel; 9 | 10 | namespace AntDesignToolbox.ViewModels 11 | { 12 | public class AddComponentViewModel : BindableBase 13 | { 14 | private SolutionItem _solutionItem; 15 | private string _rootNamespace; 16 | private string _rootPath; 17 | 18 | #region Properties 19 | 20 | public event EventHandler OnCreateSucceedEventHandler; 21 | 22 | private string _componentName; 23 | 24 | public string ComponentName 25 | { 26 | get { return _componentName; } 27 | set { SetProperty(ref _componentName, value); AddCommand?.RaiseCanExecuteChanged(); } 28 | } 29 | 30 | private bool _codeBehind; 31 | 32 | public bool CodeBehind 33 | { 34 | get { return _codeBehind; } 35 | set { SetProperty(ref _codeBehind, value); } 36 | } 37 | 38 | private bool _css; 39 | 40 | public bool Css 41 | { 42 | get { return _css; } 43 | set { SetProperty(ref _css, value); } 44 | } 45 | 46 | private string _selectedFlavor; 47 | 48 | public string SelectedFlavor 49 | { 50 | get { return _selectedFlavor; } 51 | set { _selectedFlavor = value; } 52 | } 53 | 54 | private ObservableCollection _flavors; 55 | 56 | public ObservableCollection Flavors 57 | { 58 | get { return _flavors; } 59 | set { _flavors = value; } 60 | } 61 | 62 | 63 | 64 | 65 | #endregion Properties 66 | 67 | #region Commands 68 | 69 | public DelegateCommand AddCommand { get; set; } 70 | 71 | #endregion Commands 72 | 73 | public AddComponentViewModel() 74 | { 75 | ThreadHelper.ThrowIfNotOnUIThread(); 76 | ThreadHelper.JoinableTaskFactory.Run(InitializeAsync); 77 | Flavors = new ObservableCollection() { "CSS", "LESS", "SCSS" }; 78 | SelectedFlavor = Flavors[0]; 79 | AddCommand = new DelegateCommand(() => ThreadHelper.JoinableTaskFactory.Run(OnAddAsync), CanAdd); 80 | } 81 | 82 | private async Task InitializeAsync() 83 | { 84 | var solutionItems = (await VS.Solutions.GetActiveItemsAsync()).ToList(); 85 | if (solutionItems.Count != 1) 86 | { 87 | await VS.MessageBox.ShowErrorAsync("Cannot determine where to add this file. Please select only one folder. "); 88 | return; 89 | } 90 | _solutionItem = solutionItems.First(); 91 | var ns = await ProjectHelper.GetNamespaceAsync(_solutionItem); 92 | 93 | _rootNamespace = ns; 94 | var path = ProjectHelper.GetContainingFolder(_solutionItem); 95 | _rootPath = path.FullName; 96 | } 97 | 98 | private async Task OnAddAsync() 99 | { 100 | try 101 | { 102 | await AddWithTemplateAsync(new RazorComponentTemplate(), "razor"); 103 | if (CodeBehind) 104 | { 105 | await AddWithTemplateAsync(new CodeBehindTemplate(), "razor.cs"); 106 | } 107 | if (Css) 108 | { 109 | await AddWithTemplateAsync(new CssTemplate(), $"razor.{SelectedFlavor.ToLower()}"); 110 | } 111 | } 112 | catch(Exception ex) 113 | { 114 | await VS.MessageBox.ShowErrorAsync("Failed to create file. ", ex.Message); 115 | } 116 | } 117 | 118 | private bool CanAdd() 119 | { 120 | return ComponentName?.Length > 0; 121 | } 122 | 123 | private async Task AddWithTemplateAsync(T template, string extension) where T : BaseTemplate 124 | { 125 | template.Session = GetCurrentSession(); 126 | template.Initialize(); 127 | string s = template.TransformText(); 128 | 129 | string separator = _rootPath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? string.Empty : Path.DirectorySeparatorChar.ToString(); 130 | 131 | string path = _rootPath + separator + ComponentName + "." + extension; 132 | 133 | await FileHelper.ThrowIfExistAsync(path); 134 | await FileHelper.CreateTextFileAsync(path, s); 135 | 136 | var project = _solutionItem.GetContainingProject(); 137 | await project?.AddExistingFilesAsync(path); 138 | // await VS.Documents.OpenViaProjectAsync(path); 139 | 140 | OnCreateSucceedEventHandler?.Invoke(this, null); 141 | } 142 | 143 | private Dictionary GetCurrentSession() 144 | { 145 | Dictionary result = new Dictionary(); 146 | result["Namespace"] = _rootNamespace; 147 | result["Name"] = ComponentName; 148 | result["IndependentCodeBehind"] = CodeBehind; 149 | return result; 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ViewModels/CreateCodeBehindViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Prism.Mvvm; 4 | using Prism.Commands; 5 | using System.Linq; 6 | using System.IO; 7 | using System.Collections.ObjectModel; 8 | using AntDesignToolbox.Commons; 9 | using AntDesignToolbox.TextTemplates; 10 | 11 | namespace AntDesignToolbox.ViewModels 12 | { 13 | public class CreateCodeBehindViewModel : BindableBase 14 | { 15 | public event EventHandler OnCreateSucceedEventHandler; 16 | 17 | private bool _codeBehind; 18 | public bool CodeBehind 19 | { 20 | get { return _codeBehind; } 21 | set { SetProperty(ref _codeBehind, value); AddCommand?.RaiseCanExecuteChanged(); } 22 | } 23 | 24 | private bool _styleSheet; 25 | public bool StyleSheet 26 | { 27 | get { return _styleSheet; } 28 | set { SetProperty(ref _styleSheet, value); AddCommand?.RaiseCanExecuteChanged(); } 29 | } 30 | 31 | private string _selectedFlavor; 32 | public string SelectedFlavor 33 | { 34 | get { return _selectedFlavor; } 35 | set { SetProperty(ref _selectedFlavor, value); } 36 | } 37 | 38 | private ObservableCollection _flavors; 39 | public ObservableCollection Flavors 40 | { 41 | get { return _flavors; } 42 | set { SetProperty(ref _flavors, value); } 43 | } 44 | 45 | public DelegateCommand AddCommand { get; set; } 46 | public CreateCodeBehindViewModel() 47 | { 48 | AddCommand = new DelegateCommand(() => ThreadHelper.JoinableTaskFactory.Run(OnAddAsync), CanAdd); 49 | Flavors = new ObservableCollection() { "CSS", "LESS", "SCSS" }; 50 | SelectedFlavor = Flavors[0]; 51 | } 52 | 53 | private async Task OnAddAsync() 54 | { 55 | var solutionItems = (await VS.Solutions.GetActiveItemsAsync()).ToList(); 56 | var validSolutionItems = solutionItems.Where(IsRazorFile); 57 | 58 | foreach (var validItem in validSolutionItems) 59 | { 60 | await CreateAsync(validItem); 61 | } 62 | OnCreateSucceedEventHandler?.Invoke(null, null); 63 | } 64 | 65 | private bool CanAdd() 66 | { 67 | return CodeBehind || StyleSheet; 68 | } 69 | 70 | private bool IsRazorFile(SolutionItem item) 71 | { 72 | if (item is null) return false; 73 | if (item.Type != SolutionItemType.PhysicalFile) return false; 74 | var fileInfo = new FileInfo(item.FullPath); 75 | return fileInfo.Extension.ToLower() == ".razor"; 76 | } 77 | 78 | private async Task CreateAsync(SolutionItem item) 79 | { 80 | // item: Extension: ".razor", Text: "Counter.razor" 81 | 82 | Project project = ProjectHelper.GetContainingProject(item); 83 | DirectoryInfo rootPath = ProjectHelper.GetContainingFolder(item.Parent); 84 | string @namespace = await ProjectHelper.GetNamespaceAsync(item.Parent); 85 | FileInfo info = new FileInfo(item.FullPath); 86 | var name = info.Name.Replace(info.Extension, ""); 87 | if (CodeBehind) 88 | { 89 | await AddWithTemplateAsync(new CodeBehindTemplate(), rootPath.FullName, name, @namespace, "razor.cs", item, project); 90 | } 91 | if (StyleSheet) 92 | { 93 | var flavor = string.IsNullOrEmpty(SelectedFlavor) ? "css" : SelectedFlavor.ToLower(); 94 | await AddWithTemplateAsync(new CssTemplate(), rootPath.FullName, name, @namespace, $"razor.{flavor}", item, project); 95 | } 96 | } 97 | 98 | private async Task AddWithTemplateAsync( 99 | T template, 100 | string rootPath, 101 | string name, 102 | string @namespace, 103 | string extension, 104 | SolutionItem item, 105 | Project project 106 | ) where T : BaseTemplate 107 | { 108 | try 109 | { 110 | template.Session = GetSession(name, @namespace); 111 | template.Initialize(); 112 | string s = template.TransformText(); 113 | 114 | string separator = rootPath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? string.Empty : Path.DirectorySeparatorChar.ToString(); 115 | 116 | string path = rootPath + separator + name + "." + extension; 117 | if (File.Exists(path)) 118 | { 119 | return; 120 | } 121 | await FileHelper.CreateTextFileAsync(path, s); 122 | await project?.AddExistingFilesAsync(path); 123 | } 124 | catch(Exception ex) 125 | { 126 | 127 | } 128 | } 129 | 130 | private Dictionary GetSession(string name, string @namespace) 131 | { 132 | Dictionary result = new Dictionary(); 133 | result["Namespace"] = @namespace; 134 | result["Name"] = name; 135 | return result; 136 | } 137 | 138 | } 139 | } -------------------------------------------------------------------------------- /src/AntDesignToolbox/ViewModels/SurroundWithComponentViewModel.cs: -------------------------------------------------------------------------------- 1 | using EnvDTE; 2 | using Prism.Commands; 3 | using Prism.Mvvm; 4 | using System.Collections.Generic; 5 | using System.Collections.ObjectModel; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace AntDesignToolbox.ViewModels 10 | { 11 | internal class SurroundWithComponentViewModel : BindableBase 12 | { 13 | public event EventHandler OnCreateSucceedEventHandler; 14 | 15 | private ComponentItem _selectedComponent; 16 | public ComponentItem SelectedComponent 17 | { 18 | get => _selectedComponent; 19 | set 20 | { 21 | SetProperty(ref _selectedComponent, value); 22 | ConfirmCommand.RaiseCanExecuteChanged(); 23 | } 24 | } 25 | 26 | private ObservableCollection _components; 27 | public ObservableCollection Components { get => _components; set => SetProperty(ref _components, value); } 28 | 29 | public DelegateCommand ConfirmCommand { get; set; } 30 | 31 | public SurroundWithComponentViewModel() 32 | { 33 | InitializeComponents(); 34 | ConfirmCommand = new DelegateCommand(() => { ThreadHelper.JoinableTaskFactory.Run(GenerateAsync); }, CanGenerate); 35 | } 36 | 37 | private void InitializeComponents() 38 | { 39 | var items = new List 40 | { 41 | new ComponentItem{ ComponentName = "CascadingValue", OpenTag = "", CloseTag = "" }, 42 | new ComponentItem{ ComponentName = "ChildContent", OpenTag = "", CloseTag = "" }, 43 | new ComponentItem{ ComponentName = "Unbound", OpenTag = "", CloseTag = "" }, 44 | new ComponentItem{ ComponentName = "Popconfirm", OpenTag = @"", CloseTag = "" }, 45 | }; 46 | var ordered = items.OrderBy(a => a.ComponentName); 47 | Components = new ObservableCollection(ordered); 48 | } 49 | 50 | private bool CanGenerate() 51 | { 52 | return SelectedComponent != null; 53 | } 54 | 55 | public async Task GenerateAsync() 56 | { 57 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 58 | var activeDocument = AntDesignToolboxPackage.DTE.ActiveDocument.Object("TextDocument") as TextDocument; 59 | 60 | TextSelection selection = activeDocument.Selection; 61 | var text = selection.Text; 62 | var lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 63 | var newText = GetNewText(lines); 64 | selection.ReplaceText(text, newText); 65 | 66 | OnCreateSucceedEventHandler?.Invoke(null, null); 67 | } 68 | 69 | private Tuple GetIndent(string[] lines) 70 | { 71 | if (lines is null || lines.Length == 0) return new Tuple(' ', 0); 72 | string line = lines.FirstOrDefault(a => a.Length > 0); 73 | if (line is null) return new Tuple(' ', 0); 74 | if (line.StartsWith("\t")) 75 | { 76 | int count = 0; 77 | foreach (char c in line) 78 | { 79 | if (c == '\t') 80 | { 81 | count++; 82 | } 83 | else 84 | { 85 | break; 86 | } 87 | } 88 | return new Tuple('\t', count); 89 | } 90 | else if (line.StartsWith(" ")) 91 | { 92 | int count = 0; 93 | foreach (char c in line) 94 | { 95 | if (c == ' ') 96 | { 97 | count++; 98 | } 99 | else 100 | { 101 | break; 102 | } 103 | } 104 | return new Tuple(' ', count); 105 | } 106 | return new Tuple(' ', 0); 107 | } 108 | 109 | private string GetNewText(string[] lines) 110 | { 111 | var tuple = GetIndent(lines); 112 | string indent = tuple.Item1 == ' ' ? " " : "\t"; 113 | string divIndent = new string(Enumerable.Repeat(tuple.Item1, tuple.Item2).ToArray()); 114 | StringBuilder builder = new StringBuilder(); 115 | builder.AppendLine(divIndent + SelectedComponent.OpenTag); 116 | foreach (var line in lines) 117 | { 118 | if (line.Length == 0) 119 | { 120 | builder.AppendLine(line); 121 | } 122 | else 123 | { 124 | builder.AppendLine(indent + line); 125 | } 126 | } 127 | builder.AppendLine(divIndent + SelectedComponent.CloseTag); 128 | return builder.ToString(); 129 | } 130 | 131 | } 132 | 133 | internal class ComponentItem : BindableBase 134 | { 135 | private string _componentName; 136 | public string ComponentName { get => _componentName; set => SetProperty(ref _componentName, value); } 137 | 138 | public string OpenTag { get; set; } 139 | public string CloseTag { get; set; } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/ViewModels/SurroundWithTagViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Prism.Mvvm; 7 | using System.Collections.ObjectModel; 8 | using System.Windows.Input; 9 | using Prism.Commands; 10 | using EnvDTE; 11 | 12 | namespace AntDesignToolbox.ViewModels 13 | { 14 | public class SurroundWithTagViewModel: BindableBase 15 | { 16 | public event EventHandler OnCreateSucceedEventHandler; 17 | public DelegateCommand GenerateCommand { get; set; } 18 | 19 | private string _text; 20 | public string Text { get => _text; set => SetProperty(ref _text, value); } 21 | 22 | public SurroundWithTagViewModel() 23 | { 24 | GenerateCommand = new DelegateCommand(()=>ThreadHelper.JoinableTaskFactory.Run(GenerateAsync)); 25 | } 26 | 27 | 28 | 29 | public async Task GenerateAsync() 30 | { 31 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 32 | var activeDocument = AntDesignToolboxPackage.DTE.ActiveDocument.Object("TextDocument") as TextDocument; 33 | 34 | TextSelection selection = activeDocument.Selection; 35 | var text = selection.Text; 36 | var lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 37 | var newText = GetNewText(lines); 38 | selection.ReplaceText(text, newText); 39 | 40 | OnCreateSucceedEventHandler?.Invoke(null, null); 41 | } 42 | 43 | private Tuple GetIndent(string[] lines) 44 | { 45 | if (lines is null || lines.Length == 0) return new Tuple(' ', 0); 46 | string line = lines.FirstOrDefault(a => a.Length > 0); 47 | if (line is null) return new Tuple(' ', 0); 48 | if (line.StartsWith("\t")) 49 | { 50 | int count = 0; 51 | foreach (char c in line) 52 | { 53 | if (c == '\t') 54 | { 55 | count++; 56 | } 57 | else 58 | { 59 | break; 60 | } 61 | } 62 | return new Tuple('\t', count); 63 | } 64 | else if (line.StartsWith(" ")) 65 | { 66 | int count = 0; 67 | foreach (char c in line) 68 | { 69 | if (c == ' ') 70 | { 71 | count++; 72 | } 73 | else 74 | { 75 | break; 76 | } 77 | } 78 | return new Tuple(' ', count); 79 | } 80 | return new Tuple(' ', 0); 81 | } 82 | 83 | private string GetNewText(string[] lines) 84 | { 85 | var tuple = GetIndent(lines); 86 | string indent = tuple.Item1 == ' ' ? " " : "\t"; 87 | string divIndent = new string(Enumerable.Repeat(tuple.Item1, tuple.Item2).ToArray()); 88 | StringBuilder builder = new StringBuilder(); 89 | builder.AppendLine(divIndent + $"<{Text}>"); 90 | foreach (var line in lines) 91 | { 92 | if (line.Length == 0) 93 | { 94 | builder.AppendLine(line); 95 | } 96 | else 97 | { 98 | builder.AppendLine(indent + line); 99 | } 100 | } 101 | builder.AppendLine(divIndent + $""); 102 | return builder.ToString(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Views/AddComponentWindow.xaml: -------------------------------------------------------------------------------- 1 |  15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Views/CreateCodeBehindWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using AntDesignToolbox.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Shapes; 15 | 16 | namespace AntDesignToolbox.Views 17 | { 18 | /// 19 | /// Interaction logic for CreateCodeBehindWindow.xaml 20 | /// 21 | public partial class CreateCodeBehindWindow : Window 22 | { 23 | public CreateCodeBehindWindow() 24 | { 25 | InitializeComponent(); 26 | var vm = new CreateCodeBehindViewModel(); 27 | vm.OnCreateSucceedEventHandler += Vm_OnCreateSucceedEventHandler; 28 | this.DataContext = vm; 29 | } 30 | 31 | private void Vm_OnCreateSucceedEventHandler(object sender, EventArgs e) 32 | { 33 | this.Close(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/AntDesignToolbox/Views/SurroundWithComponentWindow.xaml: -------------------------------------------------------------------------------- 1 |  17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 35 | 36 | 37 | 42 | 43 | 44 | 45 | 46 | 47 |