Example #1
0
        // ------------------------------------------------------------------
        // Dump Text specific data.
        // ------------------------------------------------------------------
        private static bool DumpText(XmlTextWriter writer, UIElement element, bool uiElementsOnly)
        {
            System.Windows.Controls.TextBlock text = element as System.Windows.Controls.TextBlock;
            Debug.Assert(text != null, "Dump function has to match element type.");

            // Dump text range
            if (text.HasComplexContent)
            {
                DumpTextRange(writer, text.ContentStart, text.ContentEnd);
            }
            else
            {
                DumpTextRange(writer, text.Text);
            }

            // Dump baseline info
            writer.WriteStartElement("Metrics");
            writer.WriteAttributeString("BaselineOffset", ((double)text.GetValue(TextBlock.BaselineOffsetProperty)).ToString("F", CultureInfo.InvariantCulture));
            writer.WriteEndElement();

            // Dump line array
            if (text.IsLayoutDataValid)
            {
                ReadOnlyCollection <LineResult> lines = text.GetLineResults();
                DumpLineResults(writer, lines, element);
            }

            return(false);
        }