Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Color Fading

Color Fading

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dsl fahk
    wrote on last edited by
    #1

    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.

    C T 2 Replies Last reply
    0
    • D dsl fahk

      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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D dsl fahk

        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.

        T Offline
        T Offline
        Tarakeshwar Reddy
        wrote on last edited by
        #3

        You had asked the same question some time back. Did you try the suggestions given by the users? Link[^]


        Tarakeshwar Reddy MCP, CCIE Q(R&S)

        D 1 Reply Last reply
        0
        • T Tarakeshwar Reddy

          You had asked the same question some time back. Did you try the suggestions given by the users? Link[^]


          Tarakeshwar Reddy MCP, CCIE Q(R&S)

          D Offline
          D Offline
          dsl fahk
          wrote on last edited by
          #4

          Oops. I'm sorry. I have short-term memory loss. ;P

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups