private void DrawHelper(IGraphicsTarget grTargetOcadMap, IGraphicsTarget grTargetBitmapMap, IGraphicsTarget grTargetCourses, RectangleF visRect, float minResolution)
{
RenderOptions renderOptions = new RenderOptions();
renderOptions.minResolution = minResolution;
if (Printing)
renderOptions.usePatternBitmaps = false; // don't use pattern bitmaps when printing, they cause some problems in some printer drivers and we want best quality.
else if (antialiased && minResolution < 0.007F) // use pattern bitmaps unless high quality and zoomed in very far
renderOptions.usePatternBitmaps = false;
else
renderOptions.usePatternBitmaps = true;
renderOptions.showSymbolBounds = showBounds;
renderOptions.renderTemplates = RenderTemplateOption.MapAndTemplates;
renderOptions.blendOverprintedColors = ocadOverprintEffect;
// First draw the real map.
switch (mapType) {
case MapType.OCAD:
grTargetOcadMap.PushAntiAliasing(Printing ? false : antialiased); // don't anti-alias on printer
DrawOcadMap(grTargetOcadMap, visRect, renderOptions);
grTargetOcadMap.PopAntiAliasing();
break;
case MapType.Bitmap:
case MapType.PDF:
grTargetBitmapMap.PushAntiAliasing(Printing ? false : antialiased); // don't anti-alias on printer
DrawBitmapMap(grTargetBitmapMap, visRect, minResolution);
grTargetBitmapMap.PopAntiAliasing();
break;
case MapType.None:
break;
}
// Now draw the courseMap on top.
if (Printing)
grTargetCourses.PushAntiAliasing(false);
else
grTargetCourses.PushAntiAliasing(true); // always anti-alias the course unless printing
// Always turn blending on.
renderOptions.blendOverprintedColors = true;
if (courseMap != null) {
using (courseMap.Read())
courseMap.Draw(grTargetCourses, visRect, renderOptions, null);
}
grTargetCourses.PopAntiAliasing();
grTargetCourses.PushAntiAliasing(false);
if (printArea.HasValue && !printArea.Value.Contains(visRect)) {
object printAreaOutline = new object();
grTargetCourses.CreateSolidBrush(printAreaOutline, CmykColor.FromCmyka(0, 0, 0, 1, 0.12F));
if (printArea.Value.Top > visRect.Top) {
RectangleF draw = RectangleF.FromLTRB(visRect.Left, visRect.Top, visRect.Right, printArea.Value.Top);
grTargetCourses.FillRectangle(printAreaOutline, draw);
}
if (printArea.Value.Bottom < visRect.Bottom) {
RectangleF draw = RectangleF.FromLTRB(visRect.Left, printArea.Value.Bottom, visRect.Right, visRect.Bottom);
grTargetCourses.FillRectangle(printAreaOutline, draw);
}
if (printArea.Value.Left > visRect.Left) {
RectangleF draw = RectangleF.FromLTRB(visRect.Left, printArea.Value.Top, printArea.Value.Left, printArea.Value.Bottom);
grTargetCourses.FillRectangle(printAreaOutline, draw);
}
if (printArea.Value.Right < visRect.Right) {
RectangleF draw = RectangleF.FromLTRB(printArea.Value.Right, printArea.Value.Top, visRect.Right, printArea.Value.Bottom);
grTargetCourses.FillRectangle(printAreaOutline, draw);
}
}
grTargetCourses.PopAntiAliasing();
}