From 30da530345d079586b2fc7bbef15213b677e97d3 Mon Sep 17 00:00:00 2001 From: Sentinel209_cp <5b554accd9e292fcb886b205d8d4c32c5d52ce2df5Ng6vpx> Date: Wed, 29 Jun 2011 23:37:53 +0000 Subject: [PATCH] --- .../Cosmos.VS.Windows.csproj | 17 +++++-- .../Cosmos.VS.Windows/Cosmos.VS.Windows.vsct | 30 +++++------- .../Cosmos.VS.WindowsPackage.cs | 31 ++++++++++--- ...ndow.cs => CosmosVSAssembly_ToolWindow.cs} | 4 +- ...xaml => CosmosVSAssembly_UserControl.xaml} | 0 ...s => CosmosVSAssembly_UserControl.xaml.cs} | 0 .../CosmosVSRegisters_ToolWindow.cs | 46 +++++++++++++++++++ .../CosmosVSRegisters_UserControl.xaml | 17 +++++++ .../CosmosVSRegisters_UserControl.xaml.cs | 35 ++++++++++++++ source2/VSIP/Cosmos.VS.Windows/PkgCmdID.cs | 5 +- 10 files changed, 151 insertions(+), 34 deletions(-) rename source2/VSIP/Cosmos.VS.Windows/{MyToolWindow.cs => CosmosVSAssembly_ToolWindow.cs} (92%) rename source2/VSIP/Cosmos.VS.Windows/{MyControl.xaml => CosmosVSAssembly_UserControl.xaml} (100%) rename source2/VSIP/Cosmos.VS.Windows/{MyControl.xaml.cs => CosmosVSAssembly_UserControl.xaml.cs} (100%) create mode 100644 source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_ToolWindow.cs create mode 100644 source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_UserControl.xaml create mode 100644 source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_UserControl.xaml.cs diff --git a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.csproj b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.csproj index d1dd5f937..028446538 100644 --- a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.csproj +++ b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.csproj @@ -117,11 +117,15 @@ - - MyControl.xaml + + CosmosVSAssembly_UserControl.xaml - + + CosmosVSRegisters_UserControl.xaml + + + True True @@ -154,6 +158,7 @@ Menus.ctmenu + Designer @@ -164,7 +169,11 @@ - + + Designer + MSBuild:Compile + + Designer MSBuild:Compile diff --git a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.vsct b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.vsct index 3ab79d611..ab3626204 100644 --- a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.vsct +++ b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.Windows.vsct @@ -23,9 +23,6 @@ - - - @@ -37,16 +34,13 @@ group; your package should define its own command set in order to avoid collisions with command ids defined by other packages. --> - - - - + @@ -58,8 +52,6 @@ DefaultInvisible DynamicVisibility If you do not want an image next to your command, remove the Icon node or set it to --> - - - - + @@ -85,22 +83,16 @@ - - - - - - - - + + diff --git a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.WindowsPackage.cs b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.WindowsPackage.cs index 3cb61d4d9..b500d683c 100644 --- a/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.WindowsPackage.cs +++ b/source2/VSIP/Cosmos.VS.Windows/Cosmos.VS.WindowsPackage.cs @@ -30,7 +30,8 @@ namespace Cosmos.Cosmos_VS_Windows // This attribute is needed to let the shell know that this package exposes some menus. [ProvideMenuResource("Menus.ctmenu", 1)] // This attribute registers a tool window exposed by this package. - [ProvideToolWindow(typeof(MyToolWindow))] + [ProvideToolWindow(typeof(CosmosVSAssembly_ToolWindow))] + [ProvideToolWindow(typeof(CosmosVSRegisters_ToolWindow))] [Guid(GuidList.guidCosmos_VS_WindowsPkgString)] public sealed class Cosmos_VS_WindowsPackage : Package { @@ -51,12 +52,12 @@ namespace Cosmos.Cosmos_VS_Windows /// tool window. See the Initialize method to see how the menu item is associated to /// this function using the OleMenuCommandService service and the MenuCommand class. /// - private void ShowToolWindow(object sender, EventArgs e) + private void ShowCosmosVSAssemblyToolWindow(object sender, EventArgs e) { // Get the instance number 0 of this tool window. This window is single instance so this instance // is actually the only one. // The last flag is set to true so that if the tool window does not exists it will be created. - ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true); + ToolWindowPane window = this.FindToolWindow(typeof(CosmosVSAssembly_ToolWindow), 0, true); if ((null == window) || (null == window.Frame)) { throw new NotSupportedException(Resources.CanNotCreateWindow); @@ -65,6 +66,19 @@ namespace Cosmos.Cosmos_VS_Windows Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); } + private void ShowCosmosVSRegistersToolWindow(object sender, EventArgs e) + { + // Get the instance number 0 of this tool window. This window is single instance so this instance + // is actually the only one. + // The last flag is set to true so that if the tool window does not exists it will be created. + ToolWindowPane window = this.FindToolWindow(typeof(CosmosVSRegisters_ToolWindow), 0, true); + if ((null == window) || (null == window.Frame)) + { + throw new NotSupportedException(Resources.CanNotCreateWindow); + } + IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; + Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); + } ///////////////////////////////////////////////////////////////////////////// // Overriden Package Implementation @@ -84,9 +98,14 @@ namespace Cosmos.Cosmos_VS_Windows if ( null != mcs ) { // Create the command for the tool window - CommandID toolwndCommandID = new CommandID(GuidList.guidCosmos_VS_WindowsCmdSet, (int)PkgCmdIDList.cmdidCosmosAssembly); - MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); - mcs.AddCommand( menuToolWin ); + CommandID CosmosVSAssemblyToolWindowCommandID = new CommandID(GuidList.guidCosmos_VS_WindowsCmdSet, (int)PkgCmdIDList.cmdidCosmosAssembly); + MenuCommand CosmosVSAssemblyToolWindowMenuCommand = new MenuCommand(ShowCosmosVSAssemblyToolWindow, CosmosVSAssemblyToolWindowCommandID); + mcs.AddCommand(CosmosVSAssemblyToolWindowMenuCommand); + + // Create the command for the tool window + CommandID CosmosVSRegistersToolWindowCommandID = new CommandID(GuidList.guidCosmos_VS_WindowsCmdSet, (int)PkgCmdIDList.cmdidCosmosRegisters); + MenuCommand CosmosVSRegistersToolWindowMenuCommand = new MenuCommand(ShowCosmosVSRegistersToolWindow, CosmosVSRegistersToolWindowCommandID); + mcs.AddCommand(CosmosVSRegistersToolWindowMenuCommand); } } #endregion diff --git a/source2/VSIP/Cosmos.VS.Windows/MyToolWindow.cs b/source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_ToolWindow.cs similarity index 92% rename from source2/VSIP/Cosmos.VS.Windows/MyToolWindow.cs rename to source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_ToolWindow.cs index bf06b053b..f7b1dd773 100644 --- a/source2/VSIP/Cosmos.VS.Windows/MyToolWindow.cs +++ b/source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_ToolWindow.cs @@ -20,12 +20,12 @@ namespace Cosmos.Cosmos_VS_Windows /// implementation of the IVsUIElementPane interface. /// [Guid("f019fb29-c2c2-4d27-9abf-739533c939be")] - public class MyToolWindow : ToolWindowPane + public class CosmosVSAssembly_ToolWindow : ToolWindowPane { /// /// Standard constructor for the tool window. /// - public MyToolWindow() : + public CosmosVSAssembly_ToolWindow() : base(null) { // Set the window title reading it from the resources. diff --git a/source2/VSIP/Cosmos.VS.Windows/MyControl.xaml b/source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_UserControl.xaml similarity index 100% rename from source2/VSIP/Cosmos.VS.Windows/MyControl.xaml rename to source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_UserControl.xaml diff --git a/source2/VSIP/Cosmos.VS.Windows/MyControl.xaml.cs b/source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_UserControl.xaml.cs similarity index 100% rename from source2/VSIP/Cosmos.VS.Windows/MyControl.xaml.cs rename to source2/VSIP/Cosmos.VS.Windows/CosmosVSAssembly_UserControl.xaml.cs diff --git a/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_ToolWindow.cs b/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_ToolWindow.cs new file mode 100644 index 000000000..6780a9b61 --- /dev/null +++ b/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_ToolWindow.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Windows; +using System.Runtime.InteropServices; +using Microsoft.VisualStudio.Shell.Interop; +using Microsoft.VisualStudio.Shell; + +namespace Cosmos.Cosmos_VS_Windows +{ + /// + /// This class implements the tool window exposed by this package and hosts a user control. + /// + /// In Visual Studio tool windows are composed of a frame (implemented by the shell) and a pane, + /// usually implemented by the package implementer. + /// + /// This class derives from the ToolWindowPane class provided from the MPF in order to use its + /// implementation of the IVsUIElementPane interface. + /// + [Guid("CE2A2D0F-0F1B-4A1F-A9AC-5A5F2A5E2C25")] + public class CosmosVSRegisters_ToolWindow : ToolWindowPane + { + /// + /// Standard constructor for the tool window. + /// + public CosmosVSRegisters_ToolWindow() : base(null) + { + // Set the window title reading it from the resources. + this.Caption = "Cosmos x86 Registers Window"; // Resources.ToolWindowTitle; + // Set the image that will appear on the tab of the window frame + // when docked with an other window + // The resource ID correspond to the one defined in the resx file + // while the Index is the offset in the bitmap strip. Each image in + // the strip being 16x16. + this.BitmapResourceID = 301; + this.BitmapIndex = 1; + + // 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. + base.Content = new CosmosVSRegisters_UserControl(); + } + } +} diff --git a/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_UserControl.xaml b/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_UserControl.xaml new file mode 100644 index 000000000..7c7cc5f9c --- /dev/null +++ b/source2/VSIP/Cosmos.VS.Windows/CosmosVSRegisters_UserControl.xaml @@ -0,0 +1,17 @@ + + + + This is a toolwindow with WPF content +