With the warning that I never used it, I just stumbled upon it once, thought "carefully!". and moved on ...
Take a look at System.Drawing.Drawing2D.GraphicsPath and set the Region property. I added two buttons to the main Windows forms application:
public Form1() { InitializeComponent(); Rectangle r1 = new Rectangle(button1.Location, button1.Size); Rectangle r2 = new Rectangle(button2.Location, button2.Size); GraphicsPath gp = new GraphicsPath(); gp.AddRectangle(r1); gp.AddRectangle(r2); this.Region = new Region(gp); }
I approximated the shape of a button with a rectangle; with this code you can see the background color of the form in the corners of the buttons. You will need to develop a path for each of your controls and add them to the path individually. You will need to consider any offset introduced by the form's title bar or border style.
Update: I did some investigation and several possible approaches to the problem:
- Using the
GraphicsPath method, set pictureBox.Visible to False if the image is not loaded. - When you load an image into the image window, analyze the image to get a list of all the colors in it, and then arbitrarily create one that is not. Set the
BackColor and TransparencyKey form properties to match this new color, answer> .
source share