Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I solved a very similar problem by using a <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawinggroup" rel="nofollow noreferrer"><code>DrawingGroup</code></a> and adding or removing <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawing" rel="nofollow noreferrer"><code>Drawing</code></a> objects from the <code>DrawingGroup</code> as they either needed to be displayed or hidden. The key is to organize your <code>Drawing</code> objects in such a way that they are easy to manage and to understand how to add and remove them from the <code>DrawingGroup</code>.</p> <p>Remember that you want to add and remove the <code>Drawing</code> objects from the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawinggroup.children" rel="nofollow noreferrer"><code>DrawingCollection</code></a> exposed by the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection" rel="nofollow noreferrer"><code>DrawingGroup.Children</code></a> property. So use <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection.add" rel="nofollow noreferrer"><code>DrawingGroup.Children.Add()</code></a> or the other <code>DrawingCollection</code> methods: <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection.insert" rel="nofollow noreferrer"><code>Insert</code></a>, <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection.remove" rel="nofollow noreferrer"><code>Remove</code></a>, <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection.removeat" rel="nofollow noreferrer"><code>RemoveAt</code></a>, <a href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.drawingcollection.clear" rel="nofollow noreferrer"><code>Clear</code></a>. You will need to keep an external list of the <code>Drawing</code> objects you add/remove to the <code>DrawingGroup</code> to do this successfully.</p> <p>I used this technique to great effect by drawing an Image (bitmap) into the first child in my instance of <code>DrawingGroup</code> and then adding and removing <code>Drawing</code> objects to this instance of <code>DrawingGroup</code> in order to layer polygons, paths, text, etc on top of the drawing. </p> <p>I "draw" or "erase" on the image by adding or removing <code>Drawing</code> objects to the instance of the <code>DrawingGroup</code>. The <code>DrawingGroup</code> is treated as a single <code>Drawing</code> and so any scaling, panning, or other manipulations will affect all <code>Drawing</code> objects within the <code>DrawingGroup</code>. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload