ImageMapDrawImage Event

This event is raised when owner draw mode is enabled and the image map needs to be drawn

Definition

Namespace: EWSoftware.ImageMaps.Windows.Forms
Assembly: EWSoftware.ImageMaps.Windows.Forms (in EWSoftware.ImageMaps.Windows.Forms.dll) Version: 2023.1.3.0
public event EventHandler<DrawImageEventArgs> DrawImage

Value

EventHandlerDrawImageEventArgs

Example

This is an example of an owner drawn image event handler. For some other examples, see the demo application.
C#
/// <summary>
/// When the image map is owner drawn, you can draw just the background
/// or you can draw the image areas too.
/// </summary>
/// <param name="sender">The sender of the event (the image map)</param>
/// <param name="e">The event arguments</param>
private void imMap_DrawImage(object sender, DrawImageEventArgs e)
{
    // For this demo, we'll just draw a gradient fill background.
    // You could get the image using the ImageMap.Image property too.
    // Offset the drawing rectangle by the image offset in the event
    // arguments.  This indicates the true position of the image when
    // centered or scrolled.
    Rectangle r = new Rectangle(e.ImageOffset.X, e.ImageOffset.Y,
        imMap.ImageMapWidth, imMap.ImageMapHeight);

    using(LinearGradientBrush lgBrush = new LinearGradientBrush(r,
      Color.White, Color.SteelBlue, LinearGradientMode.ForwardDiagonal))
    {
        e.Graphics.FillRectangle(lgBrush, r);
    }

    e.Graphics.DrawString("All items seen on this form are drawn by " +
        "the image map or image area DrawImage event handlers.  " +
        "Even with owner draw disabled for the image map, image " +
        "areas can still be set to owner drawn.", imMap.Font,
        Brushes.Black, new Rectangle(r.X + 250, r.Y + 10, 325, 100),
        sfFormat);

    // The image map can draw areas too.  In this case, we defer to
    // the event handlers as they'll take over if owner drawing of the
    // image map is turned off.
    this.OwnerDrawOnOff_DrawImage(sender, e);
    this.VisitWebSite_DrawImage(sender, e);
}

See Also