File tree Expand file tree Collapse file tree 6 files changed +17
-11
lines changed Expand file tree Collapse file tree 6 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 2
2
using Community . VisualStudio . Toolkit ;
3
3
using EnvDTE ;
4
4
using Microsoft . VisualStudio . Shell ;
5
+ using Microsoft . VisualStudio . Text . Editor ;
5
6
using Task = System . Threading . Tasks . Task ;
6
7
7
8
namespace InsertGuid
@@ -11,10 +12,10 @@ internal sealed class MyCommand : BaseCommand<MyCommand>
11
12
{
12
13
protected override async Task ExecuteAsync ( OleMenuCmdEventArgs e )
13
14
{
14
- await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
15
- TextDocument doc = await VS . Editor . GetActiveTextDocumentAsync ( ) ;
15
+ IWpfTextView view = await VS . Documents . GetCurrentTextViewAsync ( ) ;
16
+ var position = view . Selection . Start . Position . Position ;
16
17
17
- doc ? . Selection . Insert ( Guid . NewGuid ( ) . ToString ( ) ) ;
18
+ view . TextBuffer . Insert ( position , Guid . NewGuid ( ) . ToString ( ) ) ;
18
19
}
19
20
}
20
21
}
Original file line number Diff line number Diff line change 83
83
<Reference Include =" System.Design" />
84
84
</ItemGroup >
85
85
<ItemGroup >
86
- <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.81 " ExcludeAssets =" runtime" >
86
+ <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.152-pre " ExcludeAssets =" runtime" >
87
87
<IncludeAssets >compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
88
88
</PackageReference >
89
89
<PackageReference Include =" Community.VisualStudio.VSCT" Version =" 16.0.29.6" PrivateAssets =" all" />
Original file line number Diff line number Diff line change 84
84
<Reference Include =" System.Design" />
85
85
</ItemGroup >
86
86
<ItemGroup >
87
- <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.81" ExcludeAssets =" Runtime" />
87
+ <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.152-pre" ExcludeAssets =" Runtime" >
88
+ <IncludeAssets >compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
89
+ </PackageReference >
88
90
<PackageReference Include =" Community.VisualStudio.VSCT" Version =" 16.0.29.6" PrivateAssets =" all" />
89
91
<PackageReference Include =" Microsoft.VSSDK.BuildTools" Version =" 16.10.11" />
90
92
</ItemGroup >
Original file line number Diff line number Diff line change 96
96
<Reference Include =" WindowsBase" />
97
97
</ItemGroup >
98
98
<ItemGroup >
99
- <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.81" ExcludeAssets =" Runtime" />
99
+ <PackageReference Include =" Community.VisualStudio.Toolkit" Version =" 16.0.75.152-pre" ExcludeAssets =" Runtime" >
100
+ <IncludeAssets >compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
101
+ </PackageReference >
100
102
<PackageReference Include =" Community.VisualStudio.VSCT" Version =" 16.0.29.6" PrivateAssets =" all" />
101
103
<PackageReference Include =" Microsoft.VSSDK.BuildTools" Version =" 16.10.11" />
102
104
</ItemGroup >
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ public class MyToolWindow : BaseToolWindow<MyToolWindow>
16
16
17
17
public override async Task < FrameworkElement > CreateAsync ( int toolWindowId , CancellationToken cancellationToken )
18
18
{
19
- EnvDTE80 . DTE2 dte = await VS . GetDTEAsync ( ) ;
20
- return new MyToolWindowControl ( dte ) ;
19
+ Version vsVersion = await VS . Shell . GetVsVersionAsync ( ) ;
20
+ return new MyToolWindowControl ( vsVersion ) ;
21
21
}
22
22
23
23
[ Guid ( "03030460-e1a2-49ab-a4c5-b7b9cfc2a4df" ) ]
Original file line number Diff line number Diff line change 1
1
using Community . VisualStudio . Toolkit ;
2
+ using System ;
2
3
using System . Windows ;
3
4
using System . Windows . Controls ;
4
5
5
6
namespace ToolWindow
6
7
{
7
8
public partial class MyToolWindowControl : UserControl
8
9
{
9
- public MyToolWindowControl ( EnvDTE80 . DTE2 dte )
10
+ public MyToolWindowControl ( Version vsVersion )
10
11
{
11
12
InitializeComponent ( ) ;
12
13
13
- lblHeadline . Content = $ "Visual Studio v{ dte . Version } ";
14
+ lblHeadline . Content = $ "Visual Studio v{ vsVersion } ";
14
15
}
15
16
16
17
private void button1_Click ( object sender , RoutedEventArgs e )
17
18
{
18
- VS . Notifications . ShowMessage ( "ToolWindow" , "Button clicked" ) ;
19
+ VS . MessageBox . Show ( "ToolWindow" , "Button clicked" ) ;
19
20
}
20
21
}
21
22
}
You can’t perform that action at this time.
0 commit comments