Skip to content
This repository was archived by the owner on Oct 14, 2022. It is now read-only.

Commit 6740919

Browse files
author
Mathias Storm
committed
Adding optionspage
1 parent bef67dd commit 6740919

9 files changed

Lines changed: 362 additions & 10 deletions

CodeStats.Client/CodeStats.Client.csproj

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
77
<NuGetPackageImportStamp>
88
</NuGetPackageImportStamp>
9+
<UseCodebase>true</UseCodebase>
10+
</PropertyGroup>
11+
<PropertyGroup>
12+
<SignAssembly>true</SignAssembly>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
916
</PropertyGroup>
1017
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1118
<PropertyGroup>
@@ -19,11 +26,11 @@
1926
<RootNamespace>CodeStats.Client</RootNamespace>
2027
<AssemblyName>CodeStats.Client</AssemblyName>
2128
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
22-
<GeneratePkgDefFile>false</GeneratePkgDefFile>
29+
<GeneratePkgDefFile>true</GeneratePkgDefFile>
2330
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
2431
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
2532
<IncludeDebugSymbolsInLocalVSIXDeployment>true</IncludeDebugSymbolsInLocalVSIXDeployment>
26-
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
33+
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
2734
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
2835
<StartAction>Program</StartAction>
2936
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
@@ -47,11 +54,18 @@
4754
<WarningLevel>4</WarningLevel>
4855
</PropertyGroup>
4956
<ItemGroup>
50-
<Compile Include="CodeStatsAdornmentTextViewCreationListener.cs" />
57+
<Compile Include="FilterProvider.cs" />
5158
<Compile Include="CommandFilter.cs" />
59+
<Compile Include="OptionsPage\SettingsPage.cs">
60+
<SubType>Component</SubType>
61+
</Compile>
62+
<Compile Include="OptionsPage\SettingsPage.Designer.cs">
63+
<DependentUpon>SettingsPage.cs</DependentUpon>
64+
</Compile>
5265
<Compile Include="Properties\AssemblyInfo.cs" />
5366
</ItemGroup>
5467
<ItemGroup>
68+
<None Include="Key.snk" />
5569
<None Include="packages.config" />
5670
<None Include="source.extension.vsixmanifest">
5771
<SubType>Designer</SubType>
@@ -62,14 +76,75 @@
6276
<Content Include="stylesheet.css" />
6377
</ItemGroup>
6478
<ItemGroup>
79+
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
80+
<EmbedInteropTypes>False</EmbedInteropTypes>
81+
</Reference>
82+
<Reference Include="EnvDTE100, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
83+
<EmbedInteropTypes>False</EmbedInteropTypes>
84+
</Reference>
85+
<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
86+
<EmbedInteropTypes>False</EmbedInteropTypes>
87+
</Reference>
88+
<Reference Include="EnvDTE90, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
89+
<EmbedInteropTypes>False</EmbedInteropTypes>
90+
</Reference>
6591
<Reference Include="Microsoft.CSharp" />
92+
<Reference Include="Microsoft.VisualStudio.CommandBars, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
93+
<EmbedInteropTypes>False</EmbedInteropTypes>
94+
</Reference>
6695
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
6796
<HintPath>..\packages\Microsoft.VisualStudio.CoreUtility.15.0.26606\lib\net45\Microsoft.VisualStudio.CoreUtility.dll</HintPath>
6897
<Private>True</Private>
6998
</Reference>
7099
<Reference Include="Microsoft.VisualStudio.Editor, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
71-
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
72-
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
100+
<Reference Include="Microsoft.VisualStudio.Imaging, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
101+
<HintPath>..\packages\Microsoft.VisualStudio.Imaging.15.0.26606\lib\net45\Microsoft.VisualStudio.Imaging.dll</HintPath>
102+
<Private>True</Private>
103+
</Reference>
104+
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
105+
<HintPath>..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
106+
<Private>True</Private>
107+
</Reference>
108+
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
109+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.15.0.15.0.26606\lib\Microsoft.VisualStudio.Shell.15.0.dll</HintPath>
110+
<Private>True</Private>
111+
</Reference>
112+
<Reference Include="Microsoft.VisualStudio.Shell.Framework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
113+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Framework.15.0.26606\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll</HintPath>
114+
<Private>True</Private>
115+
</Reference>
116+
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
117+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
118+
<Private>True</Private>
119+
</Reference>
120+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
121+
<EmbedInteropTypes>True</EmbedInteropTypes>
122+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll</HintPath>
123+
<Private>True</Private>
124+
</Reference>
125+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
126+
<EmbedInteropTypes>True</EmbedInteropTypes>
127+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll</HintPath>
128+
<Private>True</Private>
129+
</Reference>
130+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
131+
<EmbedInteropTypes>True</EmbedInteropTypes>
132+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll</HintPath>
133+
<Private>True</Private>
134+
</Reference>
135+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
136+
<EmbedInteropTypes>True</EmbedInteropTypes>
137+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.15.0.26606\lib\net20\Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.dll</HintPath>
138+
<Private>True</Private>
139+
</Reference>
140+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
141+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll</HintPath>
142+
<Private>True</Private>
143+
</Reference>
144+
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
145+
<HintPath>..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll</HintPath>
146+
<Private>True</Private>
147+
</Reference>
73148
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
74149
<HintPath>..\packages\Microsoft.VisualStudio.Text.Data.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.Data.dll</HintPath>
75150
<Private>True</Private>
@@ -86,17 +161,48 @@
86161
<HintPath>..\packages\Microsoft.VisualStudio.Text.UI.Wpf.15.0.26606\lib\net45\Microsoft.VisualStudio.Text.UI.Wpf.dll</HintPath>
87162
<Private>True</Private>
88163
</Reference>
89-
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
164+
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
165+
<HintPath>..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
166+
<Private>True</Private>
167+
</Reference>
168+
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
169+
<HintPath>..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll</HintPath>
170+
<Private>True</Private>
171+
</Reference>
172+
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
173+
<HintPath>..\packages\Microsoft.VisualStudio.Threading.15.3.23\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
174+
<Private>True</Private>
175+
</Reference>
176+
<Reference Include="Microsoft.VisualStudio.Utilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
177+
<HintPath>..\packages\Microsoft.VisualStudio.Utilities.15.0.26606\lib\net45\Microsoft.VisualStudio.Utilities.dll</HintPath>
178+
<Private>True</Private>
179+
</Reference>
180+
<Reference Include="Microsoft.VisualStudio.Validation, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
181+
<HintPath>..\packages\Microsoft.VisualStudio.Validation.15.3.15\lib\net45\Microsoft.VisualStudio.Validation.dll</HintPath>
182+
<Private>True</Private>
183+
</Reference>
90184
<Reference Include="PresentationCore" />
91185
<Reference Include="PresentationFramework" />
186+
<Reference Include="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
187+
<EmbedInteropTypes>False</EmbedInteropTypes>
188+
</Reference>
92189
<Reference Include="System" />
93190
<Reference Include="System.ComponentModel.Composition" />
94191
<Reference Include="System.Data" />
95192
<Reference Include="System.Data.DataSetExtensions" />
193+
<Reference Include="System.Design" />
194+
<Reference Include="System.Drawing" />
195+
<Reference Include="System.Windows.Forms" />
96196
<Reference Include="System.Xaml" />
97197
<Reference Include="System.Xml" />
198+
<Reference Include="System.Xml.Linq" />
98199
<Reference Include="WindowsBase" />
99200
</ItemGroup>
201+
<ItemGroup>
202+
<EmbeddedResource Include="OptionsPage\SettingsPage.resx">
203+
<DependentUpon>SettingsPage.cs</DependentUpon>
204+
</EmbeddedResource>
205+
</ItemGroup>
100206
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
101207
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
102208
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -105,8 +211,10 @@
105211
</PropertyGroup>
106212
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.props'))" />
107213
<Error Condition="!Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets'))" />
214+
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.SDK.EmbedInteropTypes.15.0.9\build\Microsoft.VisualStudio.SDK.EmbedInteropTypes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.VisualStudio.SDK.EmbedInteropTypes.15.0.9\build\Microsoft.VisualStudio.SDK.EmbedInteropTypes.targets'))" />
108215
</Target>
109216
<Import Project="..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.VSSDK.BuildTools.15.1.192\build\Microsoft.VSSDK.BuildTools.targets')" />
217+
<Import Project="..\packages\Microsoft.VisualStudio.SDK.EmbedInteropTypes.15.0.9\build\Microsoft.VisualStudio.SDK.EmbedInteropTypes.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SDK.EmbedInteropTypes.15.0.9\build\Microsoft.VisualStudio.SDK.EmbedInteropTypes.targets')" />
110218
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
111219
Other similar extension points exist, see Microsoft.Common.targets.
112220
<Target Name="BeforeBuild">

