c# - WPF DrawingContext: How to keep existing content when draw new content? -


i have drawingvisual , want draw grape tree, show screen after that, draw fox. this:

public class gif : drawingvisual {     void draw_geometry(geometry geo)     {         using (drawingcontext dc = renderopen())         {             dc.drawgeometry(brushes.brown, new pen(brushes.brown, 0), geo);         }     }      void draw_grape ()     {         draw_geometry(grape);     }      void draw_fox ()     {         draw_geometry(fox);     } } 

problem when call draw_fox (), drawingcontext auto clear existing grape tree. want ask how keep existing drawing content when draw new geometry? thank!

from documentation:

when call close method of drawingcontext, current drawing content replaces previous drawing content defined drawingvisual. means there no way append new drawing content existing drawing content.

i feel that's pretty clear. not possible literally ask. opening visual rendering always end new rendering replacing whatever there before.

if want append current rendering, need include explicitly. example:

void draw_geometry(geometry geo) {     using (drawingcontext dc = renderopen())     {         dc.drawdrawing(drawing);         dc.drawgeometry(brushes.brown, new pen(brushes.brown, 0), geo);     } } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -