Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ARRRRRRGGGGGGGGGG HELP

Posted on 2006-11-07
3
Medium Priority
?
215 Views
Last Modified: 2012-05-05
Hi,
I am using the following code to have the form fade in over 5 seconds, but i cant see the shapes....

Opacity has been set to zero....


        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Opacity = this.Opacity + 0.01;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.TransparencyKey = Color.WhiteSmoke;
            this.BackColor = Color.WhiteSmoke;
            this.Refresh();
            Graphics g = this.CreateGraphics();
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            g.DrawArc(new Pen(Brushes.Yellow, 6f), 10, 25, 817, 817, 315, 90);
            g.DrawArc(new Pen(Brushes.Green, 6f), 10, 25, 817, 817, 45, 90);
            g.DrawArc(new Pen(Brushes.Blue, 6f), 10, 25, 817, 817, 135, 90);
            g.DrawArc(new Pen(Brushes.Red, 6f), 10, 25, 817, 817, 225, 90);
            g.DrawRectangle(new Pen(Brushes.Black, 6f), 5, 20, 830, 830);
        }
0
Comment
Question by:schenkp
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 17896011
Move drawing code to Paint event handler:

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            g.DrawArc(new Pen(Brushes.Yellow, 6f), 10, 25, 817, 817, 315, 90);
            g.DrawArc(new Pen(Brushes.Green, 6f), 10, 25, 817, 817, 45, 90);
            g.DrawArc(new Pen(Brushes.Blue, 6f), 10, 25, 817, 817, 135, 90);
            g.DrawArc(new Pen(Brushes.Red, 6f), 10, 25, 817, 817, 225, 90);
            g.DrawRectangle(new Pen(Brushes.Black, 6f), 5, 20, 830, 830);
        }

If changing opacity doesn't redraw form, invalidate it:

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Opacity = this.Opacity + 0.01;
            Invalidate();
        }
0
 

Author Comment

by:schenkp
ID: 17898327
I am getting a huge amount of flickering when the form reaches 100% Opacity.  How can i fix this?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17900644
Try to use ControlStyles.DoubleBuffer style for the form.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question