Example #1
0
 public static void Draw3DBorder(Control c, Graphics g, System.Drawing.Color color, int width)
 {
     System.Drawing.Point[] point =
     {
         new System.Drawing.Point(0,                              0),
         new System.Drawing.Point(0,               c.Height),
         new System.Drawing.Point(width,           c.Height - width),
         new System.Drawing.Point(width,           width),
         new System.Drawing.Point(c.Width - width, width),
         new System.Drawing.Point(c.Width, 0)
     };
     g.FillPolygon(new SolidBrush(HMIBeveledButtonDisplay.GetRelativeColor(color, 1.8)), point);
     g.DrawLine(new Pen(System.Drawing.Color.FromArgb(128, 32, 32, 32), 1.0F), point[0], point[3]);
     point[0].X = c.Width;
     point[0].Y = c.Height;
     point[3].X = c.Width - width;
     point[3].Y = c.Height - width;
     g.FillPolygon(new SolidBrush(HMIBeveledButtonDisplay.GetRelativeColor(color, 0.5)), point);
     g.DrawLine(new Pen(System.Drawing.Color.FromArgb(128, 120, 120, 120), 1.0F), point[0], point[3]);
     System.Drawing.Point point1 = new System.Drawing.Point(0, 0);
     System.Drawing.Point point2 = new System.Drawing.Point(c.Width, c.Height);
     System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(point1, point2, HMIBeveledButtonDisplay.GetRelativeColor(color, 1.2), HMIBeveledButtonDisplay.GetRelativeColor(color, 2.1));
     g.FillRectangle(linearGradientBrush, width, width, c.Width - width * 2, c.Height - width * 2);
 }
Example #2
0
 protected override void CreateStaticImage()
 {
     if (!(this.Width <= 0 || this.Height <= 0))
     {
         this.OnImage  = new Bitmap(this.Width, this.Height);
         this.OffImage = new Bitmap(this.Width, this.Height);
         Graphics graphic  = Graphics.FromImage(this.OnImage);
         Graphics graphic1 = Graphics.FromImage(this.OffImage);
         HMIBeveledButtonDisplay.Draw3DBorder(this, graphic, this.m_BorderColor, this.m_BorderWidth);
         HMIBeveledButtonDisplay.Draw3DBorder(this, graphic1, this.m_BorderColor, this.m_BorderWidth);
         int width = this.Width - this.m_BorderWidth * 4;
         if (width <= 0)
         {
             width = 1;
         }
         int height = this.Height - this.m_BorderWidth * 4;
         if (height <= 0)
         {
             height = 1;
         }
         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(this.m_BorderWidth * 2, this.m_BorderWidth * 2, width, height);
         System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
         graphicsPath.AddRectangle(rectangle);
         System.Drawing.Drawing2D.PathGradientBrush pathGradientBrush = new System.Drawing.Drawing2D.PathGradientBrush(graphicsPath);
         if (this.m_BackColorOn != Color.Black)
         {
             pathGradientBrush.CenterColor = HMIBeveledButtonDisplay.GetRelativeColor(this.m_BackColorOn, 20);
         }
         else
         {
             pathGradientBrush.CenterColor = HMIBeveledButtonDisplay.GetRelativeColor(this.BackColor, 20);
         }
         Color[] mBackColorOn = new Color[1];
         if (this.m_BackColorOn != Color.Black)
         {
             mBackColorOn[0] = this.m_BackColorOn;
         }
         else
         {
             mBackColorOn[0] = HMIBeveledButtonDisplay.GetRelativeColor(this.BackColor, 0.9);
         }
         pathGradientBrush.SurroundColors = mBackColorOn;
         graphic.FillRectangle(pathGradientBrush, rectangle);
         if (this.m_BackColorOn != Color.Black)
         {
             graphic.DrawRectangle(new Pen(new SolidBrush(HMIBeveledButtonDisplay.GetRelativeColor(this.m_BackColorOn, 0.75)), 2.0F), rectangle);
         }
         else
         {
             graphic.DrawRectangle(new Pen(new SolidBrush(HMIBeveledButtonDisplay.GetRelativeColor(this.m_BorderColor, 0.5)), 2.0F), rectangle);
         }
         graphic1.FillRectangle(new SolidBrush(this.BackColor), rectangle);
         graphic1.DrawRectangle(new Pen(new SolidBrush(HMIBeveledButtonDisplay.GetRelativeColor(this.m_BorderColor, 0.5)), 2.0F), rectangle);
         this.TextRectangle = new System.Drawing.Rectangle(this.m_BorderWidth * 2 + 1, this.m_BorderWidth * 2 + 1, this.Width - (this.m_BorderWidth * 4 + 2), this.Height - (this.m_BorderWidth * 4 + 2));
         byte  r         = this.ForeColor.R;
         byte  g         = this.ForeColor.G;
         Color foreColor = this.ForeColor;
         this.TextBrush = new SolidBrush(Color.FromArgb(216, (int)r, (int)g, (int)foreColor.B));
         this.Invalidate();
     }
 }