Home » » C# — Elips Buton Oluşturma

C# — Elips Buton Oluşturma

Elips Buton Oluşturma C#
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;
using System.Text;

using System.Windows.Forms;

using System.Drawing.Drawing2D;

namespace elips_buton_olusturma

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

ShapedButton elips_Buton = new ShapedButton();
elips_Buton.Size = new Size(100, 50);

elips_Buton.Location = new Point(120, 60);

elips_Buton.FlatAppearance.BorderSize = 0;

elips_Buton.BackColor = Color.Blue;

elips_Buton.FlatStyle = FlatStyle.Flat;

this.Controls.Add(elips_Buton);

}

}

public class ShapedButton : Button //Buton sınıfından miras alınıyor

{

// Elips buton a yeni bir boyut verildiğinde şeklini elips yapıyor

protected override void OnResize(EventArgs e)

{

base.OnResize(e);

GraphicsPath gp = new GraphicsPath();

// this.Size ın en boyu aynı oldugundan elips bir şekil oluşuyor

gp.AddEllipse(new Rectangle(Point.Empty, this.Size));

// oluşan yeni elips şekli oluşturulan butona atanıyor

this.Region = new Region(gp);

// Butonun yeni şekli elips oluyor

}

}
 
Support : Vaganzi
Copyright © 2013. Visual Studio Kod Bankası - All Rights Reserved
Powered By Vaganzi