コード例 #1
0
 protected abstract void OnRenderCore(DrawingContext dc, RenderState state);
コード例 #2
0
        protected sealed override void OnRender(DrawingContext drawingContext)
        {
            if (Viewport == null)
            {
                return;
            }

            Rect output = Viewport.Output;

            if (output.Width == 0 || output.Height == 0)
            {
                return;
            }
            if (output.IsEmpty)
            {
                return;
            }
            if (Visibility != Visibility.Visible)
            {
                return;
            }

            if (shouldReRender || manualTranslate || renderTarget == RenderTo.Image || beforeFirstUpdate || updateCalled)
            {
                if (graphContents == null)
                {
                    graphContents = new DrawingGroup();
                }
                if (beforeFirstUpdate)
                {
                    Update();
                }

                using (DrawingContext context = graphContents.Open())
                {
                    if (renderTarget == RenderTo.Screen)
                    {
                        RenderState state = CreateRenderState(Viewport.Visible, RenderTo.Screen);
                        OnRenderCore(context, state);
                    }
                    else
                    {
                        // for future use
                    }
                }
                updateCalled = false;
            }

            // thumbnail is not created, if
            // 1) CreateThumbnail is false
            // 2) this graph has IsLayer property, set to false
            if (ShouldCreateThumbnail)
            {
                RenderThumbnail();
            }

            if (!manualClip)
            {
                drawingContext.PushClip(new RectangleGeometry(output));
            }
            bool translate = !manualTranslate && IsTranslated;

            if (translate)
            {
                drawingContext.PushTransform(new TranslateTransform(offset.X, offset.Y));
            }

            drawingContext.DrawDrawing(graphContents);

            if (translate)
            {
                drawingContext.Pop();
            }
            if (!manualClip)
            {
                drawingContext.Pop();
            }
            shouldReRender = true;
        }