コード例 #1
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Create a view of the addin
        /// The view should be a UserControl which will be created directly
        /// embedded within the Window representing the AddIn in VisualStudio.
        /// the Window container of the Addin on screee,
        /// </summary>
        /// <param name="addInApplication"></param>
        /// <param name="addInInstance"></param>
        /// <param name="addInView"></param>
        /// <param name="viewGuid"></param>
        /// <param name="viewCaption"></param>
        /// <param name="viewClass"></param>
        /// <param name="viewIcon"></param>
        /// <returns></returns>
        //////////////////////////////////////////////////////////////////////////

        public static Window CreateAddinView(DTE2 addInApplication, AddIn addInInstance, ref object addInView, string viewGuid, string viewCaption, Type viewClass, Bitmap viewIcon)
        {
            Windows2 dteWindows  = (Windows2)addInApplication.Windows;
            Window   addInWindow = dteWindows.CreateToolWindow2(addInInstance, viewClass.Assembly.Location, viewClass.FullName, viewCaption, viewGuid, ref addInView);

            if (addInWindow != null)
            {
                // Set the tab icon
                if (viewIcon != null)
                {
                    StdPicture tabPicture = AddInUtils.CreatePicture(viewIcon);
                    addInWindow.SetTabPicture(tabPicture);
                }

                addInWindow.Linkable   = true;
                addInWindow.IsFloating = false;
                addInWindow.Activate();
            }

            return(addInWindow);
        }
コード例 #2
0
ファイル: VsAddin.cs プロジェクト: radtek/csql
        /// <summary>
        /// Add a command to the Visual Studio shell.
        /// </summary>
        /// <param name="vsCommand">The add in command properties</param>
        private void AddIdeCommand(VsCommand vsCommand)
        {
            Debug.WriteLine("AddIdeCommand(" + vsCommand.Name + ")");

            Command ideCommand = FindIdeCommand(vsCommand);

            if (ideCommand == null)
            {
                Commands2 ideCommands   = (Commands2)this.Application.Commands;
                bool      useMsoButtons = vsCommand.IconId == 0;
                object[]  contextGuids  = vsCommand.VsContextGuidsObjectArray;
                ideCommand = ideCommands.AddNamedCommand2(
                    this.Addin,
                    vsCommand.Name,
                    vsCommand.Title,
                    String.Empty,
                    useMsoButtons,
                    vsCommand.IconId,
                    ref contextGuids,
                    (int)vsCommandStatus.vsCommandStatusSupported | (int)vsCommandStatus.vsCommandStatusEnabled,
                    (int)vsCommandStyle.vsCommandStylePictAndText,
                    vsCommandControlType.vsCommandControlTypeButton);
            }

            string commandBarName = vsCommand.CommandBarName;

            string[]   temp       = commandBarName.Split('.');
            CommandBar commandBar = GetCommandBar(temp[0]);

            if (commandBar == null)
            {
                return;
            }

            object commandControl = null;

            if (temp.Length == 1)
            {
                if (!ContainsCommand(commandBar.Controls, ideCommand))
                {
                    commandControl = ideCommand.AddControl(commandBar, vsCommand.Position);
                }
            }
            else if (temp.Length == 2)
            {
                CommandBarPopup commandBarPopup = (CommandBarPopup)commandBar.Controls[temp[1]];
                if (!ContainsCommand(commandBarPopup.Controls, ideCommand))
                {
                    commandControl = ideCommand.AddControl(commandBarPopup.CommandBar, vsCommand.Position);
                }
            }
            else
            {
                throw new NotSupportedException("A command hierarchy greater than two is not supported yet");
            }

            if (commandControl != null)
            {
                CommandBarButton commandButton = (CommandBarButton)commandControl;
                bool             useMsoButtons = vsCommand.IconId == 0;
                if (useMsoButtons && vsCommand.Icon != null)
                {
                    StdPicture iconPicture = vsCommand.Icon.IconPicture;
                    commandButton.Picture = iconPicture;
                    StdPicture iconMask = vsCommand.Icon.IconMask;
                    commandButton.Mask  = iconMask;
                    commandButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
                }
                else
                {
                    commandButton.Style = MsoButtonStyle.msoButtonAutomatic;
                }
            }
        }
コード例 #3
0
        public void SetImage(Image image)
        {
            StdPicture picture = VSMenuCommand.ImageConverter.ImageToIPicture(image);

            this.Button.Picture = picture;
        }
コード例 #4
0
        /// <summary>
        /// Sets the image.
        /// </summary>
        /// <param name="image">The image.</param>
        public void SetImage(Image image)
        {
            StdPicture picture = ImageConverter.ImageToIPicture(image);

            Button.Picture = picture;
        }