can you please point me to a sample using DrawingVisual instead of Bitmap images for an Image?
Thanks a lot.
I tried the following code, but the image isn't recocniced in the designer:
Code: Select all
public class MyDrawing
{
private DrawingVisual _drawing = null;
public DrawingVisual Drawing
{
get { return _drawing; }
}
public int ID
{
get { return 17; }
}
public MyDrawing()
{
_drawing = new DrawingVisual();
using (DrawingContext dc = Drawing.RenderOpen())
{
// The body
dc.DrawGeometry(Brushes.Blue, null, Geometry.Parse(
@"M 240,250
C 200,375 200,250 175,200
C 100,400 100,250 100,200
C 0,350 0,250 30,130
C 75,0 100,0 150,0
C 200,0 250,0 250,150 Z"));
// Left eye
dc.DrawEllipse(Brushes.Black, new Pen(Brushes.White, 10),
new Point(95, 95), 15, 15);
// Right eye
dc.DrawEllipse(Brushes.Black, new Pen(Brushes.White, 10),
new Point(170, 105), 15, 15);
// The mouth
Pen p = new Pen(Brushes.Black, 10);
p.StartLineCap = PenLineCap.Round;
p.EndLineCap = PenLineCap.Round;
dc.DrawLine(p, new Point(75, 160), new Point(175, 150));
}
}
}