-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtension.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<ProjectGuid>{ED1D3026-8695-4B9B-9FA9-2D68E28EE850}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CodeIndex.VisualStudioExtension</RootNamespace> | ||
<AssemblyName>CodeIndex.VisualStudioExtension</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<GeneratePkgDefFile>true</GeneratePkgDefFile> | ||
<UseCodebase>true</UseCodebase> | ||
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer> | ||
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer> | ||
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment> | ||
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory> | ||
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory> | ||
<StartAction>Program</StartAction> | ||
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram> | ||
<StartArguments>/rootsuffix Exp</StartArguments> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\CodeIndex.Common\CodeSource.cs"> | ||
<Link>Models\CodeSource.cs</Link> | ||
</Compile> | ||
<Compile Include="..\CodeIndex.Common\FetchResult.cs"> | ||
<Link>Models\FetchResult.cs</Link> | ||
</Compile> | ||
<Compile Include="..\CodeIndex.Common\Status.cs"> | ||
<Link>Models\Status.cs</Link> | ||
</Compile> | ||
<Compile Include="Controls\CodeIndexSearchControl.xaml.cs"> | ||
<DependentUpon>CodeIndexSearchControl.xaml</DependentUpon> | ||
</Compile> | ||
<Compile Include="CodeIndexSearchWindow.cs" /> | ||
<Compile Include="CodeIndexSearchWindowCommand.cs" /> | ||
<Compile Include="CodeIndexSearchWindowControl.xaml.cs"> | ||
<DependentUpon>CodeIndexSearchWindowControl.xaml</DependentUpon> | ||
</Compile> | ||
<Compile Include="Models\BaseViewModel.cs" /> | ||
<Compile Include="Models\CodeIndexSearchViewModel.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="CodeIndex.VisualStudioExtensionPackage.cs" /> | ||
<Compile Include="Properties\CodeIndexSettings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
<DependentUpon>CodeIndexSettings.settings</DependentUpon> | ||
</Compile> | ||
<Compile Include="ProvideToolboxControlAttribute.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="Properties\CodeIndexSettings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>CodeIndexSettings.Designer.cs</LastGenOutput> | ||
</None> | ||
<None Include="source.extension.vsixmanifest"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="PresentationFramework.Aero2" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Design" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNet.WebApi.Client"> | ||
<Version>5.2.7</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.204" ExcludeAssets="runtime" /> | ||
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.6.2031"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<VSCTCompile Include="VisualStudioExtensionPackage.vsct"> | ||
<ResourceName>Menus.ctmenu</ResourceName> | ||
</VSCTCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Resources\CodeIndexSearchWindowCommand.png" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Page Include="Controls\CodeIndexSearchControl.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="CodeIndexSearchWindowControl.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
<Page Include="Resources\Style.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
56 changes: 56 additions & 0 deletions
56
src/CodeIndex.VisualStudioExtension/CodeIndex.VisualStudioExtensionPackage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using Microsoft.VisualStudio.Shell; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace CodeIndex.VisualStudioExtension | ||
{ | ||
/// <summary> | ||
/// This is the class that implements the package exposed by this assembly. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// The minimum requirement for a class to be considered a valid package for Visual Studio | ||
/// is to implement the IVsPackage interface and register itself with the shell. | ||
/// This package uses the helper classes defined inside the Managed Package Framework (MPF) | ||
/// to do it: it derives from the Package class that provides the implementation of the | ||
/// IVsPackage interface and uses the registration attributes defined in the framework to | ||
/// register itself and its components with the shell. These attributes tell the pkgdef creation | ||
/// utility what data to put into .pkgdef file. | ||
/// </para> | ||
/// <para> | ||
/// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file. | ||
/// </para> | ||
/// </remarks> | ||
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] | ||
[Guid(PackageGuidString)] | ||
[ProvideMenuResource("Menus.ctmenu", 1)] | ||
[ProvideToolWindow(typeof(CodeIndex.VisualStudioExtension.CodeIndexSearchWindow))] | ||
public sealed class VisualStudioExtensionPackage : AsyncPackage | ||
{ | ||
/// <summary> | ||
/// CodeIndex.VisualStudioExtensionPackage GUID string. | ||
/// </summary> | ||
public const string PackageGuidString = "1eaddb39-c1f2-42e2-807d-234d73e8ef2a"; | ||
|
||
#region Package Members | ||
|
||
/// <summary> | ||
/// Initialization of the package; this method is called right after the package is sited, so this is the place | ||
/// where you can put all the initialization code that rely on services provided by VisualStudio. | ||
/// </summary> | ||
/// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> | ||
/// <param name="progress">A provider for progress updates.</param> | ||
/// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> | ||
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) | ||
{ | ||
// When initialized asynchronously, the current thread may be a background thread at this point. | ||
// Do any initialization that requires the UI thread after switching to the UI thread. | ||
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
await CodeIndex.VisualStudioExtension.CodeIndexSearchWindowCommand.InitializeAsync(this); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/CodeIndex.VisualStudioExtension/CodeIndexSearchWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace CodeIndex.VisualStudioExtension | ||
{ | ||
/// <summary> | ||
/// This class implements the tool window exposed by this package and hosts a user control. | ||
/// </summary> | ||
/// <remarks> | ||
/// In Visual Studio tool windows are composed of a frame (implemented by the shell) and a pane, | ||
/// usually implemented by the package implementer. | ||
/// <para> | ||
/// This class derives from the ToolWindowPane class provided from the MPF in order to use its | ||
/// implementation of the IVsUIElementPane interface. | ||
/// </para> | ||
/// </remarks> | ||
[Guid("6d5fde57-9331-4f68-8c3e-2945d8049f40")] | ||
public class CodeIndexSearchWindow : ToolWindowPane | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CodeIndexSearchWindow"/> class. | ||
/// </summary> | ||
public CodeIndexSearchWindow() : base(null) | ||
{ | ||
this.Caption = "Code Index Search"; | ||
|
||
// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, | ||
// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on | ||
// the object returned by the Content property. | ||
this.Content = new CodeIndexSearchWindowControl(); | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
src/CodeIndex.VisualStudioExtension/CodeIndexSearchWindowCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using System.ComponentModel.Design; | ||
using System.Globalization; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace CodeIndex.VisualStudioExtension | ||
{ | ||
/// <summary> | ||
/// Command handler | ||
/// </summary> | ||
internal sealed class CodeIndexSearchWindowCommand | ||
{ | ||
/// <summary> | ||
/// Command ID. | ||
/// </summary> | ||
public const int CommandId = 4129; | ||
|
||
/// <summary> | ||
/// Command menu group (command set GUID). | ||
/// </summary> | ||
public static readonly Guid CommandSet = new Guid("c025b4ef-e6ed-42b4-9c22-2d6835421d25"); | ||
|
||
/// <summary> | ||
/// VS Package that provides this command, not null. | ||
/// </summary> | ||
private readonly AsyncPackage package; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CodeIndexSearchWindowCommand"/> class. | ||
/// Adds our command handlers for menu (commands must exist in the command table file) | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
/// <param name="commandService">Command service to add command to, not null.</param> | ||
private CodeIndexSearchWindowCommand(AsyncPackage package, OleMenuCommandService commandService) | ||
{ | ||
this.package = package ?? throw new ArgumentNullException(nameof(package)); | ||
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); | ||
|
||
var menuCommandID = new CommandID(CommandSet, CommandId); | ||
var menuItem = new MenuCommand(this.Execute, menuCommandID); | ||
commandService.AddCommand(menuItem); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the instance of the command. | ||
/// </summary> | ||
public static CodeIndexSearchWindowCommand Instance | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the service provider from the owner package. | ||
/// </summary> | ||
private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider | ||
{ | ||
get | ||
{ | ||
return this.package; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the singleton instance of the command. | ||
/// </summary> | ||
/// <param name="package">Owner package, not null.</param> | ||
public static async Task InitializeAsync(AsyncPackage package) | ||
{ | ||
// Switch to the main thread - the call to AddCommand in CodeIndexSearchWindowCommand's constructor requires | ||
// the UI thread. | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); | ||
|
||
OleMenuCommandService commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService; | ||
Instance = new CodeIndexSearchWindowCommand(package, commandService); | ||
} | ||
|
||
/// <summary> | ||
/// Shows the tool window when the menu item is clicked. | ||
/// </summary> | ||
/// <param name="sender">The event sender.</param> | ||
/// <param name="e">The event args.</param> | ||
private void Execute(object sender, EventArgs e) | ||
{ | ||
this.package.JoinableTaskFactory.RunAsync(async delegate | ||
{ | ||
ToolWindowPane window = await this.package.ShowToolWindowAsync(typeof(CodeIndexSearchWindow), 0, true, this.package.DisposalToken); | ||
if ((null == window) || (null == window.Frame)) | ||
{ | ||
throw new NotSupportedException("Cannot create tool window"); | ||
} | ||
}); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/CodeIndex.VisualStudioExtension/CodeIndexSearchWindowControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<UserControl x:Class="CodeIndex.VisualStudioExtension.CodeIndexSearchWindowControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0" xmlns:visualstudioextension="clr-namespace:CodeIndex.VisualStudioExtension" | ||
Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}" | ||
Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}" | ||
mc:Ignorable="d" | ||
d:DesignHeight="225.889" d:DesignWidth="783.068" | ||
Name="MyToolWindow"> | ||
<Grid> | ||
<DockPanel LastChildFill="True"> | ||
<visualstudioextension:CodeIndexSearchControl x:Name="SearchControl"></visualstudioextension:CodeIndexSearchControl> | ||
</DockPanel> | ||
</Grid> | ||
</UserControl> |
20 changes: 20 additions & 0 deletions
20
src/CodeIndex.VisualStudioExtension/CodeIndexSearchWindowControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Windows.Controls; | ||
|
||
namespace CodeIndex.VisualStudioExtension | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CodeIndexSearchWindowControl. | ||
/// </summary> | ||
public partial class CodeIndexSearchWindowControl : UserControl | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CodeIndexSearchWindowControl"/> class. | ||
/// </summary> | ||
public CodeIndexSearchWindowControl() | ||
{ | ||
InitializeComponent(); | ||
|
||
SearchControl.DataContext = new CodeIndexSearchViewModel(); | ||
} | ||
} | ||
} |
Oops, something went wrong.