Exemplo n.º 1
0
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);

            // Set the region for the control
            var r = ClientSize.Width < ClientSize.Height * 2 ? ClientSize.Width / 8f : ClientSize.Height / 4f;

            Region = new Region(Gdi.RoundedRectanglePath(new RectangleF(0, 0, 8 * r, 4 * r), 2 * r));
        }
Exemplo n.º 2
0
 protected override void OnSizeChanged(EventArgs e)
 {
     base.OnSizeChanged(e);
     Region = new Region(Gdi.RoundedRectanglePath(ClientRectangle, m_corner_radius));             // Set the clip boundary
 }
Exemplo n.º 3
0
 /// <summary>Fill a rectangle with rounded corners</summary>
 public static void FillRectangleRounded(this Graphics gfx, Brush brush, RectangleF rect, float radius)
 {
     gfx.FillPath(brush, Gdi.RoundedRectanglePath(rect, radius));
 }
Exemplo n.º 4
0
 /// <summary>Draws a rectangle with rounded corners</summary>
 public static void DrawRectangleRounded(this Graphics gfx, Pen pen, RectangleF rect, float radius)
 {
     gfx.DrawPath(pen, Gdi.RoundedRectanglePath(rect, radius));
 }
Exemplo n.º 5
0
        /// <summary>Generates the boundary of the hint balloon</summary>
        private GraphicsPath GeneratePath(bool region_border)
        {
            var width  = Width + (region_border ? 1 : 0);
            var height = Height + (region_border ? 1 : 0);
            var cr     = Math.Max(1, CornerRadius);

            GraphicsPath path;

            if (TipLength == 0 || TipBaseWidth == 0)
            {
                path = Gdi.RoundedRectanglePath(new RectangleF(0, 0, width, height), cr);
            }
            else
            {
                var tip_length = TipLength;
                var tip_width  = Math_.Clamp(width - 2 * (tip_length + cr), Math.Min(5, TipBaseWidth), TipBaseWidth);

                // Find the corner to start from
                path = new GraphicsPath();
                switch (TipCorner)
                {
                default:
                    Debug.Assert(false, "Unknown corner");
                    break;

                case ETipCorner.TopLeft:
                    path.AddLine(0, 0, tip_length + cr + tip_width, tip_length);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddLine(tip_length + cr, tip_length, 0, 0);
                    break;

                case ETipCorner.TopRight:
                    path.AddLine(width, 0, width - tip_length - cr, tip_length);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddLine(tip_length + cr, tip_length, width - tip_length - cr - tip_width, tip_length);
                    path.AddLine(width - tip_length - cr - tip_width, tip_length, width, 0);
                    break;

                case ETipCorner.BottomLeft:
                    path.AddLine(0, height, tip_length + cr, height - tip_length);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddLine(width - tip_length - cr, height - tip_length, tip_length + cr + tip_width, height - tip_length);
                    path.AddLine(tip_length + cr + tip_width, height - tip_length, 0, height);
                    break;

                case ETipCorner.BottomRight:
                    path.AddLine(width, height, width - tip_length - cr - tip_width, height - tip_length);
                    path.AddArc(tip_length, height - tip_length - cr, cr, cr, 90f, 90f);
                    path.AddArc(tip_length, tip_length, cr, cr, 180f, 90f);
                    path.AddArc(width - tip_length - cr, tip_length, cr, cr, 270f, 90f);
                    path.AddArc(width - tip_length - cr, height - tip_length - cr, cr, cr, 0f, 90f);
                    path.AddLine(width - tip_length - cr, height - tip_length, width, height);
                    break;
                }
            }
            return(path);
        }