private void ParseText(string value)
        {
            if (value == null)
            {
                value = "";
            }

            if (this.stackPanel == null)
            {
                return;
            }
            // Clear previous TextBlocks
            this.stackPanel.Children.Clear();


            bool fitIn2000Pixels = CheckFitInMaxRenderHeight(value);

            if (fitIn2000Pixels)
            {
                RichTextBox textBlock = this.GetTextBlock();
                BrowserNavigationService.SetText(textBlock, value);
                this.stackPanel.Children.Add(textBlock);
            }
            else
            {
                ParseLineExtended(value);
            }
        }
示例#2
0
        private void ParseText(string value)
        {
            if (value == null)
            {
                value = "";
            }

            if (_stackPanel == null)
            {
                return;
            }
            // Clear previous TextBlocks
            _stackPanel.Children.Clear();

            var suppressParsing = BrowserNavigationService.GetSuppressParsing(this);
            var message         = DataContext as TLMessageBase;
            var fitIn2000Pixels = CheckFitInMaxRenderHeight(value);

            if (fitIn2000Pixels)
            {
                var textBlock = GetTextBlock();
                BrowserNavigationService.SetSuppressParsing(textBlock, suppressParsing);
                BrowserNavigationService.SetMessage(textBlock, message);
                BrowserNavigationService.SetText(textBlock, value);
                _stackPanel.Children.Add(textBlock);
            }
            else
            {
                ParseLineExtended(value);
            }
        }
        private FrameworkElement CreateButton(TLKeyboardButton keyboardButton, double height, double margin)
        {
            var isLightTheme = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;
            var background   = isLightTheme ? (Brush)Resources["ButtonLightBackground"] : (Brush)Resources["ButtonBackground"];

            var text    = keyboardButton.Text.ToString();
            var textBox = new TelegramRichTextBox {
                Text = text, MaxHeight = height, Margin = new Thickness(0.0, -4.0, 0.0, 0.0), FontSize = 22, FontFamily = new FontFamily("Segoe WP Semibold")
            };

            BrowserNavigationService.SetSuppressParsing(textBox, true);

            var button = new Button();

            button.Style      = (Style)Resources["CommandButtonStyle"];
            button.Height     = height;
            button.Margin     = new Thickness(margin);
            button.Background = background;

            button.Content     = textBox;
            button.DataContext = keyboardButton;
            button.Click      += OnButtonClick;

            return(button);
        }
示例#4
0
        public void Initialize(NewsActivityComment activityComment, IEnumerable <User> users, IEnumerable <Group> groups, bool addSeparator)
        {
            if (activityComment.from_id > 0L)
            {
                User user = users != null?Enumerable.FirstOrDefault <User>(users, (Func <User, bool>)(u => u.id == activityComment.from_id)) : null;

                if (user != null)
                {
                    this._userName = user.Name;
                    string photoMax = user.photo_max;
                    if (!string.IsNullOrEmpty(photoMax))
                    {
                        this._userPhotoUri = new Uri(photoMax);
                    }
                }
            }
            else
            {
                Group group = groups != null?Enumerable.FirstOrDefault <Group>(groups, (Func <Group, bool>)(u => u.id == -activityComment.from_id)) : null;

                if (group != null)
                {
                    this._userName = group.name;
                    string photo200 = group.photo_200;
                    if (!string.IsNullOrEmpty(photo200))
                    {
                        this._userPhotoUri = new Uri(photo200);
                    }
                }
            }
            BrowserNavigationService.SetText((DependencyObject)this.textBoxComment, UIStringFormatterHelper.SubstituteMentionsWithNames(activityComment.text ?? ""));
            BrowserNavigationService.SetDisableHyperlinks((DependencyObject)this.textBoxComment, true);
            ((UIElement)this.textBoxComment).Measure(new Size(364.0, double.PositiveInfinity));
            Size desiredSize = ((UIElement)this.textBoxComment).DesiredSize;
            // ISSUE: explicit reference operation
            double height = ((Size)@desiredSize).Height;

            if (!double.IsNaN(height) && !double.IsInfinity(height) && height < 48.0)
            {
                this._height = this._height - 24.0;
            }
            this._addSeparator      = addSeparator;
            this.textBlockName.Text = this._userName;
            this.textBlockName.CorrectText(364.0);
            Canvas.SetTop((UIElement)this.borderChevron, this._height / 2.0 - ((FrameworkElement)this.borderChevron).Height / 2.0);
            if (this._addSeparator)
            {
                Canvas.SetTop((UIElement)this.rectSeparator, this._height - ((FrameworkElement)this.rectSeparator).Height);
                ((UIElement)this.rectSeparator).Visibility = Visibility.Visible;
            }
            ((FrameworkElement)this.canvasBackground).Height = this._height;
            ((FrameworkElement)this.canvas).Height           = this._height;
        }
