11 Şubat 2014 Salı

C# da Paint Yapımı

c#
c#
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 Paint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            drawBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            drawGraphics = Graphics.FromImage(drawBitmap);
            pictureBox1.Image = drawBitmap;
        }
        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;
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        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);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox2.BackColor = colorDialog1.Color;
                Color renk=new Color();
                renk=colorDialog1.Color;
                paintBrush = new SolidBrush(renk);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox3.BackColor = colorDialog1.Color;
                pictureBox1.BackColor = colorDialog1.Color;
            }
        }

    }
}



Sitemizin daha kaliteli paylaşımları yapabilmesi için sizin yorumlarınıza ihtiyacımız var :)

0 yorum :

Yorum Gönder