I am trying to replicate some basic functionality of a Windows Forms application, which I will here call Legacy. In a couple of places, Legacy allows users to drag and drop files as attachments. The filenames appear within text supplied by the user, underlined and with the forecolor green. I have this working. Subsequently, when the user double-clicks on a filename, the file selected by double-clicking is opened for viewing (assuming a suitable viewer is available). I have gotten double-click detection working and (for now) I am considering the viewer to be unrelated to the RadRichText control's functionality. Here is the problem:
Suppose I have text like: "Here's a screenshot: Bad Error.bmp" - where "Bad Error.bmp" is in green, underlined. When the user double-clicks on, say, the ".", I want the entire filename to be selected and to launch the (as yet hypothetical) viewer. I can easily select the word at, or nearest to, the current caret position. How can I select all contiguous characters that are green and underlined?
Having selected any text that is green and underlined (part of a filename), I thought I would start by verifying programmatically that is green and underlined. Given that some text is selected, all of which has the same style values, it seems from the documentation that this should work, but it doesn't:
StyleDefinition style = this.CurrentEditingStyle;
Color? foreColor = (Color?)style.GetPropertyValue(Span.ForeColorProperty);
Color? underlineColor = (Color?)style.GetPropertyValue(Span.UnderlineColorProperty);
foreColor and underlineColor are Black and Black, which are the values for the surrounding text, or the default values for the document - not the correct values for the selected text, or at the caret position, as http://www.telerik.com/help/silverlight/radrichtextbox-features-working-with-radrichtextxbox.html#Current_Span led me think would be the case. Please explain.
Checking the underline color is a rather indirect way to determine whether text is underlined, but it does seem to work.
My two questions are in bold text above.
Actually, there is a third question, which is: If what I am trying to do won't work, can you suggest a different approach that will arrive at the same result? For example, it would serve the same purpose if one could track the positions of all hyperlinks and attachment filenames as the text was edited
Thanks,
George
Suppose I have text like: "Here's a screenshot: Bad Error.bmp" - where "Bad Error.bmp" is in green, underlined. When the user double-clicks on, say, the ".", I want the entire filename to be selected and to launch the (as yet hypothetical) viewer. I can easily select the word at, or nearest to, the current caret position. How can I select all contiguous characters that are green and underlined?
Having selected any text that is green and underlined (part of a filename), I thought I would start by verifying programmatically that is green and underlined. Given that some text is selected, all of which has the same style values, it seems from the documentation that this should work, but it doesn't:
StyleDefinition style = this.CurrentEditingStyle;
Color? foreColor = (Color?)style.GetPropertyValue(Span.ForeColorProperty);
Color? underlineColor = (Color?)style.GetPropertyValue(Span.UnderlineColorProperty);
foreColor and underlineColor are Black and Black, which are the values for the surrounding text, or the default values for the document - not the correct values for the selected text, or at the caret position, as http://www.telerik.com/help/silverlight/radrichtextbox-features-working-with-radrichtextxbox.html#Current_Span led me think would be the case. Please explain.
Checking the underline color is a rather indirect way to determine whether text is underlined, but it does seem to work.
My two questions are in bold text above.
Actually, there is a third question, which is: If what I am trying to do won't work, can you suggest a different approach that will arrive at the same result? For example, it would serve the same purpose if one could track the positions of all hyperlinks and attachment filenames as the text was edited
Thanks,
George