CodeStats.Client/CommandFilter.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
using System.Threading.Tasks;
1212
using System.Threading;
1313
using System.Windows;
14+
using CodeStats.Client.OptionsPage;
1415

1516
namespace CodeStats.Client
1617
{
17-
class CommandFilter : IOleCommandTarget
18+
public class CommandFilter : IOleCommandTarget
1819
{
1920
private IWpfTextView _textView;
2021
internal IOleCommandTarget NextTarget { get; set; }
2122
internal bool Added { get; set; }
2223
private IAdornmentLayer _adornmentLayer;
23-
24+
public string MachineKey { get; set; }
2425
internal Dictionary<string, int> Experiences = new Dictionary<string, int>();
2526
private Task _publisher = null;
2627

27-
2828
public CommandFilter(IWpfTextView textView)
2929
{
3030
_textView = textView;
@@ -50,7 +50,15 @@ int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt
5050
{
5151
experiences += $"In Language {experience.Key}, you earned {experience.Value} xp\n";
5252
}
53+
54+
EnvDTE.DTE dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
55+
// Access options page
56+
var props = dte.get_Properties(@"CodeStats", "General");
57+
var pathProperty = props.Item("MachineKey");
58+
var machineKey = pathProperty.Value as string;
59+
5360
MessageBox.Show(experiences);
61+
MessageBox.Show("Pushing to " + machineKey);
5462
Experiences.Clear();
5563
_publisher = null;
5664
});

CodeStats.Client/FilterProvider.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
using Microsoft.VisualStudio.Editor;
88
using Microsoft.VisualStudio.Text.Editor;
99
using Microsoft.VisualStudio.TextManager.Interop;
10+
using CodeStats.Client.OptionsPage;
11+
using System.Runtime.InteropServices;
12+
using Microsoft.VisualStudio.Shell;
1013

1114
namespace CodeStats.Client
1215
{
1316
[Export(typeof(IVsTextViewCreationListener))]
1417
[ContentType("text")]
1518
[TextViewRole(PredefinedTextViewRoles.Editable)]
16-
internal class FilterProvider : IVsTextViewCreationListener
19+
[Guid("5c3c0aa0-0bc8-43c5-afc9-5aa55662794b")]
20+
[PackageRegistration(UseManagedResourcesOnly = true)]
21+
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
22+
[ProvideMenuResource("Menus.ctmenu", 1)]
23+
[ProvideOptionPage(typeof(SettingsPage), "CodeStats", "General", 0, 0, true)]
24+
public class FilterProvider : Package, IVsTextViewCreationListener
1725
{
1826
[Export(typeof(AdornmentLayerDefinition))]
1927
[Name("CodeStatsClientLayer")]
@@ -36,6 +44,7 @@ void AddCommandFilter(IVsTextView viewAdapter, CommandFilter commandFilter)
3644
{
3745
if (commandFilter.Added == false)
3846
{
47+
commandFilter.MachineKey = MachineKey;
3948
//get the view adapter from the editor factory
4049
IOleCommandTarget next;
4150
int hr = viewAdapter.AddCommandFilter(commandFilter, out next);
@@ -50,5 +59,19 @@ void AddCommandFilter(IVsTextView viewAdapter, CommandFilter commandFilter)
5059
}
5160
}
5261

62+
public string MachineKey
63+
{
64+
get
65+
{
66+
SettingsPage page = (SettingsPage)GetDialogPage(typeof(SettingsPage));
67+
return page.MachineKey;
68+
}
69+
}
70+
71+
protected override void Initialize()
72+
{
73+
base.Initialize();
74+
}
75+
5376
}
5477
}

CodeStats.Client/Key.snk

596 Bytes
Binary file not shown.

CodeStats.Client/OptionsPage/SettingsPage.Designer.cs

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Globalization;
2+
using System;
3+
using System.Windows.Forms;
4+
using Microsoft.VisualStudio.Shell;
5+
using System.ComponentModel;
6+
using System.Runtime.InteropServices;
7+
8+
namespace CodeStats.Client.OptionsPage
9+
{
10+
[CLSCompliant(false), ComVisible(true)]
11+
[ClassInterface(ClassInterfaceType.AutoDual)]
12+
[Guid("5c3c0aa0-0bc8-43c5-afc9-5aa55662794b")]
13+
public partial class SettingsPage : DialogPage
14+
{
15+
private string _machineKey = "";
16+
[Category("CodeStats Settings")]
17+
[DisplayName("Machine Key")]
18+
[Description("Set your machine´s API Key here")]
19+
public string MachineKey
20+
{
21+
get { return _machineKey; }
22+
set {
23+
_machineKey = value;
24+
}
25+
}
26+
27+
public SettingsPage()
28+
{
29+
InitializeComponent();
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)