private void MeasureText() { string text = this._text; if (this._preview) { ScrollableTextBlock scrollableTextBlock = this._textBlockFull; if ((scrollableTextBlock != null ? scrollableTextBlock.Parent : (DependencyObject)null) != null) { return; } int length = text.Length; if (length > 300) { text = BrowserNavigationService.CutTextGently(text, 300); if (!this._supportExpandText) { text = text.Trim() + "..."; } this._showReadFull = text.Length != length; } this._textBlockPreview.TextId = this._textId; this._textBlockPreview.Text = ""; this._textBlockPreview.FontSize = this._fontSize == 0.0 ? 20.0 : this._fontSize; this._textBlockPreview.FontFamily = this._fontFamily ?? new FontFamily("Segoe WP"); this._textBlockPreview.Foreground = this._foreground ?? Application.Current.Resources["PhoneAlmostBlackBrush"] as Brush; this._textBlockPreview.TextWrapping = TextWrapping.Wrap; this._textBlockPreview.Width = this.Width; if (this._lineHeight > 0.0) { this._textBlockPreview.LineHeight = this._lineHeight; } this._textBlockPreview.Text = text; Grid grid = (Grid)((UserControl)((ContentControl)Application.Current.RootVisual).Content).Content; Canvas canvas = new Canvas(); grid.Children.Add((UIElement)canvas); canvas.Children.Add((UIElement)this._textBlockPreview); canvas.UpdateLayout(); if (this._horizontalWidth > 0.1) { this._horizontalHeight = this._textBlockPreview.ActualHeight; } this._textBlockPreview.Width = this._verticalWidth; canvas.UpdateLayout(); this._verticalHeight = this._textBlockPreview.ActualHeight; canvas.Children.Remove((UIElement)this._textBlockPreview); grid.Children.Remove((UIElement)canvas); if (!this._showReadFull || !this._supportExpandText) { return; } this._verticalHeight = this._verticalHeight + 31.6; } else { ScrollableTextBlock scrollableTextBlock1 = this._textBlockFull; if ((scrollableTextBlock1 != null ? scrollableTextBlock1.Parent : (DependencyObject)null) != null) { return; } ScrollableTextBlock scrollableTextBlock2 = new ScrollableTextBlock(); scrollableTextBlock2.TextId = this._textId; int num1 = 0; scrollableTextBlock2.VerticalAlignment = (VerticalAlignment)num1; int num2 = (int)this._horizontalContentAlignment; scrollableTextBlock2.HorizontalContentAlignment = (HorizontalAlignment)num2; int num3 = (int)this._textAlignment; scrollableTextBlock2.TextAlignment = (TextAlignment)num3; string str = text; scrollableTextBlock2.Text = str; double num4 = this._fontSize == 0.0 ? 20.0 : this._fontSize; scrollableTextBlock2.FontSize = num4; FontFamily fontFamily = this._fontFamily ?? new FontFamily("Segoe WP"); scrollableTextBlock2.FontFamily = fontFamily; Brush brush = this._foreground ?? Application.Current.Resources["PhoneAlmostBlackBrush"] as Brush; scrollableTextBlock2.Foreground = brush; this._textBlockFull = scrollableTextBlock2; if (this._lineHeight > 0.0) { this._textBlockFull.LineHeight = this._lineHeight; } if (this._horizontalWidth > 0.1) { this._textBlockFull.Width = this._horizontalWidth; } Grid grid = (Grid)((UserControl)((ContentControl)Application.Current.RootVisual).Content).Content; Canvas canvas = new Canvas(); grid.Children.Add((UIElement)canvas); canvas.Children.Add((UIElement)this._textBlockFull); canvas.UpdateLayout(); if (this._horizontalWidth > 0.1) { this._horizontalHeight = this._textBlockFull.ActualHeight; } this._textBlockFull.Width = this._verticalWidth; canvas.UpdateLayout(); this._verticalHeight = this._textBlockFull.ActualHeight; canvas.Children.Remove((UIElement)this._textBlockFull); grid.Children.Remove((UIElement)canvas); } }
private void MeasureText() { string text = this._text; if (this._preview) { ScrollableTextBlock textBlockFull = this._textBlockFull; if ((textBlockFull != null ? textBlockFull.Parent : null) != null) { return; } this._textBlockPreview.TextId = this._textId; this._textBlockPreview.FontSize = (this._fontSize == 0.0 ? 20.0 : this._fontSize); this._textBlockPreview.FontFamily = (this._fontFamily ?? new FontFamily("Segoe WP")); this._textBlockPreview.Foreground = (this._foreground ?? Application.Current.Resources["PhoneAlmostBlackBrush"] as Brush); this._textBlockPreview.TextWrapping = TextWrapping.Wrap; this._textBlockPreview.Width = this._verticalWidth; this._textBlockPreview.Text = this._text; this._textBlockPreview.DisableHyperlinks = this._disableHyperlinks; this._textBlockPreview.HideHyperlinksForeground = this._hideHyperlinksForeground; if (this._lineHeight > 0.0) { this._textBlockPreview.LineHeight = this._lineHeight; } Grid content = (Grid)((UserControl)((ContentControl)Application.Current.RootVisual).Content).Content; Canvas canvas = new Canvas(); content.Children.Add(canvas); canvas.Children.Add(this._textBlockPreview); canvas.UpdateLayout(); int int32 = Convert.ToInt32((this._textBlockPreview).ActualHeight / 28.0); if (int32 > 15) { string str = BrowserNavigationService.CutTextGently(text, 399); if (str != text) { this._textBlockPreview.Text = str.Trim() + "..."; this._showReadFull = true; canvas.UpdateLayout(); } if (int32 > 150) { this._expandOnNewPageOnly = true; } } if (this._horizontalWidth > 0.1) { this._horizontalHeight = this._textBlockPreview.ActualHeight; } ((UIElement)canvas).UpdateLayout(); this._verticalHeight = ((FrameworkElement)this._textBlockPreview).ActualHeight; canvas.Children.Remove((UIElement)this._textBlockPreview); content.Children.Remove((UIElement)canvas); if (!this._showReadFull || !this._supportExpandText) { return; } this._verticalHeight = this._verticalHeight + 31.6; } else { ScrollableTextBlock textBlockFull = this._textBlockFull; if ((textBlockFull != null ? ((FrameworkElement)textBlockFull).Parent : null) != null) { return; } ScrollableTextBlock scrollableTextBlock = new ScrollableTextBlock(); scrollableTextBlock.TextId = this._textId; int num1 = 0; ((FrameworkElement)scrollableTextBlock).VerticalAlignment = ((VerticalAlignment)num1); HorizontalAlignment contentAlignment = this._horizontalContentAlignment; scrollableTextBlock.HorizontalContentAlignment = contentAlignment; TextAlignment textAlignment = this._textAlignment; scrollableTextBlock.TextAlignment = textAlignment; string str = text; scrollableTextBlock.Text = str; double num2 = this._fontSize == 0.0 ? 20.0 : this._fontSize; scrollableTextBlock.FontSize = num2; FontFamily fontFamily = this._fontFamily ?? new FontFamily("Segoe WP"); scrollableTextBlock.FontFamily = fontFamily; Brush brush = this._foreground ?? Application.Current.Resources["PhoneAlmostBlackBrush"] as Brush; scrollableTextBlock.Foreground = brush; this._textBlockFull = scrollableTextBlock; this._textBlockFull.DisableHyperlinks = this._disableHyperlinks; this._textBlockFull.HideHyperlinksForeground = this._hideHyperlinksForeground; if (this._lineHeight > 0.0) { this._textBlockFull.LineHeight = this._lineHeight; } if (this._horizontalWidth > 0.1) { ((FrameworkElement)this._textBlockFull).Width = this._horizontalWidth; } Grid content = (Grid)((UserControl)((ContentControl)Application.Current.RootVisual).Content).Content; Canvas canvas = new Canvas(); content.Children.Add((UIElement)canvas); canvas.Children.Add((UIElement)this._textBlockFull); ((UIElement)canvas).UpdateLayout(); if (this._horizontalWidth > 0.1) { this._horizontalHeight = ((FrameworkElement)this._textBlockFull).ActualHeight; } ((FrameworkElement)this._textBlockFull).Width = this._verticalWidth; ((UIElement)canvas).UpdateLayout(); this._verticalHeight = ((FrameworkElement)this._textBlockFull).ActualHeight; ((PresentationFrameworkCollection <UIElement>)((Panel)canvas).Children).Remove((UIElement)this._textBlockFull); ((PresentationFrameworkCollection <UIElement>)((Panel)content).Children).Remove((UIElement)canvas); } }