Sunday, February 9, 2014

Paint Application Code in C#




Write a C# Application and make a paint using system. Drawing

using System.Drawing;

namespace Paint_App
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        bool Paint = false;
        SolidBrush SB = new SolidBrush(Color.Black);
        private void btn_ColorChange_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            SB.Color = colorDialog1.Color;
        }
        private void btn_Clear_Click(object sender, EventArgs e)
        {
            Graphics g = Panel_Paint.CreateGraphics();
            g.Clear(Panel_Paint.BackColor);
        }
        private void Panel_Paint_MouseDown(object sender, MouseEventArgs e)
        {
            Paint = true;          
        }
        private void Panel_Paint_MouseUp(object sender, MouseEventArgs e)
        {
            Paint = false;
        }
        private void Panel_Paint_MouseMove(object sender, MouseEventArgs e)
        {
            if (Paint)
            {
                Graphics g2 = Panel_Paint.CreateGraphics();
                g2.FillEllipse(SB, e.X, e.Y, Trak_Brush.Value, Trak_Brush.Value);
                g2.Dispose();
            }

        }
    }
}



No comments:

Post a Comment