Hi,
I haven't attempted this yet but, do you have any advice on the best way to highlight any text that is NOT contained within Custom Annotations?
i.e. what do you think is the most efficient check process to find and highlight all text not contained within annotations?
Thanks for your time, any advice is appreciated,
Rob
I haven't attempted this yet but, do you have any advice on the best way to highlight any text that is NOT contained within Custom Annotations?
i.e. what do you think is the most efficient check process to find and highlight all text not contained within annotations?
Thanks for your time, any advice is appreciated,
Rob
4 Answers, 1 is accepted
0

Robert
Top achievements
Rank 1
answered on 29 Aug 2012, 12:33 AM
My logic tells me to follow something similar to your "HighlightCurrentWordLayer" example, but rather than checking for specific words I should check if the text is contained within RangeStart and RangeEnd Annotation tags.
0

Robert
Top achievements
Rank 1
answered on 29 Aug 2012, 01:16 AM
Well this seems pretty close to what I need:
All I need to do now is restric it so that it only highlights text that is not contained within my CustomAnnotations.
(I've attached an image of my document for this current UI layer).
public
override
void
UpdateUIViewPortOverride(UILayerUpdateContext context)
{
foreach
(SpanLayoutBox spanBox
in
context.GetVisibleTextLayoutBoxes())
{
SizeF spanBoxSize = spanBox.Size;
this
.AddRectangle(spanBoxSize, spanBox);
}
}
private
void
AddRectangle(SizeF spanBoxSize, SpanLayoutBox spanBox)
{
Rectangle rectangle =
new
Rectangle();
rectangle.Width = Math.Max(0, (
double
)spanBoxSize.Width);
rectangle.Height = (
double
)spanBoxSize.Height;
Canvas.SetTop(rectangle, spanBox.ControlBoundingRectangle.Top);
Canvas.SetLeft(rectangle, spanBox.BoundingRectangle.Left);
rectangle.Fill = FillBrush;
rectangle.Opacity = AddToDatabaseHighlightLayer.MouseOutOpacity;
base
.AddDecorationElement(rectangle);
}
All I need to do now is restric it so that it only highlights text that is not contained within my CustomAnnotations.
(I've attached an image of my document for this current UI layer).
0

Robert
Top achievements
Rank 1
answered on 29 Aug 2012, 01:36 AM
Ok, I now have it working so that any text surrounded by my custom annotations are ignored.
Here's my new UpdateUIViewPortOverride method:
Here's my new UpdateUIViewPortOverride method:
public
override
void
UpdateUIViewPortOverride(UILayerUpdateContext context)
{
foreach
(SpanLayoutBox spanBox
in
context.GetVisibleTextLayoutBoxes())
{
AnnotationMarkerLayoutBox previousAnnotationLayoutBox = (AnnotationMarkerLayoutBox)DocumentStructureCollection.GetPreviousElementOfType(spanBox,
typeof
(AnnotationMarkerLayoutBox));
AnnotationMarkerLayoutBox nextAnnotationLayoutBox = (AnnotationMarkerLayoutBox)DocumentStructureCollection.GetNextElementOfType(spanBox,
typeof
(AnnotationMarkerLayoutBox));
if
((previousAnnotationLayoutBox.AssociatedAnnotationMarker
is
SemanticRangeStart && nextAnnotationLayoutBox.AssociatedAnnotationMarker
is
SemanticRangeEnd) ||
(previousAnnotationLayoutBox.AssociatedAnnotationMarker
is
LineBreakSpacingRangeStart && nextAnnotationLayoutBox.AssociatedAnnotationMarker
is
LineBreakSpacingRangeEnd) ||
(previousAnnotationLayoutBox.AssociatedAnnotationMarker
is
CommentLineRangeStart && nextAnnotationLayoutBox.AssociatedAnnotationMarker
is
CommentLineRangeEnd) ||
(previousAnnotationLayoutBox.AssociatedAnnotationMarker
is
CommentParagraphStart && nextAnnotationLayoutBox.AssociatedAnnotationMarker
is
CommentParagraphEnd) ||
(previousAnnotationLayoutBox.AssociatedAnnotationMarker
is
RoomGroupRangeStart && nextAnnotationLayoutBox.AssociatedAnnotationMarker
is
RoomGroupRangeEnd))
{
}
else
{
if
(!String.IsNullOrWhiteSpace(spanBox.Text.Trim()))
{
SizeF spanBoxSize = spanBox.Size;
this
.AddRectangle(spanBoxSize, spanBox);
}
}
}
}
0
Hello Rob,
Iva Toteva
the Telerik team
We are glad to hear that you have found a solution to your question. Thank you for sharing it with the community!
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.