x5d3356d9dffccb60.cs
上传用户:xlxx0122
上传日期:2015-04-24
资源大小:3904k
文件大小:10k
源码类别:

.net编程

开发平台:

C#

  1. namespace Sunisoft.IrisSkin.InternalControls
  2. {
  3.     using System;
  4.     using System.ComponentModel;
  5.     using System.Drawing;
  6.     using System.Drawing.Imaging;
  7.     using System.Windows.Forms;
  8.     [ToolboxItem(false)]
  9.     internal class x5d3356d9dffccb60 : Control
  10.     {
  11.         protected int borderWidth;
  12.         protected int buttonDisabledImageIndex;
  13.         protected int buttonEnabledImageIndex;
  14.         protected System.Drawing.Imaging.ImageAttributes buttonImageAttr;
  15.         protected System.Windows.Forms.ImageList buttonImages;
  16.         protected MouseButtons mouseButton;
  17.         protected bool mouseCapture;
  18.         protected bool mouseOver;
  19.         protected bool popupStyle;
  20.         public x5d3356d9dffccb60()
  21.         {
  22.             this.InternalConstruct(null, -1, -1, null);
  23.         }
  24.         public x5d3356d9dffccb60(System.Windows.Forms.ImageList imageList, int imageIndexEnabled)
  25.         {
  26.             this.InternalConstruct(imageList, imageIndexEnabled, -1, null);
  27.         }
  28.         public x5d3356d9dffccb60(System.Windows.Forms.ImageList imageList, int imageIndexEnabled, int imageIndexDisabled)
  29.         {
  30.             this.InternalConstruct(imageList, imageIndexEnabled, imageIndexDisabled, null);
  31.         }
  32.         public x5d3356d9dffccb60(System.Windows.Forms.ImageList imageList, int imageIndexEnabled, int imageIndexDisabled, System.Drawing.Imaging.ImageAttributes imageAttr)
  33.         {
  34.             this.InternalConstruct(imageList, imageIndexEnabled, imageIndexDisabled, imageAttr);
  35.         }
  36.         public void InternalConstruct(System.Windows.Forms.ImageList imageList, int imageIndexEnabled, int imageIndexDisabled, System.Drawing.Imaging.ImageAttributes imageAttr)
  37.         {
  38.             this.buttonImages = imageList;
  39.             this.buttonEnabledImageIndex = imageIndexEnabled;
  40.             this.buttonDisabledImageIndex = imageIndexDisabled;
  41.             this.buttonImageAttr = imageAttr;
  42.             this.borderWidth = 2;
  43.             this.mouseOver = false;
  44.             this.mouseCapture = false;
  45.             this.popupStyle = true;
  46.             this.mouseButton = MouseButtons.None;
  47.             base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
  48.             base.SetStyle(ControlStyles.StandardDoubleClick, false);
  49.             base.SetStyle(ControlStyles.Selectable, false);
  50.         }
  51.         protected override void OnMouseDown(MouseEventArgs e)
  52.         {
  53.             if (!this.mouseCapture)
  54.             {
  55.                 this.mouseOver = true;
  56.                 this.mouseCapture = true;
  57.                 this.mouseButton = e.Button;
  58.                 base.Invalidate();
  59.             }
  60.             base.OnMouseDown(e);
  61.         }
  62.         protected override void OnMouseEnter(EventArgs e)
  63.         {
  64.             this.mouseOver = true;
  65.             base.Invalidate();
  66.             base.OnMouseEnter(e);
  67.         }
  68.         protected override void OnMouseLeave(EventArgs e)
  69.         {
  70.             this.mouseOver = false;
  71.             base.Invalidate();
  72.             base.OnMouseLeave(e);
  73.         }
  74.         protected override void OnMouseMove(MouseEventArgs e)
  75.         {
  76.             bool flag = base.ClientRectangle.Contains(new Point(e.X, e.Y));
  77.             if (flag != this.mouseOver)
  78.             {
  79.                 this.mouseOver = flag;
  80.                 base.Invalidate();
  81.             }
  82.             base.OnMouseMove(e);
  83.         }
  84.         protected override void OnMouseUp(MouseEventArgs e)
  85.         {
  86.             if (e.Button == this.mouseButton)
  87.             {
  88.                 this.mouseOver = false;
  89.                 this.mouseCapture = false;
  90.                 base.Invalidate();
  91.             }
  92.             else
  93.             {
  94.                 base.Capture = true;
  95.             }
  96.             base.OnMouseUp(e);
  97.         }
  98.         protected override void OnPaint(PaintEventArgs e)
  99.         {
  100.             if (this.buttonImages != null)
  101.             {
  102.                 if (!base.Enabled)
  103.                 {
  104.                     if (this.buttonDisabledImageIndex != -1)
  105.                     {
  106.                         if (this.buttonImageAttr == null)
  107.                         {
  108.                             e.Graphics.DrawImage(this.buttonImages.Images[this.buttonDisabledImageIndex], new Point(1, 1));
  109.                         }
  110.                         else
  111.                         {
  112.                             Image image = this.buttonImages.Images[this.buttonDisabledImageIndex];
  113.                             Point[] destPoints = new Point[3];
  114.                             destPoints[0].X = 1;
  115.                             destPoints[0].Y = 1;
  116.                             destPoints[1].X = destPoints[0].X + image.Width;
  117.                             destPoints[1].Y = destPoints[0].Y;
  118.                             destPoints[2].X = destPoints[0].X;
  119.                             destPoints[2].Y = destPoints[1].Y + image.Height;
  120.                             e.Graphics.DrawImage(this.buttonImages.Images[this.buttonDisabledImageIndex], destPoints, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel, this.buttonImageAttr);
  121.                         }
  122.                     }
  123.                     else if (this.buttonEnabledImageIndex != -1)
  124.                     {
  125.                         ControlPaint.DrawImageDisabled(e.Graphics, this.buttonImages.Images[this.buttonEnabledImageIndex], 1, 1, this.BackColor);
  126.                     }
  127.                 }
  128.                 else
  129.                 {
  130.                     ButtonBorderStyle solid;
  131.                     if (this.buttonImageAttr == null)
  132.                     {
  133.                         e.Graphics.DrawImage(this.buttonImages.Images[this.buttonEnabledImageIndex], (this.mouseOver && this.mouseCapture) ? new Point(2, 2) : new Point(1, 1));
  134.                     }
  135.                     else
  136.                     {
  137.                         Image image2 = this.buttonImages.Images[this.buttonEnabledImageIndex];
  138.                         Point[] pointArray2 = new Point[3];
  139.                         pointArray2[0].X = (this.mouseOver && this.mouseCapture) ? 2 : 1;
  140.                         pointArray2[0].Y = (this.mouseOver && this.mouseCapture) ? 2 : 1;
  141.                         pointArray2[1].X = pointArray2[0].X + image2.Width;
  142.                         pointArray2[1].Y = pointArray2[0].Y;
  143.                         pointArray2[2].X = pointArray2[0].X;
  144.                         pointArray2[2].Y = pointArray2[1].Y + image2.Height;
  145.                         e.Graphics.DrawImage(this.buttonImages.Images[this.buttonEnabledImageIndex], pointArray2, new Rectangle(0, 0, image2.Width, image2.Height), GraphicsUnit.Pixel, this.buttonImageAttr);
  146.                     }
  147.                     if (this.popupStyle)
  148.                     {
  149.                         if (this.mouseOver && base.Enabled)
  150.                         {
  151.                             solid = this.mouseCapture ? ButtonBorderStyle.Inset : ButtonBorderStyle.Outset;
  152.                         }
  153.                         else
  154.                         {
  155.                             solid = ButtonBorderStyle.Solid;
  156.                         }
  157.                     }
  158.                     else if (base.Enabled)
  159.                     {
  160.                         solid = (this.mouseOver && this.mouseCapture) ? ButtonBorderStyle.Inset : ButtonBorderStyle.Outset;
  161.                     }
  162.                     else
  163.                     {
  164.                         solid = ButtonBorderStyle.Solid;
  165.                     }
  166.                     ControlPaint.DrawBorder(e.Graphics, base.ClientRectangle, this.BackColor, this.borderWidth, solid, this.BackColor, this.borderWidth, solid, this.BackColor, this.borderWidth, solid, this.BackColor, this.borderWidth, solid);
  167.                 }
  168.             }
  169.             base.OnPaint(e);
  170.         }
  171.         [DefaultValue(2), Category("Appearance")]
  172.         public int BorderWidth
  173.         {
  174.             get
  175.             {
  176.                 return this.borderWidth;
  177.             }
  178.             set
  179.             {
  180.                 if (this.borderWidth != value)
  181.                 {
  182.                     this.borderWidth = value;
  183.                     base.Invalidate();
  184.                 }
  185.             }
  186.         }
  187.         [Category("Appearance"), DefaultValue((string) null)]
  188.         public System.Drawing.Imaging.ImageAttributes ImageAttributes
  189.         {
  190.             get
  191.             {
  192.                 return this.buttonImageAttr;
  193.             }
  194.             set
  195.             {
  196.                 if (this.buttonImageAttr != value)
  197.                 {
  198.                     this.buttonImageAttr = value;
  199.                     base.Invalidate();
  200.                 }
  201.             }
  202.         }
  203.         [Category("Appearance"), DefaultValue(-1)]
  204.         public int ImageIndexDisabled
  205.         {
  206.             get
  207.             {
  208.                 return this.buttonDisabledImageIndex;
  209.             }
  210.             set
  211.             {
  212.                 if (this.buttonDisabledImageIndex != value)
  213.                 {
  214.                     this.buttonDisabledImageIndex = value;
  215.                     base.Invalidate();
  216.                 }
  217.             }
  218.         }
  219.         [Category("Appearance"), DefaultValue(-1)]
  220.         public int ImageIndexEnabled
  221.         {
  222.             get
  223.             {
  224.                 return this.buttonEnabledImageIndex;
  225.             }
  226.             set
  227.             {
  228.                 if (this.buttonEnabledImageIndex != value)
  229.                 {
  230.                     this.buttonEnabledImageIndex = value;
  231.                     base.Invalidate();
  232.                 }
  233.             }
  234.         }
  235.         [Category("Appearance"), DefaultValue((string) null)]
  236.         public System.Windows.Forms.ImageList ImageList
  237.         {
  238.             get
  239.             {
  240.                 return this.buttonImages;
  241.             }
  242.             set
  243.             {
  244.                 if (this.buttonImages != value)
  245.                 {
  246.                     this.buttonImages = value;
  247.                     base.Invalidate();
  248.                 }
  249.             }
  250.         }
  251.         [DefaultValue(true), Category("Appearance")]
  252.         public bool PopupStyle
  253.         {
  254.             get
  255.             {
  256.                 return this.popupStyle;
  257.             }
  258.             set
  259.             {
  260.                 if (this.popupStyle != value)
  261.                 {
  262.                     this.popupStyle = value;
  263.                     base.Invalidate();
  264.                 }
  265.             }
  266.         }
  267.     }
  268. }