With LEADTOOLS Annotations, you can create your own custom thumbs (control points). You can create custom styles for the location, rotation center and rotation gripper thumbs.
To implement a user-defined thumb style, create a class that implements the IAnnThumbStyle interface. Then, assign your custom thumb style class to an IAnnObjectRenderer interface, which will then use your custom thumb style when rendering annotation objects.
The following example demonstrates how to create a custom thumb for an annotation object. Start with the example that you created in Implementing User-Defined Objects With LEADTOOLS Annotations.
First, create a new class, derived from the base class AnnThumbStyle, and override the AddPath method:
public class AnnTriangleThumbStyle : AnnThumbStyle
{
protected override AnnThumbStyle Create()
{
return new AnnTriangleThumbStyle();
}
protected override void AddPath(System.Drawing.Drawing2D.GraphicsPath path, LeadRectD rect)
{
if (path != null)
{
// Add our triangle
float left = (float)rect.Left;
float right = (float)rect.Right;
float width = (right - left) / 2;
float top = (float)rect.Top;
float bottom = (float)rect.Bottom;
path.AddLine(left, bottom, left + width, top);
path.AddLine(left + width, top, right, bottom);
path.AddLine(right, bottom, left, bottom);
path.CloseFigure();
}
}
}
Next, assign your custom thumb style class to the annotation object renderer. Replace the code after the 'Set our renderer, same as the AnnPolylineObject' comment in InitializeTriangleObject:
// Set our renderer
// Get the current polyline renderer (we need to use some of the properties we are not changing)
IAnnObjectRenderer polylineRenderer = annotations.AutomationManager.RenderingEngine.Renderers[AnnObject.PolylineObjectId];
// Create the new renderer
IAnnObjectRenderer renderer = new AnnPolylineObjectRenderer();
// Use the existing label renderer. It is not being changed
renderer.LabelRenderer = polylineRenderer.LabelRenderer;
// Now, use the new triangle thumbs:
// Change the location thumb style
AnnTriangleThumbStyle locationThumb = new AnnTriangleThumbStyle();
locationThumb.Size = LeadSizeD.Create(72 * 2, 72 * 2);
locationThumb.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("black"), LeadLengthD.Create(1));
locationThumb.Fill = AnnSolidColorBrush.Create("#7F0000FF");
renderer.LocationsThumbStyle = locationThumb;
// Change the rotation center thumb style
AnnTriangleThumbStyle rotateCenterThumb = new AnnTriangleThumbStyle();
rotateCenterThumb.Size = LeadSizeD.Create(72, 72);
rotateCenterThumb.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("black"), LeadLengthD.Create(1));
rotateCenterThumb.Fill = AnnSolidColorBrush.Create("#EFFF0000");
renderer.RotateCenterThumbStyle = rotateCenterThumb;
// Change the Rotation gripper thumb style
AnnTriangleThumbStyle rotateGripperThumb = new AnnTriangleThumbStyle();
rotateGripperThumb.Size = LeadSizeD.Create(72 * 2, 72 * 2);
rotateGripperThumb.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("black"), LeadLengthD.Create(1));
rotateGripperThumb.Fill = AnnSolidColorBrush.Create("#3F00FF00");
renderer.RotateGripperThumbStyle = rotateGripperThumb;
annotations.AutomationManager.RenderingEngine.Renderers[AnnTriangleObject.MyId] = renderer;
Products |
Support |
Feedback: Implementing User Defined Thumb Styles With LEADTOOLS Annotations |
Introduction |
Help Version 19.0.2017.6.21
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.