/// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if(String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
                return null;

            var textBlock = new TextBlock();

            switch(elementName)
            {
                case "conceptualLink":
                    var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                    string title, filename, relativePath;

                    bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id,
                        out title, out filename, out relativePath);

                    textBlock.Inlines.AddRange(new Inline[] {
                        new Bold(new Run("Title: ")),
                        new Run(title),
                        new LineBreak(),
                        new Bold(new Run("Filename: ")),
                        new Run(relativePath)
                    });

                    if(found && ctrlClickEnabled)
                        textBlock.Inlines.AddRange(new Inline[] {
                            new LineBreak(),
                            new Run("Ctrl+Click to open the file")
                        });
                    break;

                case "cref":
                    if(!ctrlClickEnabled)
                        return null;

                    if(!IntelliSense.RoslynHacks.RoslynUtilities.IsFinalRoslyn)
                        textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition (within solution only)"));
                    else
                        textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition"));
                    break;

                default:
                    if(!ctrlClickEnabled)
                        return null;

                    textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file"));
                    break;
            }

            // Set the styles in order to support other themes
            textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey);
            textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey);

            return textBlock;
        }
예제 #2
0
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if (String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
            {
                return(null);
            }

            var textBlock = new TextBlock();

            switch (elementName)
            {
            case "conceptualLink":
                var    projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                string title, filename, relativePath;

#pragma warning disable VSTHRD010
                bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id,
                                                            out title, out filename, out relativePath);
#pragma warning restore VSTHRD010

                textBlock.Inlines.AddRange(new Inline[] {
                    new Bold(new Run("Title: ")),
                    new Run(title),
                    new LineBreak(),
                    new Bold(new Run("Filename: ")),
                    new Run(relativePath)
                });

                if (found && ctrlClickEnabled)
                {
                    textBlock.Inlines.AddRange(new Inline[] {
                        new LineBreak(),
                        new Run("Ctrl+Click to open the file")
                    });
                }
                break;

            default:
                if (!ctrlClickEnabled)
                {
                    return(null);
                }

                textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file"));
                break;
            }

            // Set the styles in order to support other themes
            textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey);
            textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey);

            return(textBlock);
        }
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if (String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
            {
                return(null);
            }

            var textBlock = new TextBlock();

            switch (elementName)
            {
            case "image":
            case "link":
            case "topic":
                var    projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                string title, filename, relativePath;

                bool found = projectFileSearcher.GetInfoFor(elementName == "image" ?
                                                            ProjectFileSearcher.IdType.Image : ProjectFileSearcher.IdType.Link, id,
                                                            out title, out filename, out relativePath);

                textBlock.Inlines.AddRange(new Inline[] {
                    new Bold(new Run(elementName == "image" ? "Alternate Text: " : "Title: ")),
                    new Run(title),
                    new LineBreak(),
                    new Bold(new Run("Filename: ")),
                    new Run(relativePath)
                });

                break;

            case "codeEntityReference":
                break;

            default:
                break;
            }

            // Set the styles in order to support other themes in VS 2012 and later
            object themeKey = Utility.GetThemeKey("ToolTipBrushKey", SystemColors.ControlLightBrushKey);

            if (themeKey != null)
            {
                textBlock.SetResourceReference(TextBlock.BackgroundProperty, themeKey);
                textBlock.SetResourceReference(TextBlock.ForegroundProperty,
                                               Utility.GetThemeKey("ToolTipTextBrushKey", SystemColors.ControlTextBrushKey));
            }

            return(textBlock);
        }
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if(String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
                return null;

            var textBlock = new TextBlock();

            switch(elementName)
            {
                case "conceptualLink":
                    var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                    string title, filename, relativePath;

                    bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id,
                        out title, out filename, out relativePath);

                    textBlock.Inlines.AddRange(new Inline[] {
                        new Bold(new Run("Title: ")),
                        new Run(title),
                        new LineBreak(),
                        new Bold(new Run("Filename: ")),
                        new Run(relativePath)
                    });

                    if(found && ctrlClickEnabled)
                        textBlock.Inlines.AddRange(new Inline[] {
                            new LineBreak(),
                            new Run("Ctrl+Click to open the file")
                        });
                    break;

                case "cref":
                    if(!ctrlClickEnabled)
                        return null;

                    if(!IntelliSense.RoslynHacks.RoslynUtilities.IsFinalRoslyn)
                        textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition (within solution only)"));
                    else
                        textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition"));
                    break;

                default:
                    if(!ctrlClickEnabled)
                        return null;

                    textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file"));
                    break;
            }

            // Set the styles in order to support other themes
            textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey);
            textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey);

            return textBlock;
        }
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if(String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
                return null;

            var textBlock = new TextBlock();

            switch(elementName)
            {
                case "conceptualLink":
                    var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                    string title, filename, relativePath;

                    bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id,
                        out title, out filename, out relativePath);

                    textBlock.Inlines.AddRange(new Inline[] {
                        new Bold(new Run("Title: ")),
                        new Run(title),
                        new LineBreak(),
                        new Bold(new Run("Filename: ")),
                        new Run(relativePath)
                    });

                    break;

                case "cref":
                    break;

                default:
                    break;
            }

            // Set the styles in order to support other themes in VS 2012 and later
            object themeKey = Utility.GetThemeKey("ToolTipBrushKey", SystemColors.ControlLightBrushKey);

            if(themeKey != null)
            {
                textBlock.SetResourceReference(TextBlock.BackgroundProperty, themeKey);
                textBlock.SetResourceReference(TextBlock.ForegroundProperty,
                    Utility.GetThemeKey("ToolTipTextBrushKey", SystemColors.ControlTextBrushKey));
            }

            return textBlock;
        }
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if(String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
                return null;

            var textBlock = new TextBlock();

            switch(elementName)
            {
                case "image":
                case "link":
                case "topic":
                    var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                    string title, filename, relativePath;

                    bool found = projectFileSearcher.GetInfoFor(elementName == "image" ?
                        ProjectFileSearcher.IdType.Image : ProjectFileSearcher.IdType.Link, id,
                        out title, out filename, out relativePath);

                    textBlock.Inlines.AddRange(new Inline[] {
                        new Bold(new Run(elementName == "image" ? "Alternate Text: " : "Title: ")),
                        new Run(title),
                        new LineBreak(),
                        new Bold(new Run("Filename: ")),
                        new Run(relativePath)
                    });

                    if(elementName != "topic" && found & ctrlClickEnabled)
                        textBlock.Inlines.AddRange(new Inline[] {
                            new LineBreak(),
                            new Run("Ctrl+Click to open the file")
                        });
                    break;

                case "codeEntityReference":
                    if(!ctrlClickEnabled)
                        return null;

                    textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition (within solution only)"));
                    break;

                default:
                    if(!ctrlClickEnabled)
                        return null;

                    textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file"));
                    break;
            }

            // Set the styles in order to support other themes
            textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey);
            textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey);

            return textBlock;
        }
