

Var offsets = GuidesSettingsManager.GetColumnOffsets() "The paramenter must be between 1 and " + _maxGuides.ToString()) Static internal bool AddGuideline(int column)
COMMANDS HIVE DRAWIT CODE
1000 seems reasonable since primary scenario is long lines of code Private const string _settingName = "Guides" Private const string _collectionSettingsName = "Text Editor" New ShellSettingsManager(ServiceProvider.GlobalProvider) Internal static SettingsManager VsManagedSettingsManager = Because my code is always called from the UI thred, this succeeds. Internal static class GuidesSettingsManager Replace the contents of the GuidesSettingsManager.cs with the following code (explained below): using

There's more information in Language service and editor extension points Implement the settings manager The second line declares that the column guide adornments are applicable to text entities that fit your notion of a document, but you could declare the adornment, for example, to only work for editable text. Drawing the lines "before" the text in the view means they appear behind or below the text. The first line you changed only changes where the column guide lines appear. The line you replaced is in a group of attributes that declare an adornment layer. You can declare the ordering of your layer relative to others with attributes. When the editor updates views, it gets the adornment layers for the view and from that gets the adornment elements.

The code also must declare an adornment layer. There are attributes that control when the handler is called depending on characteristics of the view. This code implements a handler for whenever Visual Studio creates text views. Open ColumnGuideAdornmentTextViewCreationListener.cs in the editor. In the following section, you replace the contents of first and last files to define and implement the commands. In addition to several references, adding the commands and package also added ColumnGuideCommands.cs, ColumnGuideCommandsPackage.cs, and ColumnGuideCommandsPackage.vsct. Enter the name ColumnGuideCommands as the item name and choose Add. Choose Extensibility | VSPackage in the left navigation pane and choose Custom Command in the right pane. command to add a new view adornment item. In Solution Explorer, press the right pointer button on the project node. In the following section, you change a couple of lines in the view creation listener and replace the contents of ColumnGuideAdornment.cs.Ĭommands. The templates draw a purple rectangle on the view. You can see this item template added two files to the project (as well as references, and so on): ColumnGuideAdornment.cs and ColumnGuideAdornmentTextViewCreationListener.cs. Enter the name ColumnGuideAdornment as the item name and choose Add to add it. Choose Extensibility | Editor in the left navigation pane and choose Editor Viewport Adornment in the right pane. Press the right pointer button on the project node in the Solution Explorer. Enter the name ColumnGuides and choose OK to create the project. Choose the Extensibility node under C# in the left navigation pane and choose VSIX Project in the right pane. There's a ColumnGuideCommands object that runs the user commands and hooks up the command handlers for commands declared in the. There's a VSIP package that's necessary if you have user commands, but it's just boilerplate code that initializes the commands implementation object. The settings manager also has operations for updating the settings that support the user commands (add column, remove column, change color). There's a GuidesSettingsManager that handles reading and writing from the Visual Studio settings storage. This object listens for events about the view changing or settings changing, updating or redrawing column guides as necessary. You have a text view creation listener that creates a ColumnGuideAdornment object per view. Set up the solutionįirst, you create a VSIX project, add an editor view adornment, and then add a command (which adds a VSPackage to own the command).
COMMANDS HIVE DRAWIT INSTALL
For more information, see Install the Visual Studio SDK. You can also install the VS SDK later on. It's included as an optional feature in Visual Studio setup.
COMMANDS HIVE DRAWIT DOWNLOAD
Starting in Visual Studio 2015, you do not install the Visual Studio SDK from the download center. The completed code is slightly different in that it has real command icons instead of using generictemplate icons. But, soon this walkthrough will refer to a completed solution on GitHub with other extension examples. In this walkthrough, you paste a great amount of code into a few files generated by Visual Studio extension templates.
