Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a161ed5

Browse files
add refresh and pic
1 parent 8bbf79f commit a161ed5

File tree

6 files changed

+304
-3
lines changed

6 files changed

+304
-3
lines changed

‎SSMS2018Addin/My Project/Resources.Designer.vb‎

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64+
<xsd:element name="root" msdata:IsDataSet="true">
65+
<xsd:complexType>
66+
<xsd:choice maxOccurs="unbounded">
67+
<xsd:element name="metadata">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
71+
</xsd:sequence>
72+
<xsd:attribute name="name" use="required" type="xsd:string" />
73+
<xsd:attribute name="type" type="xsd:string" />
74+
<xsd:attribute name="mimetype" type="xsd:string" />
75+
<xsd:attribute ref="xml:space" />
76+
</xsd:complexType>
77+
</xsd:element>
78+
<xsd:element name="assembly">
79+
<xsd:complexType>
80+
<xsd:attribute name="alias" type="xsd:string" />
81+
<xsd:attribute name="name" type="xsd:string" />
82+
</xsd:complexType>
83+
</xsd:element>
84+
<xsd:element name="data">
85+
<xsd:complexType>
86+
<xsd:sequence>
87+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89+
</xsd:sequence>
90+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+
<xsd:attribute ref="xml:space" />
94+
</xsd:complexType>
95+
</xsd:element>
96+
<xsd:element name="resheader">
97+
<xsd:complexType>
98+
<xsd:sequence>
99+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100+
</xsd:sequence>
101+
<xsd:attribute name="name" type="xsd:string" use="required" />
102+
</xsd:complexType>
103+
</xsd:element>
104+
</xsd:choice>
105+
</xsd:complexType>
106+
</xsd:element>
107+
</xsd:schema>
108+
<resheader name="resmimetype">
109+
<value>text/microsoft-resx</value>
110+
</resheader>
111+
<resheader name="version">
112+
<value>2.0</value>
113+
</resheader>
114+
<resheader name="reader">
115+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116+
</resheader>
117+
<resheader name="writer">
118+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119+
</resheader>
120+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121+
<data name="sql-file-format" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\sql-file-format.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123+
</data>
124+
</root>
44.4 KB
Binary file not shown.

‎SSMS2018Addin/SSMS2018Addin.vbproj‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
</ItemGroup>
6363
<ItemGroup>
6464
<Compile Include="My Project\AssemblyInfo.vb" />
65+
<Compile Include="My Project\Resources.Designer.vb">
66+
<AutoGen>True</AutoGen>
67+
<DesignTime>True</DesignTime>
68+
<DependentUpon>Resources.resx</DependentUpon>
69+
</Compile>
6570
<Compile Include="SSMS2018AddinPackage.vb" />
6671
<Compile Include="ToolWindow1.vb" />
6772
<Compile Include="ToolWindow1Command.vb" />
@@ -173,6 +178,7 @@
173178
</ItemGroup>
174179
<ItemGroup>
175180
<Content Include="Resources\CommandAddin.png" />
181+
<None Include="Resources\sql-file-format.ico" />
176182
<Content Include="Resources\ToolWindow1Command.png" />
177183
</ItemGroup>
178184
<ItemGroup>
@@ -181,6 +187,14 @@
181187
<Generator>MSBuild:Compile</Generator>
182188
</Page>
183189
</ItemGroup>
190+
<ItemGroup>
191+
<EmbeddedResource Include="My Project\Resources.resx">
192+
<CustomToolNamespace>My.Resources</CustomToolNamespace>
193+
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
194+
<SubType>Designer</SubType>
195+
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
196+
</EmbeddedResource>
197+
</ItemGroup>
184198
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
185199
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
186200
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

