23 Rectangle theRectangle = new Rectangle(new Point(0, 0), new Size(0, 0));
24 Point startPoint;
25 Point startMPoint;
26 Point ingPoint;
27 Point startPointS;
28 bool isMouseDown = false;
159 protected void ControlBase_MouseDown(object sender, MouseEventArgs e)
160 {
161
162 if (e.Button == MouseButtons.Left)
163 {
164
165 this.isMouseDown = true;
166
167 Control control = (Control)sender;
168
169 startPoint = new Point(this.Location.X, this.Location.Y);
170
171 startMPoint = control.PointToScreen(new Point(e.X, e.Y));
172 Point startPointS = control.PointToScreen(new Point(this.Location.X, this.Location.Y));
173
174 theRectangle = new Rectangle(startPoint, this.Size);
175
176 ControlPaint.DrawReversibleFrame(theRectangle, Color.Black, FrameStyle.Dashed);
177 }
178
179 }
180
181 protected void ControlBase_MouseMove(object sender, MouseEventArgs e)
182 {
183
184 if (this.isMouseDown)
185 {
186 ControlPaint.DrawReversibleFrame(theRectangle, Color.Black, FrameStyle.Dashed);
187
188 Point endPoint = ((Control)sender).PointToScreen(new Point(e.Location.X, e.Location.Y));
189
190 int X;
191 int Y;
192
193 if (startMPoint.X >= endPoint.X)
194 {
195 X = startPointS.X + (endPoint.X - startMPoint.X);
196
197 if (startMPoint.Y >= endPoint.Y) Y = startPointS.Y - (startMPoint.Y - endPoint.Y);
198 else Y = startPointS.Y + (endPoint.Y - startMPoint.Y);
199 }
200 else
201 {
202 X = startPointS.X - (startMPoint.X - endPoint.X);
203
204 if (startMPoint.Y >= endPoint.Y) Y = startPointS.Y - (startMPoint.Y - endPoint.Y);
205 else Y = startPointS.Y + (endPoint.Y - startMPoint.Y);
206 }
207
208 ingPoint = ((Control)sender).PointToScreen(new Point(X, Y));
209
210 theRectangle = new Rectangle(ingPoint, this.Size);
211 ControlPaint.DrawReversibleFrame(theRectangle, this.BackColor, FrameStyle.Dashed);
212 }
213
214 }
215
216 protected void ControlBase_MouseUp(object sender, MouseEventArgs e)
217 {
218 this.isMouseDown = false;
219
220 ControlPaint.DrawReversibleFrame(theRectangle, Color.Black, FrameStyle.Dashed);
221
222 this.Location = new Point(ingPoint.X, ingPoint.Y);
223
224 theRectangle = new Rectangle(0, 0, 0, 0);
225 }
Socket 통신시 byte배열로 변환하기 [패킷화 하기] (0) | 2011.05.13 |
---|---|
Form 을 마우스로 Drag 하여 이동하기 (0) | 2011.03.22 |
Control.AllowDrop 에 의한 메모리 누수 (0) | 2011.01.27 |
string to Enum Conversion (0) | 2011.01.27 |
[단일 프로세스 실행] (0) | 2010.12.31 |