예제 #7
0
        /// <summary>
        /// This is used to get the content to add to the quick info by looking up the given topic ID to get its
        /// title and filename if possible.
        /// </summary>
        /// <param name="elementName">The element name for which to create content</param>
        /// <param name="id">The ID to look up if necessary</param>
        /// <returns>The content to add to the quick info (a text block element containing the additional info
        /// about the element)</returns>
        private UIElement CreateInfoText(string elementName, string id)
        {
            if (String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id))
            {
                return(null);
            }

            var textBlock = new TextBlock();

            switch (elementName)
            {
            case "image":
            case "link":
            case "topic":
                var    projectFileSearcher = new ProjectFileSearcher(serviceProvider, null);
                string title, filename, relativePath;

                bool found = projectFileSearcher.GetInfoFor(elementName == "image" ?
                                                            ProjectFileSearcher.IdType.Image : ProjectFileSearcher.IdType.Link, id,
                                                            out title, out filename, out relativePath);

                textBlock.Inlines.AddRange(new Inline[] {
                    new Bold(new Run(elementName == "image" ? "Alternate Text: " : "Title: ")),
                    new Run(title),
                    new LineBreak(),
                    new Bold(new Run("Filename: ")),
                    new Run(relativePath)
                });

                if (elementName != "topic" && found & ctrlClickEnabled)
                {
                    textBlock.Inlines.AddRange(new Inline[] {
                        new LineBreak(),
                        new Run("Ctrl+Click to open the file")
                    });
                }
                break;

            case "codeEntityReference":
                if (!ctrlClickEnabled)
                {
                    return(null);
                }

                textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition (within solution only)"));
                break;

            default:
                if (!ctrlClickEnabled)
                {
                    return(null);
                }

                textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file"));
                break;
            }

            // Set the styles in order to support other themes
            textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey);
            textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey);

            return(textBlock);
        }