OPI_RGZ_2011
.pdf101
( F n K K K
float):
//E8@65<r:6 9HB9:?F5D@ rectanglefFull D rectfText H?I7K RectangleF
C?F
//[MB;Ic9;;F 6J?I789O C5KHK D 89H78K.
RectangleF rectanglefFull, rectfText;
// E8@65<r:6 B:D;;D C?F LDC5ISK;HK cM7?I 7M:@6?D@ D 5FCHD@. int NumberSymbols, NumberLines;
' d 9 — , n ,
, A4 9 A3. „ K K 9 n -
PageBounds PrintPageEventArgs. ‚ n 9'n Rectangle, X 0, Width Height
K , (
K. A 9 ' 9
— 9 d K o, - d . .9 n -
VisibleClipBounds Graphics, n 9'n RectangleF. : ‡ 9'n K 0, -
Width Height -
9 . 9 ,
n . Microsoft Word, ,
Kn . , 9
n K ).
n 9'n Rectangle MarginBounds.
9- , 9 K 9'n Rectangle 9 RectangleF, ( :
Rectangle (int x, int y, int width, int height); RectangleF (float x, float y, float width, float height);
v K , - K . J 9, o n 9 K -
.
' d . u 9 Kn
9'n rectanglefFull:
if (graph.VisibleClipBounds.X <0) rectanglefFull = e.MarginBounds; else
//[MB;IcIr:6 6J'rH8 rectanglefFull rectanglefFull = new RectangleF (
//[78I;6@?<r:6 H665CM;I8K X e.MarginBounds.Left - (e.PageBounds.Width - graph.VisibleClipBounds.Width) / 2,
//[78I;6@?<r:6 H665CM;I8K Y e.MarginBounds.Top - (e.PageBounds.Height - graph.VisibleClipBounds.Height) / 2,
102
//[78I;6@?<r:6 eM5M;K 6J?I78D e.MarginBounds.Width,
//[78I;6@?<r:6 @M768K 6J?I78D e.MarginBounds.Height);
fJ?I78T 89H78K JKC9 L59C78I@?F8M 76J6< H6LD< 6J?I78D rectanglefFull c K5ISK@I;;F: @M768M e5M•8K:
rectanglefText = RectangleF.Inflate (rectanglefFull, 0, -2 * HeightFont);
//[MB;IcIr:6 HD?THD78T 5FCHD@
int NumDisplayLines = (int) Math.Floor (rectanglefText.Height / HeightFont);
// [78I;6@?<r:6 @M768K 6J?I78D
rectanglefText.Height = NumDisplayLines * HeightFont;
s RichTextBox n WordWrap, -
True
. ' 9 ( (
9 rectanglefText. ” 9 ,
stringformat StringFormat, K- n Trimming:
if (rtbText.WordWrap)
{
stringformat.Trimming = StringTrimming.Word;
}
else
{
stringformat.Trimming = StringTrimming.EllipsisCharacter; stringformat.FormatFlags | = StringFormatFlags.NoWrap;
}
A , ( :
//45M C5KHK @MJ5I;MS 7865D;6H L959S6CM:6 C6 L95e6G 78I586@DO 7865D;-
bD
while ((PageNumber <StartPage)&&(stringPrintText.Length> 0))
{
if (rtbText.WordWrap)
//[M:D5<r:6 89H786@D B:D;;D,
//N65:Kr:6 C5KH, D L6@958Ir:6 cM7?6 7M:@6?D@ NumberSymbols
//y HD?THD78T 5FCHD@ NumberLines
graph.MeasureString (stringPrintText, font, rectanglefText.Size, stringformat, out NumberSymbols, out NumberLines);
else
NumberSymbols = SymbolsInLines (stringPrintText, NumDisplayLines); stringPrintText = stringPrintText.Substring (NumberSymbols);
//XJD?TeKr:6 HD?THD78T 7865D;6H
PageNumber + +;
}
//tHj6 C6@_M;I 5FCHI stringPrintText C65D@;<r ;K?< (;9:Ir 89H78K //C?F C5KHK),
//XKLM;Fr:6 C5KH
if (stringPrintText.Length == 0)
{
103
e.Cancel = true; return;
}
//[M@6CM:6 (:I?<r:6) 89H78 C?F C5KHK - stringPrintText, //@MH65M786@Kr:6 C?F bT6U6 e5M•8 font,
//YM78T c65;6U6 H6?T65K - Brushes.Black, 6J?I78T C5KHK - rectanglefText,
//4959CIr:6 5FC6H C6CI8H6@6U6 •65:I8K@I;;F stringformat graph.DrawString (stringPrintText, font, Brushes.Black, rectanglefText, stringformat);
//f85M:Kr:6 89H78 C?F ;I78KL;6G 7865D;HM
if (rtbText.WordWrap)
graph.MeasureString (stringPrintText, font, rectanglefText.Size, stringformat, out NumberSymbols, out NumberLines);
else
NumberSymbols = SymbolsInLines (stringPrintText, NumDisplayLines); stringPrintText = stringPrintText.Substring (NumberSymbols);
//fcMjIr:6 6J'rH8 stringformat, @MH65M78I;MO C?F •65:K@I;;F L6?D@. stringformat = new StringFormat ();
//W6CIr:6 @M7;6@6H ;I H6_;K 7865D;HK GG ;6:95I stringformat.Alignment = StringAlignment.Far;
graph.DrawString ("E865D;HI" + PageNumber, font, Brushes.Black, rectanglefFull, stringformat);
PageNumber + +;
//C;6@I L959@D5Fr:6, cM r 89H78 C?F C5KHK D ;6:95 7865D;HM, BICI;6G C?F C5KHK
e.HasMorePages = (stringPrintText.Length> 0) & & (PageNumber <StartPage + NumPages);
//W?F C5KHK B @DH;I L6L959C;T6U6 L959U?FCK B;6@K D;DbDI?DBK@I?M B:D;;D
if (! e.HasMorePages)
{
stringPrintText = rtbText.Text; StartPage = 1;
NumPages = printDialog1.PrinterSettings.MaximumPage; PageNumber = 1;
}
}
printDocument1_Print-Page. A
n , o
RichTextBox (
WordWrap). MeasureString n , o -
. A 9 , o K 9 rectanglefText, n SymbolsInLines:
int SymbolsInLines (string stringPrintText, int NumLines)
{
int index = 0;
for (int i = 0; i <NumLines; i + +)
{
index = 1 + stringPrintText.IndexOf ('\ n', index);
104
if (index == 0)
return stringPrintText.Length;
}
return index;
}
8 Kn 9 9 mnuPageSetup mnuPrintPreview K:
private void mnuPageSetup_Click (object sender, System.EventArgs e)
{
//46HIBKr:6 CDI?6U pageSetupDialog1.ShowDialog ();
}
private void mnuPrintPreview_Click (object sender, System.EventArgs e)
{
//y;DbDI?DBD5K9: B:D;;D
printDocument1.DocumentName = Text; stringPrintText = rtbText.Text; StartPage = 1;
NumPages = printDialog1.PrinterSettings.MaximumPage; PageNumber = 1;
// 46HIBKr:6 CDI?6U printPreviewDialog1.ShowDialog ();
}
:9 9 K mnuPrint n -
– , 9 9:
private void mnuPrint_Click (object sender, System.EventArgs e)
{
printDialog1.AllowSelection = rtbText.SelectionLength> 0; if (printDialog1.ShowDialog () == DialogResult.OK)
{
printDocument1.DocumentName = Text;
//[MB;IcIr:6 CDILIB6; 7865D;6H C?F C5KHK switch (printDialog1.PrinterSettings.PrintRange)
{
//[MJ5I;D @7D 7865D;HM
case PrintRange.AllPages: stringPrintText = rtbText.Text; StartPage = 1;
NumPages = printDialog1.PrinterSettings.MaximumPage; break;
//fJ5I;I @MCD?9;I 6J?I78T case PrintRange.Selection:
stringPrintText = rtbText.SelectedText; StartPage = 1;
NumPages = printDialog1.PrinterSettings.MaximumPage; break;
//[MJ5I;6 5FC 7865D;6H
case PrintRange.SomePages: stringPrintText = rtbText.Text;
StartPage = printDialog1.PrinterSettings.FromPage;
105
NumPages = printDialog1.PrinterSettings.ToPage - StartPage +1; break;
}
PageNumber = 1;
// [MH?MHIr:6 @JKC6@I;MO :986C C?F L6cI8HK C5KHK printDocument1.Print ();
}
}
n . , 9 "'-
", 9 K,
( 9 .
( -. ' 9 9 9 -
.
: , o 9 -
, 9 (
. . , , -
— .
9 9, ( 9
( 9 . ' d (
pdfFactoryPro — 'n -
, o n 9 pdf.
4.2.2 ! ' ) '/'-' %! ' ! ) (-# 8. `ET
Framework
4.2.2.1 ! ) GDI +
Windows – . J-
KK , K
. ” 9 9-
( Windows,
. .NET Framework n 9 n
. ' 9 9 ( -
, ( -. ” 9 K K Windows, 9
( (Graphic Device
106
Interface, GDI). .NET Framework K -
K GDI+.
6 GDI + .NET Framework K -
K GDI, n 9 (
'K. A n
d , GDI+.
N % %-' System.Drawing
' System.Drawing n d (-
. A ( n
K , -
(9. 4.4).
6 9 4.4 – ' System.Drawing
„’ |
|
” |
System.Drawing |
. , 9 9- |
|
|
( . v K - |
|
|
|
|
|
|
|
Sys- |
J, |
K |
tem.Drawing.Design |
( 9 |
|
|
||
Sy'stem.Drawing.2D |
J, o 9 ( K |
|
|
|
|
Sys- |
J, |
o K ( |
tem.Drawing.Imaging |
K K |
|
|
||
Sys- |
J |
|
tem.Drawing.Printing |
|
|
System.Drawing.Text |
J, o K ( |
|
|
d |
' Graphics
J K 9 ( n
Graphics System.Drawing. .9'n Graphics n
9 K, d -
107
, — , 9 9'n Image. -
' 9'n Graphics, n K -
9 ( n , o .
. 9'n Graphics 9 ' -
, ( , d
9. 9 9'n Graphics . € - -o Control (K K Form) n CreateGraphics. . n
9'n Graphics, ' -. 5 n 9'n
Graphics myForm:
System.Drawing.Graphics myGraphics; myGraphics = myForm.CreateGraphics();
Kn 9'n Graphics,
( 9 ( -
.
' 9 9 ( Graphics. FromImage - n 9'n Graphics, ' 9'n Image. v
, 9'n Graphics
9. .9'n Image ( n 9- 9'n-o
Image, Bitmap. . 9'n Bitmap
' 9'n Graphics:
Bitmap myImage = new Bitmap ("C: \\ myImage.bmp"); System.Drawing.Graphics myGraphics;
myGraphics = Graphics. FromImage (myImage);
(, o 9'n Image n
9'n Graphics K .
J. 2 9 ( 9 n 9,
( . 6 n -
, ( K X Y. -
(0,0) ( - 9 n , K -
. ' System. Drawing (9 4.5), o K 9 9 .
108
6 9 4.5 – 8, o K -
„’ |
. |
Point |
' n X Y, - |
|
Integer (Int). |
PointF |
' n ‡ Y, - |
|
Single (float) |
Size |
' n 9, - |
|
K Height Width Integer |
SizeF |
' n 9, - |
|
K Height Width Single (float) |
Rectangle |
' n 9, ( |
|
Top, Bottom, Left Right Integer |
|
(Int) |
RectangleF |
' n 9, ( |
|
Top, Bottom, Left Right Single |
|
(float) |
u 9 4.5, n 9 : , o
K , , o K
K K K.
8 Point, Size Rectangle d n -
K . ” 9
, (
K K K , :
Point myPoint;
PointF myPointF = new PointF (13.5F, 33.21F);
myPoint = new Point ((int) myPointF.X, (int) myPointF.Y);
( 9 Size Rectangle: 9 K n 9, -
Size n , ( ,
Rectangle n n-
9. A Rectangle 9 : Size
Point, o K ( :
Point myOrigin = new Point (10, 10); Size mySize = new Size (20, 20);
109
//E8@65M8M L5F:6HK8;MH 56B:D56: 20 ;I 20 LDH79?D@, @95S;DO
//uD@MO HK8 FH6U6 56B8Ie6@I;MO K 86cbD B H665CM;I8I:M (10,10), Rectangle myRectangle = new Rectangle (myOrigin, mySize);
K . .9'n Graphics Kn 9
K . „ n
. A d , -
n «Draw» (9 4.6). v K
K , . „ d , -
n «Fill» (9 4.7), ( K
- , 9.
v K 9 , o - K ( 9 ( . J , - 9 9'n, o n 9 ( ,
7n, 9 – Brush.
6 9 4.6 – K
„' |
. |
DrawArc |
Kn , o n |
DrawBezier |
Kn €n |
DrawBeziers |
Kn €n |
DrawClosedCurve |
' |
DrawCurve |
' - |
|
|
DrawEllipse |
Kn , |
DrawLine |
' n n nK |
DrawPath |
Kn 9'n GraphicsPath, - |
|
n |
DrawPie |
Kn , |
DrawPolygon |
Kn 9 K K - |
|
|
DrawRectangle |
Kn |
Draw Rectangles |
Kn |
110
6 9 4.7 – K 9
„' |
. |
FillCIosedCurve |
Kn , - |
|
, 9 n |
FillEllipse |
Kn 9 |
FillPath |
Kn 9 n 9'n Graphics Path, |
|
n |
FillPie |
Kn 9 |
FillPolygon |
Kn 9, , |
|
9 n |
FillRectangle |
Kn 9 |
FillRectangles |
Kn 9 |
FillRegion |
Kn 9 n 9'n Region, |
|
n |
' Color, Brush & Pen
.9'n Color, Brush 7n K -. .9'n Brush K 9 ( 9 -
, 7n – 9 ( , 9'n Color n
.
Color. 8 Color d n
System.Drawing n . J ( n -
: Alpha, Kn ,
Red, Green Blue 0-255. ” 9 , 9-
Color.FromArgb:
Color myColor;
myColor = Color.FromArgb (128, 255, 12, 43);
u o n , Alpha ( , d d Red, Green Blue:
Color myColor; myColor=Color.FromArgb(255,12,43);
J , 9 n .NET Framework
:
Color myColor;
myColor = Color.Tomato;
Brush. .9'n Brush n ( K
9 . : n o 9
Brush K K 9 -