using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FikriPaint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string çizim = "Çizgi";//Radio Butonlar Çizgi,Dikdörtgen,Elips,Serbest
private void arac_sec_CheckedChanged_1(object sender, EventArgs e)//4 RadioButonu da Seçip CheckedChanged eventine kodu yazıyoruz.
{
RadioButton rb = (RadioButton)sender;
if (rb.Checked)
{
çizim = rb.Text;
}
}
Point p1, p2;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (çizim == "Serbest")
{
Graphics g = this.CreateGraphics();
Pen kalem = new Pen(Color.Red, 4);
Point pt1 = new Point(e.X, e.Y);
Point pt2 = new Point(e.X + 1, e.Y + 1);
g.DrawLine(kalem, pt1, pt2);
}
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
p1 = new Point(e.X, e.Y);
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
p2 = new Point(e.X, e.Y);
Graphics g = this.CreateGraphics();
Pen kalem = new Pen(Color.Red, 2);
Rectangle dortgen = new Rectangle(p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y);
SolidBrush fırça = new SolidBrush(Color.Yellow);
if (çizim == "Çizgi")
g.DrawLine(kalem, p1, p2);
else if (çizim == "Dikdörtgen")
{
if (Tara.Checked)
g.FillRectangle(fırça, dortgen);
g.DrawRectangle(kalem, dortgen);
}
else if (çizim == "Elips")
{
if (Tara.Checked)
g.FillEllipse(fırça, dortgen);
g.DrawEllipse(kalem, dortgen);
}
}
}
}
0 yorum:
Yorum Gönder