ImageGear .NET
Create and Delete Annotations

This section provides information about creating annotations...

and also information about how to...

Using the Toolbar

End users can create a mark using the ART toolbar, or your application can create them directly by calling ART functions. This section describes how to create marks with user interaction through the ART toolbar.

When a button is selected from the toolbar, ART goes into "edit mode", where the mouse is used to place and size the mark. The sequence of events depends on whether the mark is one of the types that contains text or not:

If the mark does not contain text:

  1. User drags a rectangle on the image.
  2. Mark is placed and sized on the image, and is selected.
  3. Control returns to the application.

If the mark contains text:

  1. User drags a rectangle on the image.
  2. Mark is placed and sized on the image, and is placed in text-edit mode.
  3. Blinking "I-Beam" insertion point is placed in the mark.
  4. User types text into the mark, as desired. 
  5. User clicks the mouse-button. Mark goes from text-edit mode to selected.
  6. Control returns to the application.

During the creation of polymarks, such as Polyline, Polyline Ruler or Polygon, two options can be enabled (both are disabled by default):

  1. Auto-rollback: when the user clicks on the last added point (for Polyline, Polyline Ruler, Curve, Polygon) or drags over it (for Freeline), the latest point is removed. This allows the user to fix mistakes in drawing a mark. See the IsPolyMarkAutoRollbackEnabled property.
  2. Auto-close: when the last point of the mark is quite close to the first one, and the mark has the IsClosed property, it is set to True. Marks that support the IsClosed property are Freeline and Polyline. See the IsPolylineAutoCloseEnabled property.

ART Toolbar event handlers are implemented in the ART Forms open source code and can be modified at any time and in any way, but in order for them to work, your application needs to interact with the following events: 

C#
Copy Code
private void imGearPageView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    igARTForms.MouseDown(sender, e);
}
private void imGearPageView_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
    igARTForms.MouseMove(sender, e);
}
private void imGearPageView_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
    igARTForms.MouseUp(sender, e);
}

Using API Calls

Some applications won't use the ART Toolbar, or will provide the Toolbar and other options to create marks. In that case, some methods in your application will need to create the marks directly. ART marks are created by using their constructors. For example, a rectangle mark can be created as follows: 

C#
Copy Code
ImGearRGBQuad igRGBQuad = new ImGearRGBQuad(255, 0, 0);
ImGearRectangle igRectangle = new ImGearRectangle(0, 0, 100, 100);
ImGearARTRectangle igARTRectangle = new ImGearARTRectangle(igRectangle, igRGBQuad);

Once it is created, it should be added to the ART page:

C#
Copy Code
int markID;
markID = igARTPage.AddMark(igARTRectangle, ImGearARTCoordinatesType.IMAGE_COORD);

Mark properties can be edited at any time:

C#
Copy Code
// Get the mark we just added.
igARTRectangle = (ImGearARTRectangle)igARTPage.MarkGet(markID);
igARTRectangle.Opacity = 128;

The same mark cannot be added to the same or another ART page twice; it must be cloned prior to adding it again, otherwise the ImGearException will be thrown. To control whether the mark already has parent group, please use ImGearARTMark.ParentGroup property. See the sample code below:

C#
Copy Code
if (igARTRectangle.ParentGroup != null)
{
    igARTRectangle = igARTRectangle.Clone();
}
igARTPage.AddMark(igARTRectangle, ImGearARTCoordinatesType.IMAGE_COORD);
ImGearARTPage otherPage = new ImGearARTPage();
igARTRectangle = igARTRectangle.Clone();
otherPage.AddMark(igARTRectangle, ImGearARTCoordinatesType.IMAGE_COORD);

Delete Marks

Delete annotations using ImGearARTPage.MarkRemove Method or RemoveMarks Method

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback