using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test
{
public partial class Teachar03 : Form
{
private string path;
public Point temp;
public Teachar03()
{
InitializeComponent();
path = @"D:\새 폴더\Test\bin\Debug\img\images.jpg";
temp = new Point(0, 0);
}
private void Teachar03_Load(object
sender, EventArgs e)
{
//1. 이미지 객체 생성
//2. pictureBox의 속성에 대입
Image img = new Bitmap(path);
pictureBox1.Image = img;
}
private void pictureBox1_MouseMove(object
sender, MouseEventArgs e)
{
//Point p = new
Point(e.X, e.Y);
//pictureBox1.Location
= p;
//마우스 이동중에서 현재 눌려진 버튼이 왼쪽버튼?
if (e.Button == MouseButtons.Left)
{
this.Text
= string.Format("X
: {0} : Y : {1}", e.X, e.Y);
Point p
= new Point(pictureBox1.Location.X
+ e.X - temp.X, pictureBox1.Location.Y + e.Y - temp.Y);
pictureBox1.Location = p;
}
}
private void pictureBox1_MouseDown(object
sender, MouseEventArgs e)
{
//이미지를 드래그 하기위해서 누른 이미지내의 위치
temp.X = e.X;
temp.Y = e.Y;
}
}
}