Поделиться через


Avalon DrawingContext ...

DrawingContext is Avalon's equivalent of hdc (handle to device context) in Win32 programming or Graphics in GDI+. It provides us with low level calls to render/draw on the surface (screen/print/other visuals).

Here's a list of useful draw method in DrawingContext:

1. DrawDrawing
2. DrawEllipse
3. DrawGeometry
4. DrawGlyphs
5. DrawImage
6. DrawLine
7. DrawRectangle
8. DrawRoundedRectangle
9. DrawSubLineCollection
10. DrawText
11. DrawVideo

Most of the time, DrawingContext will be used within Render(DrawingContext dc). This is a method that custom control can override and do customize drawing. Render() will be invoked whenever the screen area is dirty. You can also imagine that certain controls like Image will make use of DrawImage, while Typography uses DrawGlyphs/DrawText and Border will use DrawRectangle. It's really up to your imagination to mix and match these capabilities to come out with something slick.

DrawVideo is definitely something fresh considering we are looking at the equivalent of HDC. IMO, this shows that Avalon is really making it easier and easier for UI developer like me :).

Finally, Transform, Clip and Opacity are also controllable from this class. What a powerful class!!!