",
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 |
14 |
17 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
36 |
42 |
48 |
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 + $"{Text}>");
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 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
54 |
58 |
62 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/src/AntDesignToolbox/Views/AddComponentWindow.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 AddComponentWindow.xaml
20 | ///
21 | public partial class AddComponentWindow : Window
22 | {
23 | public AddComponentWindow()
24 | {
25 | InitializeComponent();
26 | var vm = new AddComponentViewModel();
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/CreateCodeBehindWindow.xaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
41 |
45 |
52 |
53 |
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 |
34 |
35 |
36 |
37 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/AntDesignToolbox/Views/SurroundWithComponentWindow.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 SurroundWithComponentWindow.xaml
20 | ///
21 | public partial class SurroundWithComponentWindow : Window
22 | {
23 | public SurroundWithComponentWindow()
24 | {
25 | InitializeComponent();
26 | var vm = new SurroundWithComponentViewModel();
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/SurroundWithTagWindow.xaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/AntDesignToolbox/Views/SurroundWithTagWindow.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 SurroundWithTagWindow.xaml
20 | ///
21 | public partial class SurroundWithTagWindow : Window
22 | {
23 | public SurroundWithTagWindow()
24 | {
25 | InitializeComponent();
26 | var vm = new SurroundWithTagViewModel();
27 | vm.OnCreateSucceedEventHandler += Vm_OnCreateSucceedEventHandler;
28 | this.DataContext = vm;
29 | textBox.Focus();
30 | }
31 |
32 | private void Vm_OnCreateSucceedEventHandler(object sender, EventArgs e)
33 | {
34 | this.Close();
35 | }
36 |
37 | private async void TextBox_KeyUp(object sender, KeyEventArgs e)
38 | {
39 | if(e.Key == Key.Enter && this.DataContext is SurroundWithTagViewModel vm)
40 | {
41 | await vm.GenerateAsync();
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/AntDesignToolbox/source.extension.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------------
2 | //
3 | // This file was generated by VSIX Synchronizer
4 | //
5 | // ------------------------------------------------------------------------------
6 | namespace AntDesignToolbox
7 | {
8 | internal sealed partial class Vsix
9 | {
10 | public const string Id = "AntDesignToolbox.fc7d754e-7e4b-4b67-9e21-1d44298675e9";
11 | public const string Name = "Ant Design Blazor Toolbox";
12 | public const string Description = @"Your companion for Ant Design Blazor development.";
13 | public const string Language = "en-US";
14 | public const string Version = "0.2";
15 | public const string Author = "Bin Dong";
16 | public const string Tags = "";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/AntDesignToolbox/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ant Design Blazor Toolbox
6 | Your companion for Ant Design Blazor development.
7 | Resources\Icon.png
8 | Resources\Icon.png
9 | true
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------