Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, August 22, 2013 1:11:03 PM(UTC)

RobertB  
Guest

Groups: Guests
Posts: 3,049

Was thanked: 1 time(s) in 1 post(s)

Suppose you are satisfied with the features of the default annotation objects but wish change their default values.
For example:
  • Change the default text, text color, and background color in the AnnNoteObject.
  • Automatically close and fill the AnnPolyLineObject.
  • Remove the tick marks from the AnnProtractorObject.
  • Change the units on the ruler (AnnPolyRulerOjbect) to Millimeters(mm).
  • etc...

To accomplish this you must modify the AnnObject held in the corresponding AnnAutomationObject.ObjectTemplate property. One implementation is to create the default objects with the AnnAutomationManager and iterate through the AnnAutomationObjects held in the AnnAutomationManager.Objects property, modifying the ObjectTemplate objects like so:
            // Initialize automationManger and populate with automation annotation objects.
            var annAutoManager = new AnnAutomationManager();
            annAutoManager.CreateDefaultObjects();
            foreach (AnnAutomationObject autoObj in annAutoManager.Objects)
            {                 switch(autoObj.Id)
                {                     // Customize note.                     case(AnnObject.NoteObjectId):                         AnnNoteObject note = autoObj.ObjectTemplate as AnnNoteObject;                         note.TextBackground = AnnSolidColorBrush.Create("Red");                         note.TextForeground = AnnSolidColorBrush.Create("White");                         note.Fill = AnnSolidColorBrush.Create("Blue");                         note.Text = "This is a Note!";                         break;
                    // Fill all polylineObjects with black.                     case(AnnObject.PolylineObjectId):                         autoObj.ObjectTemplate.Fill = AnnSolidColorBrush.Create("Black");                         break;
                    // Remove protractor tickmarks.                     case(AnnObject.ProtractorObjectId):                         (autoObj.ObjectTemplate as AnnProtractorObject).ShowTickMarks = false;                         break;
                                         // Change ruler units to mm.                     case(AnnObject.RulerObjectId):                         (autoObj.ObjectTemplate as AnnPolyRulerObject).MeasurementUnit = AnnUnit.Millimeter;                         break;
                }             }

Please see the full source in the attached project.



Using Visual Studio 2010, .NET4.0, Leadtools.Annotations.Core
File Attachment(s):
CustomDefaultAnnObjects.zip (85kb) downloaded 37 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2017, Yet Another Forum.NET
This page was generated in 0.259 seconds.