程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 用C# 實現截圖功能(1)(類似QQ截圖)(3)

用C# 實現截圖功能(1)(類似QQ截圖)(3)

編輯:關於C語言

MyRectagle類代碼實現如下:

class MyRectangle
2  {
3    /**//// <summary>
4    /// The x-coordinate of the upper-left corner of the main rectangle
5    /// </summary>
6    private int x;
7
8    /**//// <summary>
9    /// The star x-coordinate when you draw the main rectangle
10    /// </summary>
11    private int downPointX;
12
13    /**//// <summary>
14    /// The y-coordinate of the upper-left corner of the main rectangle
15    /// </summary>
16    private int y;
17
18    /**//// <summary>
19    /// The star y-coordinate when you draw the main rectangle
20    /// </summary>
21    private int downPointY;
22
23    /**//// <summary>
24    /// The width of the main rectangle
25    /// </summary>
26    private int width;
27
28    /**//// <summary>
29    /// The height of the main rectangle
30    /// </summary>
31    private int height;
32
33    /**//// <summary>
34    /// The least width of the main rectangle
35    /// </summary>
36    private int minWidth;
37
38    /**//// <summary>
39    /// The least height of the main rectangle
40    /// </summary>
41    private int minHeight;
42
43    /**//// <summary>
44    /// Sign the main rectangle is on change size mode or not
45    /// </summary>
46    private bool changeSizeMode;
47
48    /**//// <summary>
49    /// Sign the main rectangle is on move mode or not
50    /// </summary>
51    private bool moveMode;
52
53    /**//// <summary>
54    /// Sign the current mouse position is on the upper-left corner of the main rectangle or not
55    /// </summary>
56    private bool mouSEOnLeftTop;
57    /**//// <summary>
58    /// Sign the current mouse position is on the middle point of the left line of the main rectangle or not
59    /// </summary>
60    private bool mouSEOnLeftMiddle;
61    /**//// <summary>
62    /// Sign the current mouse position is on the bottom-left corner of the main rectangle or not
63    /// </summary>
64    private bool mouSEOnLeftBottom;
65
66    /**//// <summary>
67    /// Sign the current mouse position is on the upper-right corner of the mian rectangle or not
68    /// </summary>
69    private bool mouSEOnRightTop;
70    /**//// <summary>
71    /// 鼠標落點在右中點標志
72    /// </summary>
73    private bool mouSEOnRightMiddle;
74    /**//// <summary>
75    /// Sign the current mouse position is on the middle point of the right line of the main rectangle or not
76    /// </summary>
77    private bool mouSEOnRightBottom;
78
79    /**//// <summary>
80    /// Sign the current mouse position is on the middle point of the top line of the main rectangle or not
81    /// </summary>
82    private bool mouSEOnTopMiddle;
83    /**//// <summary>
84    /// Sign the current mouse position is on the middle point of the bottom line of the main rectangle or not
85    /// </summary>
86    private bool mouSEOnBottomMiddle;
87
88    /**//// <summary>
89    /// Sign the current mouse position is in the main rectangle or not
90    /// </summary>
91    private bool mouSEOnMiddle;
92    /**//// <summary>
93    /// The width of the 8 little rectangles that on the 4 corners and the 4 middle points that of the 4 lines of the main rectangle
94    /// </summary>
95    private int littleRectangleWidth;
96    /**//// <summary>
97    /// The height of the 8 little rectangles that on the 4 corners and the 4 middle points that of the 4 lines of the main rectangle
98    /// </summary>
99    private int littleRectangleHeight;
100
101    /**//// <summary>
102    /// The little rectangle on the upper-left corner of the main rectangle
103    /// </summary>
104    private Rectangle leftTopRectangle;
105    /**//// <summary>
106    /// The little rectangle on the middle point of the left line of the main rectangle
107    /// </summary>
108    private Rectangle leftMiddleRectangle;
109    /**//// <summary>
110    /// The little rectangle on the bottom-left corner of the main rectangle
111    /// </summary>
112    private Rectangle leftBottomRectangle;
113
114    /**//// <summary>
115    /// The little rectangle on the upper-right corner of the main rectangle
116    /// </summary>
117    private Rectangle rightTopRectangle;
118    /**//// <summary>
119    /// The little rectangle on the middle point of the right line of the main rectangle
120    /// </summary>
121    private Rectangle rightMiddleRectangle;
122    /**//// <summary>
123    /// The little rectangle on the bottom-right corner of the main rectangle
124    /// </summary>
125    private Rectangle rightBottomRectangle;
126
127    /**//// <summary>
128    /// The little rectangle on the middle point of the top line of the main rectangle
129    /// </summary>
130    private Rectangle topMiddleRectangle;
131    /**//// <summary>
132    /// The little rectangle on the middle point of the bottom line of the main rectangle
133    /// </summary>
134    private Rectangle bottomMiddleRectangle;
135
136    /**//// <summary>
137    /// The main rectangle
138    /// </summary>
139    private Rectangle rect;
140
141    /**//// <summary>
142    /// The size of the main rectangle
143    /// </summary>
144    private Size size;
145
146    /**//// <summary>
147    /// The background image of the screen
148    /// </summary>
149    private Image backImage;
150
151    /**//// <summary>
152    /// The cursor manner
153    /// </summary>
154    private Cursor myCursor;
155
156    /**//// <summary>
157    /// Gets of sets the x-coordinate of the upper-left corner of the main rectangle
158    /// </summary>
159    public int X
160    {
161      get { return x; }
162      set
163      {
164        x = value;
165        rect.X = value;
166      }
167    }
168    /**//// <summary>
169    /// Gets of sets the y-coordinate of the upper-left corner of the main rectangle
170    /// </summary>
171    public int Y
172    {
173      get { return y; }
174      set
175      {
176        y = value;
177        rect.Y = value;
178      }
179    }
180
181    /**//// <summary>
182    /// Gets of sets the star x-coordinate when you draw the main rectangle
183    /// </summary>
184    public int DownPointX
185    {
186      get { return downPointX; }
187      set { downPointX = value; }
188    }
189    /**//// <summary>
190    /// Gets of sets the star y-coordinate when you draw the main rectangle
191    /// </summary>
192    public int DownPointY
193    {
194      get { return downPointY; }
195      set { downPointY = value; }
196    }
197    /**//// <summary>
198    /// Gets of sets the width of the main rectangle
199    /// </summary>
200    public int Width
201    {
202      get { return width; }
203      set
204      {
205        width = value;
206        rect.Width = value;
207      }
208    }
209    /**//// <summary>
210    /// Gets or sets the height of the main rectangle
211    /// </summary>
212    public int Height
213    {
214      get { return height; }
215      set
216      {
217        height = value;
218        rect.Height = value;
219      }
220    }
221
222    /**//// <summary>
223    /// Gets or sets the least width of the main rectangle
224    /// </summary>
225    public int MinWidth
226    {
227      get { return minWidth; }
228      set { minWidth = value; }
229    }
230
231    /**//// <summary>
232    /// Gets or sets the least height of the main rectangle
233    /// </summary>
234    public int MinHeight
235    {
236      get { return minHeight; }
237      set { minHeight = value; }
238    }
239
240    /**//// <summary>
241    /// Gets or sets the sign of the change size mode of the main rectangle
242    /// </summary>
243    public bool ChangeSizeMode
244    {
245      get { return changeSizeMode; }
246      set
247      {
248        changeSizeMode = value;
249        moveMode = !value;
250      }
251    }
252
253    /**//// <summary>
254    /// Gets or sets the sign of the move mode of the main rectangle
255    /// </summary>
256    public bool MoveMode
257    {
258      get { return moveMode; }
259      set
260      {
261        moveMode = value;
262        changeSizeMode = !value;
263      }
264    }
265
266    /**//// <summary>
267    /// Gets or sets the sign of current mouse position
268    /// (is on the upper-left corner of the main rectangle or not)
269    /// </summary>
270    public bool MouSEOnLeftTop
271    {
272      get { return mouSEOnLeftTop; }
273      set
274      {
275        mouSEOnLeftTop = value;
276        if (value)
277        {
278          mouSEOnLeftMiddle = false;
279          mouSEOnLeftBottom = false;
280
281          mouSEOnRightTop = false;
282          mouSEOnRightMiddle = false;
283          mouSEOnRightBottom = false;
284
285          mouSEOnTopMiddle = false;
286          mouSEOnBottomMiddle = false;
287
288          mouSEOnMiddle = false;
289        }
290      }
291    }
292    /**//// <summary>
293    /// Gets or sets the sign of current mouse position
294    /// (is on the middle point of the left line of the main rectangle or not)
295    /// </summary>
296    public bool MouSEOnLeftMiddle
297    {
298      get { return mouSEOnLeftMiddle; }
299      set
300      {
301        mouSEOnLeftMiddle = value;
302        if (value)
303        {
304          mouSEOnLeftTop = false;
305          mouSEOnLeftBottom = false;
306
307          mouSEOnRightTop = false;
308          mouSEOnRightMiddle = false;
309          mouSEOnRightBottom = false;
310
311          mouSEOnTopMiddle = false;
312          mouSEOnBottomMiddle = false;
313
314          mouSEOnMiddle = false;
315        }
316      }
317    }
318    /**//// <summary>
319    /// Gets or sets the sign of current mouse position
320    /// (is on the bottom-left corner of the main rectangle or not)
321    /// </summary>
322    public bool MouSEOnLeftBottom
323    {
324      get { return mouSEOnLeftBottom; }
325      set
326      {
327        mouSEOnLeftBottom = value;
328        if (value)
329        {
330          mouSEOnLeftTop = false;
331          mouSEOnLeftMiddle = false;
332
333          mouSEOnRightTop = false;
334          mouSEOnRightMiddle = false;
335          mouSEOnRightBottom = false;
336
337          mouSEOnTopMiddle = false;
338          mouSEOnBottomMiddle = false;
339
340          mouSEOnMiddle = false;
341        }
342      }
343    }
344
345    /**//// <summary>
346    /// Gets or sets the sign of current mouse position
347    /// (is on the upper-right corner of the main rectangle or not)
348    /// </summary>
349    public bool MouSEOnRightTop
350    {
351      get { return mouSEOnRightTop; }
352      set
353      {
354        mouSEOnRightTop = value;
355        if (value)
356        {
357          mouSEOnLeftTop = false;
358          MouSEOnLeftMiddle = false;
359          mouSEOnLeftBottom = false;
360
361          mouSEOnRightMiddle = false;
362          mouSEOnRightBottom = false;
363
364          mouSEOnTopMiddle = false;
365          mouSEOnBottomMiddle = false;
366
367          mouSEOnMiddle = false;
368        }
369      }
370    }
371    /**//// <summary>
372    /// Gets or sets the sign of current mouse position
373    /// (is on the middle point of the right line of the main rectangle or not)
374    /// </summary>
375    public bool MouSEOnRightMiddle
376    {
377      get { return mouSEOnRightMiddle; }
378      set
379      {
380        mouSEOnRightMiddle = value;
381        if (value)
382        {
383          mouSEOnLeftTop = false;
384          mouSEOnLeftBottom = false;
385          mouSEOnLeftMiddle = false;
386
387          mouSEOnRightTop = false;
388          mouSEOnRightBottom = false;
389
390          mouSEOnTopMiddle = false;
391          mouSEOnBottomMiddle = false;
392
393          mouSEOnMiddle = false;
394        }
395      }
396    }
397    /**//// <summary>
398    /// Gets or sets the sign of current mouse position
399    /// (is on the bottom-right corner of the main rectangle or not)
400    /// </summary>
401    public bool MouSEOnRightBottom
402    {
403      get { return mouSEOnRightBottom; }
404      set
405      {
406        mouSEOnRightBottom = value;
407        if (value)
408        {
409          mouSEOnLeftTop = false;
410          mouSEOnLeftBottom = false;
411          mouSEOnLeftMiddle = false;
412
413          mouSEOnRightTop = false;
414          mouSEOnRightMiddle = false;
415
416          mouSEOnTopMiddle = false;
417          mouSEOnBottomMiddle = false;
418
419          mouSEOnMiddle = false;
420        }
421      }
422    }
423
424    /**//// <summary>
425    /// Gets or sets the sign of current mouse position
426    /// (is on the middle point of the top line of the main rectangle or not)
427    /// </summary>
428    public bool MouSEOnTopMiddle
429    {
430      get { return mouSEOnTopMiddle; }
431      set
432      {
433        mouSEOnTopMiddle = value;
434        if (value)
435        {
436          mouSEOnLeftTop = false;
437          mouSEOnLeftBottom = false;
438          mouSEOnLeftMiddle = false;
439
440          mouSEOnRightTop = false;
441          mouSEOnRightBottom = false;
442          mouSEOnRightMiddle = false;
443
444          mouSEOnBottomMiddle = false;
445
446          mouSEOnMiddle = false;
447        }
448      }
449    }
450    /**//// <summary>
451    /// Gets or sets the sign of current mouse position
452    /// (is on the middle point of the middle line of the main rectangle or not)
453    /// </summary>
454    public bool MouSEOnBottomMiddle
455    {
456      get { return mouSEOnBottomMiddle; }
457      set
458      {
459        mouSEOnBottomMiddle = value;
460        if (value)
461        {
462          mouSEOnLeftTop = false;
463          mouSEOnLeftBottom = false;
464          mouSEOnLeftMiddle = false;
465
466          mouSEOnRightTop = false;
467          mouSEOnRightBottom = false;
468          mouSEOnRightMiddle = false;
469
470          mouSEOnTopMiddle = false;
471
472          mouSEOnMiddle = false;
473        }
474      }
475    }
476
477    /**//// <summary>
478    /// Gets or sets the sign of current mouse position
479    /// (is in the main rectangle or not)
480    /// </summary>
481    public bool MouSEOnMiddle
482    {
483      get { return mouSEOnMiddle; }
484      set
485      {
486        mouSEOnMiddle = value;
487        if (value)
488        {
489          mouSEOnLeftTop = false;
490          mouSEOnLeftBottom = false;
491          mouSEOnLeftMiddle = false;
492
493          mouSEOnRightTop = false;
494          mouSEOnRightBottom = false;
495          mouSEOnRightMiddle = false;
496
497          mouSEOnTopMiddle = false;
498          MouSEOnBottomMiddle = false;
499        }
500      }
501    }
502    /**//// <summary>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved