Added:
trunk/NiftySolution/Commands/Configure.cs
trunk/NiftySolution/Options.cs
trunk/NiftySolution/Resources/DeleteTool.bmp (contents, props changed)
trunk/NiftySolution/UI/ConfigDialog.cs
trunk/NiftySolution/UI/ConfigDialog.designer.cs
trunk/NiftySolution/UI/ConfigDialog.resx
trunk/Shared/CommandRegistry.cs
trunk/Shared/EventRegistry.cs
trunk/Shared/File.cs
Modified:
trunk/NiftyPerforce/EventHandlers/AutoCheckout.cs
trunk/NiftyPlugins.sln
trunk/NiftySolution/Commands/CloseToolWindows.cs
trunk/NiftySolution/Commands/QuickOpen.cs
trunk/NiftySolution/Commands/ToggleFile.cs
trunk/NiftySolution/Connect.cs
trunk/NiftySolution/EventHandlers/SolutionBuildTimings.cs
trunk/NiftySolution/NiftySolution.csproj
trunk/NiftySolution/ToolbarIcons.Designer.cs
trunk/NiftySolution/ToolbarIcons.resx
trunk/Shared/AuroraCore.csproj
trunk/Shared/CommandBase.cs
trunk/Shared/Plugin.cs
Log:
- Changed how the commands are registered in a plugin and converted
niftysolution to use it.
- Broke niftyperforce, it still uses the old way to register stuff.
Modified: trunk/NiftyPerforce/EventHandlers/AutoCheckout.cs
==============================================================================
--- trunk/NiftyPerforce/EventHandlers/AutoCheckout.cs (original)
+++ trunk/NiftyPerforce/EventHandlers/AutoCheckout.cs Thu Mar 5 00:38:18
2009
@@ -77,7 +77,7 @@
void tryEditFile(string sFileName)
{
- if (0 != (File.GetAttributes(sFileName) & FileAttributes.ReadOnly))
+ if (0 != (System.IO.File.GetAttributes(sFileName) &
FileAttributes.ReadOnly))
P4Operations.EditFileImmediate(m_outputPane, sFileName);
}
Modified: trunk/NiftyPlugins.sln
==============================================================================
--- trunk/NiftyPlugins.sln (original)
+++ trunk/NiftyPlugins.sln Thu Mar 5 00:38:18 2009
@@ -28,7 +28,6 @@
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CEC088B7-2C6E-433F-B308-FF75159BC02D}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
- {CEC088B7-2C6E-433F-B308-FF75159BC02D}.Debug|Any CPU.Build.0 = Debug|Any
CPU
{CEC088B7-2C6E-433F-B308-FF75159BC02D}.Release|Any CPU.ActiveCfg =
Release|Any CPU
{CEC088B7-2C6E-433F-B308-FF75159BC02D}.Release|Any CPU.Build.0 = Release|
Any CPU
{4D100496-4276-4B76-8A59-A325A479E63F}.Debug|Any CPU.ActiveCfg = Debug
Modified: trunk/NiftySolution/Commands/CloseToolWindows.cs
==============================================================================
--- trunk/NiftySolution/Commands/CloseToolWindows.cs (original)
+++ trunk/NiftySolution/Commands/CloseToolWindows.cs Thu Mar 5 00:38:18
2009
@@ -14,19 +14,32 @@
// now and then.
public class CloseToolWindow : CommandBase
{
- public CloseToolWindow()
+ override public int IconIndex { get { return 4; } }
+
+ public CloseToolWindow(Plugin plugin)
+ : base("CloseToolWindow", plugin, "Closes all active tool windows")
{
}
- public override void OnCommand(DTE2 application, OutputWindowPane pane)
+ override public void BindToKeyboard(Command vsCommand)
{
- CloseToolWindows(application);
+ object[] bindings = new object[2];
+ bindings[0] = "Global::ctrl+del";
+ bindings[1] = "Text Editor::ctrl+del";
+ vsCommand.Bindings = bindings;
+ }
+
+ public override bool OnCommand()
+ {
+ CloseToolWindows(Plugin.App);
// Sometimes this really doesn't "bite", so we need to run through the
list again.
- CloseToolWindows(application);
+ CloseToolWindows(Plugin.App);
+
+ return true;
}
- public override bool IsEnabled(DTE2 application)
+ public override bool IsEnabled()
{
return true;
}
Added: trunk/NiftySolution/Commands/Configure.cs
==============================================================================
--- (empty file)
+++ trunk/NiftySolution/Commands/Configure.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,49 @@
+// Copyright (C) 2006-2008 Jim Tilander. See COPYING for and README for
more details.
+using System;
+using System.Collections.Generic;
+using System.IO;
+using EnvDTE;
+using EnvDTE80;
+
+namespace Aurora
+{
+ namespace NiftySolution
+ {
+ public class Configure : CommandBase
+ {
+ override public int IconIndex { get { return 3; } }
+
+ public Configure(Plugin plugin)
+ : base("Configure", plugin, "Configures the plugin")
+ {
+ }
+
+ public override bool OnCommand()
+ {
+ Log.Debug("Launching the configure tool");
+
+ Options options = (Options)Plugin.Options;
+ options.Save();
+
+ ConfigDialog dlg = new ConfigDialog();
+ dlg.propertyGrid1.SelectedObject = options;
+
+ if(dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
+ {
+ Plugin.Options = Options.Load(options.mFileName);
+ }
+ else
+ {
+ options.Save();
+ }
+
+ return true;
+ }
+
+ public override bool IsEnabled()
+ {
+ return true;
+ }
+ }
+ }
+}
Modified: trunk/NiftySolution/Commands/QuickOpen.cs
==============================================================================
--- trunk/NiftySolution/Commands/QuickOpen.cs (original)
+++ trunk/NiftySolution/Commands/QuickOpen.cs Thu Mar 5 00:38:18 2009
@@ -15,16 +15,24 @@
private SolutionFiles mFiles = null;
QuickOpenDialog mDialog = null;
- public QuickOpen()
+ override public int IconIndex { get { return 1; } }
+
+ public QuickOpen(Plugin plugin)
+ : base("QuickOpen", plugin, "Quickly opens any file in the solution")
+ {
+ }
+
+ override public void BindToKeyboard(Command vsCommand)
{
+ vsCommand.Bindings = "Global::ctrl+o";
}
- public override void OnCommand(DTE2 application, OutputWindowPane pane)
+ public override bool OnCommand()
{
if(null == mFiles)
{
Log.Info("First time fast open is run, scanning solution for files");
- mFiles = new SolutionFiles(application);
+ mFiles = new SolutionFiles(Plugin.App);
mFiles.Refresh();
}
@@ -35,15 +43,16 @@
{
string name = mDialog.FileToOpen;
if(name.Length > 0 )
- application.DTE.ExecuteCommand("File.OpenFile", name);
-
+ Plugin.App.DTE.ExecuteCommand("File.OpenFile", name);
// TODO: Each time here we could save off the window position into
the registry and
// use it when we open the window the next time around.
}
+
+ return true;
}
- public override bool IsEnabled(DTE2 application)
+ public override bool IsEnabled()
{
return true;
}
Modified: trunk/NiftySolution/Commands/ToggleFile.cs
==============================================================================
--- trunk/NiftySolution/Commands/ToggleFile.cs (original)
+++ trunk/NiftySolution/Commands/ToggleFile.cs Thu Mar 5 00:38:18 2009
@@ -16,7 +16,10 @@
{
private Dictionary<string, string[]> m_knownExtensions;
- public ToggleFile()
+ override public int IconIndex { get { return 2; } }
+
+ public ToggleFile(Plugin plugin)
+ : base("ToggleFile", plugin, "Toggles between the header and the cpp
file")
{
m_knownExtensions = new Dictionary<string, string[]>();
m_knownExtensions.Add(".h", new string[]
{ ".cpp", ".c", ".inl", ".cxx" });
@@ -24,34 +27,47 @@
m_knownExtensions.Add(".cpp", new string[] { ".h", ".hxx", ".hpp" });
}
- public override void OnCommand(DTE2 application, OutputWindowPane pane)
+ override public void BindToKeyboard(Command vsCommand)
+ {
+ //object[] bindings = new object[1];
+ //bindings[0] = "Global::Ctrl+G";
+ //bindings[0] = "Text Editor::Ctrl+Return";
+ //vsCommand.Bindings = bindings;
+ }
+
+ public override bool OnCommand()
{
- if (null == application.DTE.ActiveDocument)
- return;
+ if (null == Plugin.App.DTE.ActiveDocument)
+ return false;
- string fullPath = application.DTE.ActiveDocument.FullName;
+ string fullPath = Plugin.App.DTE.ActiveDocument.FullName;
string extension = Path.GetExtension(fullPath);
string filename = Path.Combine(Path.GetDirectoryName(fullPath),
Path.GetFileNameWithoutExtension(fullPath));
+ // TODO: This needs to cycle though the indices based on the current
extension
+
try
{
string[] candidates = m_knownExtensions[extension];
foreach (string candidate in candidates)
{
string candidatePath = filename + candidate;
- if (File.Exists(candidatePath))
+ if (System.IO.File.Exists(candidatePath))
{
- application.DTE.ExecuteCommand("File.OpenFile", candidatePath);
+ Plugin.App.DTE.ExecuteCommand("File.OpenFile", candidatePath);
break;
}
}
}
catch (KeyNotFoundException)
{
+ return false;
}
+
+ return true;
}
- public override bool IsEnabled(DTE2 application)
+ public override bool IsEnabled()
{
return true;
}
Modified: trunk/NiftySolution/Connect.cs
==============================================================================
Binary files. No diff available.
Modified: trunk/NiftySolution/EventHandlers/SolutionBuildTimings.cs
==============================================================================
--- trunk/NiftySolution/EventHandlers/SolutionBuildTimings.cs (original)
+++ trunk/NiftySolution/EventHandlers/SolutionBuildTimings.cs Thu Mar 5
00:38:18 2009
@@ -14,13 +14,13 @@
private Stopwatch m_timer;
BuildEvents m_buildEvents;
- public SolutionBuildTimings(DTE2 application)
+ public SolutionBuildTimings(Plugin plugin)
{
- m_pane = Plugin.FindOutputPane(application, "Build");
+ m_pane = Plugin.FindOutputPane(plugin.App, "Build");
if (null == m_pane)
return;
- m_buildEvents = ((EnvDTE80.Events2)application.Events).BuildEvents;
+ m_buildEvents = ((EnvDTE80.Events2)plugin.App).BuildEvents;
m_buildEvents.OnBuildBegin += new
_dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin);
m_buildEvents.OnBuildDone += new
_dispBuildEvents_OnBuildDoneEventHandler(OnBuildDone);
Modified: trunk/NiftySolution/NiftySolution.csproj
==============================================================================
--- trunk/NiftySolution/NiftySolution.csproj (original)
+++ trunk/NiftySolution/NiftySolution.csproj Thu Mar 5 00:38:18 2009
@@ -43,6 +43,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Commands\CloseToolWindows.cs" />
+ <Compile Include="Commands\Configure.cs" />
<Compile Include="Connect.cs">
<SubType>Code</SubType>
</Compile>
@@ -50,6 +51,7 @@
<Compile Include="Commands\QuickOpen.cs">
</Compile>
<Compile Include="Commands\ToggleFile.cs" />
+ <Compile Include="Options.cs" />
<Compile Include="SearchEntry.cs" />
<Compile Include="SolutionFiles.cs" />
<Compile Include="ToolbarIcons.Designer.cs">
@@ -57,6 +59,12 @@
<DesignTime>True</DesignTime>
<DependentUpon>ToolbarIcons.resx</DependentUpon>
</Compile>
+ <Compile Include="UI\ConfigDialog.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="UI\ConfigDialog.designer.cs">
+ <DependentUpon>ConfigDialog.cs</DependentUpon>
+ </Compile>
<Compile Include="UI\QuickOpenDialog.cs">
<SubType>Form</SubType>
</Compile>
@@ -74,6 +82,10 @@
<EmbeddedResource Include="CommandBar.resx">
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="UI\ConfigDialog.resx">
+ <DependentUpon>ConfigDialog.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
<EmbeddedResource Include="UI\QuickOpenDialog.resx">
<SubType>Designer</SubType>
<DependentUpon>QuickOpenDialog.cs</DependentUpon>
@@ -125,6 +137,7 @@
<ItemGroup>
<Content Include="NiftySolution.AddIn" />
<Content Include="Resources\Configure.bmp" />
+ <None Include="Resources\DeleteTool.bmp" />
<Content Include="Resources\Open.bmp" />
<Content Include="Resources\Toggle.bmp" />
</ItemGroup>
Added: trunk/NiftySolution/Options.cs
==============================================================================
--- (empty file)
+++ trunk/NiftySolution/Options.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Aurora
+{
+ namespace NiftySolution
+ {
+ // TODO: How do we handle different versions of this XML file on disk?
+ [Serializable]
+ public class Options
+ {
+ private bool mDirty = false;
+ private bool mEnableBindings = false;
+
+ [XmlIgnore]
+ public string mFileName = "";
+
+ [XmlIgnore]
+ [BrowsableAttribute(false)]
+ public bool Dirty
+ {
+ get
+ {
+ return mDirty;
+ }
+ }
+
+ [Category("General"), Description("Register Key Bindings")]
+ public bool EnableBindings
+ {
+ get
+ {
+ return mEnableBindings;
+ }
+
+ set
+ {
+ mEnableBindings = value;
+ mDirty = true;
+ }
+ }
+
+ public static Options Load(string filename)
+ {
+ Options o;
+ if(System.IO.File.Exists(filename))
+ {
+ o = File.LoadXML<Options>(filename);
+ }
+ else
+ {
+ o = new Options();
+ }
+ o.mFileName = filename;
+ return o;
+ }
+
+ public void Save()
+ {
+ if(mDirty)
+ {
+ File.SaveXML<Options>(mFileName, this);
+ mDirty = false;
+ }
+ }
+ }
+ }
+}
Added: trunk/NiftySolution/Resources/DeleteTool.bmp
==============================================================================
Binary file. No diff available.
Modified: trunk/NiftySolution/ToolbarIcons.Designer.cs
==============================================================================
--- trunk/NiftySolution/ToolbarIcons.Designer.cs (original)
+++ trunk/NiftySolution/ToolbarIcons.Designer.cs Thu Mar 5 00:38:18 2009
@@ -8,96 +8,84 @@
// </auto-generated>
//------------------------------------------------------------------------------
-namespace Aurora
-{
- namespace NiftySolution
- {
- using System;
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings,
etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
-
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class ToolbarIcons
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
-
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal ToolbarIcons()
- {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
-
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if(object.ReferenceEquals(resourceMan, null))
- {
- global::System.Resources.ResourceManager temp = new
global::System.Resources.ResourceManager("Aurora.NiftySolution.ToolbarIcons",
typeof(ToolbarIcons).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
-
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
-
- internal static System.Drawing.Bitmap _1
- {
- get
- {
- object obj = ResourceManager.GetObject("1", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- internal static System.Drawing.Bitmap _2
- {
- get
- {
- object obj = ResourceManager.GetObject("2", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- internal static System.Drawing.Bitmap Configure
- {
- get
- {
- object obj = ResourceManager.GetObject("Configure", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
- }
- }
+namespace NiftySolution {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized
strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class ToolbarIcons {
+
+ private static global::System.Resources.ResourceManager
resourceMan;
+
+ private static global::System.Globalization.CultureInfo
resourceCulture;
+
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal ToolbarIcons() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this
class.
+ /// </summary>
+
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager
ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new
global::System.Resources.ResourceManager("NiftySolution.ToolbarIcons",
typeof(ToolbarIcons).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for
all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static System.Drawing.Bitmap _1 {
+ get {
+ object obj = ResourceManager.GetObject("1",
resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ internal static System.Drawing.Bitmap _2 {
+ get {
+ object obj = ResourceManager.GetObject("2",
resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ internal static System.Drawing.Bitmap _3 {
+ get {
+ object obj = ResourceManager.GetObject("3",
resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ internal static System.Drawing.Bitmap _4 {
+ get {
+ object obj = ResourceManager.GetObject("4",
resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
}
-
Modified: trunk/NiftySolution/ToolbarIcons.resx
==============================================================================
--- trunk/NiftySolution/ToolbarIcons.resx (original)
+++ trunk/NiftySolution/ToolbarIcons.resx Thu Mar 5 00:38:18 2009
@@ -124,7 +124,10 @@
<data name="2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Toggle.bmp;System.Drawing.Bitmap, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
- <data name="Configure" type="System.Resources.ResXFileRef,
System.Windows.Forms">
+ <data name="3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Configure.bmp;System.Drawing.Bitmap, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="4" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>Resources\DeleteTool.bmp;System.Drawing.Bitmap, System.Drawing,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Added: trunk/NiftySolution/UI/ConfigDialog.cs
==============================================================================
--- (empty file)
+++ trunk/NiftySolution/UI/ConfigDialog.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,40 @@
+// Copyright (C) 2006-2008 Jim Tilander. See COPYING for and README for
more details.
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Aurora
+{
+
+ namespace NiftySolution
+ {
+ public partial class ConfigDialog : Form
+ {
+ public ConfigDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void propertyGrid1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ }
+ }
+
+}
Added: trunk/NiftySolution/UI/ConfigDialog.designer.cs
==============================================================================
--- (empty file)
+++ trunk/NiftySolution/UI/ConfigDialog.designer.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,105 @@
+namespace Aurora
+{
+ namespace NiftySolution
+ {
+ partial class ConfigDialog
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be
disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.button2 = new System.Windows.Forms.Button();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
+ this.groupBox2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.button1.Location = new System.Drawing.Point(70, 442);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "Ok";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // button2
+ //
+ this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.button2.Location = new System.Drawing.Point(177, 442);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(75, 23);
+ this.button2.TabIndex = 4;
+ this.button2.Text = "Cancel";
+ this.button2.UseVisualStyleBackColor = true;
+ this.button2.Click += new System.EventHandler(this.button2_Click);
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.propertyGrid1);
+ this.groupBox2.Location = new System.Drawing.Point(12, 12);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(299, 400);
+ this.groupBox2.TabIndex = 9;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Settings";
+ //
+ // propertyGrid1
+ //
+ this.propertyGrid1.Location = new System.Drawing.Point(6, 19);
+ this.propertyGrid1.Name = "propertyGrid1";
+ this.propertyGrid1.Size = new System.Drawing.Size(287, 375);
+ this.propertyGrid1.TabIndex = 0;
+ this.propertyGrid1.Click += new
System.EventHandler(this.propertyGrid1_Click);
+ //
+ // ConfigDialog
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(323, 477);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.button1);
+ this.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "ConfigDialog";
+ this.Text = "NiftySolution configuration";
+ this.groupBox2.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.GroupBox groupBox2;
+ public System.Windows.Forms.PropertyGrid propertyGrid1;
+ }
+ }
+
+}
Added: trunk/NiftySolution/UI/ConfigDialog.resx
==============================================================================
--- (empty file)
+++ trunk/NiftySolution/UI/ConfigDialog.resx Thu Mar 5 00:38:18 2009
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader,
System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter,
System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this
is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color,
System.Drawing">Blue</data>
+ <data name="Bitmap1"
mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework
object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form
of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ :
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
/>
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string"
/>
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string"
minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"
msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string"
msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string"
msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"
/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: trunk/Shared/AuroraCore.csproj
==============================================================================
--- trunk/Shared/AuroraCore.csproj (original)
+++ trunk/Shared/AuroraCore.csproj Thu Mar 5 00:38:18 2009
@@ -40,7 +40,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CommandBase.cs" />
+ <Compile Include="CommandRegistry.cs" />
<Compile Include="DebugLogHandler.cs" />
+ <Compile Include="EventRegistry.cs" />
+ <Compile Include="File.cs" />
<Compile Include="Log.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Process.cs" />
Modified: trunk/Shared/CommandBase.cs
==============================================================================
--- trunk/Shared/CommandBase.cs (original)
+++ trunk/Shared/CommandBase.cs Thu Mar 5 00:38:18 2009
@@ -2,12 +2,41 @@
using System;
using EnvDTE;
using EnvDTE80;
+using Microsoft.VisualStudio.CommandBars;
namespace Aurora
{
public abstract class CommandBase
{
- abstract public void OnCommand(DTE2 application, OutputWindowPane
pane);
- abstract public bool IsEnabled(DTE2 application);
+ private readonly Plugin mPlugin;
+ private readonly string mName;
+ private readonly string mTooltip;
+
+ public Plugin Plugin { get { return mPlugin; } }
+ public string Name { get { return mName; } }
+ public string Tooltip { get { return mTooltip; } }
+ virtual public int IconIndex { get { return -1; } }
+
+ public CommandBase(string name, Plugin plugin, string tooltip)
+ {
+ mName = name;
+ mPlugin = plugin;
+ mTooltip = tooltip;
+ }
+
+ virtual public bool RegisterGUI(Command vsCommand, CommandBar
vsCommandbar)
+ {
+ // The default command is registered in the toolbar.
+ // pluginCommandbar;
+
+ return false;
+ }
+
+ virtual public void BindToKeyboard(Command vsCommand)
+ {
+ }
+
+ abstract public bool OnCommand(); // returns if the command was
dispatched or not.
+ abstract public bool IsEnabled(); // is the command active?
}
}
Added: trunk/Shared/CommandRegistry.cs
==============================================================================
--- (empty file)
+++ trunk/Shared/CommandRegistry.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,136 @@
+// Copyright (C) 2006-2008 Jim Tilander. See COPYING for and README for
more details.
+using System;
+using EnvDTE;
+using EnvDTE80;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.CommandBars;
+
+namespace Aurora
+{
+ // Holds a dictionary between local command names and the instance that
holds
+ // the logic to execute and update the command itself.
+ public class CommandRegistry
+ {
+ private Dictionary<string, CommandBase> mCommands;
+ private Plugin mPlugin;
+ private CommandBar mCommandBar;
+
+ public CommandRegistry(Plugin plugin, CommandBar commandBar)
+ {
+ mCommands = new Dictionary<string, CommandBase>();
+ mPlugin = plugin;
+ mCommandBar = commandBar;
+ }
+
+ public void RegisterCommand(string name, bool doBindings, CommandBase
commandHandler)
+ {
+ Command command = RegisterCommandPrivate(name, commandHandler);
+
+ if(doBindings)
+ {
+ try
+ {
+ commandHandler.BindToKeyboard(command);
+ }
+ catch(ArgumentException e)
+ {
+ Log.Error("Failed to register keybindings for {0}: {1}", name,
e.ToString());
+ }
+ }
+
+ mCommands.Add(name, commandHandler);
+ }
+
+ private Command RegisterCommandPrivate(string name, CommandBase
commandHandler)
+ {
+ Command vscommand = null;
+
+ try
+ {
+ vscommand = mPlugin.Commands.Item(Absname(name), -1);
+ return vscommand;
+ }
+ catch(System.ArgumentException)
+ {
+ }
+
+ Log.Info("Registering the command {0} from scratch", name);
+ object[] contextGuids = new object[] { };
+
+ int commandStatus = (int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatus.vsCommandStatusEnabled;
+
+ if(0 == commandHandler.IconIndex)
+ {
+ vscommand = mPlugin.Commands.AddNamedCommand2(mPlugin.AddIn, name,
commandHandler.Name, commandHandler.Tooltip, true, -1, ref contextGuids,
commandStatus, (int)vsCommandStyle.vsCommandStyleText,
vsCommandControlType.vsCommandControlTypeButton);
+ }
+ else
+ {
+ vscommand = mPlugin.Commands.AddNamedCommand2(mPlugin.AddIn, name,
commandHandler.Name, commandHandler.Tooltip, false,
commandHandler.IconIndex, ref contextGuids, commandStatus,
(int)vsCommandStyle.vsCommandStylePict,
vsCommandControlType.vsCommandControlTypeButton);
+ }
+
+ // Register the graphics controls for this command as well.
+ // First let the command itself have a stab at register whatever it
needs.
+ // Then by default we always register ourselves in the main toolbar of
the application.
+ if(!commandHandler.RegisterGUI(vscommand, mCommandBar))
+ {
+ vscommand.AddControl(mCommandBar, mCommandBar.Controls.Count + 1);
+ }
+
+ return vscommand;
+ }
+
+ public bool Execute(string name_)
+ {
+ Log.Debug("Trying to execute command \"{0}\"", name_);
+
+ string name = Basename(name_);
+ if(mCommands.ContainsKey(name))
+ {
+ bool dispatched = mCommands[name].OnCommand();
+ if(dispatched)
+ {
+ Log.Debug("{0} was dispatched", name_);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public vsCommandStatus Query(string name_)
+ {
+ Log.Debug("Trying to query command \"{0}\"", name_);
+
+ string name = Basename(name_);
+ if(!mCommands.ContainsKey(name))
+ {
+ Log.Debug("{0} is an unkown command", name_);
+ return vsCommandStatus.vsCommandStatusUnsupported;
+ }
+
+ CommandBase cmd = mCommands[name];
+
+ if(cmd.IsEnabled())
+ {
+ Log.Debug("{0} is enabled", name_);
+ return vsCommandStatus.vsCommandStatusSupported |
vsCommandStatus.vsCommandStatusEnabled;
+ }
+ else
+ {
+ Log.Debug("{0} is disabled", name_);
+ return vsCommandStatus.vsCommandStatusSupported;
+ }
+ }
+
+ // Converts the incoming name from Visual Studio into the local name.
+ private string Basename(string globalname)
+ {
+ return globalname.Replace(mPlugin.Prefix + ".", "");
+ }
+
+ private string Absname(string localname)
+ {
+ return mPlugin.Prefix + "." + localname;
+ }
+ }
+}
Added: trunk/Shared/EventRegistry.cs
==============================================================================
--- (empty file)
+++ trunk/Shared/EventRegistry.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,34 @@
+// Copyright (C) 2006-2008 Jim Tilander. See COPYING for and README for
more details.
+using System;
+using EnvDTE;
+using EnvDTE80;
+using System.Collections.Generic;
+
+namespace Aurora
+{
+ public class EventBase
+ {
+ private string mName;
+ private Plugin mPlugin;
+
+ public EventBase(string name, Plugin plugin)
+ {
+ mName = name;
+ mPlugin = plugin;
+ }
+ }
+
+ // Holds a dictionary between local command names and the instance that
holds
+ // the logic to execute and update the command itself.
+ public class EventRegistry
+ {
+ private Dictionary<string, EventBase> mEvents;
+ private Plugin mPlugin;
+
+ public EventRegistry(Plugin plugin)
+ {
+ mEvents = new Dictionary<string, EventBase>();
+ mPlugin = plugin;
+ }
+ }
+}
Added: trunk/Shared/File.cs
==============================================================================
--- (empty file)
+++ trunk/Shared/File.cs Thu Mar 5 00:38:18 2009
@@ -0,0 +1,28 @@
+using System;
+using System.IO;
+using System.Xml.Serialization;
+using System.Collections.Generic;
+
+namespace Aurora
+{
+ public static class File
+ {
+ public static Type LoadXML<Type>(string pathname) where Type : class
+ {
+ using(StreamReader reader = new StreamReader(pathname))
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(Type));
+ return (Type)serializer.Deserialize(reader);
+ }
+ }
+
+ public static void SaveXML<Type>(string pathname, Type obj) where Type :
class
+ {
+ using(StreamWriter writer = new StreamWriter(pathname))
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(Type));
+ serializer.Serialize(writer, obj);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/Shared/Plugin.cs
==============================================================================
--- trunk/Shared/Plugin.cs (original)
+++ trunk/Shared/Plugin.cs Thu Mar 5 00:38:18 2009
@@ -7,163 +7,168 @@
namespace Aurora
{
- // Wrapper class around registering other classes to handle the actual
commands.
- // Interfaces with visual studio and handles the dispatch.
+ // Wrapper class around registering other classes to handle the actual
commands.
+ // Interfaces with visual studio and handles the dispatch.
public class Plugin
- {
- private DTE2 m_application;
- private AddIn m_addIn;
- private OutputWindowPane m_outputPane;
-
- private Dictionary<string, CommandBase> m_commands = new
Dictionary<string, CommandBase>();
- private string m_connectPath;
-
- public OutputWindowPane OutputPane
- {
- get { return m_outputPane; }
- }
-
- public Plugin(DTE2 application, AddIn addIn, string panelName,
string connectPath)
- {
- // TODO: This can be figured out from traversing the assembly
and locating the Connect class...
- m_connectPath = connectPath;
-
- m_application = application;
- m_addIn = addIn;
- m_outputPane = AquireOutputPane(application, panelName);
- }
-
- public void RegisterCommand(string commandName, CommandBase
command)
- {
- m_commands.Add(commandName, command);
- }
-
- public bool CanHandleCommand(string commandName)
- {
- // TODO: Gotta be a better way to do this... std::find anyone?
- foreach (string key in m_commands.Keys)
- {
- if (commandName.EndsWith("." + key))
- return true;
- }
-
- return false;
- }
-
- public bool IsCommandEnabled(string commandName)
- {
- foreach (string key in m_commands.Keys)
- {
- if (commandName.EndsWith("." + key))
- return m_commands[key].IsEnabled(m_application);
- }
-
- return false;
- }
-
- public bool OnCommand(string name)
- {
- // TODO: Gotta be a better way to do this... std::find anyone?
- foreach (string key in m_commands.Keys)
- {
- if (name.EndsWith("." + key))
- {
- m_commands[key].OnCommand(m_application, m_outputPane);
- return true;
- }
- }
-
- return false;
- }
-
- private Command GetCommand(string commandName)
- {
- Commands2 commands = (Commands2)m_application.Commands;
-
- string fullName = m_connectPath + "." + commandName;
-
- try
- {
- Command command = commands.Item(fullName, 0);
- return command;
- }
- catch (System.ArgumentException)
- {
- return null;
- }
- }
-
- private bool IsCommandRegistered(string commandName)
- {
- return GetCommand(commandName) != null;
- }
-
- private bool HasCommand(CommandBar commandBar, string caption)
- {
- foreach (CommandBarControl control in commandBar.Controls)
- {
- if (control.Caption == caption)
- return true;
- }
- return false;
- }
-
- public CommandBar AddCommandBar(string name, MsoBarPosition
position)
- {
- CommandBars cmdBars =
(Microsoft.VisualStudio.CommandBars.CommandBars)m_application.CommandBars;
- CommandBar bar = null;
-
- try
- {
- try
- {
- // Create the new CommandBar
- bar = cmdBars.Add(name, position, false, false);
- bar.Visible = true;
- }
- catch (ArgumentException)
- {
- // Try to find an existing CommandBar
- bar = cmdBars[name];
- }
- }
- catch
- {
- }
-
- return bar;
- }
-
- public void AddPopupCommand(CommandBarPopup popup, string
commandName, string caption,
- string tooltip, int iconIndex, int insertIndex)
- {
- // Do not try to add commands to a null menu
- if (popup == null)
- return;
-
- // Get commands collection
- Commands2 commands = (Commands2)m_application.Commands;
- object[] contextGUIDS = new object[] { };
-
- // Add command
- Command command = GetCommand(commandName);
- if (command == null)
- {
- command = commands.AddNamedCommand2(m_addIn,
- commandName, caption, tooltip, false, iconIndex,
ref contextGUIDS,
- (int)vsCommandStatus.vsCommandStatusSupported +
- (int)vsCommandStatus.vsCommandStatusEnabled,
- (int)vsCommandStyle.vsCommandStylePictAndText,
- vsCommandControlType.vsCommandControlTypeButton);
- }
- if (command != null && popup != null)
- {
- if (!HasCommand(popup.CommandBar, caption))
- command.AddControl(popup.CommandBar, insertIndex);
- }
- }
+ {
+ private DTE2 m_application;
+ private AddIn m_addIn;
+ private OutputWindowPane m_outputPane;
+
+ private Dictionary<string, CommandBase> m_commands = new
Dictionary<string, CommandBase>();
+ private string m_connectPath;
+ private object mOptions;
+
+ public OutputWindowPane OutputPane { get { return m_outputPane; } }
+ public string Prefix { get { return m_connectPath; } }
+ public AddIn AddIn { get { return m_addIn; } }
+ public DTE2 App { get { return m_application; } }
+ public Commands2 Commands { get { return
(Commands2)m_application.Commands; }}
+ public object Options { get { return mOptions; } set { mOptions = value;
} }
- public void AddConsoleOnlyCommand( string commandName, string itemName,
string description)
+ public Plugin(DTE2 application, AddIn addIn, string panelName, string
connectPath, object options)
+ {
+ // TODO: This can be figured out from traversing the assembly and
locating the Connect class...
+ m_connectPath = connectPath;
+
+ m_application = application;
+ m_addIn = addIn;
+ m_outputPane = AquireOutputPane(application, panelName);
+ mOptions = options;
+ }
+
+ public void RegisterCommand(string commandName, CommandBase command)
+ {
+ m_commands.Add(commandName, command);
+ }
+
+ public bool CanHandleCommand(string commandName)
+ {
+ // TODO: Gotta be a better way to do this... std::find anyone?
+ foreach(string key in m_commands.Keys)
+ {
+ if(commandName.EndsWith("." + key))
+ return true;
+ }
+
+ return false;
+ }
+
+ public bool IsCommandEnabled(string commandName)
+ {
+ foreach(string key in m_commands.Keys)
+ {
+ if(commandName.EndsWith("." + key))
+ return m_commands[key].IsEnabled();
+ }
+
+ return false;
+ }
+
+ public bool OnCommand(string name)
+ {
+ // TODO: Gotta be a better way to do this... std::find anyone?
+ foreach(string key in m_commands.Keys)
+ {
+ if(name.EndsWith("." + key))
+ {
+ m_commands[key].OnCommand();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private Command GetCommand(string commandName)
+ {
+ Commands2 commands = (Commands2)m_application.Commands;
+
+ string fullName = m_connectPath + "." + commandName;
+
+ try
+ {
+ Command command = commands.Item(fullName, 0);
+ return command;
+ }
+ catch(System.ArgumentException)
+ {
+ return null;
+ }
+ }
+
+ private bool IsCommandRegistered(string commandName)
+ {
+ return GetCommand(commandName) != null;
+ }
+
+ private bool HasCommand(CommandBar commandBar, string caption)
+ {
+ foreach(CommandBarControl control in commandBar.Controls)
+ {
+ if(control.Caption == caption)
+ return true;
+ }
+ return false;
+ }
+
+ public CommandBar AddCommandBar(string name, MsoBarPosition position)
+ {
+ CommandBars cmdBars =
(Microsoft.VisualStudio.CommandBars.CommandBars)m_application.CommandBars;
+ CommandBar bar = null;
+
+ try
+ {
+ try
+ {
+ // Create the new CommandBar
+ bar = cmdBars.Add(name, position, false, false);
+ bar.Visible = true;
+ }
+ catch(ArgumentException)
+ {
+ // Try to find an existing CommandBar
+ bar = cmdBars[name];
+ }
+ }
+ catch
+ {
+ }
+
+ return bar;
+ }
+
+ public void AddPopupCommand(CommandBarPopup popup, string commandName,
string caption,
+ string tooltip, int iconIndex, int insertIndex)
+ {
+ // Do not try to add commands to a null menu
+ if(popup == null)
+ return;
+
+ // Get commands collection
+ Commands2 commands = (Commands2)m_application.Commands;
+ object[] contextGUIDS = new object[] { };
+
+ // Add command
+ Command command = GetCommand(commandName);
+ if(command == null)
+ {
+ command = commands.AddNamedCommand2(m_addIn,
+ commandName, caption, tooltip, false, iconIndex, ref contextGUIDS,
+ (int)vsCommandStatus.vsCommandStatusSupported +
+ (int)vsCommandStatus.vsCommandStatusEnabled,
+ (int)vsCommandStyle.vsCommandStylePictAndText,
+ vsCommandControlType.vsCommandControlTypeButton);
+ }
+ if(command != null && popup != null)
+ {
+ if(!HasCommand(popup.CommandBar, caption))
+ command.AddControl(popup.CommandBar, insertIndex);
+ }
+ //AddKeyboardBinding(command, binding);
+ }
+
+ public void AddConsoleOnlyCommand(string commandName, string itemName,
string description)
{
object[] contextGuids = new object[] { };
Commands2 commands = (Commands2)m_application.Commands;
@@ -186,416 +191,422 @@
commandStatus,
commandStyle,
controlType);
+ //AddKeyboardBinding(command, binding);
}
- catch (System.ArgumentException)
+ catch(System.ArgumentException)
{
Log.Debug("Tried to register the command \"{0}\" twice!", commandName);
}
}
- public void AddToolbarCommand(CommandBar bar, string commandName,
string caption,
- string tooltip, int iconIndex, int insertIndex)
- {
- AddToolbarOrMenuCommand(bar, commandName, caption, tooltip,
iconIndex, insertIndex,
- vsCommandStyle.vsCommandStylePict);
- }
-
- public void AddMenuCommand(CommandBar bar, string commandName,
string caption,
- string tooltip, int iconIndex, int insertIndex)
- {
- AddToolbarOrMenuCommand(bar, commandName, caption, tooltip,
iconIndex, insertIndex,
- vsCommandStyle.vsCommandStylePictAndText);
- }
-
- private void AddToolbarOrMenuCommand(CommandBar bar, string
commandName, string caption,
- string tooltip, int iconIndex, int insertIndex, vsCommandStyle
commandStyle)
- {
- // Do not try to add commands to a null bar
- if (bar == null)
- return;
-
- // Get commands collection
- Commands2 commands = (Commands2)m_application.Commands;
- object[] contextGUIDS = new object[] { };
-
- // Add command
- Command command = GetCommand(commandName);
- if (command == null)
- {
- command = commands.AddNamedCommand2(m_addIn, commandName,
- caption, tooltip, false, iconIndex, ref
contextGUIDS,
- (int)vsCommandStatus.vsCommandStatusSupported +
- (int)vsCommandStatus.vsCommandStatusEnabled,
- (int)commandStyle,
-
vsCommandControlType.vsCommandControlTypeButton);
- }
- if (command != null && bar != null)
- {
- if (!HasCommand(bar, caption))
- command.AddControl(bar, insertIndex);
- }
- }
-
- /*
- The toolbar name should be one of the following:
- MenuBar
- Standard
- Build
- XML Data
- XML Schema
- Context Menus
- Dialog Editor
- Image Editor
- Text Editor
- Source Control
- Formatting
- HTML Source Editing
- Style Sheet
- Device
- Layout
- Microsoft XML Editor
- Class Designer Toolbar
- Help
- Debug Location
- Debug
- Recorder
- Report Formatting
- Report Borders
- Data Design
- Query Designer
- View Designer
- Database Diagram
- Table Designer
- Project Node
- A&dd
- Cab Project Node
- A&dd
- File nodes
- Dep. file nodes
- Assembly nodes
- Dep. assembly nodes
- MSM nodes
- Dep. MSM nodes
- Output nodes
- Simple file nodes
- Simple output nodes
- Dependency node
- Multiple selections
- Dep. Multiple selections
- View
- Editor
- Error List
- Docked Window
- Menu Designer
- Properties Window
- Toolbox
- Task List
- Results List
- Stub Project
- No Commands Available
- Command Window
- AutoHidden Windows
- Expansion Manager
- Find Regular Expression Builder
- Replace Regular Expression Builder
- Wild Card Expression Builder
- Wild Card Expression Builder
- External Tools Arguments
- External Tools Directories
- Easy MDI Tool Window
- Easy MDI Document Window
- Easy MDI Dragging
- Open Drop Down
- Object Browser Objects Pane
- Object Browser Members Pane
- Object Browser Description Pane
- Find Symbol
- Drag and Drop
- Bookmark Window
- Error Correction
- EzMDI Files
- Ca&ll Browser
- Preview Changes
- Smart Tag
- Smart Tag
- Editor Context Menus
- Class View Context Menus
- Debugger Context Menus
- Project and Solution Context Menus
- Other Context Menus
- Sort By
- Show Columns
- Implement Interface
- Resolve
- Resolve
- Refactor
- Organize File
- Class View Project
- Class View Item
- Class View Folder
- Class View Grouping Folder
- Class View Multi-select
- Class View Multi-select members
- Class View Member
- Class View Grouping Members
- Class View Project References Folder
- Class View Project Reference
- Project
- Solution Folder
- Cross Project Solution Project
- Cross Project Solution Item
- Cross Project Project Item
- Cross Project Multi Project
- Cross Project Multi Item
- Cross Project Multi Solution Folder
- Cross Project Multi Project/Folder
- Item
- Folder
- Reference Root
- Reference Item
- Web Reference Folder
- App Designer Folder
- Web Project Folder
- Web Folder
- Web Item
- Web SubWeb
- Misc Files Project
- Solution
- Code Window
- Registry
- File System
- File System
- File Types
- User Interface
- Launch Conditions
- Custom Actions
- New
- Add
- Add Special Folder
- View
- Resource View
- Resource Editors
- Binary Editor
- Propertysheet
- Configuration
- Project
- Multi-Select
- System Propertysheet
- Checkin Dialog Context Menu
- Pending Checkin Window Context Menu
- Standard TreeGrid context menu
- GetVersion Dialog Context Menu
- Check Out Dialog Context Menu
- Context
- Basic Context
- Context
- Context
- Context
- Context
- Context
- Context
- HTML Context
- Script Context
- Context
- ASPX Context
- ASPX Code Context
- ASPX VB Code Context
- ASMX Code Context
- ASMX VB Code Context
- ASMX Context
- CSSDocOutline
- CSSSource
- Project Node
- A&dd
- Cab Project Node
- A&dd
- File nodes
- Dep. file nodes
- Assembly nodes
- Dep. assembly nodes
- MSM nodes
- Dep. MSM nodes
- Output nodes
- Dependency node
- Multiple selections
- Dep. Multiple selections
- View
- Registry
- File System
- File System
- New
- Add
- Add Special Folder
- View
- Selection
- Container
- TraySelection
- Document Outline
- Component Tray
- Exe Project
- Debug
- OTBObjCtxtMenu
- Class Designer Context Menu
- Class Diagram Context Menu
- TocContext
- ResListContext
- Editor
- Script Outline
- DefaultContext
- ImageContext
- SelectionContext
- AnchorContext
- Autos Window
- Breakpoint
- Breakpoints Window
- Call Stack Window
- Data Tip Window
- Disassembly Window
- Locals Window
- Memory Window
- Modules Window
- Output Window
- Processes Window
- Registers Window
- Threads Window
- Watch Window
- Server Explorer
- PropertyBrowser
- Macro
- Module
- Project
- Root
- Control
- Report
- Row/Column
- Cell
- Field Chooser
- Row/Column
- Chart
- Database Project
- DB Project Connection
- DB Project Folder
- Database References Folder
- Folders
- DB Project File
- Query
- Script
- Database Reference Node
- Files
- Multi-select
- Database Connection
- Folder Multi-Selection
- All Diagrams
- All Tables
- All Views
- All Stored Procedures
- All Package Specifications
- All Package Bodies
- All Synonyms
- All Databases
- All Users
- All Roles
- Node Multi-Selection
- Diagram
- Table
- View
- Stored Procedure
- Function
- Synonym
- Package Spec
- Package Body
- Trigger
- Column
- SQL Editor
- All Functions
- Oracle Function
- Oracle Procedure
- Change &View
- Single objet
- Single static
- Homogeneous objects
- Mixed objects
- Multiple static nodes
- Mixed nodes
- Add &New
- Add &New
- Surface
- DataSourceContext
- DbTableContext
- DataTableContext
- RelationContext
- FunctionContext
- ColumnContext
- QueryContext
- DataAccessorContext
- Query Diagram Pane
- Query Diagram Table
- Query Diagram Table Column
- Query Diagram Join Line
- Query Diagram Multi-select
- Query Grid Pane
- Query SQL Pane
- Query Results Pane
- Database Designer
- Database Designer Table
- Database Designer Relationship
- Text Annotation
- Class Details Context Menu
- TopicMenu
- TopicMenu
- Favorites Window Context Menu
- Data Sources
- Managed Resources Editor Context Menu
- Settings Designer
- System
- */
- public void AddToolbarCommand(string toolbarName, string
commandName, string caption,
- string tooltip, int iconIndex, int insertIndex)
- {
- CommandBar commandBar =
((CommandBars)m_application.CommandBars)[toolbarName];
- if (commandBar != null)
- AddToolbarCommand(commandBar, commandName, caption,
tooltip, iconIndex, insertIndex);
- }
-
- public void AddMenuCommand(string toolbarName, string commandName,
string caption,
- string tooltip, int iconIndex, int insertIndex)
- {
- CommandBar commandBar =
((CommandBars)m_application.CommandBars)[toolbarName];
- if (commandBar != null)
- AddMenuCommand(commandBar, commandName, caption, tooltip,
iconIndex, insertIndex);
- }
-
- private static OutputWindowPane AquireOutputPane(DTE2 app, string
name)
- {
- if ("" == name)
- return null;
-
- OutputWindowPane result = FindOutputPane(app, name);
- if (null != result)
- return result;
-
- OutputWindow outputWindow =
(OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
- OutputWindowPanes panes = outputWindow.OutputWindowPanes;
- return panes.Add(name);
- }
-
- public static OutputWindowPane FindOutputPane(DTE2 app, string
name)
- {
- if ("" == name)
- return null;
-
- OutputWindow outputWindow =
(OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
- OutputWindowPanes panes = outputWindow.OutputWindowPanes;
-
- foreach (OutputWindowPane pane in panes)
- {
- if (name != pane.Name)
- continue;
-
- return pane;
- }
-
- return null;
- }
- }
+ public void AddToolbarCommand(CommandBar bar, string commandName, string
caption, string tooltip, int iconIndex, int insertIndex)
+ {
+ AddToolbarOrMenuCommand(bar, commandName, caption, tooltip, iconIndex,
insertIndex,
+ vsCommandStyle.vsCommandStylePict);
+ }
+
+ public void AddMenuCommand(CommandBar bar, string commandName, string
caption,
+ string tooltip, int iconIndex, int insertIndex)
+ {
+ AddToolbarOrMenuCommand(bar, commandName, caption, tooltip, iconIndex,
insertIndex,
+ vsCommandStyle.vsCommandStylePictAndText);
+ }
+
+ private void AddToolbarOrMenuCommand(CommandBar bar, string commandName,
string caption,
+ string tooltip, int iconIndex, int insertIndex, vsCommandStyle
commandStyle)
+ {
+ // Do not try to add commands to a null bar
+ if(bar == null)
+ return;
+
+ // Get commands collection
+ Commands2 commands = (Commands2)m_application.Commands;
+ object[] contextGUIDS = new object[] { };
+
+ // Add command
+ Command command = GetCommand(commandName);
+ if(command == null)
+ {
+ command = commands.AddNamedCommand2(m_addIn, commandName,
+ caption, tooltip, false, iconIndex, ref contextGUIDS,
+ (int)vsCommandStatus.vsCommandStatusSupported +
+ (int)vsCommandStatus.vsCommandStatusEnabled,
+ (int)commandStyle,
+ vsCommandControlType.vsCommandControlTypeButton);
+ }
+ if(command != null && bar != null)
+ {
+ if(!HasCommand(bar, caption))
+ command.AddControl(bar, insertIndex);
+ }
+ //AddKeyboardBinding(command, binding);
+ }
+
+ /*
+ The toolbar name should be one of the following:
+ MenuBar
+ Standard
+ Build
+ XML Data
+ XML Schema
+ Context Menus
+ Dialog Editor
+ Image Editor
+ Text Editor
+ Source Control
+ Formatting
+ HTML Source Editing
+ Style Sheet
+ Device
+ Layout
+ Microsoft XML Editor
+ Class Designer Toolbar
+ Help
+ Debug Location
+ Debug
+ Recorder
+ Report Formatting
+ Report Borders
+ Data Design
+ Query Designer
+ View Designer
+ Database Diagram
+ Table Designer
+ Project Node
+ A&dd
+ Cab Project Node
+ A&dd
+ File nodes
+ Dep. file nodes
+ Assembly nodes
+ Dep. assembly nodes
+ MSM nodes
+ Dep. MSM nodes
+ Output nodes
+ Simple file nodes
+ Simple output nodes
+ Dependency node
+ Multiple selections
+ Dep. Multiple selections
+ View
+ Editor
+ Error List
+ Docked Window
+ Menu Designer
+ Properties Window
+ Toolbox
+ Task List
+ Results List
+ Stub Project
+ No Commands Available
+ Command Window
+ AutoHidden Windows
+ Expansion Manager
+ Find Regular Expression Builder
+ Replace Regular Expression Builder
+ Wild Card Expression Builder
+ Wild Card Expression Builder
+ External Tools Arguments
+ External Tools Directories
+ Easy MDI Tool Window
+ Easy MDI Document Window
+ Easy MDI Dragging
+ Open Drop Down
+ Object Browser Objects Pane
+ Object Browser Members Pane
+ Object Browser Description Pane
+ Find Symbol
+ Drag and Drop
+ Bookmark Window
+ Error Correction
+ EzMDI Files
+ Ca&ll Browser
+ Preview Changes
+ Smart Tag
+ Smart Tag
+ Editor Context Menus
+ Class View Context Menus
+ Debugger Context Menus
+ Project and Solution Context Menus
+ Other Context Menus
+ Sort By
+ Show Columns
+ Implement Interface
+ Resolve
+ Resolve
+ Refactor
+ Organize File
+ Class View Project
+ Class View Item
+ Class View Folder
+ Class View Grouping Folder
+ Class View Multi-select
+ Class View Multi-select members
+ Class View Member
+ Class View Grouping Members
+ Class View Project References Folder
+ Class View Project Reference
+ Project
+ Solution Folder
+ Cross Project Solution Project
+ Cross Project Solution Item
+ Cross Project Project Item
+ Cross Project Multi Project
+ Cross Project Multi Item
+ Cross Project Multi Solution Folder
+ Cross Project Multi Project/Folder
+ Item
+ Folder
+ Reference Root
+ Reference Item
+ Web Reference Folder
+ App Designer Folder
+ Web Project Folder
+ Web Folder
+ Web Item
+ Web SubWeb
+ Misc Files Project
+ Solution
+ Code Window
+ Registry
+ File System
+ File System
+ File Types
+ User Interface
+ Launch Conditions
+ Custom Actions
+ New
+ Add
+ Add Special Folder
+ View
+ Resource View
+ Resource Editors
+ Binary Editor
+ Propertysheet
+ Configuration
+ Project
+ Multi-Select
+ System Propertysheet
+ Checkin Dialog Context Menu
+ Pending Checkin Window Context Menu
+ Standard TreeGrid context menu
+ GetVersion Dialog Context Menu
+ Check Out Dialog Context Menu
+ Context
+ Basic Context
+ Context
+ Context
+ Context
+ Context
+ Context
+ Context
+ HTML Context
+ Script Context
+ Context
+ ASPX Context
+ ASPX Code Context
+ ASPX VB Code Context
+ ASMX Code Context
+ ASMX VB Code Context
+ ASMX Context
+ CSSDocOutline
+ CSSSource
+ Project Node
+ A&dd
+ Cab Project Node
+ A&dd
+ File nodes
+ Dep. file nodes
+ Assembly nodes
+ Dep. assembly nodes
+ MSM nodes
+ Dep. MSM nodes
+ Output nodes
+ Dependency node
+ Multiple selections
+ Dep. Multiple selections
+ View
+ Registry
+ File System
+ File System
+ New
+ Add
+ Add Special Folder
+ View
+ Selection
+ Container
+ TraySelection
+ Document Outline
+ Component Tray
+ Exe Project
+ Debug
+ OTBObjCtxtMenu
+ Class Designer Context Menu
+ Class Diagram Context Menu
+ TocContext
+ ResListContext
+ Editor
+ Script Outline
+ DefaultContext
+ ImageContext
+ SelectionContext
+ AnchorContext
+ Autos Window
+ Breakpoint
+ Breakpoints Window
+ Call Stack Window
+ Data Tip Window
+ Disassembly Window
+ Locals Window
+ Memory Window
+ Modules Window
+ Output Window
+ Processes Window
+ Registers Window
+ Threads Window
+ Watch Window
+ Server Explorer
+ PropertyBrowser
+ Macro
+ Module
+ Project
+ Root
+ Control
+ Report
+ Row/Column
+ Cell
+ Field Chooser
+ Row/Column
+ Chart
+ Database Project
+ DB Project Connection
+ DB Project Folder
+ Database References Folder
+ Folders
+ DB Project File
+ Query
+ Script
+ Database Reference Node
+ Files
+ Multi-select
+ Database Connection
+ Folder Multi-Selection
+ All Diagrams
+ All Tables
+ All Views
+ All Stored Procedures
+ All Package Specifications
+ All Package Bodies
+ All Synonyms
+ All Databases
+ All Users
+ All Roles
+ Node Multi-Selection
+ Diagram
+ Table
+ View
+ Stored Procedure
+ Function
+ Synonym
+ Package Spec
+ Package Body
+ Trigger
+ Column
+ SQL Editor
+ All Functions
+ Oracle Function
+ Oracle Procedure
+ Change &View
+ Single objet
+ Single static
+ Homogeneous objects
+ Mixed objects
+ Multiple static nodes
+ Mixed nodes
+ Add &New
+ Add &New
+ Surface
+ DataSourceContext
+ DbTableContext
+ DataTableContext
+ RelationContext
+ FunctionContext
+ ColumnContext
+ QueryContext
+ DataAccessorContext
+ Query Diagram Pane
+ Query Diagram Table
+ Query Diagram Table Column
+ Query Diagram Join Line
+ Query Diagram Multi-select
+ Query Grid Pane
+ Query SQL Pane
+ Query Results Pane
+ Database Designer
+ Database Designer Table
+ Database Designer Relationship
+ Text Annotation
+ Class Details Context Menu
+ TopicMenu
+ TopicMenu
+ Favorites Window Context Menu
+ Data Sources
+ Managed Resources Editor Context Menu
+ Settings Designer
+ System
+ */
+ public void AddToolbarCommand(string toolbarName, string commandName,
string caption,
+ string tooltip, int iconIndex, int insertIndex)
+ {
+ CommandBar commandBar =
((CommandBars)m_application.CommandBars)[toolbarName];
+ if(commandBar != null)
+ AddToolbarCommand(commandBar, commandName, caption, tooltip,
iconIndex, insertIndex);
+ }
+
+ public void AddMenuCommand(string toolbarName, string commandName,
string caption,
+ string tooltip, int iconIndex, int insertIndex)
+ {
+ CommandBar commandBar =
((CommandBars)m_application.CommandBars)[toolbarName];
+ if(commandBar != null)
+ AddMenuCommand(commandBar, commandName, caption, tooltip, iconIndex,
insertIndex);
+ }
+
+ private static OutputWindowPane AquireOutputPane(DTE2 app, string name)
+ {
+ if("" == name)
+ return null;
+
+ OutputWindowPane result = FindOutputPane(app, name);
+ if(null != result)
+ return result;
+
+ OutputWindow outputWindow =
(OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
+ OutputWindowPanes panes = outputWindow.OutputWindowPanes;
+ return panes.Add(name);
+ }
+
+ public static OutputWindowPane FindOutputPane(DTE2 app, string name)
+ {
+ if("" == name)
+ return null;
+
+ OutputWindow outputWindow =
(OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
+ OutputWindowPanes panes = outputWindow.OutputWindowPanes;
+
+ foreach(OutputWindowPane pane in panes)
+ {
+ if(name != pane.Name)
+ continue;
+
+ return pane;
+ }
+
+ return null;
+ }
+
+ public static void AddKeyboardBinding(Command command, string binding)
+ {
+ command.Bindings = binding;
+ }
+ }
}