コード例 #1
0
ファイル: LayoutDump.cs プロジェクト: beda2280/wpf-1
        // ------------------------------------------------------------------
        // Dump content of DocumentPage.
        // ------------------------------------------------------------------
        internal static void DumpDocumentPage(XmlTextWriter writer, DocumentPage page, Visual parent)
        {
            writer.WriteStartElement("DocumentPage");
            writer.WriteAttributeString("Type", page.GetType().FullName);

            if (page != DocumentPage.Missing)
            {
                DumpSize(writer, "Size", page.Size);

                // Dump transform relative to its parent
                GeneralTransform g     = page.Visual.TransformToAncestor(parent);
                Point            point = new Point(0, 0);
                g.TryTransform(point, out point);
                if (point.X != 0 || point.Y != 0)
                {
                    DumpPoint(writer, "Position", point);
                }

                // Dump page specific information
                Type t = page.GetType();
                DumpCustomDocumentPage dumpDocumentPage = null;
                while (dumpDocumentPage == null && t != null)
                {
                    dumpDocumentPage = _documentPageToDumpHandler[t] as DumpCustomDocumentPage;
                    t = t.BaseType;
                }
                if (dumpDocumentPage != null)
                {
                    dumpDocumentPage(writer, page);
                }
            }

            writer.WriteEndElement();
        }
コード例 #2
0
        // ------------------------------------------------------------------
        // Dump content of the specified DocumentPage.
        //
        //      writer - stream to be used for dump
        //      element - element to be dumped
        //      parent - parent element
        // ------------------------------------------------------------------
        internal static void DumpDocumentPage(XmlNode writer, DocumentPage page, Visual parent)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            XmlNode node = PropertyDumpCore.xmldoc.CreateElement("DocumentPage");

            writer.AppendChild(node);

            AppendAttribute(node, "Type", page.GetType().FullName);

            if (page == DocumentPage.Missing)
            {
                AppendAttribute(node, "Missing", "True");
            }
            else
            {
                DumpSize(writer, "Size", page.Size);

                // Dump transform relative to its parent
                Matrix m;
                System.Windows.Media.GeneralTransform gt = page.Visual.TransformToAncestor(parent);
                System.Windows.Media.Transform        t  = (System.Windows.Media.Transform)gt;
                if (t == null)
                {
                    throw new System.ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change");
                }
                m = t.Value;
                Point point = new Point(0, 0) * m;
                if (point.X != 0 || point.Y != 0)
                {
                    DumpPoint(writer, "Position", point);
                }


                //check for registered handler for this document page
                DumpCustomDocumentPage dumpDocumentPage = _documentPageToDumpHandler[page.GetType()] as DumpCustomDocumentPage;

                //Hack: need to itentify if test code should be using the Debug Class
                //Debug.Assert(dumpDocumentPage == null, String.Format("Unknown documentpage of type {0}", page.GetType()));
                if (dumpDocumentPage != null)
                {
                    dumpDocumentPage(node, page);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Add new mapping from DocumentPage type to dump methdod (DumpCustomDocumentPage).
 /// </summary>
 internal static void AddDocumentPageDumpHandler(Type type, DumpCustomDocumentPage dumper)
 {
     _documentPageToDumpHandler.Add(type, dumper);
 }
コード例 #4
0
 /// <summary>
 /// Add new mapping from DocumentPage type to dump methdod (DumpCustomDocumentPage).
 /// </summary>
 internal static void AddDocumentPageDumpHandler(Type type, DumpCustomDocumentPage dumper)
 {
     _documentPageToDumpHandler.Add(type, dumper);
 }