This code snippet comes from RichEditBox style application,
Document.Selection.SetRange(paragraphStartIndex, paragraphStartIndex + data.Text.Length);
Document.Selection.CharacterFormat.Strikethrough = FormatEffect.On;
However, can we do similar things with a RichTextBlock?
I know that I can add a <run> or a <Span> and add style information to these elements, but is there any way to grab the whole RichTextBlock content and apply style to a range of text within it?
RichTextBlock and RichEditBox are rich text-related controls, but they are very different in display.
The process of RichEditBox displaying rich text is like drawing on paper, because it carries the modified function, so there is a complete Document as a carrier.
RichTextBlock is not responsible for modification, it is only responsible for display, so it is more like building blocks. RichTextBlock has a lot of display elements to render different visual effects, but they are independent of each other. You can't set effects for a certain character. You can only set the effect for the entire block (such as Paragraph).
When you select text in the RichTextBlock, you can get the parent element of the currently selected text point through RichTextBlock.SelectionStart.Parent or RichTextBlock.SelectionEnd.Parent, and set the effect.
Best regards.
Related
I need to manipulate the content streams of a page in such a way that if the contents of Tf of one of the elements of TF matches specific values the background area of those squares/glyphs needs to change.
I think that I would need save the graphics state, after creating two different string objects, then apply a fill operator then restore the graphics state.
My question is: would the fill operator recognize the area of the matched string and fill just this?
Second: would I need to repeat this sequence for each element of the TF array?
It's not quite that simple.
You have to determine the position of the text yourself (by keeping track of the current transformation matrix for the whole page content stream and the text matrix for the text object in which your text in question is drawn) and then insert a path outlining that area and filling it just before the text object in question.
But this in particular means that it is not necessary to split the strings of the text drawing instructions to have the search text be drawn by itself.
By the way, if this change of background is meant to represent something like a text marker marking, an alternative to changing the page content would be to create text markup annotations for the determined coordinates. That way you would merely have to parse the page content stream for the coordinates, you don't have to change it. In particular if the text drawing instructions may also be in some form Xobject referenced from the page content instead of the page content itself, this may simplify the code.
Does anyone know a Windows Phone textbox control that binds to HTML property? I've used C1RichTextBox and it does the job but it's too damn slow! Please help.
The control from ComponentOne is the only one I'm aware of.
Where I've had to display HTML content in the past I've used one of the following two approaches.
Display the content in a WebBrowser control.
Manually parse the HTML and convert it into XAML controls.
The first option is appropriate when there is large amount of HTML to parse and when it is likely to vary greatly. (i.e. you can't be sure you'll only get a certain set of tags being used.)
If using the second option, be sure to consider using the HTML Agility Pack to help tidy up the HTML before parsing it.
A possible workaround is to put RichTextBox into a ScrollViewer to take advantage of the hardware accelerated control.
<ScrollViewer>
<c1:C1RichTextBox Height="1000" />
</ScrollViewer>
I have some forms that I need to add expanding text boxes to.
I already have Multi-Line selected. And yes the scroll-bar appears when field is full and you keep entering text. However, when you go to print, it doesn't print out the full text.
I know in Adobe LiveCycle you can make dynamic forms, that bump onto the next page. I have done this, but you lose so much functionality in LiveCycle. To be dynamic you lose the ability to position objects without using tables and therefore doing designs and graphics are not as easy.
Has anyone found a way to do this in Adobe Acrobat X Pro?
At this point, I think it would be easier just to convince people that a web form is much easier to update and style any way you want with print CSS stylesheet.
Thanks for any suggestions.
To be dynamic you lose the ability to position objects without using tables and therefore doing designs and graphics are not as easy.
That is not true. A form being dynamic or not has nothing to do with having flowed or positioned content. A static form renders once on the server, a dynamic form can be re-rendered on the client and thus is able to reflect layout changes like hiding objects or altering heights of objects (more info).
With either form type you can have both positioned and flowed content. The trick is to divide your form into subforms according to the structure of the data you want to display (tutorial).
To let the text field grow automatically with the amount of text, enclose it in a subform with flowed content, allow multiple lines and enable "expand to fit" (or "auto-fit).
In my app I want to provide bookmarks for text in NSTextView. Should I use RTF bookmarks?
And if so, how to determine their position later?
What options are possible to solve this problem?
See the Attributed String Programming Guide and the Text Attribute Programming Guide. You can set standard or custom attributes attributed strings (which NSTextView consumes) for a given range. You can also use an NSTextAttachment to show some sort of visible "anchor". Scroll the range of the attribute run or attachment to visible when the "bookmark" is selected.
Really, the sky is the limit in terms of "style". It just depends on what you're trying to do and how much functionality you want.
I want to adjust the size of the "Browse" section seen in the file upload button in HTML. When I try to adjust the size using "size" or "width" attributes, only the whole size is reduced. But I want only the size of the "Browse" button part to be reduced and not the textbox part which displays file path. Can I do this without using CSS? If yes , how?
The file input element is notoriously difficult to style. One of the problems is that it's really a single element, even though it renders as two elements.
One approach is to obscure the entire element behind the scenes and present the user with custom elements instead. Here's an article about it. Basically the file input element is hidden and some custom elements backed by some JavaScript are handling the UI and passing the necessary information to the file input.
It is very difficult to change the appearance of the Browse button as it is typically hardwired into the browser.
However, at Quirksmode.org|Styling an input type="file", there is a long post that discusses complex CSS techniques for changing the appearance of file input elements.