Implementing Emoticon in windows store chat - windows

I am developing a Windows Store chat app.
In this apps, I am using a TextBox to receive message content from the user. I want to implement Emoticons (Smileys) such that typing a code gives a respective image inline with the text.
For example, for :), I want to have a 'smile' image.

What you'll need to do is use a RichTextBlock to display your text. This will give you access to a adding in an InlineUIContainer block where necessary.
So, your process will be:
Accept text in a regular text box
Parse the text into a series of Inlines (Run, InlineUIContainer, etc)
Create a new Paragraph for the message
Add the Inliness to the Paragraph.
Add the Paragraph to your RichTextBlock's Blocks property (a BlockCollection).
For each piece of text:
Split the text, likely using Regex, searching for the keys which trigger an Image (':)', '(heart)', etc).
For each non-image text, create a Run with the Text set to the text of the split
For each Image, create an InlineUIContainer and an Image. Set the Image source to the proper Image path, then set the Child of the InlineUIContainer to the Image.
Add the Run or InlineUIContainer the Paragraph via Paragraph.Blocks.Add(Inline).
Certain icons may be included in the Segoe UI Symbol Font Family. If this is the case, you may choose to not use an Image for that symbol, and instead use a Run with the FontFamily set to Segoe UI Symbol. You can play around with the FontSize if you want them to be more prominent.
Hope this helps and happy coding!

Related

Refresh text size/layout in PowerPoint/PPTX with OpenXML.Presentation

I made a PowerPoint template where one of the text boxes is configured with a font size, a fixed height and width, and "Shrink text on overflow".
I read the PPTX in a web service, replace the text inside the text box, and send the finished document to the client. Regularly the text inside the box is more than would fit within the box with the default font size. However, when the PPTX from the server is opened by the client, the text is still overflowing outside the bounds of the text box. Only after for example duplicating the slide will PowerPoint adapt the font size in the text box to let the text fit.
How can I force PowerPoint to already update the layout when first opening/displaying the document, instead of only when actually modifying the document manually? I tried setting each and every "dirty" attribute inside the slide XML, as I was confident this would force PowerPoint to recalculate the layout, but didn't actually help.
Any ideas on the issue? My only other option would be to open the document via automation on the server and force the layout update there.
Thanks in advance!

Extract text from rectangle on Windows screen without using OCR

Given a rectangle that represents an area on a Windows screen that contains text, what is the best way to extract the text?
I know that it is possible using OCR, but even after significant pre processing, the quality is really poor.
Getting the Window Text using Win32 API does not always work as well.
Assuming that the text was rendered using a font, is it possible to get it from there?
Any directions would be extremely helpful. Thanks!
Given a rectangle that represents an area on window screen, the best way to extract text is indeed OCR. Use a better OCR library like this one from Microsoft.
The reason getting the window text using Win32 API does not work well is because there may be multiple windows in that rectangle. You will have to find out what all windows the rectangle contains and send a message to get the text for each window. It is not impossible but difficult to do and even if you manage to do that, you will run into issues of text alignment, etc. OCR is your best option.
It does seem possible without using OCR, as NirSoft SysExporter can do this:
https://www.nirsoft.net/utils/sysexp.html
This may be suitable for programmatic use as it can be run from a command line:
Starting from version 1.70, you can export the content of Windows
control from command-line, without displaying any user interface.
You may not be able to target it at a specific rectangle on the screen, but maybe the same result could be achieved by first scraping everything followed by some post-processing.
Further basic info:
SysExporter utility allows you to grab the data stored in standard
list-views, tree-views, list boxes, combo boxes, text-boxes, and
WebBrowser/HTML controls from almost any application running on your
system, and export it to text, HTML or XML file.
...
Known Limitations
SysExporter can export data from most combo boxes, list boxes,
tree-view, and list-view controls, but not from all of them. There are
some applications that use these controls to display data, but the
data itself is not actually stored in the control, but in another
location in the computer's memory. In such cases, SysExporter won't be
able to export the data.
Personally I've used it to grab text from what look like label controls.

Tool to recognize text in Image and edit it and create new image with edited text

Hi is there any tools which do the following steps:
Recognize Text in image
Edit the text
Create new image with ne text
In the general case, this is very difficult (especially for a picture).
You need a good OCR.
The OCR needs to be able to recognize the exact font.
If the background isn't a solid color, the OCR will be perturbed and possibly not able to extract the exact characters and erase them correctly.
But also, if there is a background, when you change the characters you need to reconstruct the background where characters have been erased.
Then the editor needs to paint the new text with the same rendering attributes (size, italics, outline...), which may be a difficult task.
Because of this complexity, the best option is often to do it by hand.

