NetPro'09 โปรแกรมวาดรูป offline

1 view
Skip to first unread message

Nati

unread,
Aug 4, 2009, 11:50:32 PM8/4/09
to net...@googlegroups.com

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Drawing.Imaging;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace CSPaint

{

    public partial class Form1 : Form

    {

        Bitmap bitmap;

        Graphics graphics;

        Point oldPoint;

        bool isDrag = false;


        public Form1()

        {

            InitializeComponent();

            bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format24bppRgb);

            graphics = Graphics.FromImage(bitmap);

            oldPoint = new Point(0,0);

            pictureBox1.Image = bitmap;

            graphics.Clear(Color.White);

        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)

        {

            isDrag = true;

            oldPoint = e.Location;

        }

        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)

        {

            isDrag = false;

        }

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)

        {

            if (isDrag)

            {

                graphics.DrawLine(new Pen(Color.Black, 4), oldPoint, e.Location);

                oldPoint = e.Location;

                pictureBox1.Image = bitmap;

            }

        }

    }

}


Reply all
Reply to author
Forward
0 new messages