コード例 #1
0
        private void textEditorMenuItem_BeforeQueryStatus(object sender, System.EventArgs e)
        {
            OleMenuCommand menuItem = sender as OleMenuCommand;
            ToolWindowPane window   = this.package.FindToolWindow(typeof(AlfredWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

            AlfredWindow alfredWindow = window as AlfredWindow;

            if (alfredWindow != null && !String.IsNullOrEmpty(VisualStudioHandler.GetCurrentLineSelectedText()))
            {
                menuItem.Enabled = true;
                menuItem.Visible = true;
            }
            else
            {
                menuItem.Enabled = false;
                menuItem.Visible = false;
            }
        }
コード例 #2
0
        private void ExecuteToolMenuTextEditorMenu(object sender, System.EventArgs e)
        {
            OleMenuCommand menuItem = sender as OleMenuCommand;
            ToolWindowPane window   = this.package.FindToolWindow(typeof(AlfredWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

            AlfredWindow alfredWindow = window as AlfredWindow;
            string       selectedText = VisualStudioHandler.GetCurrentLineSelectedText();
            AlfredInput  alfredInput  = AlfredInputManager.Instance.GetInputForAlfredWindowSearchBar(selectedText);

            alfredWindow.SearchSpecificInput(alfredInput);
        }