Convert string automatically to inline image

I'm using InDesign's data merge to generate playing cards for my game. Is it possible to convert a specific string to an inline image?
"You may roll :red_die: and add the rolled valued to this card's value"
For example the :red_die: in the text above would be automatically converted to an inline icon of a red coloured die.
No you can't this way. But you can place images with datamerge to the condition some fields of your source is set as an image one meaning having a "#" prefix. InDesign will process fields like #image as an image to place. It's up to you to add such a field in your source. However you can't nest it within another datamerge tag so it may not work eventually.
Other solution is using F/C dialog to replace :red_die: with clipboard content (your image) or to use scripting. You may also consider variable content plugin like EasyCatalog.

Changing font of text error

I have a textbox control inside of a software app which has some text in it. That software is using a custom font which doesn't exist anywhere else and is just specific to this program. I don't have it's source or access to it's creators. Now I want to copy that text inside of a notepad or MS word but when I do the text is no more readable unless I change the font of word processor to the font that the software is using (the font that text is written with). So I want the text to be readable anywhere and not to depend on a specific font. So is it possible?
I'm a c# programmer. Here is an example of unreadable text:
ý¶† ±øõœ ­ý¶† –ý¾‡¨ ÿ†°†¬ ­ñð‡ì úÞ±¶ Ä쇤 ½±”
à¥ì ±øõœ þ·ñœ­Œ Ý稆­Œ ô±º±” (.ì)
[þü‡íý‘†õø]
ý¶†
[þ¶­ñùì ïõéÎ]
±øõœ ­ý¶† ‡º±”
[þíýº]
ý¶†
[úð‡ýì‡Î —‡¤çȾ†] ÿ¬.¹†.ë† °­©ì ÿû¬‡ì ²† þÎõð.ÿ¬.¹†.ë†"
The interesting thing is that it's showing up like this in almost all the fonts except the one that text is originally written with. By the way the text is in Arabic and all of fonts that I tested the text with are supporting Arabic chars.
Now if I type some text that consist of English and Arabic in that font then change the font of notepad to some other font it's looks OK and works normal! So the problem only appears when the text is pasted into the word processor.
EDIT: I think I found the problem! The custom font is a raster font (bitmap font) which has a .fon extension and in the following thread someone wanted to convert the bitmap font to ttf since he was having a problem in printing the documents. I want to copy and paste, so maybe I have to convert the font ?
The discussion:
how to convert a bitmap font .fon into a truetype font ttf
Any kind of help is really appreciated.
thank you.
any kind of help is really appreciated.
If I had seen this question on superuser.com my answer would have been:
You can change the font of text from font A to Arial.
For example in Microsoft Word
Open the Replace dialog box (Edit >> Replace or Ctrl + H)
Make sure no text is specified in the Find what or Replace with boxes
Click in the Find what box, then click Format (If you don’t see the Format button, click More to expand the search options)
Select Font from the pop up list
In the Find Font dialog box, select the text formatting options you would like to replace
Click OK
Click in the Replace with box
Click Format
Select Font from the pop up list
In the Replace Font dialog box, select the new text formatting options you would like to apply
Click OK
Click Replace all
Click OK
Click Close
(from http://wordprocessing.about.com/cs/quicktips/qt/fontreplace.htm)
As an aside: If the document uses styles, it is actually much easier to change the font. For this reason I try to always use styles and never directly apply fonts to text.
If you are not referring to Word documents, please amend your question to say exactly what software was used to create the text - or exactly what file-format the text is stored in.
Since you asked on stackoverflow.com I slowly deduced you may be writing a program in some unspecified programming language. I suggest you edit your question and specify what programming language you are using and give some example code to illustrate the problem.
For example, in Java you might do something like
JLabel label = new JLabel("hello world");
label.setFont(new Font("Arial", Font.PLAIN, 12));
It sounds very much as though the author of the original program has invented their own character encoding and provided a font to go with it. Maybe the development tools were restricted to ANSI text and the developers came up with this extreme solution.
Test out the hypothesis by writing some English text in the custom
font and see if Arabic
characters appear.
If this is so then you will have to work out what the encoding is and translate the strings character by character.

Resources