示例#1
0
        public void ShowVSExtensionManager(object parameter)
        {
            MenuCommandService menuCommandService = serviceProvider.Get <MenuCommandService>();
            CommandID          commandId          = new CommandID(VSConstants.VsStd2010, 3000);

            menuCommandService.GlobalInvoke(commandId, parameter);
            serviceProvider.Get <ITeamExplorer>().HideNotification(GuidList.UpdateNotificationId);
        }
示例#2
0
        /// <summary>
        ///  Called to do control-specific processing for this window.
        /// </summary>
        void IWindowTarget.OnMessage(ref Message m)
        {
            // Get the Designer for the currently selected item on the Designer...
            // SET STATE ..
            ignoreMessages = false;

            // Here lets query for the ISupportInSituService.
            // If we find the service then ask if it has a designer which is interested
            // in getting the keychars by querying the IgnoreMessages.
            if ((m.Msg >= (int)User32.WM.KEYFIRST && m.Msg <= (int)User32.WM.KEYLAST) ||
                (m.Msg >= (int)User32.WM.IME_STARTCOMPOSITION && m.Msg <= (int)User32.WM.IME_COMPOSITION))
            {
                if (InSituSupportService != null)
                {
                    ignoreMessages = InSituSupportService.IgnoreMessages;
                }
            }

            switch (m.Msg)
            {
            case WM_PRIVATE_POSTCHAR:

                if (bufferedChars == null)
                {
                    return;
                }

                // recreate the keystroke to the newly activated window
                IntPtr hWnd;
                if (!ignoreMessages)
                {
                    hWnd = User32.GetFocus();
                }
                else
                {
                    if (InSituSupportService != null)
                    {
                        hWnd = InSituSupportService.GetEditWindow();
                    }
                    else
                    {
                        hWnd = User32.GetFocus();
                    }
                }

                if (hWnd != m.HWnd)
                {
                    foreach (BufferedKey bk in bufferedChars)
                    {
                        if (bk.KeyChar.MsgInternal == User32.WM.CHAR)
                        {
                            if (bk.KeyDown.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYDOWN, bk.KeyDown.WParamInternal, bk.KeyDown.LParamInternal);
                            }

                            User32.SendMessageW(hWnd, User32.WM.CHAR, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                            if (bk.KeyUp.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYUP, bk.KeyUp.WParamInternal, bk.KeyUp.LParamInternal);
                            }
                        }
                        else
                        {
                            User32.SendMessageW(hWnd, bk.KeyChar.MsgInternal, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                        }
                    }
                }

                bufferedChars.Clear();
                return;

            case (int)User32.WM.KEYDOWN:
                lastKeyDown = m;
                break;

            case (int)User32.WM.IME_ENDCOMPOSITION:
            case (int)User32.WM.KEYUP:
                lastKeyDown.Msg = 0;
                break;

            case (int)User32.WM.CHAR:
            case (int)User32.WM.IME_STARTCOMPOSITION:
            case (int)User32.WM.IME_COMPOSITION:
                if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
                {
                    break;
                }

                if (bufferedChars == null)
                {
                    bufferedChars = new ArrayList();
                }

                bufferedChars.Add(new BufferedKey(lastKeyDown, m, lastKeyDown));

                if (!ignoreMessages && MenuCommandService != null)
                {
                    // throw the properties window command, we will redo the keystroke when we actually
                    // lose focus
                    postCharMessage = true;
                    MenuCommandService.GlobalInvoke(StandardCommands.PropertiesWindow);
                }
                else if (ignoreMessages && m.Msg != (int)User32.WM.IME_COMPOSITION)
                {
                    if (InSituSupportService != null)
                    {
                        postCharMessage = true;
                        InSituSupportService.HandleKeyChar();
                    }
                }

                if (postCharMessage)
                {
                    // If copy of message has been buffered for forwarding, eat the original now
                    return;
                }

                break;

            case (int)User32.WM.KILLFOCUS:
                if (postCharMessage)
                {
                    // see ASURT 45313
                    // now that we've actually lost focus, post this message to the queue.  This allows
                    // any activity that's in the queue to settle down before our characters are posted.
                    // to the queue.
                    //
                    // we post because we need to allow the focus to actually happen before we send
                    // our strokes so we know where to send them
                    //
                    // we can't use the wParam here because it may not be the actual window that needs
                    // to pick up the strokes.
                    //
                    User32.PostMessageW(target.Handle, (User32.WM)WM_PRIVATE_POSTCHAR, IntPtr.Zero, IntPtr.Zero);
                    postCharMessage = false;
                }

                break;
            }

            if (oldTarget != null)
            {
                oldTarget.OnMessage(ref m);
            }
        }
 public bool GlobalInvoke(CommandID commandID)
 {
     return(_menuCommandService.GlobalInvoke(commandID));
 }
 private void tsmiLeft_Click(object sender, EventArgs e)
 {
     _menuCommandService.GlobalInvoke(StandardCommands.AlignLeft);
 }