Пример #1
0
        private static Uri GetHelpLink(Diagnostic diagnostic, out string helpLinkToolTipText)
        {
            var isBing = false;

            helpLinkToolTipText = string.Empty;

            Uri helpLink;

            if (!BrowserHelper.TryGetUri(diagnostic.Descriptor.HelpLinkUri, out helpLink))
            {
                // We use the ENU version of the message for bing search.
                helpLink = BrowserHelper.CreateBingQueryUri(diagnostic.Id, diagnostic.GetMessage(DiagnosticData.USCultureInfo));
                isBing   = true;
            }

            // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url dislayed in the tooltip stays human readable.
            if (helpLink != null)
            {
                helpLinkToolTipText =
                    string.Format(ServicesVSResources.DiagnosticIdHyperlinkTooltipText, diagnostic.Id,
                                  isBing ? ServicesVSResources.FromBing : null, Environment.NewLine, helpLink);
            }

            return(helpLink);
        }
Пример #2
0
        private static Uri GetHelpLink(DiagnosticData diagnostic, string language, string projectType, out string helpLinkToolTipText)
        {
            var isBing = false;

            helpLinkToolTipText = string.Empty;

            Uri helpLink;

            if (!BrowserHelper.TryGetUri(diagnostic.HelpLink, out helpLink))
            {
                // We use the ENU version of the message for bing search.
                helpLink = BrowserHelper.CreateBingQueryUri(diagnostic.Id, diagnostic.ENUMessageForBingSearch, language, projectType);
                isBing   = true;
            }

            // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url displayed in the tooltip stays human readable.
            if (helpLink != null)
            {
                helpLinkToolTipText =
                    string.Format(ServicesVSResources.Get_help_for_0_1_2_3, diagnostic.Id,
                                  isBing ? ServicesVSResources.from_Bing : null, Environment.NewLine, helpLink);
            }

            return(helpLink);
        }
        public static string GetHelpLink(DiagnosticData item)
        {
            if (BrowserHelper.TryGetUri(item.HelpLink, out var link))
            {
                return(link.AbsoluteUri);
            }

            if (!string.IsNullOrWhiteSpace(item.Id))
            {
                return(BrowserHelper.CreateBingQueryUri(item).AbsoluteUri);
            }

            return(null);
        }
        public static string GetHelpLink(Workspace workspace, DiagnosticData data)
        {
            if (BrowserHelper.TryGetUri(data.HelpLink, out var link))
            {
                return(link.AbsoluteUri);
            }

            if (!string.IsNullOrWhiteSpace(data.Id))
            {
                return(BrowserHelper.CreateBingQueryUri(workspace, data).AbsoluteUri);
            }

            return(null);
        }
                    private static string GetHelpLink(DiagnosticData item)
                    {
                        Uri link;

                        if (BrowserHelper.TryGetUri(item.HelpLink, out link))
                        {
                            return(link.AbsoluteUri);
                        }

                        if (!string.IsNullOrWhiteSpace(item.Id))
                        {
                            return(BrowserHelper.CreateBingQueryUri(item.Id, item.ENUMessageForBingSearch).AbsoluteUri);
                        }

                        return(null);
                    }
Пример #6
0
        public PreviewPane(Image severityIcon, string id, string title, string helpMessage, string description, string helpLink,
                           bool telemetry, object previewContent, IServiceProvider serviceProvider)
        {
            InitializeComponent();

            InitializeHyperlinkStyles();

            if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title))
            {
                HeaderStackPanel.Visibility = Visibility.Visible;

                SeverityIconBorder.Child = severityIcon;

                // Set the initial title text to three lines worth so that we can measure the pixel height
                // that WPF requires to render three lines of text under the current font and DPI settings.
                TitleRun.Text = s_dummyThreeLineTitle;
                TitleTextBlock.Measure(availableSize: s_infiniteSize);
                _heightForThreeLineTitle = TitleTextBlock.DesiredSize.Height;

                // Now set the actual title text.
                TitleRun.Text = title;

                Uri helpUri;
                if (BrowserHelper.TryGetUri(helpLink, out helpUri))
                {
                    InitializeDiagnosticIdHyperLink(id, helpUri, bingLink: false);
                }
                else
                {
                    InitializeDiagnosticIdHyperLink(id, BrowserHelper.CreateBingQueryUri(id, helpMessage), bingLink: true);
                }

                if (!string.IsNullOrWhiteSpace(description))
                {
                    DescriptionParagraph.Inlines.Add(description);
                }
            }

            InitializePreviewElement(previewContent);

            _serviceProvider = serviceProvider;
            _errorId         = id;

            // save permission whether we are allowed to save data as it is or not.
            _telemetry = telemetry;
        }
