🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / usercontrol border radius kullanımı köşeleri yuvarlama

1-) C# RMOS - usercontrol border radius kullanımı köşeleri yuvarlama

 

kaynak : https://stackoverflow.com/questions/28486521/rounded-edges-in-button-c-sharp-winforms

 

1-ekran görüntüsü

2-kodlar

 

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Windows.Forms;

 

namespace Proje.EkHizmetler

{

    public partial class ButtonStil : UserControl

    {

        public ButtonStil()

        {

            InitializeComponent();

        }

 

        private void ButtonStil_Paint(object sender, PaintEventArgs e)

        {

            //ButtonStil_Paint(sender,e);

            RectangleF Rect = new RectangleF(0, 0, this.Width, this.Height);

            using (GraphicsPath GraphPath = GetRoundPath(Rect, 10))

            {

                this.Region = new Region(GraphPath);

                using (Pen pen = new Pen(Color.CadetBlue, 2f))

                {

                    pen.Alignment = PenAlignment.Inset;

                    e.Graphics.DrawPath(pen, GraphPath);

                }

            }

        }

 

        GraphicsPath GetRoundPath(RectangleF Rect, int radius)

        {

            float r2 = radius / 0.4f;

            GraphicsPath GraphPath = new GraphicsPath();

            GraphPath.AddArc(Rect.X, Rect.Y, radius, radius, 180, 90);

            GraphPath.AddLine(Rect.X + r2, Rect.Y, Rect.Width - r2, Rect.Y);

            GraphPath.AddArc(Rect.X + Rect.Width - radius, Rect.Y, radius, radius, 270, 90);

            GraphPath.AddLine(Rect.Width, Rect.Y + r2, Rect.Width, Rect.Height - r2);

            GraphPath.AddArc(Rect.X + Rect.Width - radius,

                             Rect.Y + Rect.Height - radius, radius, radius, 0, 90);

            GraphPath.AddLine(Rect.Width - r2, Rect.Height, Rect.X + r2, Rect.Height);

            GraphPath.AddArc(Rect.X, Rect.Y + Rect.Height - radius, radius, radius, 90, 90);

            GraphPath.AddLine(Rect.X, Rect.Height - r2, Rect.X, Rect.Y + r2);

            GraphPath.CloseFigure();

            return GraphPath;

        }

    }

}

 

 

 

 2023 Şubat 04 Cumartesi
 334