📜 ⬆️ ⬇️

Making the extension StartPage for Visual Studio 2010

Good day.

Today, having installed a new “fenichka” for the studio, I wanted to try to experiment with the extensions for the studio myself. We will build an extension for the VS start page. In order to be able to do extensions at all, you need to install the Visual Studio 2010 SDK

There are no project templates in the pure SDK to create a start page. Although you can manually create a xaml page and replace it in the directories where the studio is installed. But then you can not share your extension, and can this be called an extension? Custom Start Page Project Template comes to the rescue . This template allows you to create your own welcome pages very quickly and easily (and how).
')
So, how to make your own extension for the start page of Visual Studio 2010

Training


After installing all the SDK and project templates, create a new project CustomStartPage

image

The template initially generates the standard elements of the start page and a new tab with our controls. StartPage is a file with xaml markup that we can change as we want. The project was created with markup and color scheme as in the original VS. This is how the project looks after creation and our control, which we will fill with what we want.

image

Markup


In the markup MyControl.xaml write code markup Rss Reader'a

< UserControl x:Class ="HabrStartPageControl.MyControl"
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:vsfx ="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
mc:Ignorable ="d" d:DesignHeight ="414" d:DesignWidth ="690" >
< UserControl.Resources >
< XmlDataProvider x:Key ="rss" Source ="http://habrahabr.ru/rss/new/" XPath ="/rss/channel" />
</ UserControl.Resources >

<!-- Start Page controls can use VsBrushes color table resources. -->
< Grid Background ="{DynamicResource {x:Static vsfx:VsBrushes.StartPageBackgroundKey}}" >
< Border Margin ="20" CornerRadius ="10" BorderThickness ="3" BorderBrush ="{DynamicResource {x:Static vsfx:VsBrushes.StartPageSeparatorKey}}" >
< DockPanel Background ="#FFFFFF" DataContext ="{Binding Source={StaticResource rss}, XPath=/rss/channel/item}" >
< Label DockPanel . Dock ="Top" Content ="{Binding XPath=/rss/channel/title}" FontSize ="14" FontWeight ="Bold" />
< ListBox DockPanel . Dock ="Left" ItemsSource ="{Binding}" IsSynchronizedWithCurrentItem ="True" Width ="300" >
< ListBox.ItemContainerStyle >
< Style >
< Setter Property ="Control.Padding" Value ="0" ></ Setter >
< Style.Triggers >
< Trigger Property ="ListBoxItem.IsSelected" Value ="True" >
< Setter Property ="ListBoxItem.Background" Value ="#EEEEEE" ></ Setter >
</ Trigger >
</ Style.Triggers >
</ Style >
</ ListBox.ItemContainerStyle >
< ListBox.ItemTemplate >
< DataTemplate >
< Grid Margin ="3" >
< Grid.RowDefinitions >
< RowDefinition ></ RowDefinition >
< RowDefinition ></ RowDefinition >
</ Grid.RowDefinitions >
< TextBlock FontWeight ="Bold" Text ="{Binding XPath=title}" ></ TextBlock >
< TextBlock Grid . Row ="1" Foreground ="#8FACBA" Text ="{Binding XPath=author}" ></ TextBlock >
</ Grid >
</ DataTemplate >
</ ListBox.ItemTemplate >
</ ListBox >
< Frame Source ="{Binding XPath=link}" />
</ DockPanel >
</ Border >
</ Grid >
</ UserControl >

* This source code was highlighted with Source Code Highlighter .


Everything is very simple. We declare declaratively who and what will show.
This ends the programming. And we can see the ready-made control, right in the window for editing the markup.

image

After installing the VS SDK, this project will be launched and installed in a special version of VS - “Experimental Instance”. After we have checked all the settings and all the settings, uncheck the “ Deploy VSIX content for experimental instance for debugging ” checkbox and after that the assembled extension will be installed into the working VS.

image

Installation


Having saved settings and having collected versions of the project, we can safely install it. At the output, the project is compiled into the Visual Studio HabrStartPage.vsix extension . Having installed expansion we will receive an opportunity to enjoy new articles of a habr directly from the main page VS. In order to replace StartPage after installation on our page, you need to change the settings in the settings like this

image

And we get a pretty nice RCC reader, with the ability to view the article directly on the VS page.

image

And after installation, our extension will appear in the list of extensions.

image

Conclusion


The purpose of this article was to show how easy it is to make your extensions for Visual Studio 2010. On the start page, you can hang everything you want, or you can just repaint the page. The Internet is full of small and not complex, as well as large and serious additions for VS. Now we can do it ourselves.

The extension can be downloaded from the Visual Studio Gallery

Visual Studio 2010 SDK
Custom Start Page Project Template

Source: https://habr.com/ru/post/97312/


All Articles