gradient progressbar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Kehl

    #1

    gradient progressbar

    Hi!

    Does anyone have a tipp for me where can I found (or how can I programm) a
    "progressba r" which has a gradient and the color go from the left side to
    right and back ... I should have a waiting-progressbar :-)

    Thanks
    Thomas


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: gradient progressbar

    Thomas,
    I would use a System.Drawing. Drawing2D.Linea rGradientBrush to get the color
    gradient.

    I would start a new Control (inherit System.Windows. Forms.Control) that had
    properties similar to System.Windows. Forms.ProgressB ar, plus 2 color
    properties (for first & second color of the gradient).

    In the OnPaint event of the control I would fill the client area with my
    brush.

    Then depending on the effect you desire I would set different options on the
    brush.

    Charles Petzold's book "Programmin g Microsoft Windows With Microsft Visual
    Basic .NET" has a chapter where is discusses the different effects possible
    with the LinearGradientB rush.

    Hope this helps
    Jay

    "Thomas Kehl" <lhek.t@heeb.co m> wrote in message
    news:%23Qbn1AYm DHA.2456@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > Hi!
    >
    > Does anyone have a tipp for me where can I found (or how can I programm) a
    > "progressba r" which has a gradient and the color go from the left side to
    > right and back ... I should have a waiting-progressbar :-)
    >
    > Thanks
    > Thomas
    >
    >[/color]


    Comment

    • Tom Clement

      #3
      Re: gradient progressbar

      How about something like this:

      using System.Drawing;
      using System.Drawing. Drawing2D;
      ....
      public void SetPercentCompl ete( int percent )
      {
      int width = (int)Math.Floor (pnlProgress.Cl ientRectangle.W idth *
      ((double)percen t)/100.0);
      int height = pnlProgress.Cli entRectangle.He ight;
      if( width > 0 && height > 0 )
      {
      pnlProgress.Inv alidate(new Rectangle( pnlProgress.Cli entRectangle.X,
      pnlStatus.Clien tRectangle.Y, width, height));
      }
      }
      private void pnlProgress_Pai nt(object sender,
      System.Windows. Forms.PaintEven tArgs e)
      {
      if( e.ClipRectangle .Width > 0 )
      {
      LinearGradientB rush brBackground = new
      LinearGradientB rush(e.ClipRect angle, System.Drawing. Color.FromArgb( 255, 0,
      0), Color.FromArgb( 0, 255, 0), LinearGradientM ode.Horizontal) ;
      e.Graphics.Fill Rectangle(brBac kground, e.ClipRectangle );
      }
      }

      Tom Clement
      Apptero, Inc.


      "Thomas Kehl" <lhek.t@heeb.co m> wrote in message
      news:%23Qbn1AYm DHA.2456@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > Hi!
      >
      > Does anyone have a tipp for me where can I found (or how can I programm) a
      > "progressba r" which has a gradient and the color go from the left side to
      > right and back ... I should have a waiting-progressbar :-)
      >
      > Thanks
      > Thomas
      >
      >[/color]


      Comment

      Working...