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;
            }
        }
        private void ExecuteErrrorListMenu(object sender, 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;

            alfredWindow.SearchSelectedErrorAsync();
        }
        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);
        }
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ExecuteToolMenu(object sender, EventArgs e)
        {
            // *** CODE DUPLICATION extracted to method but havent used here
            ThreadHelper.ThrowIfNotOnUIThread();

            // 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.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;
            //alfredWindow.SearchSelectedErrorAsync();

            // if there is selected error so search the error
        }