Esempio n. 1
0
        void ResetControlsBounds()
        {
            if (Buttons.IsNullOrEmpty())
            {
                return;
            }

            Rectangle rect = ClientRectangle.Inflate(Padding);

            if (BackgroundStyle == CaptionStyle.BaseLine)
            {
                rect.Height -= BaseLineSize;
            }

            var btnRect = new Rectangle(rect.Right - ButtonSize,
                                        rect.Top + (rect.Height - ButtonSize) / 2,
                                        ButtonSize,
                                        ButtonSize);

            foreach (var b in Buttons)
            {
                if (b.Visible)
                {
                    b.Bounds   = btnRect;
                    btnRect.X -= ButtonSize + 4;
                }
            }
        }
 protected override void OnPaint(PaintEventArgs pe)
 {
     base.OnPaint(pe);
     if (this.Focused)
     {
         ClientRectangle.Inflate(-2, -2);
         ControlPaint.DrawFocusRectangle(pe.Graphics, ClientRectangle);
     }
 }
Esempio n. 3
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            ClientRectangle.Inflate(-100, -100);

            ControlPaint.DrawBorder(pe.Graphics, ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
            GraphicsPath graphics = new GraphicsPath();

            graphics.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
            this.Region = new System.Drawing.Region(graphics);
            base.OnPaint(pe);
        }
Esempio n. 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            DrawBackground(e);

            Rectangle rect = ClientRectangle.Inflate(Padding);

            if (!Buttons.IsNullOrEmpty())
            {
                rect.Width = Buttons.Min(b => b.Bounds.Left) - rect.X;
            }

            if (Icon != null && rect.Width > 16)
            {
                e.Graphics.DrawImage(Icon,
                                     new Rectangle(rect.Left, rect.Top + (rect.Height - Icon.Height) / 2, Icon.Width, Icon.Height),
                                     0, 0, Icon.Width, Icon.Height, GraphicsUnit.Pixel);
                rect.X     += Icon.Width + 4;
                rect.Width -= Icon.Width + 4;
            }

            if (!string.IsNullOrEmpty(Text) && rect.Width > 10)
            {
                StringFormat sf = PaintHelper.SFLeft;
                sf.FormatFlags |= StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rect, sf);
            }

            if (!Buttons.IsNullOrEmpty())
            {
                foreach (var btn in Buttons)
                {
                    if (!btn.Visible)
                    {
                        continue;
                    }
                    DrawButton(e, btn);
                }
            }
        }
Esempio n. 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            e.Graphics.Clear(BackColor);

            Rectangle rect = ClientRectangle.Inflate(Padding);

            if (RoundSize == 0)
            {
                e.Graphics.DrawRectangle(new Pen(BorderColor),
                                         rect.X,
                                         rect.Y,
                                         rect.Width - 1,
                                         rect.Height - 1);
            }
            else
            {
                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                GraphicsPath path = PaintHelper.GetRoundRectangle(rect, RoundSize);
                e.Graphics.FillPath(new SolidBrush(ContentBackColor), path);
                e.Graphics.DrawPath(new Pen(BorderColor), path);
            }
        }