‎SSMS2018Addin/ToolWindow1Control.xaml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@
77
Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
88
Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"
99
mc:Ignorable="d"
10-
d:DesignHeight="40" d:DesignWidth="300"
10+
d:DesignHeight="400" d:DesignWidth="300"
1111
Name="ToolBox">
1212
<Grid Margin="0,0,0,10">
1313
<StackPanel Orientation="Vertical" Margin="0,0,0,0">
1414
<StackPanel Orientation="Horizontal">
15+
1516
</StackPanel>
1617
<StackPanel Orientation="Horizontal">
17-
<Button Content="Format selection" Click="button1_Click" x:Name="button1" Margin="0,0,0,0" RenderTransformOrigin="-0.486,-0.136"/>
18+
<Button Content="Format selection" Click="button1_Click" x:Name="button1" Margin="2,2,5,0" RenderTransformOrigin="-0.486,-0.136"/>
19+
<Menu Name="FileMenu" Margin="2,2,5,0">
20+
<MenuItem Header="TSQL Templates" Name="FileMenuTemplates"/>
21+
</Menu>
22+
<Button Content="Refresh templates" Click="buttonRefresh_Click" />
1823
</StackPanel>
1924

25+
2026
</StackPanel>
2127
</Grid>
2228
</UserControl>

‎SSMS2018Addin/ToolWindow1Control.xaml.vb‎

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Imports System
44
Imports System.Collections.Generic
5+
Imports System.Drawing
56
Imports System.IO
7+
Imports System.Windows.Controls
68
Imports EnvDTE
79
Imports Microsoft.SqlServer.TransactSql.ScriptDom
810
Imports Microsoft.VisualStudio.Shell
@@ -25,13 +27,95 @@ Partial Public Class ToolWindow1Control
2527

2628
Function AddFiles()
2729

30+
Dim Folder = "C:\glassdoor\addin\ssms-addin\QueryTemplates"
2831

32+
If My.Computer.FileSystem.DirectoryExists(Folder) Then
2933

30-
'ToolBox
34+
DimiAsInteger=1
3135

36+
FileMenuTemplates.Items.Clear()
37+
38+
CreateCommands(FileMenuTemplates, Folder, i)
39+
40+
End If
41+
42+
End Function
43+
44+
Function CreateCommands(MenuItem As MenuItem, Folder As String, ByRef i As Integer)
45+
46+
47+
Dim Dirs = My.Computer.FileSystem.GetDirectories(Folder)
48+
For Each DirStr In Dirs
49+
50+
Dim DI = My.Computer.FileSystem.GetFileInfo(DirStr)
51+
52+
Dim mi = New MenuItem
53+
mi.Header = DI.Name
54+
55+
MenuItem.Items.Add(mi)
56+
57+
CreateCommands(mi, Path.Combine(Folder, DirStr), i)
58+
59+
i = i + 1
60+
61+
Next
62+
63+
Dim Files = My.Computer.FileSystem.GetFiles(Folder)
64+
65+
For Each File In Files
66+
67+
Dim FI = My.Computer.FileSystem.GetFileInfo(File)
68+
69+
70+
71+
Dim mi = New MenuItem
72+
mi.Header = FI.Name
73+
mi.ToolTip = File
74+
mi.Icon = My.Resources.ResourceManager.GetObject("sql-file-format")
75+
76+
AddHandler mi.Click, AddressOf insert_template
77+
78+
MenuItem.Items.Add(mi)
79+
80+
i = i + 1
81+
82+
Next
3283

3384
End Function
3485

86+
Private Sub buttonRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs)
87+
88+
AddFiles()
89+
90+
System.Windows.MessageBox.Show("Templates have been refreshed!")
91+
92+
End Sub
93+
94+
Private Sub insert_template(ByVal sender As Object, ByVal e As System.EventArgs)
95+
96+
Try
97+
98+
Dim FileName As String = sender.ToolTip
99+
100+
Dim FileContent = My.Computer.FileSystem.ReadAllText(FileName)
101+
102+
Dim dte As DTE = TryCast(Package.GetGlobalService(GetType(DTE)), DTE)
103+
104+
Dim selection As TextSelection = DirectCast(dte.ActiveDocument.Selection, TextSelection)
105+
106+
selection.Delete()
107+
108+
selection.Insert(FileContent.Trim)
109+
110+
Catch ex As Exception
111+
System.Windows.MessageBox.Show(ex.Message)
112+
End Try
113+
114+
115+
116+
End Sub
117+
118+
35119
''' <summary>
36120
''' Handles click on the button by displaying a message box.
37121
''' </summary>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /