Beispiel #1
0
        string GetIDEName(string selectorPattern)
        {
            try
            {
                Match m = GetMatchingPattern(DTEService.Get().MainWindow.Caption, selectorPattern);

                if (!m.Success || m.Groups.Count < 2)
                {
                    return(null);
                }

                if (m.Groups.Count >= 3)
                {
                    return(m.Groups[2].Captures[0].Value);
                }

                return(m.Groups[1].Captures[0].Value);
            }
            catch (Exception ex)
            {
                mLog.LogEntry(
                    (UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
                    "WindowTitleBuilder",
                    string.Format("Couldn't get IDE name: {0}", ex.Message));
            }

            return(string.Empty);
        }
Beispiel #2
0
        string GetWindowTitlePattern()
        {
            DTE2     dte      = DTEService.Get();
            Solution solution = dte.Solution;

            if (solution == null || solution.FullName == string.Empty)
            {
                var document = dte.ActiveDocument;
                var window   = dte.ActiveWindow;
                if ((document == null || string.IsNullOrEmpty(document.FullName)) &&
                    (window == null || string.IsNullOrEmpty(window.Caption)))
                {
                    return(IDE_NAME);
                }

                return(string.Format("{0} - {1}", DOCUMENT_NAME, IDE_NAME));
            }

            if (dte.Debugger == null || dte.Debugger.CurrentMode == dbgDebugMode.dbgDesignMode)
            {
                return(string.Format("{0}{1} - {2}", SOLUTION_NAME, PLASTIC_SELECTOR, IDE_NAME));
            }

            if (dte.Debugger.CurrentMode == dbgDebugMode.dbgBreakMode)
            {
                return(string.Format("{0} (Debugging){1} - {2}", SOLUTION_NAME, PLASTIC_SELECTOR, IDE_NAME));
            }

            if (dte.Debugger.CurrentMode == dbgDebugMode.dbgRunMode)
            {
                return(string.Format("{0} (Running){1} - {2}", SOLUTION_NAME, PLASTIC_SELECTOR, IDE_NAME));
            }

            return(IDE_NAME);
        }
Beispiel #3
0
        Match GetMatchingPattern(string currentTitle, string selectorPattern)
        {
            DTE2 dte = DTEService.Get();

            Match match = new Regex(
                @"^(.*) - (" + dte.Name + ".*) " + Regex.Escape(string.Format("{0} {1}", selectorPattern, "(.*)")) + "$",
                RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
            {
                return(match);
            }

            match = new Regex(@"^(.*) - (" + dte.Name + @".* \(.+\)) \(.+\)$", RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
            {
                return(match);
            }

            match = new Regex(@"^(.*) - (" + dte.Name + ".*)$", RegexOptions.RightToLeft).Match(currentTitle);

            if (match.Success)
            {
                return(match);
            }

            match = new Regex(@"^(" + dte.Name + ".*)$", RegexOptions.RightToLeft).Match(currentTitle);
            return(match);
        }
Beispiel #4
0
        string GetActiveDocumentName(Document activeDocument, Window activeWindow)
        {
            if (activeDocument != null)
            {
                return(Path.GetFileName(activeDocument.FullName));
            }

            if (activeWindow != null && activeWindow.Caption != DTEService.Get().MainWindow.Caption)
            {
                return(activeWindow.Caption);
            }

            return(string.Empty);
        }
Beispiel #5
0
        internal string BuildWindowTitle()
        {
            if (mIdeName == null && DTEService.Get().MainWindow != null)
            {
                mIdeName = GetIDEName(SELECTOR_PATTERN);
            }

            if (string.IsNullOrEmpty(mIdeName))
            {
                return(null);
            }

            return(GetNewTitle(mIdeName, GetWindowTitlePattern()));
        }
        protected override void Initialize()
        {
            base.Initialize();

            ActivityLog.Initialize(GetService(typeof(SVsActivityLog)) as IVsActivityLog);

            mWindowTitleBuilder = new WindowTitleBuilder();
            mSelectorWatcher    = new SelectorWatcher(mWindowTitleBuilder);
            mTitleUpdater       = new WindowTitleUpdater(mWindowTitleBuilder);

            DTEService.Get().Events.SolutionEvents.AfterClosing += SolutionClosed;
            DTEService.Get().Events.SolutionEvents.Opened += SolutionOpened;

            mTitleUpdater.Start();
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!disposing)
            {
                return;
            }

            DTEService.Get().Events.SolutionEvents.AfterClosing -= SolutionClosed;
            DTEService.Get().Events.SolutionEvents.Opened -= SolutionOpened;

            if (mTitleUpdater != null)
            {
                mTitleUpdater.Stop();
            }

            if (mSelectorWatcher != null)
            {
                mSelectorWatcher.StopWatcher();
            }
        }
Beispiel #8
0
        string GetNewTitle(string ideName, string pattern)
        {
            DTE2     dte            = DTEService.Get();
            Solution solution       = dte.Solution;
            Document activeDocument = dte.ActiveDocument;
            Window   activeWindow   = dte.ActiveWindow;

            if (activeDocument == null && (solution == null || string.IsNullOrEmpty(solution.FullName)))
            {
                var window = dte.ActiveWindow;
                if (window == null || window.Caption == dte.MainWindow.Caption)
                {
                    return(ideName);
                }
            }

            pattern = pattern.Replace(DOCUMENT_NAME, GetActiveDocumentName(activeDocument, activeWindow));
            pattern = pattern.Replace(SOLUTION_NAME, GetSolutionName(solution));
            pattern = pattern.Replace(IDE_NAME, ideName);
            pattern = pattern.Replace(PLASTIC_SELECTOR, GetSelectorString());

            return(pattern);
        }
 void SolutionOpened()
 {
     mSelectorWatcher.StartWatcher(DTEService.Get().Solution.FullName);
 }