How to print BIOHAZARD SIGN on console in c# - c#

How to print '\u2623' on console in c#. I tried with Console.OutputEncoding = Encoding.UTF8;. But it does not work. When I write Console.WriteLine("\u2623"); my output is ?(question mark)

Try adding this code
Console.OutputEncoding = System.Text.Encoding.Unicode
It's also possible that your choice of Console font does not support that particular character. Click on the Windows Toolbar Menu (icon like C:.) and select Properties -> Font. Try some other fonts to see if they display your character properly

Related

UWP application not reading line feed

I am creating a C# UWP application and I have noticed that the line feed (\n) character is missing from the output text when I enter it into a Textbox. When I press enter into my Textbox it produces CR+LF character (\r\n). what can I do to bring the textbox behavior to notice both CR+LF & LF. I have set AcceptReturn = "true" and I have even tried replacing \n with \r\n but that doesn't work either.
As #lindexi said the new TextBox used \r as line feed character in Windows 10 build 15063. If you want to bring the textbox behavior to notice both CR+LF & LF. You may handle it programmatically on KeyUp event. However the \n & \n\r will turn to \r automatically.
For example :
// original
MyTextBox.Text = "Nico Zhu \nzhuminghao\nwanglaoshi\r\n\rzhuzhuz\n";
// converted
MyTextBox.Text = "Nico Zhu \rzhuminghao\rwanglaoshi\r\rzhuzhuz\r"
For more please refer to UWP TextBox control giving unexpected results.

Is the way to disable path shortening in windows TaskDialogs (c#)?

I've used WindowsApiCodePack C# wrapper of windows TaskDialogs.
When I tried to show long text with paths, I got all my paths shortened by ellipsis instead of true word-wrap. This makes filenames in paths non-readable. Like here:
Same behavior when settings this text in spolier text or in main text.
Is the way to disable this feature? I want my paths to be shown completely, wrapped or somehow else.
This is what I expect from text. How MessageBox work with text:

Null unicode in a clipboard does not paste

I have a button in wpf that when clicked does the following:
Clipboard.SetText("a\u0000b")
When I try and paste the contents of the clipboard into notepad all i get is:
a
How can I get the entire string?
If I render this string in a wpf control, i see a[square thing]b. In other words, the view control does not terminate at a null unicode character.
I tried to find if you can copy text with NUL in Windows, and it presumably is not possible. Maybe you could temporarily replace NUL with some other character, which should never appear in any text you process (although it probably will one day, as Murphy's law states), then open the text file and convert all occurrences of this character back to NUL?
var text = "a\u0000b";
var textToCopy = text.Replace("\u0000", "\u3f45");
Clipboard.SetText(textToCopy);
// Next paste the contents to the file and reverse the replacement there
It is a workaround, but if you're the one using those text files, it might be worth a try.

Printing Background Colors from WPF WebBrowser

Currently, I'm printing the contents of a WPF WebBrowser like so:
mshtml.IHTMLDocument2 doc = WebBrowser.Document as mshtml.IHTMLDocument2;
doc.execCommand("Print", true, null);
My HTML content has tables with background colors. Currently, when I print the content, the background colors do not print -- everything is solid white. Is there a way to tell the WebBrowser to print the background colors as well?
Also, this still causes a print dialog to pop up. Does anyone know what the command is to print the contents dialog-less?
Thanks a lot!
Assuming you're using 'SHDocVw.WebBrowser', you can use the ExecWB command. To print without the dialog, use the OLECMDEXECOPT_PROMPTUSER (1) constant. You can also pass an IE print template (just an HTML file) for more control over how the page is displayed.
It's something like this (taken from this MSDN question)
browser.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
"print_template.html", ref nullObject);
As for the background, it appears to be one of the options you can specify in the print template's LayoutRect. All print dialog settings are stored in the registry, but a print template is preferable because it won't change system-wide settings.

quick print in c#

how can I print quickly without show print dialog just click on button and print in default printer ?
For WinForms, use the PrintDocument class and do not specify a printer, then it will print to the default printer.
I have not printed in WPF, but I found the following (maybe it will help?):
http://www.switchonthecode.com/tutorials/printing-in-wpf

Categories