I would like to create an outer glow effect on a UserControl derived class in c# 2.0 (WinForms). Is this (easily) possible?
If yes, please show me how :)
What I mean with "glow effect" is something like this:
Hope this helps http://www.codeproject.com/KB/buttons/VistaButton.aspx
I also rem reading an article where the author draws 2 rectangles over the button (each is covering half from top and bottom) and then when mouse is hover, he does some overlapping logic. I forgot the full logic. Sorry, ill think/search and come back with the answer.
Here are a few tutorials on how to easily achieve halo- and special effects on graphical objects in winforms:
Text Halo Effect
Text Effects
Drawing text with a drop shadow effect
Related
I am in the process of learning C# as I am most familiar with C++ so if there is a simple answer to this question please forgive me. Also thank you for taking the time to read this, I appreciate it!!! :)
I am currently in the process of creating a program similar to MS Paint. I would like to be able to draw text on a panel. I've found the .DrawString() which can apparently be used to do exactly this, though in all of the examples I've seen they have coordinates predefined and do not allow the user to choose where to place it. I want this to be similar to MS Paint by allowing the user to click and drag to make the size of the box the text shall appear in. I am not concerned about allowing them to move the text around once the rectangle is drawn with the text.
I was originally thinking to have them type their string into a textbox and then draw it onto a rectangle so they could size it appropriately to fit their string since the string should wrap inside of the rectangle. So I have two questions:
How can I have the text wrap around the rectangle and obviously cut
off anything that does not fit (again similar to MS Paint)?
By drawing a rectangle (if my idea is plausible of course) it will
leave a border around the text since it is making a rectangle. I do
not want this border, I only want the text. How can I achieve this?
summarizing I have implemented a chart control as a simple Canvas with a Polyline on it. The next thing I need is to be able to zoom the chart.
I would like to know how would you that (just the idea, no details needed). What I would like to do is to create somehow a bigger Canvas and paint the line bigger and just show a part of the Canvas to the user, and the he drags the Chart it will move the Canvas. Something like in the following picture. Do you think this is possible?
Kael Rowan from Microsoft Research built a ZoomableCanvas class that may do exactly what you want. You can also see all the posts he wrote about it. You can even try a running XBAP example if your browser supports it.
We use the RenderTransform for this, create your zoom and pan matrix( or transform ) and apply that to your canvas. The nice thing is, that you can still have elements that can display behind or on top of the canvas with the identity transform or with another. For example for a grid or screen space elements like a minimap, which should always be visible. You might also want to look into this old question, which is somehow related.
I use windows form with GlassForm(using Microsoft.WindowsAPICodePack.Shell;). my problem when I change form to GlassForm my textbox texts doesnt
Place a panel on the form set the dock style to fill, set the panel's BackColor to color X and then set the form's TransparencyKey to the same color X.
Yes, that's how it works. With the Aero Glass effect applied, anything drawn in the color black will be rendered as transparent. That includes text in a textbox control. This general theme has been the subject of many other questions here. When well-written, they gather lots of upvotes, but few answers.
There just aren't a lot of good solutions here. All of them that I've come across qualify as both "ugly" and "hackish". Owner-drawing is a reasonable approach when you're using something like a label control, but I wouldn't recommend trying to draw your own textbox—it's just too hard to get right. Someone tried to do that here; like I said, the result is both ugly and hackish. I wasn't satisfied with it for my own use, but it may work for you, depending on how high your standards are.
The goal with owner-drawing, of course, is either to do all of the drawing using GDI+ (which natively supports transparency) instead of GDI (which all of the built-in controls use by default), or calling functions like DrawThemeTextEx, which is specifically designed for rendering text with a shadow that is [somewhat] readable over glass.
As well, the usual tricks like enabling compatible text rendering (which causes the built-in controls to draw using GDI+ routines, as they did in the early versions of .NET) don't work for a textbox.
Honestly, your best bet is to place the textbox over a region of your form that is not rendered as glass. Use the DwmEnableBlurBehindWindow function to selectively enable the glass effect behind certain areas of your form, rather than the entire thing. I provide a complete, ready-to-use .NET implementation in my answer here.
Check this sample out:
http://www.danielmoth.com/Blog/Glass-In-C-An-Alternative-Approach.aspx
I was not studying it any further but putting a TextBox or Button or other components over this Aero glass area worked - the rendered component didn't have the transparency problem. The labels aren't perfect but these can be easily drawn with GDI+
The direct link to the sample project is here: http://www.danielmoth.com/Blog/MothGlass.zip
It looks like he puts a panel behind the control and setting the TransparencyKey for the panel.
say your silverlight area on a webpage is 200px by 200px.
you open a child window, is there a way to make it moveable outside the 200x200 silverlight area?
or say you drop down a combo box, let the drop down go out side of the 200x200 aea?
Thank you
Sorry there isn't any practical way to do this.
(There are is a fairly ridiculous/heroic option suggested in the duplicate thread mentioned in the comment above...)
my current free-time project, in order to dive into WPF MVVM, is a "digital" copy of an old puzzle I used to play a lot in my childhood. It basically is a simple puzzle where one has to fill a given space with different kind of pieces so the whole space is filled. But with the extra twist of being in hexagonal space.
Just to illustrate, this is what it currently looks like in WPF:
http://img190.imageshack.us/img190/2553/atomgridmolecule.png
So basically there is a number of predefined pieces(like the orange one above) which can be "plugged" into the given grid(the gray stuff above).
So the result might look something like this:
http://img30.imageshack.us/img30/2553/atomgridmolecule.png
I want the user(probably only me^^) to be able to drag and drop the pieces into the grid. I want the dragging to look natural meaning having the correct offset while dragging depending on where the user clicked the piece.
Both grid and molecule are the same control, a custom hexagonal panel control derived from the WPF Panel class.
The problem is on how to do the "plugging in" and especially the "unplugging".
I have two ideas on how I might tackle this:
Just color the cells in the grid and hiding the original piece
Pro:
Zero cost perfect alignment of the cells
Cons:
Recreating the piece at the right spot with the correct mouse offset if dragging out, seems impossibly? hard to do
Snapping the piece to the grid and show it on top
Pro:
Dragging out is a simple dragging operation, just as dragging in
Disadvantage:
Somehow have to align the piece with the underlying grid, some kind of snapping
So which approach should I take? Even more important how can I even implement this in WPF? Especially using a clean MVVM way.
Thanks so much for your help! Any input is highly appreciated!
EDIT:
Thanks Aran, I thought so too.
But how do I actually implement this now?
How can I actually get the coordinates?
All the orange circles are linked, so how can I "move" or better "plug" them in as one piece?
Im inclined to go with the second idea. a simple snapping would just be to test if the centre point of the circle you are dragging is within some tolerance factor of a circle on the grid and if so snap them.