示例#5
0
 private void GeneratePhotoText()
 {
     if (!string.IsNullOrEmpty(this.PhotoVM.Text))
     {
         BrowserNavigationService.SetText((DependencyObject)this.textPhotoText, this.PhotoVM.Text);
         ((UIElement)this.textPhotoText).Visibility = Visibility.Visible;
     }
     else
     {
         BrowserNavigationService.SetText((DependencyObject)this.textPhotoText, "");
         ((UIElement)this.textPhotoText).Visibility = Visibility.Collapsed;
     }
 }
        private void ParseLineExtended(string allText)
        {
            if (string.IsNullOrEmpty(allText))
            {
                return;
            }


            int cutIndex = MAX_STR_LENGTH;

            if (cutIndex >= allText.Length)
            {
                cutIndex = allText.Length - 1;
            }

            var endOfSentenceIndAfterCut = allText.IndexOf(".", cutIndex);

            if (endOfSentenceIndAfterCut >= 0 && endOfSentenceIndAfterCut - cutIndex < 200)
            {
                cutIndex = endOfSentenceIndAfterCut;
            }
            else
            {
                var whiteSpaceIndAfterCut = allText.IndexOf(' ', cutIndex);

                if (whiteSpaceIndAfterCut >= 0 && whiteSpaceIndAfterCut - cutIndex < 100)
                {
                    cutIndex = whiteSpaceIndAfterCut;
                }
            }

            // add all whitespaces before cut
            while (cutIndex + 1 < allText.Length &&
                   allText[cutIndex + 1] == ' ')
            {
                cutIndex++;
            }

            string      leftSide  = allText.Substring(0, cutIndex + 1);
            RichTextBox textBlock = this.GetTextBlock();

            BrowserNavigationService.SetText(textBlock, leftSide);
            this.stackPanel.Children.Add(textBlock);

            allText = allText.Substring(cutIndex + 1);

            if (allText.Length > 0)
            {
                ParseLineExtended(allText);
            }
        }
示例#7
0
        private void ParseText(string value)
        {
            if (value == null)
            {
                value = "";
            }

            if (_stackPanel == null)
            {
                return;
            }

            //System.Diagnostics.Debug.WriteLine("{0} ParseText", GetHashCode());
            // Clear previous TextBlocks
            _stackPanel.Children.Clear();

            var suppressParsing  = BrowserNavigationService.GetSuppressParsing(this);
            var message          = DataContext as TLMessageBase ?? BrowserNavigationService.GetMessage(this);
            var decryptedMessage = DataContext as TLDecryptedMessageBase;
            var fitIn2000Pixels  = CheckFitInMaxRenderHeight(value);

            if (fitIn2000Pixels)
            {
                var textBlock = GetTextBlock();
                BrowserNavigationService.SetSuppressParsing(textBlock, suppressParsing);
                BrowserNavigationService.SetMessage(textBlock, message);
                BrowserNavigationService.SetDecryptedMessage(textBlock, decryptedMessage);
                BrowserNavigationService.SetAddFooter(textBlock, true);
                BrowserNavigationService.SetText(textBlock, value);
                _stackPanel.Children.Add(textBlock);

                _footerRun = GetFooter(textBlock);
            }
            else
            {
                ParseLineExtended(value);
            }
        }
示例#8
0
        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);
            }
        }
