Hi,
I was using the following code to highlight ALL the matching text in one document at one time - not seaching and moving to the next one by one. It takes minutes to highlight all, which is not acceptable for my purpose of doing a quick search in a document.
foreach (var textRange in search.FindAll(Text))
{
view.MainMessageBodyTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
view.MainMessageBodyTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
}
Please help and suggest if there's a better way of getting all the matching text highlighted at the same time without that much delay. i'm using silverlight. thanks so much.
Regards,
Mia
I was using the following code to highlight ALL the matching text in one document at one time - not seaching and moving to the next one by one. It takes minutes to highlight all, which is not acceptable for my purpose of doing a quick search in a document.
foreach (var textRange in search.FindAll(Text))
{
view.MainMessageBodyTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
view.MainMessageBodyTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
}
Please help and suggest if there's a better way of getting all the matching text highlighted at the same time without that much delay. i'm using silverlight. thanks so much.
Regards,
Mia
10 Answers, 1 is accepted
0
Hello Mia,
Could you please provide additional information about the issue you are observing such as:
I tried this scenario and did not notice any significant delay. That said we would greatly appreciate a sample project if possible.
We are looking forward to your reply.
Regards,
Petya
Telerik
Could you please provide additional information about the issue you are observing such as:
- What version of RadControls for Silverlight are you using?
- How big is the document you test this behavior with and what is its content?
- How many instances of the word you are searching for are there in the document?
I tried this scenario and did not notice any significant delay. That said we would greatly appreciate a sample project if possible.
We are looking forward to your reply.
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mia
Top achievements
Rank 1
answered on 03 Oct 2013, 08:29 PM
Hi Petya,
Thanks for your reply. I'm using version 2013.2.0611.1050. It's a text document with 233 lines(4528 words).
Highlighting string "the" which has 266 matches took me about 4 seconds. If I search for "a" or space that will make the application hang.
Sorry i could not post you a sample project at the moment. The reason why i post this question was because If I put the break point just before and just after the foreach loop I posted before, which is exactly the same as the other posts that telerik has been suggesting for highlighting in document, it takes a long time to get out...
Best regards,
Mia
Thanks for your reply. I'm using version 2013.2.0611.1050. It's a text document with 233 lines(4528 words).
Highlighting string "the" which has 266 matches took me about 4 seconds. If I search for "a" or space that will make the application hang.
Sorry i could not post you a sample project at the moment. The reason why i post this question was because If I put the break point just before and just after the foreach loop I posted before, which is exactly the same as the other posts that telerik has been suggesting for highlighting in document, it takes a long time to get out...
Best regards,
Mia
0
Hi Mia,
We generally evaluate the performance of RadRichTextBox's Search functionality as pretty good. Actually, if you remove the code that selects content you will notice instant execution even with big documents. That said can you please share why you want to select all instances of particular string in a document?
Additionally, note that the results may vary in Release and Debug mode and we'd suggest testing performance only when no debugger is attached.
Other than that here are all performance hints we have when using RadRichTextBox. I hope this is helpful!
Regards,
Petya
Telerik
We generally evaluate the performance of RadRichTextBox's Search functionality as pretty good. Actually, if you remove the code that selects content you will notice instant execution even with big documents. That said can you please share why you want to select all instances of particular string in a document?
Additionally, note that the results may vary in Release and Debug mode and we'd suggest testing performance only when no debugger is attached.
Other than that here are all performance hints we have when using RadRichTextBox. I hope this is helpful!
Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mia
Top achievements
Rank 1
answered on 08 Oct 2013, 10:11 PM
Hi Petya,
Yes I found the search returns instant results, however they are not visible on the application unless I highlight them all.
I was trying to have all the matches highlighted like the find functionality in Chrome and other browsers. Instead of stepping one by one, I would like to see every match highlighted and then have a different colour on the current one I'm stepping through.
Please advice how I could achieve this
Thanks,
Mia
Yes I found the search returns instant results, however they are not visible on the application unless I highlight them all.
I was trying to have all the matches highlighted like the find functionality in Chrome and other browsers. Instead of stepping one by one, I would like to see every match highlighted and then have a different colour on the current one I'm stepping through.
Please advice how I could achieve this
Thanks,
Mia
0
Hi Mia,
Maybe you can adopt the approach demonstrated in this SDK example and create an UI Layer which highlights all instances of a string. UI Layers are used for representational purposes and work significantly faster than adding a lot of ranges to the selection.
Let me know how this works for you.
Regards,
Petya
Telerik
Maybe you can adopt the approach demonstrated in this SDK example and create an UI Layer which highlights all instances of a string. UI Layers are used for representational purposes and work significantly faster than adding a lot of ranges to the selection.
Let me know how this works for you.
Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mia
Top achievements
Rank 1
answered on 14 Oct 2013, 03:48 AM
Thanks Petya, that worked well.
I have all the matching terms highlighted using the customised layer. I also want to select one of the matches and move selection one by one. How do I scroll into view when I move the selection to the next range if it's out of the viewport?
Thanks,
Mia
I have all the matching terms highlighted using the customised layer. I also want to select one of the matches and move selection one by one. How do I scroll into view when I move the selection to the next range if it's out of the viewport?
Thanks,
Mia
0
Mia
Top achievements
Rank 1
answered on 15 Oct 2013, 02:37 AM
Also, after I have applied the UILayers for highlighting all, it worked fine for highlighting 300 matches. However if there are more than 1600 matches on the document, it still takes a long time to do the search and the application will freeze for these 45 seconds. How would you suggest me to prevent this from happening? Thanks so much.
Mia
Mia
0
Hi,
The easiest way to scroll particular content into view is to change the caret position in the document. This could be achieved similarly to the approach you were previously using - finding the first/ next instance of the string with the Find() method and move the caret to the start position of the result .
As for the performance issue you are observing, UI layers are wired to work only for the currently visible part of the document. For the particular case this means that the number of occurrences in the whole document is not the cause for the delay. So for example, a document with 1300 occurrences which only has the searched string in every other paragraph should work just as fast as a small document with one occurrence of the string.
While I understand that delay of the magnitude you are observing is not desired please note that a document consisting of the very same word a lot of times, for example, is considered a border case. At this point there is not much we could do to improve the performance in such cases.
Other than the document content, the layout mode of the control can also influence the performance. If you change it to Paged in the SDK example, the content that is shown will be reduced which means less occurrences of a particular string will be shown in the viewport even if the document consists of the same word repeated numerous times.
I hope this information is helpful!
Regards,
Petya
Telerik
The easiest way to scroll particular content into view is to change the caret position in the document. This could be achieved similarly to the approach you were previously using - finding the first/ next instance of the string with the Find() method and move the caret to the start position of the result .
As for the performance issue you are observing, UI layers are wired to work only for the currently visible part of the document. For the particular case this means that the number of occurrences in the whole document is not the cause for the delay. So for example, a document with 1300 occurrences which only has the searched string in every other paragraph should work just as fast as a small document with one occurrence of the string.
While I understand that delay of the magnitude you are observing is not desired please note that a document consisting of the very same word a lot of times, for example, is considered a border case. At this point there is not much we could do to improve the performance in such cases.
Other than the document content, the layout mode of the control can also influence the performance. If you change it to Paged in the SDK example, the content that is shown will be reduced which means less occurrences of a particular string will be shown in the viewport even if the document consists of the same word repeated numerous times.
I hope this information is helpful!
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mia
Top achievements
Rank 1
answered on 16 Oct 2013, 09:46 PM
Thanks for your reply Petya, I have tried to use MoveToPosition of CaretPosition to scroll into view as the following. The document/view didn't move at all. Could you please advice otherwise?
Thanks,
Mia
view.MainMessageBodyTextBox.Document.CaretPosition.MoveToPosition(textrange.StartPosition);
Thanks,
Mia
0
Hello Mia,
I am not sure what the issue might be, generally moving the caret position should cause the editor to scroll with the caret. I could not replicate inconsistent behavior in this regard.
What you could also try is to use the ScrollToVerticalOffset() method like this:
If you are still experiencing issues scrolling please get back to us with further details on your setup.
Regards,
Petya
Telerik
I am not sure what the issue might be, generally moving the caret position should cause the editor to scroll with the caret. I could not replicate inconsistent behavior in this regard.
What you could also try is to use the ScrollToVerticalOffset() method like this:
this
.radRichTextBox.ScrollToVerticalOffset(textrange.StartPosition.Location.Y);
If you are still experiencing issues scrolling please get back to us with further details on your setup.
Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>