The source code is for VS2010 Beta 1 only and made as a VSIX / Visual Studio Integration Package using .NET 4.0. To work with the code, the VS2010 SDK must be installed.

Getting Started
First, install Visual Studio 2010, then download and install VS2010 SDK Beta 1. VS2010 Beta 1 can be downloaded in many ways and places, but the SDK is available here: http://www.microsoft.com/downloads/details.aspx?FamilyID=d197feb6-ced5-40d4-949d-a51f02309ee8&displaylang=en

Getting Started With VSPackage
We strongly suggest you run through the VSPackage tutorials available here: http://msdn.microsoft.com/en-us/library/cc138589.aspx They are quite simple and don't take much time at all.

Getting Started With This Code
The project started out with a simple File->New Project... Other Project Types->Visual Studio Integration Package... Via the Wizard, a menu and a tool window was created, the rest has been added manually after that.

Solution Structure
The structure of the solution is quite simple, with the main Addin project, a data/repository project and a small test project.

Significant Code Parts
The class/file where things start is the SQLAzure2010AddinPackage.cs and the Initialize() method which wires up the menu items to create the explorer tool window itself in the CreateExplorerToolWindow() method which finds the ExplorerToolWindow and displays it. This package class also contains a useful method for creating MDI windows of certain types, CreateWindow<T>.

For a tool window to end up where we like it, tabbed and docked to the left side of the window, We've modified the class attribute:

    [ProvideToolWindow(typeof(ExplorerToolWindow), Style = VsDockStyle.Tabbed, Orientation = ToolWindowOrientation.Left)]
    [ProvideToolWindow(typeof(TableDataWindow), Style = VsDockStyle.MDI, MultiInstances = true)]
    [ProvideToolWindow(typeof(SqlEditorWindow), Style = VsDockStyle.MDI, MultiInstances = true)]
    [ProvideToolWindowVisibility(typeof(TableDataWindow), /*UICONTEXT_SolutionExists*/"f1536ef8-92ec-443c-9ed7-fdadf150da82")]
    [ProvideToolWindowVisibility(typeof(SqlEditorWindow), /*UICONTEXT_SolutionExists*/"f1536ef8-92ec-443c-9ed7-fdadf150da82")]
    [Guid(GuidList.guidSQLAzure2010AddinPkgString)]
    public sealed class SQLAzure2010AddinPackage : Package
    {
        //and so on...

The ProvideToolWindowVisibility attribute tells VS to get rid of the window when the solution close.

Tool Windows
The tool window inherits from ToolWindowPane and consists of a single WPF control. The ExplorerControl is the one for the SQL Azure Explorer window.

Spawning New Windows From Explorer
Most of the actions and features are trigged from the context menu associated with the various items in the database explorer treeview. Each contex menu item has a command binding which handles things. Like displaying the SQL Editor window. To create a new, MDI style code window like this, use the helper method in the package class and make sure you call it with an id which is unique for this window of this type, for example:

  var sqlEditorWindow = pkg.CreateWindow<SqlEditorWindow>(Math.Abs(databaseInfo.Database.GetHashCode()));
  var control = sqlEditorWindow.Content as SqlEditorControl;
  control.Database = databaseInfo.Database;
  sqlEditorWindow.Caption = databaseInfo.Database;

The use of Math.Abs and the hash code is just to get the same unique id of the tool window for the same database in this case.

Database Properties
The properties for servername, login and password are stored in the Addin project settings.

Testing
The project doesn't contain much in way of testing right now. To be able to run the integration tests right now, you have to add a my.config and put it in the /bin/default/ directory of the test project, and it must contain your servername, login and password. See app.config for more information.

Note to project members: To be able to use VS2010 Beta 1 Team Explorer against Codeplex source control, you need to add a few registry keys described here: http://blogs.msdn.com/ablock/archive/2009/05/20/for-tfs-2010-beta-1-resolving-tf31001-the-servicepointmanager-does-not-support-proxies-with-the-https-scheme.aspx

Last edited Sep 28, 2009 at 9:09 PM by JohanDanforth, version 7

Comments

No comments yet.