Esempio n. 1
0
        private string RunToString(System.Windows.Documents.Inline inline)
        {
            switch (inline)
            {
            case System.Windows.Documents.Run run: {
                return(run.Text);
            }

            case System.Windows.Documents.Span span: {
                var ret = string.Empty;
                foreach (var sinline in span.Inlines)
                {
                    ret += RunToString(sinline);
                }
                return(ret);
            }

            case System.Windows.Documents.LineBreak lb: {
                return(Environment.NewLine);
            }

            case System.Windows.Documents.InlineUIContainer uicontainer: {
                return(string.Empty);
            }

            case System.Windows.Documents.AnchoredBlock ab: {
                return(string.Empty);
            }

            default:
                throw new InvalidOperationException($"Inline {inline.GetType().Name} not implemented.");
            }
        }
Esempio n. 2
0
        public static void htmlToTextBlockText(System.Windows.Controls.TextBlock textBlock, string html)
        {
            try
            {
                textBlock.Text = "";
                string xaml = HtmlToXamlConverter.ConvertHtmlToXaml(html, false);
                System.Windows.Documents.InlineCollection xamlLines =
                    (
                        (System.Windows.Documents.Paragraph)(
                            (System.Windows.Documents.Section)System.Windows.Markup.XamlReader.Parse(xaml)
                            ).Blocks.FirstBlock
                    ).Inlines;

                System.Windows.Documents.Inline[] newLines = new System.Windows.Documents.Inline[xamlLines.Count];
                xamlLines.CopyTo(newLines, 0);

                foreach (var item in newLines)
                {
                    textBlock.Inlines.Add(item);
                }
            }
            catch (Exception)
            {
                System.Diagnostics.Debugger.Break();
            }
        }
Esempio n. 3
0
        private double?Measure(System.Windows.Documents.Inline inline)
        {
            if (inline is System.Windows.Documents.Run run)
            {
                var ft = new FormattedText(run.Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(run.FontFamily, run.FontStyle, run.FontWeight, run.FontStretch), run.FontSize, Brushes.Black);
                return(ft.Width);
            }
            else if (inline is System.Windows.Documents.Span span)
            {
                return(Measure(span.Inlines));
            }

            return(null);
        }
        public void GetVisualParents2()
        {
            Grid           grid           = new Grid();
            ContentControl contentControl = new ContentControl();
            TextBlock      textBox;

            System.Windows.Documents.Inline textBoxContent = null;
            Window.Content = grid;
            grid.Children.Add(contentControl);
            contentControl.ContentTemplate = textBlockTemplate;
            EnqueueShowWindow();
            EnqueueCallback(() => {
                textBox        = (TextBlock)LayoutHelper.FindElement(contentControl, x => x is TextBlock);
                textBoxContent = textBox.Inlines.First();

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x is ContentControl).First());
                Assert.AreSame(grid, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x is Grid).First());
                Assert.AreSame(Window, LayoutTreeHelper.GetVisualParents(textBoxContent).Where(x => x.GetType() == Window.GetType()).First());

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBoxContent, contentControl).Where(x => x is ContentControl).First());
                Assert.IsNull(LayoutTreeHelper.GetVisualParents(textBoxContent, contentControl).Where(x => x is Grid).FirstOrDefault());
            });
            EnqueueTestComplete();
        }
 public static System.Windows.Documents.Inline InsertRange(this System.Windows.Documents.Inline inline, System.Collections.Generic.IEnumerable <System.Windows.Documents.Inline> inlines)
 {
 }
 public static System.Windows.Documents.Inline Insert(this System.Windows.Documents.Inline inline, System.Windows.Documents.Inline inlineToAdd)
 {
 }
 public static System.Windows.Documents.Bold Bold(this System.Windows.Documents.Inline inline)
 {
 }
 public static System.Windows.Documents.Inline Append(this System.Windows.Documents.Inline inline, System.Windows.Documents.Inline inlineToAdd)
 {
 }
 public static void AddIfNotNull(this System.Windows.Documents.InlineCollection inlineCollection, System.Windows.Documents.Inline inline)
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Parameterised constructor
 /// </summary>
 /// <param name="inline"></param>
 public S360TextBlock(System.Windows.Documents.Inline inline)
     : base(inline)
 {
     InitControll();
 }
Esempio n. 11
0
 public AdvancedTextBlock(System.Windows.Documents.Inline inline) : base(inline)
 {
 }
 public TextBlock(System.Windows.Documents.Inline inline)
 {
     Contract.Ensures(0 <= this.Inlines.Count);
 }