ImageGear for .NET
Annotations

All annotation user interface functionality can be accessed through the PageView control by adding a reference in your project to ImageGear.Windows.Controls.Art.dll. This includes functionality for setting the PageView.MouseTool property so that the user can use the mouse to create and edit annotation marks. For information on using a toolbar to select the PageView mouse tool, see the Toolbar section.

The ImageGear.Windows.Controls.Art assembly also provides functionality for accessing the annotation context menu items in the PageView context menu, which is described in the Context Menu section.

This section provides information about the following:

Mouse Tool and Mode

You can do either of the following:

If you do not reference ImageGear.Windows.Controls.Art.dll in your project, then the PageView.AnnotationMode property will have no effect, and if the PageView.MouseTool property is set to an annotation mouse tool, the behavior will be the same as setting the MouseTool property to None. The PageView.AnnotationsAreAvailable method will return true if your application is referencing ImageGear.Windows.Controls.Art.dll and is able to locate it.

Mouse Tool Settings

You can use the PageView.MouseToolSettings.Annotation property to access the mouse tool settings for annotation marks.

The PageView.MouseToolSettings.Annotation.Templates property provides a property for each mark type, which can be set to specify the properties of the mark when it is added using the mouse. These template properties only affect mark creation if PageView.MouseToolSettings.Annotation.DrawPreview is set to false.

The SelectionStyle property can be used to set a Style for the annotation selection rectangle to specify its look. For example, the code below demonstrates how to create a SolidColorBrush with an opacity and color, create a Style, and add a Setter for the Brush Stroke property.

C# Example
Copy Code
System.Windows.Media.Color annColor = System.Windows.Media.Color.FromArgb(myOpacity, myColor.R, myColor.G, myColor.B);
System.Windows.Media.Brush annBrush = new System.Windows.Media.SolidColorBrush(annColor);
Style selectStyle = new Style(typeof(System.Windows.Shapes.Rectangle));
Setter setterStroke = new Setter(System.Windows.Shapes.Rectangle.StrokeProperty, annBrush);
selectStyle.Setters.Add(setterStroke);
pageView.MouseToolSettings.Annotation.SelectionStyle = selectStyle;

PageView.MouseToolSettings.Annotation also provides properties for:

There are also preview mark settings, which are described in the next section.

In-Progress Mark and Preview Mark

When using the mouse to create an annotation mark, by default an "in-progress mark" is drawn as the mark will appear when it is added. This in-progress mark can be accessed through the PageView.InProgressMark property.

To instead draw a preview mark during mark creation, set the PageView.MouseToolSettings.Annotation.DrawPreview property to true. The preview mark is drawn using the PageView.MouseToolSettings.Annotation.CreatorColor and PageView.MouseToolSettings.Annotation.CreatorOpacity settings.

Annotation Events

PageView contains MarkCreatingMarkRemoved, and MarkChanged events as well as mouse events that can be used to programmatically handle when a mark is edited, clicked, etc. You can access the ImGearARTMark at the current mouse position by using the PageView.Display.HitTestCanvas method as shown in the following code.

C# Example
Copy Code
Point mousePoint = e.GetPosition(pageView);
 
if (pageView.Display != null)
{
    int markID = -1;
    if (pageView.Display.ARTPage != null)
    {
        ImGearARTPage art = (ImGearARTPage)pageView.Display.ARTPage;
        ImGearDoublePoint[] pnts = new ImGearDoublePoint[]
            {
            new ImGearDoublePoint(mousePoint.X, mousePoint.Y),
            new ImGearDoublePoint(mousePoint.X - 1, mousePoint.Y),
            new ImGearDoublePoint(mousePoint.X + 1, mousePoint.Y),
            new ImGearDoublePoint(mousePoint.X - 2, mousePoint.Y),
            new ImGearDoublePoint(mousePoint.X + 2, mousePoint.Y),
            new ImGearDoublePoint(mousePoint.X, mousePoint.Y - 1),
            new ImGearDoublePoint(mousePoint.X, mousePoint.Y + 1),
            new ImGearDoublePoint(mousePoint.X, mousePoint.Y - 2),
            new ImGearDoublePoint(mousePoint.X, mousePoint.Y + 2)
            };

        for (int i = 0; i < pnts.Length; i++)
        {
            markID = pageView.Display.HitTestCanvas(
                pnts[i], pageView, pageView.Canvas, 0, 0);
            if (markID >= 0) break;
        }

Using Keyboard Input for Different Annotation Resize Behavior

The Shift and Ctrl keys can be used to affect how a mark is resized.

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback