Color Fading
-
I have a form that picks a color and then returns it to the main form. it is then supposed to fade to that color. I have tried using a loop and have tried:
Form1 ReplacementForm = new Form1();
ReplacementForm.Opacity = 0;
ReplacementForm.splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
...
ReplacementForm.splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Opacity = .5;
Thread.Sleep(50);
ReplacementForm.Opacity = .10;
Thread.Sleep(50);
ReplacementForm.Opacity = .15;
Thread.Sleep(50);
...
ReplacementForm.Opacity = .90;
Thread.Sleep(50);
ReplacementForm.Opacity = .95;
Thread.Sleep(50);
ReplacementForm.Opacity = 1;
Thread.Sleep(50);
splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer2.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer3.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer4.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Close();Neither have worked. Why? what do i have to do to get it to fade from one color to the other? I don't care if it doesn't literally fade colors, as long as it looks like it does. Thanks in advance.
-
I have a form that picks a color and then returns it to the main form. it is then supposed to fade to that color. I have tried using a loop and have tried:
Form1 ReplacementForm = new Form1();
ReplacementForm.Opacity = 0;
ReplacementForm.splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
...
ReplacementForm.splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Opacity = .5;
Thread.Sleep(50);
ReplacementForm.Opacity = .10;
Thread.Sleep(50);
ReplacementForm.Opacity = .15;
Thread.Sleep(50);
...
ReplacementForm.Opacity = .90;
Thread.Sleep(50);
ReplacementForm.Opacity = .95;
Thread.Sleep(50);
ReplacementForm.Opacity = 1;
Thread.Sleep(50);
splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer2.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer3.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer4.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Close();Neither have worked. Why? what do i have to do to get it to fade from one color to the other? I don't care if it doesn't literally fade colors, as long as it looks like it does. Thanks in advance.
Thread.Sleep should always be a last resort. Instead, work out a smooth path from the old color to the new, and set the color incrementally using a timer.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
I have a form that picks a color and then returns it to the main form. it is then supposed to fade to that color. I have tried using a loop and have tried:
Form1 ReplacementForm = new Form1();
ReplacementForm.Opacity = 0;
ReplacementForm.splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
...
ReplacementForm.splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Opacity = .5;
Thread.Sleep(50);
ReplacementForm.Opacity = .10;
Thread.Sleep(50);
ReplacementForm.Opacity = .15;
Thread.Sleep(50);
...
ReplacementForm.Opacity = .90;
Thread.Sleep(50);
ReplacementForm.Opacity = .95;
Thread.Sleep(50);
ReplacementForm.Opacity = 1;
Thread.Sleep(50);
splitContainer1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer2.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer3.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer4.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel1.BackColor = Properties.Settings.Default.BackGroundColor;
splitContainer1.Panel2.BackColor = Properties.Settings.Default.BackGroundColor;
ReplacementForm.Close();Neither have worked. Why? what do i have to do to get it to fade from one color to the other? I don't care if it doesn't literally fade colors, as long as it looks like it does. Thanks in advance.
-