My requirement is highlighting the text on Image while drawing the rectangular on Image Text .I have tried different ways but Color is not applying to Text.Please help me Thank you.
What I have tried:
protected void HighlightImageText(ImageViewerRubberBandEventArgs e)
{
int left = 0;
int right = 0;
int top = 0;
int bottom = 0;
int PAX = -1, PAY = -1, PBX = -1, PBY = -1, PCX = -1, PCY = -1, PDX = -1, PDY = -1;
LeadRect selectedImageRectangle = new LeadRect(0, 0, 0, 0);
selectedImageRectangle = this._imageViewer.ConvertRect(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image,
LeadRect.FromLTRB(e.Points[0].X, e.Points[0].Y, e.Points[1].X, e.Points[1].Y));
left = selectedImageRectangle.Left;
right = selectedImageRectangle.Right;
top = selectedImageRectangle.Top;
bottom = selectedImageRectangle.Bottom;
PAX = selectedImageRectangle.X;
PAY = selectedImageRectangle.Y;
PBX = PAX + selectedImageRectangle.Width;
PBY = PAY;
PCX = PAX;
PCY = PAY + selectedImageRectangle.Height;
PDX = PBX;
PDY = PCY;
try
{
if (_annManager == null)
{
_annManager = new AnnAutomationManager();
_annManager.CreateDefaultObjects();
}
_automationControl = new ImageViewerAutomationControl();
{
_annAutomation = new AnnAutomation(_annManager, _automationControl);
_annAutomation.Active = true;
}
Leadtools.Annotations.AnnContainer container = new Leadtools.Annotations.AnnContainer();
left = PAX;
if (left > PBX) left = PBX;
if (left > PCX) left = PCX;
if (left > PDX) left = PDX;
top = PAY;
if (top > PBY) top = PBY;
if (top > PCY) top = PCY;
if (top > PDY) top = PDY;
right = PDX;
if (right < PCX) right = PCX;
if (right < PBX) right = PBX;
if (right < PAX) right = PAX;
bottom = PDY;
if (bottom < PCY) bottom = PCY;
if (bottom < PBY) bottom = PBY;
if (bottom < PAY) bottom = PAY;
if (left != -1 && right != -1 && top != -1 && bottom != -1)
{
float width = 0;
float height = 0;
width = System.Math.Abs(right - left);
height = System.Math.Abs(bottom - top);
double inch = 720.0;
Leadtools.Annotations.Core.AnnHiliteObject hiliteObj = new Leadtools.Annotations.Core.AnnHiliteObject();
hiliteObj.Points.Add(LeadPointD.Create(1 * inch, 1 * inch));
hiliteObj.Points.Add(LeadPointD.Create(2 * inch, 1 * inch));
hiliteObj.Points.Add(LeadPointD.Create(2 * inch, 2 * inch));
hiliteObj.Points.Add(LeadPointD.Create(1 * inch, 2 * inch));
hiliteObj.Rect = LeadRectD.Create(left, top, width, height);
hiliteObj.HiliteColor = "Yellow";
hiliteObj.RenderedObjectBounds = LeadRectD.Create(left, top, width, height);
hiliteObj.Fill = AnnSolidColorBrush.Create("Yellow");
hiliteObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Yellow"), LeadLengthD.Create(1));
hiliteObj.Bounds.ContainsRect(LeadRectD.Create(left, top, width, height));
_annAutomation.Container.Children.Add(hiliteObj);
_annAutomation.ActiveContainer.Children.Add(hiliteObj);
AnnRectangleObject rectObj = new AnnRectangleObject();
rectObj.Rect = LeadRectD.Create(left, top, width, height);
rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthD.Create(1));
rectObj.Fill = AnnSolidColorBrush.Create("Yellow");
rectObj.RenderedObjectBounds= LeadRectD.Create(left, top, width, height); ;
_annAutomation.ActiveContainer.Children.Add(rectObj);
this._imageViewer.Invalidate();
Size imgSize = this._imageViewer.Size;
Size newImgSize = imgSize;
newImgSize.Height = newImgSize.Height - 1;
this._imageViewer.Size = newImgSize;
this._imageViewer.Size = imgSize;
}
}
catch (Exception ex)
{
}
}