private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            if (removeTags)
            {
                Control.Text = HtmlToText.ConvertHtml(Control.Text);
            }
            else
            {
                var value   = Element.Text ?? string.Empty;
                var attr    = new NSAttributedStringDocumentAttributes();
                var nsError = new NSError();
                attr.DocumentType = NSDocumentType.HTML;

                var myHtmlData = NSData.FromString(value, NSStringEncoding.Unicode);
                Control.AttributedText = new NSAttributedString(myHtmlData, attr, ref nsError);
            }
            SetNeedsDisplay();
        }
Exemplo n.º 2
0
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            var helper = new LabelRendererHelper(Element, text);

            var html = Html.FromHtml(helper.ToString(), FromHtmlOptions.ModeCompact);

            Control.SetText(html, TextView.BufferType.Spannable);
        }
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            var helper = new LabelRendererHelper(Element, text);

            CreateAttributedString(Control, helper.ToString());
            SetNeedsDisplay();
        }
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            var helper = new LabelRendererHelper(Element, text);

            var value = helper.ToString();
            var html  = Build.VERSION.SdkInt >= BuildVersionCodes.N ?
                        Html.FromHtml(value, FromHtmlOptions.ModeCompact) :
                        Html.FromHtml(value);

            Control.SetText(html, TextView.BufferType.Spannable);
            Control.MovementMethod = LinkMovementMethod.Instance;
        }
Exemplo n.º 5
0
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }


            var attr    = new NSAttributedStringDocumentAttributes();
            var nsError = new NSError();

            attr.DocumentType = NSDocumentType.HTML;

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            var helper = new LabelRendererHelper(Element, text);

            var htmlData = NSData.FromString(helper.ToString(), NSStringEncoding.Unicode);

            Control.AttributedText = new NSAttributedString(htmlData, attr, ref nsError);

            SetNeedsDisplay();
        }
Exemplo n.º 6
0
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            var helper = new LabelRendererHelper(Element, text);

            Control.Text = helper.ToString();

            var behavior = new HtmlTextBehavior();

            Interaction.GetBehaviors(Control).Add(behavior);
        }
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            if (removeTags)
            {
                Control.Text = HtmlToText.ConvertHtml(Control.Text);
            }
            else
            {
                var value = Element.Text ?? string.Empty;
                var html  = Build.VERSION.SdkInt >= BuildVersionCodes.N
                    ? Html.FromHtml(value, FromHtmlOptions.ModeCompact)
                    : Html.FromHtml(value);
                Control.SetText(html, TextView.BufferType.Spannable);
            }
        }
Exemplo n.º 8
0
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(Control.Text))
            {
                return;
            }

            var isHtml = HtmlLabel.GetIsHtml(Element);

            if (!isHtml)
            {
                return;
            }

            var removeTags = HtmlLabel.GetRemoveHtmlTags(Element);

            var text = removeTags ?
                       HtmlToText.ConvertHtml(Control.Text) :
                       Element.Text;

            Control.MovementMethod = LinkMovementMethod.Instance;

            var helper = new LabelRendererHelper(Element, text);
            var value  = helper.ToString();

            var html = Build.VERSION.SdkInt >= BuildVersionCodes.N ?
                       Html.FromHtml(value, FromHtmlOptions.ModeCompact, null, new ListTagHandler()) :
#pragma warning disable CS0618 // Il tipo o il membro è obsoleto
                       Html.FromHtml(value, null, new ListTagHandler());

#pragma warning restore CS0618 // Il tipo o il membro è obsoleto

            Control.SetIncludeFontPadding(false);

            html = RemoveLastChar(html);
            Control.SetText(html, TextView.BufferType.Spannable);
        }