示例#9
0
        public static void ShowPhotoIsSavedInSavedPhotos()
        {
            GenericInfoUC genericInfoUc = new GenericInfoUC(3000);

            ((UIElement)genericInfoUc.richTextBox).Visibility   = Visibility.Visible;
            ((UIElement)genericInfoUc.textBlockInfo).Visibility = Visibility.Collapsed;
            RichTextBox richTextBox = genericInfoUc.richTextBox;
            Paragraph   paragraph   = new Paragraph();
            string      text1       = CommonResources.PhotoIsSaved.Replace(".", "") + " ";

            ((PresentationFrameworkCollection <Inline>)paragraph.Inlines).Add((Inline)BrowserNavigationService.GetRunWithStyle(text1, richTextBox));
            Hyperlink hyperlink = HyperlinkHelper.GenerateHyperlink(CommonResources.InTheAlbum, "", (Action <Hyperlink, string>)((hl, str) => Navigator.Current.NavigateToPhotoAlbum(AppGlobalStateManager.Current.LoggedInUserId, false, "SavedPhotos", "", CommonResources.AlbumSavedPictures, 1, "", "", false, 0, false)), ((Control)richTextBox).Foreground, HyperlinkState.Normal);

            ((TextElement)hyperlink).FontSize = (((Control)richTextBox).FontSize);
            ((PresentationFrameworkCollection <Inline>)paragraph.Inlines).Add((Inline)hyperlink);
            ((PresentationFrameworkCollection <Block>)richTextBox.Blocks).Add((Block)paragraph);
            string text2 = "";

            // ISSUE: variable of the null type

            genericInfoUc.ShowAndHideLater(text2, null);
        }
        private FrameworkElement CreateButton(TLKeyboardButtonBase keyboardButton, double height, Thickness margin, double padding, int maxTextLength)
        {
            var isLightTheme = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;
            var background   = isLightTheme ? (Brush)Resources["ButtonLightBackground"] : (Brush)Resources["ButtonBackground"];

            var text      = keyboardButton.Text.ToString();
            var buttonBuy = keyboardButton as TLKeyboardButtonBuy;

            if (buttonBuy != null)
            {
                var message = DataContext as TLMessage;
                if (message != null)
                {
                    var mediaInvoice = message.Media as TLMessageMediaInvoice;
                    if (mediaInvoice != null)
                    {
                        var receiptMsgId = mediaInvoice.ReceiptMsgId;
                        if (receiptMsgId != null)
                        {
                            text = AppResources.Receipt;
                        }
                    }
                }
            }

            if (text.Length > maxTextLength)
            {
                text = text.Substring(0, maxTextLength) + "...";
            }
            else
            {
                text = string.Format(" {0} ", text);
            }
            var textBox = new TelegramRichTextBox {
                MaxHeight = height, Margin = new Thickness(0.0, 0.0, 0.0, 0.0), Padding = new Thickness(0.0, 0.0, 0.0, 0.0), FontSize = 22, TextWrapping = TextWrapping.NoWrap
            };

            BrowserNavigationService.SetSuppressParsing(textBox, true);
            textBox.Text       = text;
            textBox.Margin     = new Thickness(-12.0 + padding, 0.0, -12.0, 0 + padding);
            textBox.FontSize   = Inline ? 17.776 : textBox.FontSize;
            textBox.Foreground = Inline ? new SolidColorBrush(Colors.White) : textBox.Foreground;

            var button = new Button();

            button.Style      = (Style)Resources["CommandButtonStyle"];
            button.MaxHeight  = height;
            button.Margin     = margin;
            button.Background = Inline ? (Brush)Resources["ButtonInlineBackground"] : background;

            button.Content     = textBox;
            button.DataContext = keyboardButton;
            button.Click      += OnButtonClick;

            if (keyboardButton is TLKeyboardButtonUrl)
            {
                var imageSource = isLightTheme && !Inline ? "/Images/Messages/inline.openweb.light.png" : "/Images/Messages/inline.openweb.png";

                var grid = new Grid();
                grid.Children.Add(button);
                grid.Children.Add(new Image
                {
                    Width  = 11.0,
                    Height = 11.0,
                    Margin = new Thickness(8.0),
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Source = new BitmapImage(new Uri(imageSource, UriKind.Relative))
                });

                return(grid);
            }

            if (keyboardButton is TLKeyboardButtonSwitchInline)
            {
                var imageSource = isLightTheme && !Inline ? "/Images/Messages/inline.share.light.png" : "/Images/Messages/inline.share.png";

                var grid = new Grid();
                grid.Children.Add(button);
                grid.Children.Add(new Image
                {
                    Width  = 13.0,
                    Height = 12.0,
                    Margin = new Thickness(8.0),
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Source = new BitmapImage(new Uri(imageSource, UriKind.Relative))
                });

                return(grid);
            }

            return(button);
        }
