-1

I'm playing around with visual controls and colors in a simple background color changing program I've written. I also wanted to incorporate the circular application window, which I did by creating a bitmap of a solid circle surrounded by black and making the black transparent. Now my back ground color doesn't loop. Can anyone tell me how to fix this. Ill include my code just in case it helps but I think this is a form properties problem. Thanks for any help!

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();      
    }

    public Point mouse_offset;
    public int c;

    private void button1_Click(object sender, EventArgs e)
    {
        using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
        {
            synth.Speak("This is a test of the emergency see sharp broadcasting network!");
            synth.Speak("The man to the left is actually trying to dance without graphics capabilities");

        }
        while (Visible)
        {
            using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
            {
                synth.Speak("Flash dance commencing in three. two. one.");
            }
            while (Visible)
            {
                for (int c = 0; c < 255 && Visible; c++)
                {
                    this.BackColor = Color.FromArgb(c, 255 - c, c);
                    Application.DoEvents();
                    //slow();

                }


                for (int c = 255; c > 0 && Visible; c--)
                {
                    this.BackColor = Color.FromArgb(c, 255 - c, c);
                    Application.DoEvents();
                    //slow();

                }

            }
        }
    }

    public static void slow()
    {
        System.Threading.Thread.Sleep(3);
    }

    private void button2_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        mouse_offset = new Point(-e.X, -e.Y);

    }

    private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left) 
        {
            Point mousePos = Control.MousePosition;
             mousePos.Offset(mouse_offset.X, mouse_offset.Y);
            Location = mousePos;
        }
    }


}

}

1
  • you should add a language tag
    – Gerrat
    Dec 1, 2010 at 22:11

1 Answer 1

0

Every time you have changed the looks of a component and want to display this change, call

myComponent.Invalidate();

This forces the conponent to redraw itself. Now that you're there, there are a number of ways to optimize redraws, but I think the above should get you started.

1
  • Thanks. I do appreciate the help. Ill give it a try.
    – Delete Me
    Dec 2, 2010 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.