public void SetCheckedEnterImageIndex(BorisBord.WinForms.ImageButton imageButton, int index)
        {
            ExtendersProperties currentButton;

            if (!m_initializing)
            {
                if (index > m_ImageList.Images.Count)
                {
                    index = m_ImageList.Images.Count - 1;                                           //-1;
                }
            }
            if (index >= 0)
            {
                currentButton = IsPropertiesExists(imageButton);
                currentButton.CheckedEnterImageIndex = index;
            }
            else
            {
                if ((currentButton = (ExtendersProperties)m_ExtenderControls[imageButton]) != null)
                {
                    currentButton.CheckedEnterImageIndex = -1;
                    if (IsEmpty(currentButton))
                    {
                        m_ExtenderControls.Remove(currentButton);
                    }
                    ;
                }
            }
        }
 private bool ShouldSerializePaintExtender(BorisBord.WinForms.ImageButton imageButton)
 {
     if (GetPaintExtender(imageButton) != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private bool ShouldSerializeCheckedEnterImageIndex(BorisBord.WinForms.ImageButton imageButton)
 {
     if (GetCheckedEnterImageIndex(imageButton) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private bool ShouldSerializeNormalPressImageIndex(BorisBord.WinForms.ImageButton imageButton)
 {
     if (GetNormalPressImageIndex(imageButton) >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private ExtendersProperties IsPropertiesExists(BorisBord.WinForms.ImageButton imageButton)
        {
            ExtendersProperties extProperty = (ExtendersProperties)m_ExtenderControls[imageButton];

            if (extProperty == null)
            {
                extProperty = new ExtendersProperties();
                m_ExtenderControls[imageButton] = extProperty;
            }
            return(extProperty);
        }
        public BorisBord.WinForms.IPaintHelper  GetPaintExtender(BorisBord.WinForms.ImageButton imageButton)
        {
            ExtendersProperties extProperty = (ExtendersProperties)m_ExtenderControls[imageButton];

            if (extProperty == null)
            {
                return(null);
            }
            else
            {
                return(extProperty.PaintExtender);
            }
        }
        public int GetCheckedEnterImageIndex(BorisBord.WinForms.ImageButton imageButton)
        {
            ExtendersProperties extProperty = (ExtendersProperties)m_ExtenderControls[imageButton];

            if (extProperty == null)
            {
                return(-1);
            }
            else
            {
                return(extProperty.CheckedEnterImageIndex);
            }
        }
        public void SetPaintExtender(BorisBord.WinForms.ImageButton imageButton, BorisBord.WinForms.IPaintHelper paintExtender)
        {
            ExtendersProperties currentButton;

            if (paintExtender != null)
            {
                currentButton = IsPropertiesExists(imageButton);
                currentButton.PaintExtender = paintExtender;
            }
            else
            {
                if ((currentButton = (ExtendersProperties)m_ExtenderControls[imageButton]) != null)
                {
                    currentButton.PaintExtender = null;
                    if (IsEmpty(currentButton))
                    {
                        m_ExtenderControls.Remove(currentButton);
                    }
                    ;
                }
            }
        }
        override public void Paint(object sender, System.Windows.Forms.PaintEventArgs pe)
        {
            BorisBord.WinForms.ImageButton tabButton = sender as BorisBord.WinForms.ImageButton;
            if (tabButton == null)
            {
                return;
            }

            string text = tabButton.Text;

            System.Drawing.Color textColor    = tabButton.Enabled?tabButton.ForeColor:System.Drawing.Color.Gray;
            System.Drawing.Image image        = tabButton.Image;
            System.Drawing.SizeF sizeText     = pe.Graphics.MeasureString(text, tabButton.Font);
            System.Drawing.SizeF sizeInterval = pe.Graphics.MeasureString("A", tabButton.Font);


            #region highlight bar

            if (tabButton.Entered)
            {
                BackColor = System.Drawing.Color.FromArgb(Alpha, EnterBackColor);
                if (tabButton.Pressed)
                {
                    BackColor = System.Drawing.Color.FromArgb(Alpha, PressBackColor);
                }
            }
            else
            {
                if (tabButton.Checked)
                {
                    BackColor = System.Drawing.Color.FromArgb(Alpha, CheckBackColor);
                }
                else
                {
                    BackColor = (LeaveBackColor);
                }
            }
            if (!tabButton.Enabled)
            {
                BackColor = System.Drawing.Color.FromArgb(Alpha, System.Drawing.Color.Gray);
            }

            pe.Graphics.FillRectangle(new System.Drawing.SolidBrush(BackColor), 0, 0, tabButton.Size.Width, tabButton.Size.Height);

            if (tabButton.Entered || tabButton.Checked)
            {
                System.Drawing.Pen Pen;
                Pen          = new System.Drawing.Pen(new System.Drawing.SolidBrush(BorderColor), 0);
                Pen.StartCap = System.Drawing.Drawing2D.LineCap.Square;
                Pen.EndCap   = System.Drawing.Drawing2D.LineCap.Square;
                System.Drawing.Point[] Points = new System.Drawing.Point[]
                {
                    new System.Drawing.Point(0, 0),
                    new System.Drawing.Point(tabButton.Size.Width - 1, 0),
                    new System.Drawing.Point(tabButton.Size.Width - 1, tabButton.Size.Height - 1),
                    new System.Drawing.Point(0, tabButton.Size.Height - 1),
                    new System.Drawing.Point(0, 0)
                };
                pe.Graphics.DrawLines(Pen, Points);
            }

            #endregion

            #region Paint Text and Image

            if (tabButton.OwnerDraw)
            {
                if (image != null)
                {
                    #region


                    int dy = (tabButton.Size.Height - image.Height) / 2;
                    if (text.Length > 0)
                    {
                        System.Drawing.Point dPoint = new System.Drawing.Point((int)sizeInterval.Width, dy);

                        pe.Graphics.DrawImageUnscaled(image, dPoint);

                        pe.Graphics.DrawString(text, tabButton.Font, new System.Drawing.SolidBrush(textColor),
                                               new System.Drawing.RectangleF(
                                                   dPoint.X + image.Width + sizeInterval.Width, (tabButton.Size.Height - sizeText.Height) / 2, image.Width + 3 * sizeInterval.Width + sizeText.Width, tabButton.Size.Height - (tabButton.Size.Height - sizeText.Height) / 2));
                    }
                    else
                    {
                        pe.Graphics.DrawImageUnscaled(image, (tabButton.Size.Width - image.Width) / 2, dy);
                    }
                    #endregion
                }
                else
                {
                    #region
                    if (text.Length > 0)
                    {
                        System.Drawing.Point pp = new System.Drawing.Point((int)sizeInterval.Width, 0);
                        pe.Graphics.DrawString(text, tabButton.Font, new System.Drawing.SolidBrush(textColor),
                                               new System.Drawing.RectangleF(
                                                   pp.X, 3, 2 * sizeInterval.Width + sizeText.Width, sizeText.Height));
                    }
                    else
                    {
                    }
                    #endregion
                }
            }
            else
            if (text.Length > 0)
            {
                #region
                System.Drawing.Font font = new Font(tabButton.Font, System.Drawing.FontStyle.Bold);

                System.Drawing.Point pp = new System.Drawing.Point((int)(int)(tabButton.Width - sizeText.Width) / 2, (int)(tabButton.Height - sizeText.Height) / 2);
                pe.Graphics.DrawString(text, font, new System.Drawing.SolidBrush(textColor),
                                       new System.Drawing.RectangleF(
                                           pp.X, pp.Y, pp.X + sizeText.Width, pp.Y + sizeText.Height));
                #endregion
            }

            #endregion
        }
        override public void Paint(object sender, System.Windows.Forms.PaintEventArgs pe)
        {
            BorisBord.WinForms.ImageButton tabButton = sender as BorisBord.WinForms.ImageButton;
            if (tabButton == null)
            {
                return;
            }

            #region highlight Ellipse

            if (tabButton.Entered)
            {
                BackColor = System.Drawing.Color.FromArgb(Alpha, EnterBackColor);
                if (tabButton.Pressed)
                {
                    BackColor = System.Drawing.Color.FromArgb(Alpha, PressBackColor);
                }
            }
            else
            {
                if (tabButton.Checked)
                {
                    BackColor = System.Drawing.Color.FromArgb(Alpha, CheckBackColor);
                }
                else
                {
                    BackColor = LeaveBackColor;
                }
            }
            if (!tabButton.Enabled)
            {
                BackColor = System.Drawing.Color.FromArgb(Alpha, System.Drawing.Color.Gray);
            }
            pe.Graphics.FillEllipse(new System.Drawing.SolidBrush(BackColor), 0, 0, tabButton.Size.Width - 1, tabButton.Size.Height - 1);

            if (tabButton.Entered || tabButton.Checked)
            {
                System.Drawing.Pen Pen;
                Pen          = new System.Drawing.Pen(new System.Drawing.SolidBrush(BorderColor), 0);
                Pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
                Pen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
                pe.Graphics.DrawEllipse(Pen, 0, 0, tabButton.Size.Width - 1, tabButton.Size.Height - 1);
            }

            #endregion

            #region Paint Text and Image
            string text = tabButton.Text;
            System.Drawing.Color textColor    = tabButton.Enabled?tabButton.ForeColor:System.Drawing.Color.Gray;                        //???????
            System.Drawing.Image image        = tabButton.Image;
            System.Drawing.SizeF sizeText     = pe.Graphics.MeasureString(text, tabButton.Font);
            System.Drawing.SizeF sizeInterval = pe.Graphics.MeasureString("A", tabButton.Font);
            if (tabButton.OwnerDraw)
            {
                if (image != null)
                {
                    #region image != null
                    if (text.Length > 0)
                    {
                        System.Drawing.Point pp = new System.Drawing.Point((int)sizeInterval.Width, 0);
                        pe.Graphics.DrawImageUnscaled(image, pp);
                        pe.Graphics.DrawString(text, tabButton.Font, new System.Drawing.SolidBrush(textColor),
                                               new System.Drawing.RectangleF(
                                                   pp.X + image.Width + sizeInterval.Width, 3, image.Width + 3 * sizeInterval.Width + sizeInterval.Width, sizeInterval.Height));
                    }
                    else
                    {
                        pe.Graphics.DrawImageUnscaled(image, (tabButton.Size.Width - image.Width) / 2, (tabButton.Size.Height - image.Height) / 2);
                    }
                    #endregion
                }
                else
                {
                    #region image == null
                    if (text.Length > 0)
                    {
                        System.Drawing.Point pp = new System.Drawing.Point((int)sizeInterval.Width, 0);
                        pe.Graphics.DrawString(text, tabButton.Font, new System.Drawing.SolidBrush(textColor),
                                               new System.Drawing.RectangleF(
                                                   pp.X, 3, 2 * sizeInterval.Width + sizeInterval.Width, sizeInterval.Height));
                    }
                    else
                    {
                    }
                    #endregion
                }
            }
            #endregion
        }
        void ISupportInitialize.EndInit()
        {
            if (!DesignMode)
            {
                foreach (DictionaryEntry de in m_ExtenderControls)
                {
                    BorisBord.WinForms.ImageButton imageButton     = de.Key as BorisBord.WinForms.ImageButton;
                    ExtendersProperties            extendersButton = de.Value as ExtendersProperties;

                    if (imageButton != null)
                    {
                        if (ImageList != null)
                        {
                            #region Refresh data before start
                            int index;
                            if ((index = extendersButton.NormalDisableImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.NormalDisabledImage = ImageList.Images[extendersButton.NormalDisableImageIndex];
                            }
                            if ((index = extendersButton.NormalEnterImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.NormalEnterImage = ImageList.Images[extendersButton.NormalEnterImageIndex];
                            }
                            if ((index = extendersButton.NormalLeaveImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.NormalLeaveImage = ImageList.Images[extendersButton.NormalLeaveImageIndex];
                            }
                            if ((index = extendersButton.NormalPressImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.NormalPressImage = ImageList.Images[extendersButton.NormalPressImageIndex];
                            }
                            if ((index = extendersButton.CheckedDisableImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.CheckedDisabledImage = ImageList.Images[extendersButton.CheckedDisableImageIndex];
                            }
                            if ((index = extendersButton.CheckedEnterImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.CheckedEnterImage = ImageList.Images[extendersButton.CheckedEnterImageIndex];
                            }
                            if ((index = extendersButton.CheckedLeaveImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.CheckedLeaveImage = ImageList.Images[extendersButton.CheckedLeaveImageIndex];
                            }
                            if ((index = extendersButton.CheckedPressImageIndex) > -1 && index < ImageList.Images.Count)
                            {
                                imageButton.CheckedPressImage = ImageList.Images[extendersButton.CheckedPressImageIndex];
                            }
                            imageButton.Invalidate();

                            imageButton.RefreshLayout();
                            #endregion
                        }
                    }
                    if (extendersButton.PaintExtender != null)
                    {
                        imageButton.Paint += new PaintEventHandler(extendersButton.PaintExtender.Paint);
                    }
                }
            }
            m_initializing = false;
        }