In Depth Banner
Skip Navigation Links

Select your preferred language

The Paint Handler for the Transition Control

    protected override void OnPaint(PaintEventArgs e)

    {

      if(_imageA==null || _imageB==null)

        return;

      

      switch(this.TransitionType)

      {

        case TransitionTypes.Fade:

        {

          if(_currentPercentage<100)

            e.Graphics.DrawImage(_imageA, this.ClientRectangle, 0, 0, _imageA.Width, _imageA.Height, GraphicsUnit.Pixel);

          ImageAttributes ia=new ImageAttributes();

          ColorMatrix cm=new ColorMatrix();

          cm.Matrix33=1f/255*(255*_currentPercentage/100);

          ia.SetColorMatrix(cm);

          e.Graphics.DrawImage(_imageB, this.ClientRectangle, 0, 0, _imageB.Width, _imageB.Height, GraphicsUnit.Pixel, ia);

          ia.Dispose();

        }

          break;

        case TransitionTypes.BarnDoor:

          break;

        case TransitionTypes.Iris:

          break;

        case TransitionTypes.Checker:

          break;

        case TransitionTypes.Slide:

          break;

        case TransitionTypes.Spin:

          break;

        case TransitionTypes.Spiral:

          break;

        case TransitionTypes.Blinds:

          break;

      }

 

      if(_currentPercentage==100)

      {

        _running=false;

        if(t!=null)

          t.Dispose();

        t=null;

      }

      base.OnPaint (e);

    }

 

 

Return to the article.

Copyright © Bob Powell 2003-2009. All rights reserved