ImageGear .NET v24.12 - Updated
User Interaction
User Guide > How to Work with... > ART Mark Annotations > Custom Annotations > User Interaction

ImageGear ART Forms provides 3 classes to support the end user’s interaction and UI for custom marks. You must take one of them as a base class and implement a custom annotator controller in your application, just like you did for the custom class and custom controller. The custom annotator controller is responsible for:

Base classes are as follows:

This topic provides information about the following:

Create Custom Marks

Custom mark creation is processed by two overridden methods: CanCreateMark and CreateMark.

Annotator calls CanCreateMark each time the user releases a mouse button. Annotator passes a set of already entered points as parameters, along with some data that can be used in CanCreateMark method (see ImGearARTFormsCreateMarkData class description). It’s the controller’s responsibility to analyze if already entered points are enough for creating a mark (and/or by some conditions in the creation data). For example, all rectangular annotations can be created by 2 points, so default implementation in ImGearARTFormsRectangleController returns true without any checks (when MouseUp occurs, point list contains exactly two points). As another example, in PolyController default implementation checks if the last mouse click event was a double-click. This behavior is overridden in SectorMark, which needs 3 points for creation, and it is checked in SectorEditController.CanCreateMark.

CreateMark is a public controller’s method. It is called by Annotator if last call of CanCreateMark was successful. This method should be overridden in all custom controllers. It creates a new instance of the custom mark by given set of points.

Resize Custom Marks

To process resizing of marks that are rectangular, the user must override UpdateBounds method. It takes a rectangle containing new bounds for mark, and updates custok mark’s properties with it. It is necessary, because there is no common properties for custom mark, that determines custom mark’s bounds. All other functionality, including cursors handling, is implemented in the ImGearARTFormsRectangleController class.

To process resizing of marks that are not rectangular, the user must override at least Resize method, which takes a point, a point identifier, and updates one of the mark’s points with a given point. It will work for marks that are similar to the Polyline mark, i.e., marks based on a list of points. For more complex marks (for example, if custom mark is similar to Art Callout mark), the user may also want to override ManageCursor method. Here the user is able to:

ManageCursor is called by Annotator every time when mouse hovers the mark which is selected. Default ManageCursor implementation method analyzes if the mouse is over one of mark’s resizing points, and, if yes, sets up the cursor and store a point ID in the data structure passed by annotator. Resize method is called by Annotator if mouse moved while mouse button is pressed, and appropriate resizing cursor and point identifier was set up during previous call of ManageCursor. Overridden Resize must update the internal point with new passed coordinates, using point identifier passed by Annotator (see ImGearARTFormsMarkControllerData in API Reference).

Implement a Custom Property Window

To implement a custom property window for the custom mark, the user must override the GetPropertiesWindow method in the custom mark edit controller. Annotator calls this method when the “Properties” menu item is selected in the Annotator UI, and passes a mark for which property window is requested, and a current ImGearPageView object. In overridden method the user must create a Form-derived window which will display and modify mark’s properties. Please refer to SectorPropertyWindow class in ART sample.

It is not necessary to implement your property window for custom mark, if you are not going to use it. If edit controller returns null instead of form, the annotator doen not display anything.

Create a Toolbar

When Annotator creates a toolbar, it iterates a list of registered custom mark edit controllers and gets a ToolbarInfo property for each. ToolbarInfo is a read-only edit controller’s property of public type ImGearARTFormsToolbarButtonInfo.

This class has fields that are necessary for creating a toolbar button which will be associated to custom mark/edit controller. In user’s overridden ToolbarInfo property the user must create a new ImGearARTFormsToolbarButtonInfo object and fill its fields with the button’s icon, tooltip string and user type identifier (string, same as was used when the controller is registered).