ImageGear .NET v25.0 - Updated
WPF Annotations
User Guide > How to Work with... > ART Mark Annotations > WPF Annotations

This topic provides information about the following:

WPF Marks Supported

While ImageGear .NET supports the entire list of ART 2.0 and 3.0 annotations for editing and displaying in WinForms applications using ImageGear.ART.Forms Namespace and System.Drawing API from ImageGear.Display namespaces, only the following subset of ART 3.0 annotations is supported by the WPF annotation renderer and viewer, allowing display, editing, and UI interaction:

WPF annotations can be created, imported, or exported to/from XML, viewed, changed, moved, or resized in ImageGear .NET.

Additionally, the annotations can be rasterized (using Burn In) and operated via the clipboard API.

WPF annotations can also be viewed with both ImageGear scaling modes: Native and WPF. See more info about scaling modes in Viewing.

WPF Annotation UI Controls

The ImageGear.ART.Windows.Controls Namespace provides WPF annotation UI controls that can simplify development of WPF .NET applications interacting with ART annotations. This functionality is implemented in a separate assembly, using the public ImageGear API, with source code provided to enable modifications. This section provides information about the following:

Annotator

The WPF annotations UI is mainly implemented in the Annotator Class. Use this class in your application to enable interactions with the annotations loaded by ImageGear. This will allow you to create annotation marks with or without a toolbar; edit, move, resize, or delete annotations; and view and edit their properties. The Annotator is associated with the PageView Class control during initialization. A reference to the associated PageView Class control is available via the Annotator.PageView Property. The following code demonstrates initialization of the Annotator: 

C#
Copy Code
 Annotator m_Annotator;
 m_Annotator = new Annotator(m_igPageView);

The Annotator is applicable to the same image and the annotation page used by the PageView Class. The image page is accessible via the PageView.Display Property.Page Property. The annotation page is accessible via the PageView.Display Property.ARTPage Property.

To display an image in your PageView Class control, you would load or create an ImGearPage Class object using the ImageGear API and set it to the PageView.Display Property.Page Property. A similar approach can be used for annotations - load or create an ImGearARTPage Class object using the ImageGear.ART Namespace API and set it to the PageView.Display Property.ARTPage Property. The following code demonstrates PageView.Display Property initialization with a new image and annotation pages:

C#
Copy Code
 ImGearPage m_CurrentPage;
 ImGearARTPage m_CurrentArtPage;
 m_CurrentPage = ImGearFileFormats.LoadPage(f, 0);
 m_CurrentArtPage = ImGearART.LoadPage(page);
 if (m_CurrentArtPage == null)
 {
  m_CurrentArtPage = new ImGearARTPage();
 }
 m_igPageView.Display = new ImGearPresentationPageDisplay(m_ CurrentPage, m_CurrentArtPage);

To enable Annotator support, initialize the Annotator Class as demonstrated in the code example above.

The Annotator Class provides a set of events that allows you to control the process of creating, editing, and deleting marks using the UI. The following code demonstrates initialization and use of Annotator Class events:

C#
Copy Code
m_Annotator.PreCreateMark += new Annotator.PreCreateMarkEventHandler(Page_PreCreateMark);
m_Annotator.PreDeleteMark += new Annotator.PreDeleteMarkEventHandler(Page_PreDeleteMark);
m_Annotator.ModifyMark += new Annotator.ModifyMarkEventHandler(Page_ModifyMark);
 public void Page_PreCreateMark(object sender, PreCreateMarkEventArgs e)
 {
  // Check the mark.
 }
 public void Page_PreDeleteMark(object sender, PreDeleteMarkEventArgs e)
 {
  // Check the mark.
 }
 public void Page_ModifyMark(object sender, ModifyMarkEventArgs e)
 {
  // Check the modified mark.
 }

The Annotator Class also provides a set of customizable UI parameters accessed via its Settings Property. This allows you to change the Annotator's global settings as well as its behavior at runtime.  

Toolbar Annotator

While it is not required for the Annotator to use a toolbar (you can force the Annotator to change its Tool property using menu items, radio buttons, etc.), most applications will probably use a toolbar.

The ToolBarAnnotator Class is a version of the Annotator that implements a toolbar-based UI control. The purpose of this class is to demonstrate the use of a toolbar, implemented in the ToolBar Class, with the Annotator in WPF .NET applications. This class, as the rest of this namespace, is distributed with the source code and could be adjusted and modified as required. The following code demonstrates initialization of the ToolBarAnnotator Class

C#
Copy Code
  Annotator m_Annotator;
  m_Annotator = new ToolBarAnnotator(m_igPageView, m_AnnotationMenu.ToolBar);

ToolBarAnnotator Class inherits all the properties of the Annotator Class.

See Also