LEADTOOLS Support
Document
Document SDK Questions
HOW TO: Customizing the default annotation objects (C#, v18.0, WinForms)
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, August 22, 2013 1:06:03 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 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
LEADTOOLS Support
Document
Document SDK Questions
HOW TO: Customizing the default annotation objects (C#, v18.0, WinForms)
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.