as the title says, I would like to have a black font with a white border
in my TextBox.
How could it be achieved?
Cheers.
It's possible to convert text into geometry objects with advanced formatting like outlines and fills for individual letters - you can find out more about how to do that here.
Having said that, I'm not sure that this is possible inside a TextBox. It may be for read-only text (TextBlock) only.
Edit
This blog post shows some advanced font rendering techniques inside a TextBox. It may be handy for you.
What I always do for that is set the font color to white and set a DropShadow effect on the text.
Next, play around with depth, angle (set to 0 or something) and blur and you should be able to get what you want.
Check out Blacklight controls # http://blacklight.codeplex.com/. In particular look at the sample on http://mightymeaty.members.winisp.net/blacklight.silverlight/ | Visual Controls | TEXT | Stroke Text Block (Alpha).
A full class and example using Geometries:
http://blogs.msdn.com/b/wpfsdk/archive/2006/12/24/using-text-as-a-decorative-graphic.aspx
Related
I'm currently creating a Xamarin.Forms app. One of my pages uses SkiaSharp to allow users to highlight parts of an image in a text marker style (i.e. a yellow brush with low opacity).
This is how the related SKPaint object is defined:
var strokePaint = new SKPaint()
{
Color = Color.FromRgba(255, 255, 0, 100).ToSKColor(),
Style = SKPaintStyle.Stroke,
StrokeWidth = StrokeWidth
};
That's working fine so far, but what bothers me is that the opacity "increases" when I have multiple overlapping paths, until at some point the underlying picture isn't visible anymore.
What could I do to avoid this overlapping? I was thinking about merging all paths into one, but that doesn't seem to work because the user is allowed to change StrokeWidth in between strokes and I didn't see any way of drawing paths with varying width.
I hope any of you guys has some help for me. Any idea is appreciated!
I'm not super familiar with Skia, but I took a look at the documentation for SKPaint, and it looks like it has a BlendMode property. Based on how similar things work in other systems, that should control how colors are combined. You might have to try different values to get the effect you are looking for. Dst, or Modulate look like good candidates. – Bradley Uffner
Thanks for your answer Bradley! I went with the Darken blend mode and set opacity to 255, which creates a very nice effect when highlighting text (only the darker color is visible, so dark text on a light background becomes dark text on a background of my marker color).
I have just started studying at an university and came up with an idea to manage my transcripts. It's basically a text editor with a small versioning system wrapped around it.
To avoid ending up with walls of black and white text I had the idea to add some presets for "graphics" (not sure what is the right word to use here). For example, if my professor writes down some kind of definition like this one:
Integral
Also called Riemann integral. the numerical measure of the area
bounded above by the graph of a given function, below by the x -axis, and on .........
I would like to wrap it into some kind of different background and styling, just like here on StackExchange on the quote above, with the press of a button. Another example is in one of my books:
Is it even possible to include such styling into a RichTextBox or should I look for alternatives / existing text editors?
Yeah, implementation Example is given to this URL Stack Overflow Answer
and some code for knowledge purpose
//Apply Some Font to selection
richTextBox1.SelectionFont = new Font("Arial", 16);
// Apply same color of text
richTextBox1.SelectionColor = Color.Purple;
//backgroud colour of Selection
richTextBox1.SelectionBackColor = Color.Red;
One more thing is to clearify, if you want to make a text editor, you have to given combo box for colour, size etc, and change this on IndexChange Event.
I'm trying to use the RichTextBox (that I've modified a bit with some additions found here and there) so that when I print, my white text becomes black.
To be more precise, I have a RichTextBox with a PrintDocument, PrintPreviewDialog, and so on. I can print without problem with this setup. The only thing is that my application has a dark theme (it is made to be used mainly by night) and the RichTextBox has a black background and the default text is white.
Therefore, when I print (or preview), the white text stays white and it can't be seen when printed...
I would then like to know how I would need to modify my components to change the font color from white to black upon printing. I do not care about other colors (they are the assumed choice of the user) that will be printed fine anyway.
Thanks so much for your pointers on this!
Put this code in your print handler,
var selection = myRichTextBox.Selection;
if (!selection.IsEmpty)
richTextBox1.SelectionColor = Color.Black;
For our winforms application, we've been asked to colour invalid cells in a DataGridView in a red colour. We need to find a red colour that matches the current visual style but which is still distinctive if the user has chosen a palette with mostly reds. How do I create a colour that will match the current visual style? How do I make sure I avoid clashes?
I don't think the original poster is looking to make a palette of colors (colours), instead he is trying to highlight an invalid cell. The chosen highlight color is red, but he is concerned that red might not stick out if the user has chosen a red palette.
How about this: When painting an invalid cell, use SystemColors.Window for the text and SystemColors.WindowText for the background. (or whatever equivalents there are for a DataGridView). This way, you are guaranteed that the invalid cell will be the opposite colors of a normal cell.
I think that you are looking at this the wrong way. Red is often chosen for several reasons. It is (in western culture among others) commonly used to depict that something is wrong or danger. But red is also a colour that usually stands out. However, when trying to direct a users attention to something on the page, there are two infallible methods.
1) Animated gifs or videos (annoying as f***) or
2) Clashing colours
Usually red stands out, but in your situation where a user may have a red themed style, your best bet is to go with a colour that will clash. It is possible to have clashing colours that go together (if that makes sense).
Here are a few websites that I have used in the past to help me find colour schemes that may help you as well:
Kuler, Color Combos and Color scheme designer
This may not have been the answer you were looking for but i hope it helps
The question is a bit ambiguous and a little subjective; it much easier to comment directly on examples. However, there are a multitude of on-line tools that will help you create colour palettes for websites, and these may be useful to gauge how a particular shade of red interacts with various other colours.
Hope this helps.
You could maybe try to use the Light and Dark methods of the ControlPaint class? I do something similar, although kind of in the opposite direction. I needed to make some rows in a grid stand out, but not stand out as much as the selected rows. So I created a color that was a bit lighter than the default selection color like this:
checkedColor = ControlPaint.Light(grid.DefaultCellStyle.SelectionBackColor, 1.65f);
Could try to use that, maybe with some added logic, and base it on some system color that is made to stand out. For example System.Drawing.SystemColors.HighLight or System.Drawing.SystemColors.HotTrack.
take a look at the Krypton Toolkit (http://www.componentfactory.com). They offer a free toolkit for WinForms controls with a theme manager. This theme manager provides ready to use methods to extract the current color values.
I have nothing to do with them. I use it for my own Product (Royal TS at http://www.code4ward.net) and found it really useful.
If you want to build beautiful UI, you should take a look at the Krypton stuff.
How can we produce the effect of the red line under a bad spelling word like the image below :
alt text http://img505.imageshack.us/img505/7253/options285x395rg9.th.png
Update
I do not want to use Google or whatever spell program. I would like to know how to create the effect of the red line.
You can do this using a RichTextBox control, which will allow you to set the underline style and underline color on any portion of text.
And here's an example doing exactly what you want to do.
use google's spellchecker
http://www.asp101.com/articles/jeremy/googlespell/default.asp
This page shows how to owner-draw a TextBox to draw the wavy red line.
You can use rich edit control's properties and methods to do the drawing of the wavy lines. For more information visit this site: http://geekswithblogs.net/pvidler/archive/2003/10/15/188.aspx