The Edit class contains the properties and methods for annotating images. For a list of all members of the Edit class, please refer to Edit Members
Explanation
The ImageKit.NET2 ImageKit control implements a number of annotation functions. These functions allow annotation objects to be drawn using the mouse or by executing various Edit methods. The annotation objects implemented by the Edit class are listed below:
- Annotation objects include: Line, PasteImage, Polyline, Polygon, Rectangle, Ellipse, and Text. These can be drawn on the control using the mouse or be drawn by executing various methods.
- Annotation objects can be selected individually, can selected as a group, or all annotation objects can be selected. Annotation objects can be selected using the mouse. All objects can be selected by executing a method.
- Annotation objects can be moved individually, as a group, or in their entirety. Annotation objects can be enlarged, reduced, and rotated (individually selected objects only). This can be done on the control using the mouse.
- Annotation objects can be deleted, copied, and pasted (individually, as a group, or in their entirety). Annotation objects can be moved to front or moved to back. After annotation objects have been drawn, their properties can be accessed and changed (individually selected objects only). This can be done by right clicking on the control to display the context menu or by executing various methods.
- Changes to annotation objects can be undone or redone. This is done by right clicking on the control to display the context menu or by executing various methods.
- Annotation objects can be saved in a seperate annotation file. The saved annotation file can be loaded on the same image or a different image. This is done by executing a method.
- Annotation objects drawn on the control can be rasterized and embedded into a raster image. This is done by executing a method.
Using the mouse to draw annotation objects:
NOTE: annotations are enabled only on the base image in the ImageKit control. (For more information about using methods to draw annotation objects, please refer to explanation of those methods in the Help documentation under the Edit interface.)
- Lines
- Set the PenWidth and ForeColor properties.
- Set the EditKind property to KindOfEdit.Line.
- Set the starting point of the line by left-clicking the mouse in the appropriate location on the image and while holding down the left mouse button drag the mouse across the image to draw the line. The endpoint of the line will be the location where the left mouse button was released.
- Polylines
- Set the PenWidth and ForeColor properties.
- Set the EditKind property to KindOfEdit.Polyline.
- Set the starting point of the polyline by left-clicking (and
releasing) the mouse in the appropriate location on the image. Move
the mouse to the location of the second point in the polyline. A
line will be drawn connecting the starting point to the second
point. Once the mouse is in the correct location for the second
point, left-click the mouse again to draw the second point. Move
the mouse to the location of the third point and left click the
mouse to set that point. Continue in this way until all the points
of the polyline have been drawn. When the endpoint of the polyline
is determined, double click the left mouse button to stop
drawing.
When the ContextMenuEnable property is set to True, right-clicking will display the Context Menu which can be used to undo or redo line segments and return the annotation to its prior state.
- Polygons
- Set the PenWidth , ForeColor, BackColor, and Fill properties.
- Set the EditKind property to KindOfEdit.Polygon.
- Set the starting point of the polygon by left-clicking (and
releasing) the mouse in the appropriate location on the image. Move
the mouse to the location of the second point in the polygon. A
line will be drawn connecting the starting point to the second
point. Once the mouse is in the correct location for the second
point, left-click the mouse again to draw the second point. Move
the mouse to the location of the third point and left click the
mouse to set that point. Continue in this way until all the points
of the polygon have been drawn. When the last point of the polygon
is determined, double click the left mouse button to set the last
point and to draw a line segment from the last point to the start
point.
When the ContextMenuEnable property is set to True, right-clicking will display the Context Menu which can be used to undo or redo line segments and return the annotation to its prior state.
- Rectangles, Ellipses, Squares, and Circles
- Set the PenWidth, ForeColor, BackColor, and Fill properties.
- Set the EditKind property to KindOfEdit.Rectangle or to KindOfEdit.Ellipse as the case may be.
- Set one corner of the rectangle (of the bounding rectangle in
the case of an ellipse) by left-clicking the mouse in the
appropriate location on the image. Hold the left mouse button down
while dragging the mouse across the image. This will draw the
rectangle. Releasing the left mouse button will set the opposite
corner of the rectangle. The rectangle object will be drawn on this
rectangle, the ellipse will use this area as a bounding rectangle
and the ellipse drawn within.
NOTE: Holding down the Shift key while drawing a rectangle or an ellipse, will make the object a square or circle respectively
- Pen
- Set the PenWidth and ForeColor properties.
- Set the EditKind property to KindOfEdit.Pen.
- Set the starting point for the pen by left-clicking the mouse in the appropriate location on the image. While holding down the left mouse button, move the mouse over the image to draw with the pen. When the mouse button is released, the pen object is completed.
- PasteImage
- Set the EditKind property to KindOfEdit.Image.
- Use the mouse to determine the location where the image will be pasted. Set one corner of the area by left-clicking the mouse in the appropriate location on the image and while holding down the left mouse button moving the mouse. When the left mouse button is released, the area where the image is pasted is determined and the "File" Dialog will be displayed.
- Select the image file that will be pasted and click the "Open"
button in the "File" Dialog. The selected image will be pasted in
the area determined in step 2. The image will be stretched to fit
within this area. If the AspectRatio property is True, the
pasted image will maintain the height to width ratio of the
original image.
NOTE: Only images that can be loaded into the ImageKit control can be pasted using PasteImage annotation function. If an unsupported file is selected, the area drawn with the mouse in step 2 will be deleted and the annotation will be returned to the state prior to use of the PasteImage function. Even if the selected image is of a supported format, if the area in which the image is to be pasted is too large and uses up available memory resources so the image cannot be displayed, a small image with a white background and red x will be displayed in its place. In this case, remove the Image object by selected "Delete" or "Undo" in the context menu and then create a small area to paste the image.
- Text
- Set the FontName, FontSize, FontBold, FontItalic, FontStrikeout, FontUnderline, ForeColor, BackColor, and Fill properties.
- Set the EditKind property to KindOfEdit.Text.
- Set the upper left corner of the location where you want to draw text by left-clicking the mouse and then while holding down the left mouse button move the mouse down and to the right. When you release the left mouse button, the text input area will be created on the image. When the& Fill property is True, the area will be filled with the color set in the BackColor property. When the Fill property is False, the text area background color will be the reverse of the RGB values set in the FoleColor property. The final size of the Text object is automatically determined by the coordinates of the upper left corner of the text area, the font settings, and the text content. If the size of the Text object is not correct, the text area can be selected and the size of the text changed.
- Use the keyboard to enter the text that you want to draw. The Enter key will allow you to enter multiple lines of text.
- Once the text has been entered into the text area, clicking the mouse outside of the text area will set the text and draw in on the image. (The text content entered in this way is automatically set into the Text property.) When the Fill property is True, the background color of the text will be the color set in the BackColor property.
- Select
- Set the EditKind property to KindOfEdit.Select.
- Click on any of the annotation objects currently drawn on the
image (*) and that object will be selected. Selected objects can be
moved, their shape changed, rotated, deleted, and copied.
(*) The location that must be clicked in order for an annotation object to be selected is different depending on the object.
Line Objects: Click on the line to select it.
Polylines, Polygons, and Pen Objects: Click inside the object. Inside means within the area defined by the x coordinate of the left-most point, the y coordinated of the upper most point, the x coordinate of the right-most point and the y coordinate of the lowest point.
Rectangle and Ellipse Objects: Click inside these objects.
Text Object: Click inside the text area.
- MultiSelect
- Set the EditKind property to KindOfEdit.MultiSelect.
- Dragging the mouse will draw the selection area for MultiSelect. Any objects that have a point within this selection area will automatically be selected. All selected objects can be moved, deleted, and copied.
- SelectAll
- Set the EditKind property to KindOfEdit.MultiSelect.
- Set the ContextMenuEnable property to
True and then right-click anywhere in the ImageKit control to
display the Context menu. Choose the "Select All" item and all
annotation objects drawn on the image will automatically be
selected. These selected objects can then be moved, deleted, or
copied.
Note: If not all objects have been selected, choosing the "Select All" item in the Context menu will select all of the objects. When all objects have been selected, they can be deselected by selecting the "Deselect All Objects" item in the Context menu.
- Moving Objects
- Set the EditKind property to KindOfEdit.Select or to KindOfEdit.MultiSelect.
- Moving the mouse cursor over an object that is in a selected
state will cause the following pointer,
, to be displayed on the annotation object. Placing the mouse cursor over that pointer and pressing the left mouse button will allow you to grab the object and drag the object while holding down the left button. Releasing the left mouse button will place the annotation object at that location.
- Changing Shapes of Objects
- Only single selected objects can have their shape changed. Set the& EditKind property to KindOfEdit.Select and select the object whose shape you want to change.
- Moving the mouse cursor over the selected object will change
the pointers to one of the following,
,
,
,
in different locations on the object. Placing the mouse cursor on one of these locations and left clicking it with the mouse will allow you to change the shape of the object by dragging the mouse.
Note: With Rectangles, holding the Shift key down while altering shape will restrict the rectangle to a square. Likewise doing the same thing with an Ellipse will restrict the ellipse to a circle. When resizing an image, if the AspectRatio property is true, the original image's aspect ratio will be maintained while resizing.
- Rotating Objects
- Only single selected objects can be rotated. Set the EditKind property to KindOfEdit.Select and select the object.
- Moving the mouse cursor over the corner of the selected
object's selection area will change the pointer to one of the
following,
,
,
,
. Placing the mouse cursor on one of these locations and left clicking the mouse will allow you to rotate the object. Releasing the mouse button set the rotated object.
IMPORTANT: While editing, all annotation objects will be cleared if the EditEnable property is set to False, or a new image is loaded into the ImageKit control, or the Image property changes. To save any annotation objects, execute the SaveAnnotationFile method to save the annotation information to XML file or execute the DrawEditedObjectsToImage method to rasterize the annotations and embed them into the image.
If the image displayed is larger than the ImageKit control and a Line, Rectangle, Ellipse, Pen, or Text object is selected, moved, changed, etc and the mouse is dragged beyond the ImageKit control, the image will automatically be scrolled according to the mouse movement.
For more information about the Context menu, please refer to the ContextMenuEnable property.
See Also