form'a bir pictureBox ve bir richtextbox ekleyin. picturebox'a varsayılan olarak test için bir resim yükleyebilirsiniz.
using System; using System.Drawing; using System.Windows.Forms;
namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Rectangle rcx = new Rectangle(0,0,0,0); Boolean lstart = false; Point lct; Point imgs;
private void Form1_Load(object sender, EventArgs e) { pictureBox1.Image = new Bitmap("C:/test.bmp"); imgs.X = pictureBox1.Image.Width; imgs.Y = pictureBox1.Image.Height; }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { lstart = true; lct = e.Location; Point startPoint = pictureBox1.PointToScreen(new Point(e.X, e.Y)); rcx.X = startPoint.X; rcx.Y = startPoint.Y; }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { this.Text = e.X + " : " + e.Y;
if (lstart) { Point endPoint = pictureBox1.PointToScreen(new Point(e.X, e.Y));
if (e.X > -1 && e.X <= imgs.X && e.Y > -1 && e.Y <= imgs.Y) { rcx.Height = endPoint.Y - rcx.Y - 1; rcx.Width = endPoint.X - rcx.X - 1;
this.Refresh(); ControlPaint.DrawReversibleFrame(rcx, this.BackColor, FrameStyle.Dashed); } } }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { lstart = false; Point endPoint = e.Location; if (endPoint.X < 0) endPoint.X = 0; if (endPoint.Y < 0) endPoint.Y = 0;
richTextBox1.Text = "x1:" + lct.X.ToString() + "\n" + "y1:" + lct.Y.ToString() + "\n" + "x2:" + endPoint.X.ToString() + "\n" + "y2:" + endPoint.Y.ToString(); //rcx = new Rectangle(0, 0, 0, 0); } } }
örnek görünüm: 
------------- http://www.kasatakip.com - Kasa Takip | http://www.caritakip.com - Cari Takip | http://www.evraktakip.com - Evrak Takip | http://www.etasqlmobil.com - ETA SQL Mobil
|