0

I have a form that I added a transparency key of magenta to. I then add a panel to the form and dock fill it to create a shaded border as so:

private void addEditNcs_Paint(object sender, PaintEventArgs e)
    {
        var panel = (Panel)sender;
        _mt6006.InmarsatCWin.Custom_Transparent_Window_Border(panel,
                                                              e,
                                                              SystemColors.Control,
                                                              Color.Transparent);
    }

public void Custom_Transparent_Window_Border(Panel panel, PaintEventArgs e,
                                                 Color dark, Color light)
    {
        var gp = new GraphicsPath();
        Draw_GraphicsPath(4, panel.ClientRectangle, gp);
        var fillBrush = new PathGradientBrush(gp);
        fillBrush.CenterColor = dark;
        Color[] colorArray = {light};
        fillBrush.SurroundColors = colorArray;
        fillBrush.Blend = _mt6006.InmarsatCWin.GetWindowBorderBlend();
        e.Graphics.FillPath(fillBrush, gp);
        gp.CloseFigure();
    }

public Blend GetWindowBorderBlend()
    {
        var relativeIntensities = new[] { 0f, 1f, 1f };
        var relativePositions = new[] { 0f, .08f, 1f };
        var blend = new Blend { Factors = relativeIntensities, Positions = relativePositions };
        return blend;
    }

Below is what it turns out to look like:

Magenta showing

Why is the magenta showing when its set to the transparency key. I don't want the magenta to show at all, instead I want to be able to see what is behind it. Any idea on why this is happening? Thanks.

Nolemonpledge
  • 139
  • 1
  • 2
  • 11
  • Only exact color will be used as a transparent key color (winforms?). If you change color a even a little (e.g. alpha or worse - by gradient brush applied on top of it) - it's not transparent anymore. – Sinatr Jun 30 '16 at 14:15
  • @Sinatr hmmm I figured. Do you think there is a solution behind this to make it transparent instead of using transparency key? – Nolemonpledge Jun 30 '16 at 14:17
  • Why? Transparency key is ok to make [form transparent](http://stackoverflow.com/q/4387680/1997232). The problem is what you are doing after that. Do you want to [draw form shadow](http://stackoverflow.com/q/16493698/1997232)? – Sinatr Jun 30 '16 at 14:26
  • Take a look at this post [TransparencyKey leaves pixels on rounded corner background images](http://stackoverflow.com/questions/38496911/transparencykey-leaves-pixels-on-rounded-corner-background-images/38497941#38497941). – Reza Aghaei Jul 30 '16 at 01:12

0 Answers0