Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw Transparent shape over transparent WinForm #66

Open
mostafa901 opened this issue May 28, 2021 · 1 comment
Open

Draw Transparent shape over transparent WinForm #66

mostafa901 opened this issue May 28, 2021 · 1 comment

Comments

@mostafa901
Copy link

Can say how much I liked your lib. Thanks indeed!

I come up to hide a winform window and tried to draw semitransparent shapes over, but it didn't work so well.
see this quick code.

public class TransientWindow : D2DForm
    {
        public TransientWindow()
        {
            BackColor = System.Drawing.Color.FromArgb(255, 255, 255, 255);
            TransparencyKey = BackColor;
            FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            AllowTransparency = true;
        }

        protected override void OnRender(D2DGraphics g)
        {
            g.Clear(D2DColor.FromGDIColor(BackColor));

            g.FillRectangle(50, 50, 500, 500, new D2DColor(.1f, D2DColor.CornflowerBlue));
            g.DrawText("This is a test", new D2DColor(.2f, D2DColor.Red), "Arial", 20, 50, 50);
        }
    }

image

not sure if it is to draw a bitmap of the shape area, that to be used as a background to the shape to simulate transperency? seems too expensive.

Thoughts?

@jingwood
Copy link
Owner

Hi! Glad to know that it helps you!

I will have a check on how to implement a semi-transparent rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants