ImageAreaBase Class

This is the abstract base class for the image area types of the Windows Forms ImageMap control.

Definition

Namespace: EWSoftware.ImageMaps.Windows.Forms
Assembly: EWSoftware.ImageMaps.Windows.Forms (in EWSoftware.ImageMaps.Windows.Forms.dll) Version: 2023.1.3.0
public abstract class ImageAreaBase : IImageArea
Inheritance
Object    ImageAreaBase
Derived
Implements
IImageArea

Example

This example demonstrates creating a Windows Forms image map and its areas.
C#
using EWSoftware.ImageMaps;
using EWSoftware.ImageMaps.Windows.Forms;

// Example code that creates an image map and adds some image areas
ImageMap imMap = new ImageMap();

ImageAreaRectangle imageAreaRectangle1 = new ImageAreaRectangle();
ImageAreaCircle imageAreaCircle1 = new ImageAreaCircle();
ImageAreaPolygon imageAreaPolygon1 = new ImageAreaPolygon();
ImageAreaRectangle imageAreaRectangle2 = new ImageAreaRectangle();
ImageAreaEllipse imageAreaEllipse1 = new ImageAreaEllipse();

imageAreaRectangle1.AccessKey = "R";
imageAreaRectangle1.Rectangle = new System.Drawing.Rectangle(16, 16, 150, 94);
imageAreaRectangle1.TabIndex = 3;
imageAreaRectangle1.ToolTip = "A rectangle area";

imageAreaCircle1.AccessKey = "C";
imageAreaCircle1.CenterPoint = new System.Drawing.Point(380, 88);
imageAreaCircle1.Radius = 60;
imageAreaCircle1.TabIndex = 1;
imageAreaCircle1.ToolTip = "A circle area";

imageAreaPolygon1.AccessKey = "P";
imageAreaPolygon1.Points.AddRange(new System.Drawing.Point[] {
    new System.Drawing.Point(42, 186),
    new System.Drawing.Point(110, 286),
    new System.Drawing.Point(144, 250),
    new System.Drawing.Point(138, 230),
    new System.Drawing.Point(160, 216),
    new System.Drawing.Point(190, 214),
    new System.Drawing.Point(152, 168),
    new System.Drawing.Point(112, 172),
    new System.Drawing.Point(70, 154)});

imageAreaPolygon1.TabIndex = 2;
imageAreaPolygon1.ToolTip = "A polygon area";

imageAreaRectangle2.Action = AreaClickAction.None;
imageAreaRectangle2.Rectangle = new System.Drawing.Rectangle(316, 176, 206, 118);
imageAreaRectangle2.ToolTip = "A tool tip only area";

imageAreaEllipse1.AccessKey = "E";
imageAreaEllipse1.Ellipse = new System.Drawing.Rectangle(199, 88, 128, 58);
imageAreaEllipse1.TabIndex = 4;
imageAreaEllipse1.ToolTip = "An ellipse area";

imMap.Areas.AddRange(new IImageArea[] {
    imageAreaRectangle1,
    imageAreaCircle1,
    imageAreaPolygon1,
    imageAreaRectangle2
    imageAreaEllipse1 });

imMap.Anchor = ((System.Windows.Forms.AnchorStyles)
    ((((System.Windows.Forms.AnchorStyles.Top |
    System.Windows.Forms.AnchorStyles.Bottom)
    | System.Windows.Forms.AnchorStyles.Left)
    | System.Windows.Forms.AnchorStyles.Right)));

imMap.Image = ((System.Drawing.Image)(resources.GetObject("imMap.Image")));
imMap.Location = new System.Drawing.Point(8, 8);
imMap.Name = "imMap";
imMap.Size = new System.Drawing.Size(552, 448);
imMap.TabIndex = 0;
imMap.ToolTip = "A test image";

// Add a click event handler
imMap.Click += imMap_Click;

// A simple image area click handler
private void imMap_Click(object sender, ImageMapClickEventArgs e)
{
    MessageBox.Show(String.Format(
        "You clicked area #{0} ({1}) at point {2}, {3}",
            e.AreaIndex + 1, imMap.Areas[e.AreaIndex].ToolTip,
            e.XCoordinate, e.YCoordinate), "Image Map Clicked",
            MessageBoxButtons.OK, MessageBoxIcon.Information);
}

Constructors

ImageAreaBase Default constructor
ImageAreaBase(String) This version of the constructor takes a tool tip

Properties

AccessKey This is used to get or set the access key (a shortcut key or mnemonic) for the image area
Action This defines the action to take when the area is clicked
Coordinates This must be overridden to provide the image area coordinates
Enabled This is used to enable or disable the area
OwnerDraw This is used to turn owner draw mode on and off
Shape This must be overridden to provide the image area shape
TabIndex This is used to get or set the tab index of the area
Tag This is used to get or set an object that contains additional user-defined data for the image area
ToolTip This is used to get or set the tool tip to display when the mouse hovers over the area

Methods

DrawFocusFrame This must be overridden to get the shape to draw a focus frame around itself
Equals This is overridden to allow proper comparison of image area objects.
(Overrides ObjectEquals(Object))
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCode Get a hash code for the image area object
(Overrides ObjectGetHashCode)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
OnClick This raises the image area Click event
OnDoubleClick This raises the image area DoubleClick event
OnDrawImage This raises the image area DrawImage event
OnEnter This raises the image area Enter event
OnImageAreaChanged This raises the ImageAreaChanged event
OnLeave This raises the image area Leave event
OnMouseDown This raises the image area MouseDown event
OnMouseEnter This raises the image area MouseEnter event
OnMouseHover This raises the image area MouseHover event
OnMouseLeave This raises the image area MouseLeave event
OnMouseMove This raises the image area MouseMove event
OnMouseUp This raises the image area MouseUp event
RaiseEvent This is used to fire an event on the image area
ToString Convert the image area instance to its string description
(Overrides ObjectToString)

Events

Click This event is raised when the image area is clicked
DoubleClick This event is raised when the image area is double-clicked
DrawImage This event is raised when owner draw mode is enabled and the image area needs to be drawn
Enter This event is raised when the image area gains the focus
ImageAreaChanged This event is raised when an image area property changes that affects its visual presentation in the image map control such as its position or enabled state.
Leave This event is raised when the image area loses the focus
MouseDown This event is raised when a mouse button is pressed while the mouse is inside the image area
MouseEnter This event is raised when the mouse enters the image area
MouseHover This event is raised when the mouse remains stationary inside the image area for an amount of time
MouseLeave This event is raised when the mouse leaves the image area
MouseMove This event is raised when the mouse moves in the image area
MouseUp This event is raised when a mouse button is released while the mouse is inside the image area

See Also