Solved

ARRRRRRGGGGGGGGGG HELP

Posted on 2006-11-07
3
209 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - SQL Timeout 9 49
What are the simplest ways to create a Merge Sort? 3 34
linq, c# 8 31
C# class library debugging - Breakpoint will not hit. 8 30
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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