Пример #7
0
                    private string GetHelpLink(DiagnosticData item)
                    {
                        Uri link;

                        if (BrowserHelper.TryGetUri(item.HelpLink, out link))
                        {
                            return(link.AbsoluteUri);
                        }

                        if (!string.IsNullOrWhiteSpace(item.Id))
                        {
                            // TODO: once we link descriptor with diagnostic, get en-us message for Uri creation
                            return(BrowserHelper.CreateBingQueryUri(item.Id, item.MessageFormat).AbsoluteUri);
                        }

                        return(null);
                    }
Пример #8
0
        public Uri GetHelpLink()
        {
            if (BrowserHelper.TryGetUri(Descriptor.HelpLinkUri, out var link))
            {
                return(link);
            }

            if (!string.IsNullOrWhiteSpace(Descriptor.Id))
            {
                Workspace.GetLanguageAndProjectType(ProjectId, out var language, out var projectType);

                // we use message format here since we don't have actual instance of diagnostic here.
                // (which means we do not have a message)
                return(BrowserHelper.CreateBingQueryUri(Descriptor.Id, Descriptor.GetBingHelpMessage(), language, projectType));
            }

            return(null);
        }
Пример #9
0
        public Uri GetHelpLink()
        {
            Uri link;

            if (BrowserHelper.TryGetUri(Descriptor.HelpLinkUri, out link))
            {
                return(link);
            }

            if (!string.IsNullOrWhiteSpace(Descriptor.Id))
            {
                // we use message format here since we don't have actual instance of diagnostic here.
                // (which means we do not have a message)
                return(BrowserHelper.CreateBingQueryUri(Descriptor.Id, Descriptor.MessageFormat.ToString(DiagnosticData.USCultureInfo)));
            }

            return(null);
        }
        public static string GetHelpLinkToolTipText(DiagnosticData item)
        {
            var isBing = false;

            if (!BrowserHelper.TryGetUri(item.HelpLink, out var helpUri) && !string.IsNullOrWhiteSpace(item.Id))
            {
                helpUri = BrowserHelper.CreateBingQueryUri(item);
                isBing  = true;
            }

            // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url displayed in the tooltip stays human readable.
            if (helpUri != null)
            {
                return(string.Format(ServicesVSResources.Get_help_for_0_1_2_3, item.Id,
                                     isBing ? ServicesVSResources.from_Bing : null, Environment.NewLine, helpUri));
            }

            return(null);
        }
                    private static string GetHelpLinkToolTipText(DiagnosticData item)
                    {
                        var isBing  = false;
                        Uri helpUri = null;

                        if (!BrowserHelper.TryGetUri(item.HelpLink, out helpUri) && !string.IsNullOrWhiteSpace(item.Id))
                        {
                            helpUri = BrowserHelper.CreateBingQueryUri(item.Id, item.ENUMessageForBingSearch);
                            isBing  = true;
                        }

                        // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url dislayed in the tooltip stays human readable.
                        if (helpUri != null)
                        {
                            return(string.Format(ServicesVSResources.DiagnosticIdHyperlinkTooltipText, item.Id,
                                                 isBing ? ServicesVSResources.FromBing : null, Environment.NewLine, helpUri));
                        }

                        return(null);
                    }
        public static string GetHelpLinkToolTipText(DiagnosticData item)
        {
            var isBing = false;

            if (!BrowserHelper.TryGetUri(item.HelpLink, out var helpUri) && !string.IsNullOrWhiteSpace(item.Id))
            {
                helpUri = BrowserHelper.CreateBingQueryUri(item);
                isBing  = true;
            }

            // We make sure not to use Uri.AbsoluteUri for the url displayed in the tooltip so that the url displayed in the tooltip stays human readable.
            if (helpUri != null)
            {
                var prefix = isBing
                    ? string.Format(ServicesVSResources.Get_help_for_0_from_Bing, item.Id)
                    : string.Format(ServicesVSResources.Get_help_for_0, item.Id);

                return($"{prefix}\r\n{helpUri}");
            }

            return(null);
        }
Пример #13
0
        public Uri GetHelpLink()
        {
            Uri link;

            if (BrowserHelper.TryGetUri(Descriptor.HelpLinkUri, out link))
            {
                return(link);
            }

            if (!string.IsNullOrWhiteSpace(Descriptor.Id))
            {
                string language;
                string projectType;
                _analyzerItem.AnalyzersFolder.Workspace.GetLanguageAndProjectType(_analyzerItem.AnalyzersFolder.ProjectId, out language, out projectType);

                // we use message format here since we don't have actual instance of diagnostic here.
                // (which means we do not have a message)
                return(BrowserHelper.CreateBingQueryUri(Descriptor.Id, Descriptor.MessageFormat.ToString(DiagnosticData.USCultureInfo), language, projectType));
            }

            return(null);
        }
                    public bool TryCreateColumnContent(int index, string columnName, bool singleColumnView, out FrameworkElement content)
                    {
                        content = default(FrameworkElement);
                        if (columnName != ShimTableColumnDefinitions.ErrorCode)
                        {
                            return(false);
                        }

                        var item = GetItem(index);

                        if (item == null)
                        {
                            return(false);
                        }

                        Uri unused;

                        if (BrowserHelper.TryGetUri(item.HelpLink, out unused))
                        {
                            content = GetOrCreateTextBlock(ref _errorCodes, this.Count, index, item, i => GetHyperLinkTextBlock(i, new Uri(i.HelpLink, UriKind.Absolute), bingLink: false));
                            return(true);
                        }

                        if (!string.IsNullOrWhiteSpace(item.Id))
                        {
                            // TODO: once we link descriptor with diagnostic, get en-us message for Uri creation
                            content = GetOrCreateTextBlock(ref _errorCodes, this.Count, index, item, i => GetHyperLinkTextBlock(i, BrowserHelper.CreateBingQueryUri(item.Id, item.MessageFormat), bingLink: true));
                            return(true);
                        }

                        return(false);
                    }
Пример #15
0
        public PreviewPane(Image severityIcon, string id, string title, string helpMessage, string description, string helpLink,
                           bool telemetry, object previewContent, IServiceProvider serviceProvider)
        {
            InitializeComponent();

            InitializeHyperlinkStyles();

            if ((severityIcon != null) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(title))
            {
                HeaderStackPanel.Visibility = Visibility.Visible;

                SeverityIconBorder.Child = severityIcon;

                // Set the initial title text to three lines worth so that we can measure the pixel height
                // that WPF requires to render three lines of text under the current font and DPI settings.
                TitleRun.Text = s_dummyThreeLineTitle;
                TitleTextBlock.Measure(availableSize: s_infiniteSize);
                _heightForThreeLineTitle = TitleTextBlock.DesiredSize.Height;

                // Now set the actual title text.
                TitleRun.Text = title;

                Uri helpUri;
                if (BrowserHelper.TryGetUri(helpLink, out helpUri))
                {
                    InitializeDiagnosticIdHyperLink(id, helpUri, bingLink: false);
                }
                else
                {
                    InitializeDiagnosticIdHyperLink(id, BrowserHelper.CreateBingQueryUri(id, helpMessage), bingLink: true);
                }

                if (!string.IsNullOrWhiteSpace(description))
                {
                    DescriptionParagraph.Inlines.Add(description);
                }
            }

            FrameworkElement previewElement = null;

            if (previewContent is IWpfDifferenceViewer)
            {
                _previewDiffViewer          = previewContent as IWpfDifferenceViewer;
                previewElement              = _previewDiffViewer.VisualElement;
                PreviewDockPanel.Background = _previewDiffViewer.InlineView.Background;
            }
            else if (previewContent is string)
            {
                previewElement = GetPreviewForString(previewContent as string);
            }
            else if (previewContent is FrameworkElement)
            {
                previewElement = previewContent as FrameworkElement;
            }
            else
            {
                // previewContent is either null or some type that we don't know how to display.
                previewElement = GetEmptyPreview();
            }

            PreviewScrollViewer.Content        = previewElement;
            previewElement.VerticalAlignment   = VerticalAlignment.Top;
            previewElement.HorizontalAlignment = HorizontalAlignment.Left;

            // 1. Width of the header section should not exceed the width of the preview content.
            // In other words, the text we put in the header at the top of the preview pane
            // should not cause the preview pane itself to grow wider than the width required to
            // display the preview content at the bottom of the pane.
            // 2. Adjust the height of the header section so that it displays only three lines worth
            // by default.
            AdjustWidthAndHeight(previewElement);

            _serviceProvider = serviceProvider;
            _errorId         = id;

            // save permission whether we are allowed to save data as it is or not.
            _telemetry = telemetry;
        }