This commit is contained in:
Sentinel209_cp 2011-06-29 23:37:53 +00:00
parent dd71c1b8a4
commit 30da530345
10 changed files with 151 additions and 34 deletions

View file

@ -117,11 +117,15 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MyControl.xaml.cs">
<DependentUpon>MyControl.xaml</DependentUpon>
<Compile Include="CosmosVSAssembly_UserControl.xaml.cs">
<DependentUpon>CosmosVSAssembly_UserControl.xaml</DependentUpon>
</Compile>
<Compile Include="MyToolWindow.cs" />
<Compile Include="CosmosVSRegisters_UserControl.xaml.cs">
<DependentUpon>CosmosVSRegisters_UserControl.xaml</DependentUpon>
</Compile>
<Compile Include="CosmosVSAssembly_ToolWindow.cs" />
<Compile Include="Guids.cs" />
<Compile Include="CosmosVSRegisters_ToolWindow.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -154,6 +158,7 @@
<ItemGroup>
<VSCTCompile Include="Cosmos.VS.Windows.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
<SubType>Designer</SubType>
</VSCTCompile>
</ItemGroup>
<ItemGroup>
@ -164,7 +169,11 @@
<Content Include="Resources\Package.ico" />
</ItemGroup>
<ItemGroup>
<Page Include="MyControl.xaml">
<Page Include="CosmosVSAssembly_UserControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CosmosVSRegisters_UserControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View file

@ -23,9 +23,6 @@
<!--Definition of some VSCT specific constants. In this sample we use it for the IDs inside the guidOfficeIcon group. -->
<Extern href="msobtnid.h"/>
<!--The Commands section is where we the commands, menus and menu groups are defined.
This section uses a Guid to identify the package that provides the command defined inside it. -->
<Commands package="guidCosmos_VS_WindowsPkg">
@ -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. -->
<!-- In this section you can define new menu groups. A menu group is a container for
other menus or buttons (commands); from a visual point of view you can see the
group as the part of a menu contained between two lines. The parent of a group
must be a menu. -->
<Groups>
</Groups>
<!--Buttons section. -->
<!--This section defines the elements the user can interact with, like a menu command or a button
or combo box in a toolbar. -->
@ -58,8 +52,6 @@
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
If you do not want an image next to your command, remove the Icon node or set it to <Icon guid="guidOfficeIcon" id="msotcidNoIcon" /> -->
<Button guid="guidCosmos_VS_WindowsCmdSet" id="cmdidCosmosAssembly" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/>
<Icon guid="guidImages" id="bmpPic2" />
@ -68,8 +60,14 @@
<ButtonText>Cosmos Assembly Window</ButtonText>
</Strings>
</Button>
<Button guid="guidCosmos_VS_WindowsCmdSet" id="cmdidCosmosRegisters" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/>
<Icon guid="guidImages" id="bmpPic2" />
<Strings>
<CommandName>cmdidCosmosRegisters</CommandName>
<ButtonText>Cosmos Registers Window</ButtonText>
</Strings>
</Button>
</Buttons>
<!--The bitmaps section is used to define the bitmaps that are used for the commands.-->
@ -85,22 +83,16 @@
</Commands>
<Symbols>
<!-- This is the package guid. -->
<GuidSymbol name="guidCosmos_VS_WindowsPkg" value="{a82b45e9-2a89-43bd-925d-c7f0edd212aa}" />
<!-- This is the guid used to group the menu commands together -->
<GuidSymbol name="guidCosmos_VS_WindowsCmdSet" value="{3d4b3f35-36e7-4cea-8acc-d9601e45c0b9}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="cmdidCosmosAssembly" value="0x0101" />
</GuidSymbol>
<IDSymbol name="cmdidCosmosRegisters" value="0x0102" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{aa9d88d9-acd2-4f2c-ab40-92887bdce774}" >
<IDSymbol name="bmpPic1" value="1" />

View file

@ -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.
/// </summary>
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

View file

@ -20,12 +20,12 @@ namespace Cosmos.Cosmos_VS_Windows
/// implementation of the IVsUIElementPane interface.
/// </summary>
[Guid("f019fb29-c2c2-4d27-9abf-739533c939be")]
public class MyToolWindow : ToolWindowPane
public class CosmosVSAssembly_ToolWindow : ToolWindowPane
{
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
public MyToolWindow() :
public CosmosVSAssembly_ToolWindow() :
base(null)
{
// Set the window title reading it from the resources.

View file

@ -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
{
/// <summary>
/// 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.
/// </summary>
[Guid("CE2A2D0F-0F1B-4A1F-A9AC-5A5F2A5E2C25")]
public class CosmosVSRegisters_ToolWindow : ToolWindowPane
{
/// <summary>
/// Standard constructor for the tool window.
/// </summary>
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();
}
}
}

View file

@ -0,0 +1,17 @@
<UserControl x:Class="Cosmos.Cosmos_VS_Windows.CosmosVSRegisters_UserControl"
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="300" d:DesignWidth="300"
Name="MyToolWindow1"
Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}">
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock Margin="10" HorizontalAlignment="Center" Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowTextKey}}">This is a toolwindow with WPF content</TextBlock>
<Button Content="_Click Me!" Width="80" Height="80" Name="button1" Click="button1_Click" />
</StackPanel>
</Grid>
</UserControl>

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Cosmos.Cosmos_VS_Windows
{
/// <summary>
/// Interaction logic for MyControl1.xaml
/// </summary>
public partial class CosmosVSRegisters_UserControl : UserControl
{
public CosmosVSRegisters_UserControl()
{
InitializeComponent();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions")]
private void button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "We are inside {0}.button1_Click()", this.ToString()),
"Cosmos x86 Registers Window");
}
}
}

View file

@ -6,8 +6,7 @@ namespace Cosmos.Cosmos_VS_Windows
{
static class PkgCmdIDList
{
public const uint cmdidCosmosAssembly = 0x101;
public const uint cmdidCosmosAssembly = 0x101;
public const uint cmdidCosmosRegisters = 0x102;
};
}