OPI_LR2011_ch2m2
.pdf21
private void Form2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
drawPen = false;
}
private void Form2_Mousemove (object sender, System.Windows.Forms.MouseEventArgs e)
{
//R?N@ ?.46@4 N7 97 -,83.N79<d if(drawPen)
{
//6C-@4:OA@ @e'O?C Pen
Pen blackpen = new Pen(Color.Black, 3);
//@874=.OA@ 3@C@M97 3@+@=799R ?.46@4.
Point point = new Point(e.X, e.Y);
//6C-@4:OA@ @e'O?C Graphics
Graphics g = this.CreateGraphics(); // A5+:OA@ +,9,:
g.DrawLine(blackpen, PreviousPoint, point];
// Te74,Y5OA@ 3@C@M9. 3@T<a,: ?.46@4. PreviousPoint = point;
}
: , F. A
Form2 .
F B PreviousPoint, drawPen B DrawLine, DrawEllipse Text.
/ ( F . 7
. ` PreviousPoint drawPen:
public class Form2: System.Windows.Forms.Form
{
public bool drawPen; public Point PreviousPoint;
}
Form2.drawPen – -
, , F F . / F Form2_MouseDown [ drawPen true, i
B «/». / F Form2_MouseUp [ false. > , B drawPen - F[ true [ false , -
. / F Form2_MouseMove F[
, drawPen [ true. F
[ :
1.3 F[ '[ Pen, [ -
(Color.Black) i F , i F[ .
22
_7n bl56k47n = new Pen (Color.Black, 3);
2. A B.
Point point = new Point(e.X, e.Y);
3. 3 F[ '[ Graphics +.
Graphics g = this.CreateGraphics();
4. A [ DrawLine '[ Graphics. -
F
B. ' B
'[ , [ F .
PreviousPoint = point;
> , ( B F F
B F F ( .
B, B,
. 3 . / ( F-
. 3 F - F,
F B ( . 3.1). { i
B F – , i [-
( .
@ 3.1 – F
23
3.2.4 (;) / . # W X"8 %Y %$" %)")
/ B i B. =
+ F , .
` Form2 ( +:
void DrawLine(Point point)
//R?N@ @8<9 45T -=7 ?+5a9.+< if (FirstClick == true){
//6C-@4:OA@ @e'O?C Pen
Pen bl56?47n = new Pen (Color.Black, 3);
//6C-@4:OA@ @e'O?C Graphics Graphics g = this.CreateGraphics();
//A5+:OA@ +,9,:
g.DrawLine(bl56?47n, PreviousPoint, point); FirstClick = false;
}
else{
Firstciick = true;
}
void DrawEllipse(Point point) {
//R?N@ @8<9 45T .=7 ?+5a9.+< if (FirstClick== true){
//6C-@4:OA@ @e'O?C Pen
Pen bl56?47n = new Pen (Color.Black, 3);
//6C-@4:OA@ @e'O?C Graphics Graphics g = this.CreateGraphics();
//A5+:OA@ 7+,36
g.DrawEllipse(blackpen, PreviousPoint.X, PreviousPoint.Y, point.X - Previouspoint.X, point.Y - Previouspoint.Y);
FirstClick = false;
}
else{
FirstClick = true;
}
}
void DrawText(Point point){
//6C-@4:OA@ @e'O?C Graphics Graphics g = this.CreateGraphics();
//6C-@4:OA@ @e'O?C Font
Font titlefont = new Font("Lucida Sans Unicode", 15); // A5+:OA@ C7?6C M74-@9<A ?@+j@4@A g.DrawString("k4@Y45A.-599 95 l#", titlefont, new Solid-
Brush(Color.Red), point.X, point.Y).
}
DrawLine DrawEllipse F
FirstClick ` B [ Form2.
public bool drawPen;
24
public bool FirstClick; public Point PreviousPoint:;
DrawText DrawEllipse FF '[ -
. ' B B '[-
B [ FirstClick true. ' B [ F , -
FirstClick [ false.
` F [ DrawText. `
F[ '[ Font B +
Lucida Sans Unicode 15 . ' F
Drawstring «' 3#» . > ( DrawLine,
DrawEllipse DrawText + Form2_MouseDown.
. / F ( , A ( F B + ( ( . 3.2).
@ 3.2 – A «‰ + »
25
3.3 )! / ! %
3.3.1/
F , F , ( -
.
3.3.2A (.
3.3.3A :
1.@ «‰ + ». @
F – , , , -
. ' (, (
(.
2.@ «‰ + ». ` [
+ ( + , [
-
( .
3.3.4/+ .
3.3.5A .
3.4 $" ,)"
3.4.1> .
3.4.2.
3.4.3: .
3.4.4> .
3.4.5@ .
3.4.6A, i
(5 B. ), ( ( F -
.
3.5 (9 " , % /
3.5.1{ F ?
3.5.2{ [ +?
3.5.3` [ Polygon?
3.5.4{ i ?
3.5.5{ F ?
26
3.5.6{ Antialiasing ?
3.5.7{ B B F GDI+?
3.5.8' F GDI GDI+.
3.5.9` F ?
3.5.10A alphaGDI+.
27
4 5 + + + 5 8
+ P
4.1 . %
= F 3#.
4.2 ) " . . %8 " )"!$"
4.2.1 ) . / ! )"! %
` – - ,
. ` [ ( B-
F, F
. Š ( -
- Windows, –
MSDN ( , [, , ). 9 [ F HTML- , -
+ *. chm *. hlp. 1[ -
F[ F ( -
B. C: \ WINDOWS \ Help
+ B Windows.
{ , ,
Notepad C#. / F [
, , - [ ( . 4.1).
4.2.2 4"!W ) HTML-"
A i F -
web- , , Microsoft Front Page. `
36 , ' ( F. A +-
- (> <body bgcolor="#66CCFF">). ` F -
,
( . 4.2).
28
@ 4.1 – ‰ Notepad C#
@ 4.2 – : F
> 4.1 . v (
HTML- ,
|
|
29 |
|
|
|
> 4.1 – A HTML- |
|||||
|
|
|
|
|
|
,) |
W ( ) |
$" " % |
|||
X #( |
" % |
||||
|
|
|
|||
About |
A- |
A + About: |
|
|
|
Form. |
+ |
9 About, |
|
|
|
htm |
About |
|
|
|
|
Name |
About |
|
|||
|
|
|
|||
|
|
FormBorderStyle |
FixedSingle |
|
|
|
|
MaximizeBox |
False |
|
|
|
|
MinimizeBox |
False |
|
|
|
|
Size |
318; 214 |
|
|
|
|
Text |
About Notepad C# |
|
|
|
|
B + ( : |
|
|
‰ |
|
|
' + About. |
|
|
(' FullCodeAbout.htm) |
About |
/ F- |
private void mnuAbout_Click(object |
Progra |
{sender,System.EventArgs e) |
|
m.htm |
F |
About frm = new About(); |
|
About |
frm.Show(); |
|
Program |
} |
|
' F '[ + |
|
|
|
About |
|
|
30 |
|
|
|
' ( 4.1 |
|
|
|||
|
|
|
|
|
|
,) |
W ( ) |
$" " % |
|||
X #( |
" % |
||||
|
|
|
|||
Arrang / F- |
private void mnuArrangecons_Click(object sender, |
||||
eIcons. {System.EventArgs e) |
|
|
|||
htm |
F |
this.LayoutMdi(MdiLayout.ArrangeIcons); |
|||
|
Arrange |
} |
|
|
|
|
Icons |
|
|
|
|
blank. |
A- |
A + blank: |
|
|
|
htm |
+ |
9 blank, |
|
|
|
|
blank |
|
|
|
|
|
Name |
blank |
|
||
|
|
|
|||
|
|
Text |
blank |
|
|
|
|
WindowState |
Maximized |
|
B + ( :
' F '[ +
About ( AboutForm).