I want to display and edit serial data (e.g. NULL, STX, ETX, ENQ, etc. characters) in the text box in WPF. It should be displayed same like Notepad++ as shown here.
I have tried using textbox, RichTextBox in WPF, but only printable characters are shown. Non printable characters (e.g. NULL, STX, ETX, ENQ, etc. characters) are not shown.
Will you please guide me how can I display this?
Related
We are implementing rich editor using DraftJS. As a reference we do some study on the sample published by DraftJS Github example.
The code is here
https://github.com/facebook/draft-js/blob/main/examples/draft-0-10-0/color/color.html
But we are confused about the phenomenon that the color can not be applied on Japanese when selection is sCollapsed.
when we typing English characters into the editor, font-color will be added to the typing characters.
But when we try to type Japanese into the editor, selected color will not be applied to the typed characters
Does anyone knows how to keep the color effecting on the inputing characters event it is a Japanese characters?
I am trying to render Arabic text in WPF at Glyph level, on a character-by-character basis. Rendering Latin text was easy, each character simply translates to a Unicode codepoint and I used GlyphTypeface's CharacterToGlyphMap dictionary to retrieve a GlyphRun for each character.
With Arabic (and other languages) it seems that things are a lot more complicated: characters use different glyphs depending on the characters that surround them and on their position in a word. I suppose these contextual character forms all have their own Unicode codepoints too.
My questions are:
- How would I get these context-dependendent codepoints? A TextBlock displays Arabic text correctly (I suppose), how does it know which glyphs to use?
- Would that character-after-character approach even work for Arabic or is there more that I should know?
I am using this sequence: Alt+27 (using the numeric keypad) in order to enter the 'Esc' character in a Winforms TextBox. Then I attempt to read back the textbox string using the Text property. I was expecting the first character to be 'Esc' (integer value 27) but instead I found that the integer value of 8592. What is going on? How can I read back correctly the 'Esc' character?
Alt-27 is a shortcut for ← which is indeed Unicode character 8592 - see http://www.alt-codes.net/ for the full list.
The width of Tab (\t) character in silverlight TextBox is not equal to 4 spaces or 8 spaces. It's too short.
Is it possible to change the width of the TAB (\t) character displayed in a silverlight TextBox?
Note that I want to avoid replacing TABs with spaces.
Any ideas on how to do this?
Silverlight does not allow you to change the tab character length in a TextBox.
If your reading in a string (from a file or something) and setting the Text to it then if you look at your Text Property you'll see the escaped tab (\t). Searching for a \t is easy
TabTextBox.Text = TabTextBox.Text.Replace("\t", " ");
So this will replace all tabs with 4 spaces.
Besides pressing tab in a TextBox will not tab the text. It will focus to the next UIElement within the parent UIElement.
Or maybe on tab key press event, append the string literal to the text box. Similar to what MyK is suggesting.
If you're trying to get this to display, write a converter. the syntax is around--just grab an example, gut it, rename to something like 'tabstoptexttospacedtextconverter', add a reference to your local controls in app.xaml, then create an instance of it and give it an x:name to use it. Bind the data for your text box and assign it your new converter.
It'll be a little bit of hassle because you'll have to determine the appropriate width of the final display TB, and then probably use a converterparameter to make that work. But long story short, split on \t, then foreach(string str in splitSourceText) do something like this:
for (int i = 0; i < (str.Length % 8 > 0 ? str.Length % 8 : 8); i++) str+= " ";
You can limit the characters on the split string arrays with the parameter or split on \r\n first.
I'm developing an application for a bank, and I need a textbox for entering the money, like
My Idea was to create a textbox that has as a background the image of the grid, and than I just set the text size such that there is only a character in each box. but writing iiiii(5 characters) is as long as wwww (4 characters). Can I set a font or a character spacing such hat i ensure that the characters writen in the textbox will appear in separate boxes.
Ps: there are other similar boxes for name, so I don't inpu only digits.
You could use monospace (fixed width) font, Courier for example. Or you could create custom control with TextBox for each character, but in this case you would have to implement big chunk of custom logic.
Using a Glyphs control, you can set indices for exact spacing of the characters of the UnicodeString property. Check this for details: http://msdn.microsoft.com/en-us/library/bb979862%28VS.95%29.aspx.
You can set the value for the UnicodeString in the code-behind or viewmodel if you are using MVVM.