示例#11
0
        public StickerSpriteItem(int columns, IList <TLStickerItem> stickers, double stickerHeight, double panelWidth, bool showEmoji = false)
        {
            _stickerHeight = stickerHeight;

            var panelMargin      = new Thickness(4.0, 0.0, 4.0, 0.0);
            var panelActualWidth = panelWidth - panelMargin.Left - panelMargin.Right;
            //472, 438
            var stackPanel = new Grid {
                Width = panelActualWidth, Margin = panelMargin, Background = new SolidColorBrush(Colors.Transparent)
            };

            for (var i = 0; i < columns; i++)
            {
                stackPanel.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (var i = 0; i < stickers.Count; i++)
            {
                var binding = new Binding
                {
                    Mode               = BindingMode.OneWay,
                    Path               = new PropertyPath("Self"),
                    Converter          = new DefaultPhotoConverter(),
                    ConverterParameter = StickerHeight
                };

                var stickerImage = new Image
                {
                    Height            = StickerHeight,
                    Margin            = new Thickness(0, 12, 0, 12),
                    VerticalAlignment = VerticalAlignment.Top,
                };
                stickerImage.SetBinding(Image.SourceProperty, binding);

                var grid = new Grid();
                grid.Children.Add(stickerImage);

                if (showEmoji)
                {
                    var document22 = stickers[i].Document as TLDocument22;
                    if (document22 != null)
                    {
                        var bytes    = Encoding.BigEndianUnicode.GetBytes(document22.Emoticon);
                        var bytesStr = BrowserNavigationService.ConvertToHexString(bytes);

                        var emojiImage = new Image
                        {
                            Height = 32,
                            Width  = 32,
                            Margin = new Thickness(12, 12, 12, 12),
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment   = VerticalAlignment.Bottom,
                            Source = new BitmapImage(new Uri(string.Format("/Assets/Emoji/Separated/{0}.png", bytesStr), UriKind.RelativeOrAbsolute))
                        };
                        grid.Children.Add(emojiImage);
                    }
                }

                var listBoxItem = new ListBoxItem {
                    Content = grid, DataContext = stickers[i]
                };
                Microsoft.Phone.Controls.TiltEffect.SetIsTiltEnabled(listBoxItem, true);
                listBoxItem.Tap += Sticker_OnTap;

                Grid.SetColumn(listBoxItem, i);
                stackPanel.Children.Add(listBoxItem);
            }

            Children.Add(stackPanel);

            View.Width = panelWidth;
        }
示例#12
0
        private void ParseLineExtended(string allText)
        {
            if (string.IsNullOrEmpty(allText))
            {
                return;
            }


            int cutIndex = MAX_STR_LENGTH;

            if (cutIndex >= allText.Length)
            {
                cutIndex = allText.Length - 1;
            }

            var endOfSentenceIndAfterCut = allText.IndexOf(".", cutIndex);

            if (endOfSentenceIndAfterCut >= 0 && endOfSentenceIndAfterCut - cutIndex < 200)
            {
                cutIndex = endOfSentenceIndAfterCut;
            }
            else
            {
                var whiteSpaceIndAfterCut = allText.IndexOf(' ', cutIndex);

                if (whiteSpaceIndAfterCut >= 0 && whiteSpaceIndAfterCut - cutIndex < 100)
                {
                    cutIndex = whiteSpaceIndAfterCut;
                }
            }

            // add all whitespaces before cut
            while (cutIndex + 1 < allText.Length &&
                   allText[cutIndex + 1] == ' ')
            {
                cutIndex++;
            }

            var suppressParsing  = BrowserNavigationService.GetSuppressParsing(this);
            var message          = DataContext as TLMessageBase;
            var decryptedMessage = DataContext as TLDecryptedMessageBase;

            var leftSide = allText.Substring(0, cutIndex + 1);

            allText = allText.Substring(cutIndex + 1);
            var isLastTextBlock = allText.Length <= 0;
            var textBlock       = GetTextBlock();

            BrowserNavigationService.SetSuppressParsing(textBlock, suppressParsing);
            BrowserNavigationService.SetMessage(textBlock, message);
            BrowserNavigationService.SetDecryptedMessage(textBlock, decryptedMessage);
            if (isLastTextBlock)
            {
                BrowserNavigationService.SetAddFooter(textBlock, true);
            }
            BrowserNavigationService.SetText(textBlock, leftSide);
            _stackPanel.Children.Add(textBlock);

            _footerRun = GetFooter(textBlock);

            if (!isLastTextBlock)
            {
                ParseLineExtended(allText);
            }
        }
示例#13
0
        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);
            }
        }