/// <summary>
        /// Converts a RenderData content representation into a DrawingGroup
        /// content representation.
        /// </summary>
        /// <param name="renderData"> The RenderData to convert </param>
        /// <returns>
        /// A new DrawingGroup representation that is functionally equivalent to the
        /// passed-in RenderData.
        /// </returns>
        internal static DrawingGroup DrawingGroupFromRenderData(RenderData renderData)
        {
            //
            // Create & open a new DrawingGroup
            //

            DrawingGroup drawingGroup = new DrawingGroup();

            DrawingContext dc = drawingGroup.Open();

            //
            // Create a DrawingGroup from the RenderData by walking
            // the RenderData & having it forward it's base value's
            // and animations to DrawingGroup
            //

            //
            // The Drawing tree we're about to produce should not be an inheritance context,
            // since that would place all mutable Freezables in the render data into shared
            // state, which would in turn case them to lose their inheritance context entirely.
            // This is controlled by setting "CanBeInheritanceContext" to false on the
            // DrawingContext which will then be applied to all new objects it creates.
            //

            DrawingDrawingContext ddc = dc as DrawingDrawingContext;

            if (ddc != null)
            {
                ddc.CanBeInheritanceContext = false;
            }

            DrawingContextDrawingContextWalker walker =
                new DrawingContextDrawingContextWalker(dc);

            renderData.BaseValueDrawingContextWalk(walker);

            //
            // Close the DrawingContext & return the new DrawingGroup
            //

            dc.Close();

            return(drawingGroup);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts a RenderData content representation into a DrawingGroup
        /// content representation.
        /// </summary>
        /// <param name="renderData"> The RenderData to convert </param>
        /// <returns>
        /// A new DrawingGroup representation that is functionally equivalent to the
        /// passed-in RenderData.
        /// </returns>
        internal static DrawingGroup DrawingGroupFromRenderData(RenderData renderData)
        {
            //
            // Create & open a new DrawingGroup
            //

            DrawingGroup drawingGroup = new DrawingGroup();

            DrawingContext dc = drawingGroup.Open();

            //
            // Create a DrawingGroup from the RenderData by walking
            // the RenderData & having it forward it's base value's
            // and animations to DrawingGroup
            //

            //
            // The Drawing tree we're about to produce should not be an inheritance context,
            // since that would place all mutable Freezables in the render data into shared
            // state, which would in turn case them to lose their inheritance context entirely.
            // This is controlled by setting "CanBeInheritanceContext" to false on the
            // DrawingContext which will then be applied to all new objects it creates.
            //

            DrawingDrawingContext ddc = dc as DrawingDrawingContext;

            if (ddc != null)
            {
                ddc.CanBeInheritanceContext = false;
            }

            DrawingContextDrawingContextWalker walker =
                new DrawingContextDrawingContextWalker(dc);

            renderData.BaseValueDrawingContextWalk(walker);

            //
            // Close the DrawingContext & return the new DrawingGroup
            //

            dc.Close();

            return drawingGroup;
        }