Exemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         try
         {
         }
         catch (Exception)
         {
         }
         this.m_GetOpenFilesThread.Exit();
         this.m_TextFinder.Exit();
         this.m_SolutionFiles.Exit();
         this.m_Settings.Exit();
         FastFindToolWindowPane.Destroy();
         if (this.m_Solution != null && this.m_SolutionEventsCookie != 0u)
         {
             this.m_Solution.UnadviseSolutionEvents(this.m_SolutionEventsCookie);
         }
         this.Dispose();
     }
     catch (Exception e)
     {
         Log.Write(e.Message + "\n" + e.StackTrace);
     }
     base.Dispose(disposing);
 }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            base.Initialize();
            try
            {
                Log.OpenFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\VSAnything\\VSAnything.log");
                VSAnythingPackage.m_Inst = this;
                Log.WriteLine("----------------------------------------------------------");
                Log.WriteLine("FastFind Initialise");
                Log.WriteLine("FastFind Version: 4.8");
                this.m_Settings.Read();
                EnvDTE.DTE env_dte = (EnvDTE.DTE)base.GetService(typeof(SDTE));
                string     vs_version;
                try
                {
                    vs_version = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                }
                catch (Exception e)
                {
                    vs_version = "Error getting VS version: " + e.Message;
                }
                Log.WriteLine("Visual Studio Version: " + vs_version);
                this.m_DTE        = new DTE(env_dte);
                this.m_TextFinder = new TextFinder();
                this.m_FileFinder = new FileFinder(this.m_Settings);
                this.m_FileFinder.SetSolutionFiles(new List <string>(this.m_Settings.SolutionFiles));
                this.m_SolutionFiles      = new SolutionFiles(this.m_DTE);
                this.m_GetOpenFilesThread = new GetOpenFilesThread(env_dte);
                this.m_SolutionFiles.SolutionFileListChanged += new SolutionFiles.SolutionFileListChangedHandler(this.SolutionFilesChanged);
                this.m_DocumentEvents = env_dte.Events.get_DocumentEvents(null);
                this.m_SolutionEvents = env_dte.Events.SolutionEvents;
                this.m_WindowEvents   = env_dte.Events.get_WindowEvents(null);

                //mariotodo 改成下面那样,不知道对不对
                //this.m_DocumentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this, (UIntPtr)System.Reflection.Emit.OpCodes.Ldftn(DocumentSaved));
                //this.m_SolutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this, (UIntPtr)ldftn(ProjectAddedOrRemoved));
                //this.m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this, (UIntPtr)ldftn(ProjectAddedOrRemoved));
                //this.m_WindowEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this, (UIntPtr)ldftn(WindowActivated));

                this.m_DocumentEvents.DocumentSaved  += new _dispDocumentEvents_DocumentSavedEventHandler(this.DocumentSaved);
                this.m_SolutionEvents.ProjectAdded   += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAddedOrRemoved);
                this.m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectAddedOrRemoved);
                this.m_WindowEvents.WindowActivated  += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated);

                FastFindToolWindowPane.Initialise(this.m_DTE, this.m_SolutionFiles, this.m_FileFinder, this.m_TextFinder, this.m_GetOpenFilesThread, this.m_Settings);
                OleMenuCommandService mcs = base.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                this.m_FastFindCmd.Initialise(this.m_DTE, this.m_SolutionFiles, this.m_FileFinder, this.m_TextFinder, this.m_GetOpenFilesThread, mcs, this.m_Settings);
                this.m_FastFindWindowCmd.Initialise(this, this.m_DTE, mcs, this.m_Settings);
                this.m_SourceHeaderToggleCmd.Initialise(this.m_DTE, this.m_SolutionFiles, mcs);
                this.m_SettingsCmd.Initialise(mcs);
                this.m_Solution = (base.GetService(typeof(SVsSolution)) as IVsSolution2);
                if (this.m_Solution != null)
                {
                    int ret = this.m_Solution.AdviseSolutionEvents(this, out this.m_SolutionEventsCookie);
                    Log.WriteLine("AdviseSolutionEvents returned " + ret);
                }
                this.AddSolutionFileToSettings();
                if (this.m_DTE.EnvDTE.Solution != null)
                {
                    foreach (Project project in this.m_DTE.EnvDTE.Solution.Projects)
                    {
                        IVsHierarchy pHierarchy = null;
                        if (this.m_Solution.GetProjectOfUniqueName(project.UniqueName, out pHierarchy) == 0 && pHierarchy != null)
                        {
                            this.AdviseHierarchyEvents(pHierarchy);
                        }
                    }
                }
                if (!this.m_Settings.ShownWelcomeForm)
                {
                    new System.Threading.Thread(new ThreadStart(this.WelcomeThread)).Start();
                }
            }
            catch (Exception arg_368_0)
            {
                Utils.LogException(arg_368_0);
            }
        }