Skip to content

developers rendering

Tim Stair edited this page Aug 22, 2015 · 1 revision

Developers Section - Rendering

Rendering System

CardMaker uses System.Drawing. It does the job, though it has limitations. Certain fonts are not supported by the System.Drawing text rendering system.

General Rendering

CardMaker draws using Graphics objects. The Graphics object may be derived from a Control (as in what you see in the application), graphic file (exports), or a print surface (assuming I have not obliterated the print code).

Application Rendering

There are a number of Classes involved with rendering in the desktop application display of layouts.

  • MDICanvas - high level container (uses a Panel to allow for scrolling)
  • CardCanvas - User Control that provides the Graphics object to the CardRenderer
  • CardRenderer - The low level class that performs the actual drawing to the Graphics surface

For Rendering to images or printing the input is slightly different but there is always an object that provides a Graphics object for the CardRenderer to draw onto.

CardRenderer.DrawCard

This is the core of the rendering system. This draws an entire card based on the current active line from the loaded reference. This handles all the setup, rotation, zoom, and otherwise before the Elements are drawn onto the Graphics surface.

Element Rendering

Elements are all defined to draw in rectangles defined by a point, width, and height. This is primarily to match with exactly what the System.Drawing methods generally expect. At the top of the rendering chain for Elements is the DrawItem class. This is a high level controller that determines what to draw with. This could be thought of as a bit of a Factory mutant. At this time the DrawItem code works, but could be better organized probably.

To further cheat a bit the various renderers are actually all in the DrawItem class, just in different partial code files.

Text

It's basic text! You can align it, color it, or even auto scale it. There is some old code remaining that is if'd away related to line height. This should be obliterated.

Shape

You can draw shapes. This is very limited really.

This code is organized away with the ShapeManager. All the available shapes are discovered via reflection at startup.

Graphic

Load and draw graphic files! To avoid constantly grinding the hard drive there is a cache of images. There is also a cache of images based on opacity (another expensive operation).

Formatted Text

This topic is big enough to deserve its own page: FormattedText