How to make a nice overlay with variable transparency using WinForms? - c#

I'm looking for a way to make a WinForm transparent and allow to use semi-transparent images on it.
The common solutions are:
Changing the total opacity of the form and all of its content;
Make only a certain color fully transparent, while the rest will have to be fully opaque;
Use multiple forms to make only some controls transparent.
None of these ways allow to display images or controls which have variable per-pixel transparency value. And I'd like to achieve a cool interface like Steam does with its in-game overlay.
Is there maybe some video game technique that can be used to draw a nice overlay for the whole screen? It's okay if it will have to use 3D graphics drawing libraries and whatnot.

Related

Transparent picturebox over another transparent picturebox c#

I'm having this problem. I would like for the frog's background to be transparent so the log underneath can be seen, but instead, the background picturebox's color is shown.
problem
I googled the problem and got the suggestion to change the Parent of the picturebox, which i tried, but this happened:
it works, but only in the log's picturebox area
I'm clearly doing something wrong. Can somebody help?
WinForms does not support true alpha-transparency. "Transparent" controls re-render only the parent form's background behind themselves - controls cannot be truely layered and blended in the Z-axis.
So what you're after really isn't possible.
However, implementing a game using WinForms controls and GDI (System.Drawing) is a bad idea - performance is terrible (in part due to Microsoft's crippling of GDI since Windows Vista by removing hardware acceleration of many operations) and there are endless issues with inconsistent double-buffering and DPI-scaling.
I suggest you rewrite your game's rendering layer in Unity, Direct2D or SDL.

Complete interaction through a form using C#

I am making an overlay program with C# that will have an overlay for games. I am currently using a borderless form with a transparent background and a picture box to draw pictures to the screen, but I can't click the window behind the form. I have set the form to be always on top so that I can play games and the UI stays, but every time the mouse goes over the form in the game if I click the focused window switches to my form, preventing game interaction.
I have tried using functions to just draw images to the screen without using forms, but I cannot work out how to do that.
All I want is things like an external menu/crosshair and such, for use in minecraft. As for the menu, I could make my own media controls and such, and the crosshair would be useful because I hate the default crosshair. I could draw shapes to the screen, but if I don't use pictures the crosshair might look tacky.
A possible solution is a per pixel alpha blending window.
Here is a good starting point: Per Pixel Alpha Blend in C#
The example source code should give you the idea.
Hope this helps

Wpf Show underneath blurry

In wpf how can I make controls underneath a transparent control blurry like windows Aero?
I need this for my custom modal windows with a border in outside for locking mouse
You can use the pixel shader effects to mimic that effect. Here is a tool for building/testing pixel shaders.

16 bit grayscale image display in WPF

I am developing an application that displays 16 bit grayscale images. The UI for the application was originally created using Win Forms and since Win Forms does not support 16 bit grayscale I wrote a custom openGL control to display the image. Within the last few months we have convert the UI to WPF, but continued to use the openGL image display via a WindowsFormsHost.
WPF is DirectX based so it would make sense to try and get away from the openGL, but does WPF natively support 16 bit grayscale images? or will I have to create a DirectX control?
Also, the openGL control isn't only used to display the image data. The contol allows the user to manipulate the image in various ways (Flip, rotate, Zoom, pan, crop, etc); as well as annotate the image (draw lines, rectangles, measurement angles, etc). If I'm simply using WPF to display the image, how can I also manipulate and annotate using WPF? Plus, I am using a shader to do some color mapping on the image texture. Is something like this possible with WPF or will I have to color map the image data manually before displaying?
I have never used DirectX, so if writing a DirectX control is necessary how difficult will it be to learn and implement what I need?
As for the shaders parts, WPF have access to the HW shaders (and it can emulated them in SW if needed) they are called bitmap effects.
Greg Schechter's covered how to write a custom effect in his blog

How can I show a grey transparent overlay in C#?

How can I show a grey transparent overlay in C#?
It should overlay other process which are not owned by the application doing the overlay.
Create a transparent window the size of the whole screen, mark it always-on-top, calculate the regions of your other application windows, and make the non-window regions of the top window grey.
I suppose you could just position your own application windows on top of the transparent grey one, with it being above all the other ones, but getting a tricky z-order scenario like that right, especially in conjunction with other apps that might also be doing z-order tricks, is tough.
Here a little app which do more or less the functionnality you want :
http://www.anappaday.com/downloads/2006/09/day-10-jedi-concentrate.html

Categories

Resources