Exemplo n.º 1
0
        private void SelectionRules(BorderCorners bc, bool select)
        {
            switch (bc)
            {
            case BorderCorners.All:
                AllRule(select);
                break;

            case BorderCorners.BottomLeft:
                BottomLeftRule(select);
                break;

            case BorderCorners.BottomRight:
                BottomRightRule(select);
                break;

            case BorderCorners.TopLeft:
                TopLeftRule(select);
                break;

            case BorderCorners.TopRight:
                TopRightRule(select);
                break;

            case BorderCorners.None:
                NoneRule(select);
                break;
            }

            AllRule();
            NoneRule();
            Invalidate();
        }
Exemplo n.º 2
0
        private Button GetButton(BorderCorners bc)
        {
            switch (bc)
            {
            case BorderCorners.TopLeft:
                return(btnTL);

            case BorderCorners.TopRight:
                return(btnTR);

            case BorderCorners.BottomLeft:
                return(btnBL);

            case BorderCorners.BottomRight:
                return(btnBR);

            case BorderCorners.All:
                return(btnAll);

            case BorderCorners.None:
                return(btnNone);
            }

            return(null);
        }
Exemplo n.º 3
0
 private void SetFlag(BorderCorners flag, bool value)
 {
     if (value)
     {
         _borderCorners |= flag;
     }
     else
     {
         _borderCorners &= ~flag;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Fills a rounded rectangle with specified parameters.
 /// </summary>
 /// <param name="graphics">An encapsulated GDI+ drawing surface instance.</param>
 /// <param name="brush">Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.</param>
 /// <param name="rectangle">A Rectangle structure that represents the boundary to draw.</param>
 /// <param name="radius">The radius for each corners</param>
 /// <param name="filter">The corners to have a radius</param>
 public static void FillRoundedRectangle(this Graphics graphics, LinearGradientBrush brush, RectangleF rectangle, int radius,
                                         BorderCorners filter)
 {
     graphics.FillRoundedRectangle(
         brush,
         rectangle.X,
         rectangle.Y,
         rectangle.Width,
         rectangle.Height,
         radius,
         filter);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Draws a rounded rectangle with specified parameters.
 /// </summary>
 /// <param name="graphics">An encapsulated GDI+ drawing surface instance.</param>
 /// <param name="pen">Pen that determines the color, width, and style of the rectangle.</param>
 /// <param name="rectangle">A Rectangle structure that represents the boundary to draw.</param>
 /// <param name="radius">The radius for each corners</param>
 /// <param name="filter">The corners to have a radius</param>
 public static void DrawRoundedRectangle(this Graphics graphics, Pen pen, Rectangle rectangle, int radius, BorderCorners filter)
 {
     graphics.DrawRoundedRectangle(
         pen,
         rectangle.X,
         rectangle.Y,
         rectangle.Width,
         rectangle.Height,
         radius,
         filter);
 }
Exemplo n.º 6
0
        private static GraphicsPath GenerateRoundedRectangle(this Graphics graphics, RectangleF rectangle, float radius, BorderCorners filter)
        {
            float        diameter;
            GraphicsPath path = new GraphicsPath();

            if (radius <= 0.0F || filter == BorderCorners.None)
            {
                path.AddRectangle(rectangle);
                path.CloseFigure();
                return(path);
            }
            else
            {
                if (radius >= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0)
                {
                    return(graphics.GenerateCapsule(rectangle));
                }

                diameter = radius * 2.0f;
                SizeF      sizeF = new SizeF(diameter, diameter);
                RectangleF arc   = new RectangleF(rectangle.Location, sizeF);

                if ((BorderCorners.TopLeft & filter) == BorderCorners.TopLeft)
                {
                    path.AddArc(arc, 180, 90);
                }
                else
                {
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                }

                arc.X = rectangle.Right - diameter;

                if ((BorderCorners.TopRight & filter) == BorderCorners.TopRight)
                {
                    path.AddArc(arc, 270, 90);
                }
                else
                {
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y);
                }

                arc.Y = rectangle.Bottom - diameter;

                if ((BorderCorners.BottomRight & filter) == BorderCorners.BottomRight)
                {
                    path.AddArc(arc, 0, 90);
                }
                else
                {
                    path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height);
                }

                arc.X = rectangle.Left;

                if ((BorderCorners.BottomLeft & filter) == BorderCorners.BottomLeft)
                {
                    path.AddArc(arc, 90, 90);
                }
                else
                {
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                }
                path.CloseAllFigures();
            }
            return(path);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns a graphic path of a rounded rectangle with specified parameters.
 /// </summary>
 /// <param name="graphics">An encapsulated GDI+ drawing surface instance.</param>
 /// <param name="rectangle">A Rectangle structure that represents the boundary to draw.</param>
 /// <param name="radius">The radius for each corners</param>
 /// <param name="filter">The corners to have a radius</param>
 /// <returns>Returns a GraphicsPath of a rounded rectangle</returns>
 public static GraphicsPath RoundedRectanglePath(this Graphics graphics, RectangleF rectangle, float radius, BorderCorners filter)
 {
     return(GenerateRoundedRectangle(graphics, rectangle, radius, filter));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Draws a rounded rectangle with specified parameters.
        /// </summary>
        /// <param name="graphics">An encapsulated GDI+ drawing surface instance.</param>
        /// <param name="pen">Pen that determines the color, width, and style of the rectangle.</param>
        /// <param name="x">The x-coordinate of the upper-left corner of the rectangle to draw.</param>
        /// <param name="y">The y-coordinate of the upper-left corner of the rectangle to draw.</param>
        /// <param name="width">Width of the rectangle to draw.</param>
        /// <param name="height">Height of the rectangle to draw.</param>
        /// <param name="radius">The radius for each corners</param>
        /// <param name="filter">The corners to have a radius</param>
        public static void DrawRoundedRectangle(this Graphics graphics, Pen pen, float x, float y, float width, float height, float radius, BorderCorners filter)
        {
            RectangleF    rectangle = new RectangleF(x, y, width, height);
            GraphicsPath  path      = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
            SmoothingMode old       = graphics.SmoothingMode;

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.DrawPath(pen, path);
            graphics.SmoothingMode = old;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fills a rounded rectangle with specified parameters.
        /// </summary>
        /// <param name="graphics">An encapsulated GDI+ drawing surface instance.</param>
        /// <param name="brush">Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.</param>
        /// <param name="x">The x-coordinate of the upper-left corner of the rectangle to draw.</param>
        /// <param name="y">The y-coordinate of the upper-left corner of the rectangle to draw.</param>
        /// <param name="width">Width of the rectangle to draw.</param>
        /// <param name="height">Height of the rectangle to draw.</param>
        /// <param name="radius">The radius for each corners</param>
        /// <param name="filter">The corners to have a radius</param>
        public static void FillRoundedRectangle(this Graphics graphics, LinearGradientBrush brush, float x, float y, float width, float height, float radius, BorderCorners filter)
        {
            RectangleF    rectangle = new RectangleF(x, y, width, height);
            GraphicsPath  path      = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
            SmoothingMode old       = graphics.SmoothingMode;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.FillPath(brush, path);
            graphics.SmoothingMode = old;
        }
Exemplo n.º 10
0
 private void ImportSelection(BorderCorners bc)
 {
     _borderCorners = bc;
     SetBorderCorners();
 }
Exemplo n.º 11
0
 private bool GetFlag(BorderCorners flag)
 {
     return((_borderCorners & flag) == flag);
 }