使用混合背景使我的表单透明

时间:2016-06-30 14:07:43

标签: c# transparency

我有一个表格,我添加了品红色的透明度键。然后我在表单中添加一个面板并将其填充以创建阴影边框,如下所示:

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;
    }

以下是结果:

Magenta showing

为什么洋红色在设置为透明度键时显示。我不希望洋红色显示,而是希望能够看到背后的东西。 对于为什么会发生这种情况的任何想法?感谢。

0 个答案:

没有答案