context: //  Copyright (c) 2008, Michael unfried
  //  Email:  serbius3@gmail.com
  //  All rights reserved.
  
  //  Redistribution and use in source and binary forms, with or without modification, 
  //  are permitted provided that the following conditions are met:
  
  //  Redistributions of source code must retain the above copyright notice, 
  //  this list of conditions and the following disclaimer. 
  //  Redistributions in binary form must reproduce the above copyright notice, 
  //  this list of conditions and the following disclaimer in the documentation 
  //  and/or other materials provided with the distribution. 
  
  //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  //  PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER 
  //  REMAINS UNCHANGED.
  using System;
  using System.ComponentModel;
  using System.Collections;
  using System.Text;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Drawing.Imaging;
  using System.Windows.Forms;
  //using System.Windows.Forms.VisualStyles;
  using RainstormStudios.Drawing;
  
  namespace RainstormStudios.Controls
  {
      [System.Drawing.ToolboxBitmap(typeof(System.Windows.Forms.Button)), System.ComponentModel.DesignerCategoryAttribute("UserControl")]
      public class AdvancedButton : Button
      {
          #region Nested Types
          //***************************************************************************
          // Enums
          // 
          public enum AdvButtonStyle
          {
              Flat = 0,
              Popup = 1,
              System = 2,
              Standard = System,
              Beveled = 3,
              Image = 4
          }
          #endregion
  
          #region Declarations
          //***************************************************************************
          // Global Variables
          // 
          bool _mSamp;
          int _fthr;
          Color _brdClr;
          int _brdWidth;
          GraphicsPath _btnShape;
          AdvButtonStyle _btnType;
          int _3dHeight;
          float _hlMul;
          Color _hvrClr;
          int _hvrOpc;
          bool _msOver;
          bool _msDown;
          bool _txtShd;
          int _txtShdO;
          float _txtShdW;
          bool _txtWrp;
          bool _rndCrnr;
          Image _imgHover;
          Image _imgDown;
          int _imgPad;
          bool _txtVert;
          bool _txtOutln;
          float _txtOutlnW;
          Color _txtOutlnC;
          int _txtOutlnO;
          float _rotTxtDeg;
          float _rotBgImgDeg;
          bool _toggleType;
          bool _trigd;
          Color _disFcolor;
          Color _disBcolor;
          Color _tglClr;
          float _fgReserved;
          #endregion
  
          #region Properties
          //***************************************************************************
          // Public Properties
          // 
          [Category("Design"),Description("Specifies the size of feathering to do on the button's corners."),Browsable(true),DefaultValue(3)]
          public int CornerFeather
          {
              get { return this._fthr; }
              set
              {
                  this._fthr = System.Math.Min(value, ((this.ClientRectangle.Width > this.ClientRectangle.Height) 
                      ? (this.ClientRectangle.Height - 1) / 2 
                      : (this.ClientRectangle.Width - 1) / 2));
                  this.SetButtonRegion();
                  if (this.Visible) this.Refresh();
              }
          }
          [Category("Design"),Description("Specifies the color of the button's border."),Browsable(true)]
          public Color BorderColor
          {
              get { return this._brdClr; }
              set { this._brdClr = value; if (this.Visible) this.Refresh(); }
          }
          [Category("Design"),Description("Specifies the width of the button's border."),Browsable(true)]
          public int BorderWidth
          {
              get { return this._brdWidth; }
              set { this._brdWidth = System.Math.Min(value, ((this.ClientRectangle.Width > this.ClientRectangle.Height) ? (this.ClientRectangle.Height / 5) * 2 : (this.ClientRectangle.Width / 5) * 2)); this.SetButtonRegion(); this.Refresh(); }
          }
          [Category("Behavior"),Description("Specifies whether or not the control should use Multi-sampling when drawing iteself."),Browsable(true),DefaultValue(true)]
          public bool MultiSample
          {
              get { return this._mSamp; }
              set { _mSamp = value; if (this.Visible) this.Refresh(); }
          }
          [Browsable(false)]
          public GraphicsPath ButtonShape
          {
              get { return this._btnShape; }
              set
              {
                  _btnShape = value;
                  //this._fthr = 0;
                  if (this.Visible) this.Refresh();
              }
          }
          [Category("Design"),Description("Specifies whether or not the button should draw a shadow below its text."),Browsable(true),DefaultValue(false)]
          public bool TextShadow
          {
              get { return this._txtShd; }
              set { this._txtShd = value; this.Refresh(); }
          }
          [Category("Design"),Description("Specifies the offset to use when drawing a text shadow."),Browsable(true),DefaultValue(1.0f)]
          public float TextShadowOffset
          {
              get { return this._txtShdW; }
              set { this._txtShdW = value; this.Refresh(); }
          }
          [Category("Design"),Description("Specifies the opacity of the text shadow, using a 0-255 scale."),Browsable(true),DefaultValue(80)]
          public int TextShadowOpacity
          {
              get { return this._txtShdO; }
              set { this._txtShdO = System.Math.Max(System.Math.Min(value, 255), 0); this.Refresh(); }
              //set
              //{
              //    if (value > 100) this._txtShdO = 255;
              //    else if (value < 0) this._txtShdO = 0;
              //    else this._txtShdO = (value * 255) / 100;
              //}
          }
          public bool TextOutline
          {
              get { return this._txtOutln; }
              set { this._txtOutln = value; if (this.Visible) this.Refresh(); }
          }
          public Color TextOutlineColor
          {
              get { return this._txtOutlnC; }
              set { this._txtOutlnC = value; if (this.Visible) this.Refresh(); }
          }
          public float TextOutlineWeight
          {
              get { return this._txtOutlnW; }
              set { this._txtOutlnW = System.Math.Max(value, 0); if (this.Visible) this.Refresh(); }
          }
          public int TextOutlineOpacity
          {
              get { return this._txtOutlnO; }
              set { this._txtOutlnO = System.Math.Max(0, System.Math.Min(value, 255)); if (this.Visible) this.Refresh(); }
          }
          [Category("Design"),Description("Indicates whether the button's text should be drawn vertically, rotated 90 degress counter-clockwise."),Browsable(true),DefaultValue(false)]
          public bool TextVeritcal
          {
              get { return this._txtVert; }
              set { this._txtVert = value; if (this.Visible) this.Refresh(); }
          }
          public Color HoverHighlightColor
          {
              get { return this._hvrClr; }
              set { _hvrClr = value; }
          }
          public int HoverHighlightOpacity
          {
              get { return this._hvrOpc; }
              set { this._hvrOpc = System.Math.Max(System.Math.Min(value, 255), 0); }
          }
          public int ThreeDEffectDepth
          {
              get { return this._3dHeight; }
              set { this._3dHeight = System.Math.Max(System.Math.Min(value, 100), 0); if (this.Visible) this.Refresh(); }
          }
          public float HighlightMultiplier
          {
              get { return this._hlMul; }
              set { this._hlMul = System.Math.Max(System.Math.Min(value, 10), 1); if (this.Visible) this.Refresh(); }
          }
          public new AdvButtonStyle FlatStyle
          {
              get { return this._btnType; }
              set { this._btnType = value; this.Refresh(); }
          }
          [Category("Behavior"),Description("Indicates whether or not the button's text should automatically wrap when it is too long to fit the control's available space."),Browsable(true),DefaultValue(false)]
          public bool AllowWordWrap
          {
              get { return this._txtWrp; }
              set { this._txtWrp = value; this.Refresh(); }
          }
          public Image HoverImage
          {
              get { return this._imgHover; }
              set { this._imgHover = value; }
          }
          public Image MouseDownImage
          {
              get { return this._imgDown; }
              set { this._imgDown = value; }
          }
          public int ImagePadding
          {
              get { return this._imgPad; }
  
gt:             set { this._imgPad = value; if (this.Visible) this.Refresh(); }