.
In Depth Banner
Skip Navigation Links

Select your preferred language

Character coding in the Paint handler

    protected override void OnPaint(PaintEventArgs e)

    {

      Color c = ControlPaint.Light(this.BackColor,0.5f);

      

      if(this.Width < 1 || this.Height <1)

        return;

 

      GraphicsState gs = e.Graphics.Save();

 

      Matrix mx = new Matrix();

 

      mx.Scale(this.Width/10,this.Height/10);

      try

      {

        e.Graphics.Transform=mx;

      }

      catch(Exception ex)

      {

        e.Graphics.Restore(gs);

        return;

      }

 

      if(Decimal)

        SegmentDP(e.Graphics,this.ForeColor);

      else if(this.ShowInactiveSegments)

      {

        SegmentDP(e.Graphics,c);

      }

 

      switch(_displayChar)

      {

        case ' ':

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '0':

        case 'O':

        case 'o':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '1':

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '2':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentC(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '3':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '4':

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '5':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '6':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '7':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '8':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '9':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentE(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'A':

        case 'a':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentD(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'B':

        case 'b':

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentB(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'C':

        case 'c':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'D':

        case 'd':

          SegmentB(e.Graphics, this.ForeColor);

          SegmentC(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'E':

        case 'e':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentD(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case 'F':

        case 'f':

          SegmentA(e.Graphics, this.ForeColor);

          SegmentE(e.Graphics, this.ForeColor);

          SegmentF(e.Graphics, this.ForeColor);

          SegmentG(e.Graphics, this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case '+':

          SegmentG(e.Graphics,this.ForeColor);

          SegmentP_CL(e.Graphics,this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

          }

          break;

        case '-':

          SegmentG(e.Graphics,this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

        case ':':

          SegmentP_CL(e.Graphics,this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentA(e.Graphics,c);

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentE(e.Graphics,c);

            SegmentF(e.Graphics,c);

            SegmentG(e.Graphics,c);

          }

          break;

        case 'r':

        case 'R':

          SegmentA(e.Graphics,this.ForeColor);

          SegmentE(e.Graphics,this.ForeColor);

          SegmentF(e.Graphics,this.ForeColor);

          if(this.ShowInactiveSegments)

          {

            SegmentB(e.Graphics,c);

            SegmentC(e.Graphics,c);

            SegmentD(e.Graphics,c);

            SegmentG(e.Graphics,c);

            SegmentP_CL(e.Graphics,c);

          }

          break;

      }

      e.Graphics.Restore(gs);

    }

 

 

Return to the article.

Copyright © Bob Powell 2000-.  All rights reserved.