Friday, July 16, 2010

Translucency and Transparency Effects in Windows Applications

video
Transparency is a feature in .NET that can make your applications with that Vista/Windows 7 feel. This simple code excerpt lets you adjust the Opacity on the Form with only marginal resource consumption with a Timer Control.


public string upOrDown = "down";

private void tmrOp_Tick
(object sender, EventArgs e)
        {
            if (upOrDown == "down")
            {
                this.Opacity = this.Opacity - 0.01;
            }
            else
            {
                this.Opacity = this.Opacity + 0.01;
            }


            if (this.Opacity < 0.81)
            {
                upOrDown = "up";
            }
            if (this.Opacity > 0.99)
            {
                upOrDown = "down";
            }
        }

No comments:

Post a Comment