// This method adjusts the width of the header section to match that of the preview content // thereby ensuring that the preview pane itself is never wider than the preview content. // This method also adjusts the height of the header section so that it displays only three lines // worth by default. private void AdjustWidthAndHeight(FrameworkElement previewElement) { PreviewDockPanel.Measure(availableSize: new Size(previewElement.Width, double.PositiveInfinity)); var width = PreviewDockPanel.DesiredSize.Width; if (IsNormal(width)) { HeaderStackPanel.Width = width; TitleTextBlock.Measure(availableSize: new Size(width, double.PositiveInfinity)); var height = TitleTextBlock.DesiredSize.Height; // If the pixel height required to render the complete title in the // TextBlock is larger than that required to render three lines worth, // then trim the contents of the TextBlock with an ellipsis at the end and // display the expander button that will allow users to view the full text. if ((IsNormal(height) && (height > _heightForThreeLineTitle)) || HasDescription) { TitleTextBlock.MaxHeight = _heightForThreeLineTitle; TitleTextBlock.TextTrimming = TextTrimming.CharacterEllipsis; ExpanderToggleButton.Visibility = Visibility.Visible; if (_isExpanded) { ExpanderToggleButton.IsChecked = true; } } } }
public PreviewPane(Image severityIcon, string id, string title, string description, Uri helpLink, string helpLinkToolTipText, object previewContent, bool logIdVerbatimInTelemetry) { InitializeComponent(); _id = id; _logIdVerbatimInTelemetry = logIdVerbatimInTelemetry; // Initialize header portion. 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; InitializeHyperlinks(helpLink, helpLinkToolTipText); if (!string.IsNullOrWhiteSpace(description)) { DescriptionParagraph.Inlines.Add(description); } } // Initialize preview (i.e. diff view) portion. InitializePreviewElement(previewContent); }
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; }
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; }