Paint programı C#

Paint programı C#

[code lang=”csharp”]

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;//www.gorselprogramlama.com

using System.Text;

using System.Windows.Forms;

namespace WindowsApplication1

{

public partial class Form1 : Form

{

private Bitmap drawBitmap;

private Graphics drawGraphics;

private SolidBrush paintBrush = new SolidBrush(Color.Blue);

private int paintXSize = 4;

private int paintYSize = 4;

private SolidBrush clearBrush = new SolidBrush(Color.White);

private int clearXSize = 20;

private int clearYSize = 20;

public Form1()//www.gorselprogramlama.com

{

InitializeComponent();

drawBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);

drawGraphics = Graphics.FromImage(drawBitmap);

pictureBox1.Image = drawBitmap;

}

//www.gorselprogramlama.com

private void cizimYap(int xKoor, int yKoor,MouseEventArgs e)

{

drawGraphics.FillRectangle(paintBrush, e.X, e.Y, xKoor, yKoor);

pictureBox1.Image = drawBitmap;

}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

{

if (e.Button == System.Windows.Forms.MouseButtons.Right)

{

cizimYap(paintXSize, paintYSize,e);

}

else if (e.Button == System.Windows.Forms.MouseButtons.Left)

{

drawGraphics.FillRectangle(clearBrush, e.X, e.Y, clearXSize, clearYSize);

pictureBox1.Image = drawBitmap;

}

//www.gorselprogramlama.com

}

private void Form1_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

paintBrush = new SolidBrush(Color.Red);

}

private void button3_Click(object sender, EventArgs e)

{

paintBrush = new SolidBrush(Color.Black);

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

{

if (comboBox1.Text == "1")

{

paintXSize = 4;

paintYSize = 4;

}

else if (comboBox1.Text == "2")

{

paintXSize = 8;

paintYSize = 8;

}

else if (comboBox1.Text == "3")

{

paintXSize = 16;

paintYSize = 16;//www.gorselprogramlama.com

}

}

private void button2_Click(object sender, EventArgs e)

{

paintBrush = new SolidBrush(button2.BackColor);

drawGraphics.FillRectangle(paintBrush, 0, 0, pictureBox1.Width, pictureBox1.Height);

pictureBox1.Image = drawBitmap;

}

private void button4_Click(object sender, EventArgs e)

{

paintBrush = new SolidBrush(button4.BackColor);

drawGraphics.FillRectangle(paintBrush, 0, 0, pictureBox1.Width, pictureBox1.Height);

pictureBox1.Image = drawBitmap;

}

private void button5_Click(object sender, EventArgs e)

{

paintBrush = new SolidBrush(button5.BackColor);

drawGraphics.FillRectangle(paintBrush, 0, 0, pictureBox1.Width, pictureBox1.Height);

pictureBox1.Image = drawBitmap;

}

}

}

[/code]


Projeyi İNDİR

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir