public void ActivateDoc(string filename, int line, bool force)
 {
     VSAnythingPackage.ActivateDocEvent activation_event = new VSAnythingPackage.ActivateDocEvent();
     filename = Utils.NormalisePathAndLowerCase(filename);
     activation_event.m_SetLine     = true;
     activation_event.m_RequestTime = Environment.TickCount;
     activation_event.m_Filename    = filename;
     activation_event.m_Line        = line;
     this.m_ActivateDocEvents[activation_event.m_Filename] = activation_event;
     if (force)
     {
         this.m_ForceActivateDocCount = 2;
         this.m_ForceActivateDocEvent = activation_event;
     }
 }
        private void WindowActivated(Window GotFocus, Window LostFocus)
        {
            if (GotFocus.Caption == VSAnythingPackage.m_ProductName)
            {
                //this.m_FastFindWindowCmd.SelectText(false);
            }
            string doc_name = null;

            if (GotFocus != null && GotFocus.Document != null)
            {
                doc_name = Utils.NormalisePathAndLowerCase(GotFocus.Document.FullName);
            }
            VSAnythingPackage.ActivateDocEvent active_doc_event = this.GetActivateDocEvent(doc_name);
            if (active_doc_event != null && Utils.NormalisePathAndLowerCase(this.m_DTE.GetActiveDocumentFilename()) == active_doc_event.m_Filename && active_doc_event.m_SetLine)
            {
                if (active_doc_event.m_Line != -1)
                {
                    this.m_DTE.SetActiveDocumentLine(active_doc_event.m_Line);
                    /// 通过ListBox打开文档后,把焦点拿回来,否则在非autoHide 情况下,界面不会关掉,很烦
                    ToolWindowPane window = VSAnythingPackage.Inst.FindToolWindow(typeof(FastFindToolWindowPane), 0, true);
                    if (window != null && window.Frame != null)
                    {
                        Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame frame = (Microsoft.VisualStudio.Shell.Interop.IVsWindowFrame)window.Frame;
                        if (frame != null && frame.IsVisible() == 0) // 0 is visible !!!
                        {
                            frame.Show();
                        }
                    }
                }
                active_doc_event.m_SetLine = false;
            }
            if (this.m_ForceActivateDocEvent != null && doc_name != this.m_ForceActivateDocEvent.m_Filename)
            {
                if (Environment.TickCount - this.m_ForceActivateDocEvent.m_RequestTime < 200 && this.m_ForceActivateDocCount > 0)
                {
                    this.m_ForceActivateDocCount--;
                    this.m_ForceActivateDocEvent.m_SetLine = true;
                    this.m_DTE.OpenFile(this.m_ForceActivateDocEvent.m_Filename);
                    return;
                }
                this.m_ForceActivateDocEvent = null;
            }
        }