OPI_RGZ_2011
.pdf91
F /b-,
5 9 , o n ,
n , o 9 -9 -
. ' 9 , o -
, 9 , -. 6 , -9 -
.
” 9 , n
, PrinterSettings.SupportsColor. u o ,
DefaultPageSettings.Color true,
9 d . A - 9 Default PageSettings.Color false.
5 n K -
-9 K
PrinterSettings.SupportsColor.
//w9O L5MH?IC L5MLK7HIr ;IF@;D78T 6L95I865D@ Imports System. Drawing,
//System. Drawing. Drawing2D D System. Drawing. Printing Brush BrushOne;
Brush BrushTwo;
if (PrintDocument1. PrinterSettings.SupportsColor == true)
{
//E8@65M8M L9;B?D C?F H6?T656@6U6 C5KHK.
BrushOne = Brushes. Red;
BrushTwo = Brushes. Blue;
}
else
{
// E8@65M8M 6J'rH8M HatchedBrush C?F c65;6-JD?6U6 C5KHK.
BrushOne - new HatchBrushfHatchStyle. DarkVertical, Color. Black); BrushTwo = new HatchBrush (HatchStyle. DashedHorizontal,
Color. Black);
}
. :
–9'n PrintDocument Toolbox -
— 9 '
, d
. 8 PrintDocument ( -
;
–d 9 9 PrintDocument PrintPage;
–9 9 PrintPage , Kn
n 9 . ' 9 (
K 9'n PrintPageEventArgs.Graphics;
92
– o Kn 9 , - d , o Kn 9 .
4.2.1.3 ! ) |
'/'-' |
' ! ) |
PrintPreviewControl |
|
|
.NET Framework n PrintPreviewControl, o 9 n ( -
K . PrintPreviewControl
Windows Forms Toolbox, (
.
” 9 d ,9 ' -
PrintPreviewControl
PrintDocument, d PrintPreviewControl.Document
:
myPrintPreview. Document = myPrintDocument;
' PrintPreviewControl 9 - 9 ( , . : 9 9
PrintDocument.Print, o 9 9
9 PrintPreviewControl. ' Kn -
.
” 9 9 , o 9 ( n -
, InvalidatePreview: myPrintPreview.InvalidatePreview();
Zoom — o (
PrintPreviewControl. : n d 9
. u o Kn 1, d 9 Kn 100%. ' -
1 9 ( d -, , o o K 1, 9 ( 9- d.
/'-' ' ! ) PrintPreviewDialog
s PrintPreviewControl d n -
, o K,
( . . 9- d -
. A .NET Framework 9-
93
PrintPreviewDialog, n
d d ( -. PrintPreviewDialog 9 ( n , . 4.1.
7 4.1 – : PrintPreviewDialog
A -
Document 9'n PrintPreviewDialog 9'n Print Document,
n 9 . s
PrintPreviewDialog n
, K d 9 . :-
PrintPreviewDialog n 9-
d Kn K Show 9
ShowDialog.
94
4.2.1.4 / + ! ) -' %! (
„ .NET Framework n 9 K
. : PrintDocument PrinterSettings -
, ,
PrintDocument.DefaultPageSettings — -
( K, o 9 9 PrintPage
d ). K , n 9
. 5 o, 9 d -
9 . J , 9'n PrintDocument PrinterSettings o n 9'n -
, -
, DefaultPageSettings K -
. 6 , -
( 9 .
u o -
, Visual Studio .NET, o 9 n 9 d K d
—
PrintDialog PageSetupDialog.
PrintDialog
: PrintDialog n PrinterSettings 9'n PrintDocument . ” 9
PrintDialog , Windows Forms -
Toolbox . ” 9 9 PrintDialog
, ShowDialog : PrintDialog1.ShowDialog ();
: PrintDialog 9 ' 9'n
PrintDocument. A PrintDialog.Document
9'n PrintDocument, o n 9 .
' 9 ( PrintDialog ( . 4.2) 'n
K PrinterSettings 9'n PrintDocument, - K Document, K - d .
95
7 4.2 – : PrintDialog
PageSetupDialog
PageSetupDialog PrintDialog - 9. : PageSetupDialog ( . 4.3) n
d -. J ( 9 n K ,
, ( d .
u PrintDialog, PageSetupDialog n
Document, 9'n PrintDocument, o n 9-
. : d Document, ( '
9'n PrintDocument PageSetupDialog. ' 9- ,
9 d , 9 9 ( -
9'n PrintDocument.PrinterSettings DefaultPageSettings.
96
7 4.3 – : PageSetup Dialog
$%# ! ) PageSettings ! ' % ( !, )
„ 9 9
, d, - 9 n, d — (. -
n PrintPageEventArgs. PageSettings,
n . , 9
K n , K , d
97
K,
. 5 n -
, KK 9 n K :
//w9O •5IU:9;8 6J56J;MHI L6CDO PrintPage.
//X:D;;I 9 L59C78I@?Fr 6J'rH8 PrintPageEventArgs.
9.PageSettings.Landscape = true;
J PageSettings :
–, o K
PrintDocument. v n PrinterSettings, o -
n , DefaultPageSettings, o n
;
–K d
PrintDocument.Print. : n PrintPage,
9 9 o K ;
–9'n PrintPageEventArgs n -
, 9 -
. A K 9'n Graphics, o n
; 9'n Graphics n 9'n
PrintPageEventArgs;
–9 9
, o n 9 . A -
PrintPage
PrintEventArgs.HasMorePages true;
–PrintPreviewControl 9 n
K , a PrintPreviewDialog
n 9 d 9 ( PrintPreview
;
–PrintDialog PageSetupDialog K (-
d -
. ' 9 ( ( d
–
PrintPageEventArgs.PageSettings .
4.2.1.5 N , / ( ( !-% % , -' %!
7 d RichTextBox MenuStrip (9. 4.2).
98
6 9 4.2 – ' K
Name |
Text |
Shortcut |
mnuFile |
&2 |
|
Name |
Text |
Shortcut |
mnuOpen |
&: |
Ctrl+O |
mnuSave |
&9 |
Ctrl+S |
menuItem1 |
- |
|
mnuPageSetup |
'& |
|
mnuPrintPreview |
'& |
|
mnuPrint |
&A |
Ctrl+P |
' ToolBox : PrintDocument, PageSetupDialog, PrintPreviewDialog PrintDialog. '-
9 d , 9 ( K -
o Visual Studio. NET. ' n
9 , n 9'n PrintDocument. s-
PageSetupDialog, PrintPreviewDialog PrintDialog
K 9 K ,
. 5 d 9'n n -
d , d , o,
, , OpenFileDialog 9 SaveFileDialog, n K , :
//PrintDocument printDocument1 = new PrintDocument ();
//PageSetupDialog pageSetupDialog1 = new PageSetupDialog ();
//PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ();
//PrintDialog printDialog1 = new PrintDialog ();
v K K -
. , , 9 (. : Document PageSetupDialog
PrintPreviewDialog Kn Name
PrintDocument – printDocument1. 6 'n 9'n printDocument1, o n , -
. : Kn
PrintDialog (9. 4.3).
|
|
99 |
|
6 9 4.3 – : PrintDialog |
|||
|
|
|
|
printDialog1, |
|
|
. |
|
|
||
|
|
|
|
AllowSelection |
True |
|
A - |
|
|
|
|
AllowSomePages |
True |
|
A |
PrintDocument |
printDocu |
|
' 9'- |
|
ment1 |
|
n PrintDocument |
5 Properties 9 -
AllowSelection 9 AllowSomePages (
— Enables and disables the Selection/Pages radio button (: K n 9
K n ": / 8-
"). 8 9 o K n
— o , -
9'n o :
InitializeComponent ();
//PageSetupDialog1.Document = printDocument1;
//PrintPreviewDialog1.Document = printDocument1;
//PrintDialog1.Document = printDocument1;
//PrintDialog1.AllowSomePages = true;
//PrintDialog1.AllowSelection = true;
' . A 9 9 9
.NET Framework n System.Drawing.Printing,
9 K 9:
using System.Drawing.Printing;
d n :
//X:D;;I C?F BJ95DUI;;F 89H78K C?F C5KHK.
//z ;9G :M JKC9:6 56B:DjK@I8M 89H78 B RichTextBox string stringPrintText;
//X:D;;I, FHI @MB;IcIr ;6:95 7865D;HM, B FH6G L685DJ;6 L6cI8M C5KH int StartPage;
//X:D;;I, FHI @MB;IcIr HD?THD78T 7865D;6H C?F C5KHK:
int NumPages;
// X:D;;I, FHI @MB;IcIr ;6:95 L686c;6G 7865D;HM: int PageNumber;
8 stringPrintText — 9
9'n . .
, n, o (
K — n, RichTextBox n
( ( , K d -
100
Microsoft Word d ). : 9 9 d , o, , n
).
n :
public Form1 ()
{
InitializeComponent ();
...
// [MB;IcIr:6 ;6:95 7865D;HM, B FH6G 7?DC L6cI8M C5KH printDialog1.PrinterSettings.FromPage = 1;
// [MB;IcIr:6 :IH7M:I?T;MO ;6:95 C5KH6@I;6G 7865D;HM. printDialog1.PrinterSettings.ToPage = printDialog1.PrinterSettings.MaximumPage;
}
— 9999; , o 9- -. .K nK, 9 9 9 K-
, 9 PrintPage printDocument1. ' n ( , n ,
K d Properties , n
n :
private void printDocument1_PrintPage (object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
}
A 9 9- 9. J Graphics, o ( System.Drawing —
( d , o K K
. '
System.Drawing K n d 9. A -
Kn :
Graphics graph = e.Graphics;
// E8@65<r:6 6J'rH8 font, FH6:K @78I;6@?<r:6
//‹5M•8 9?9:9;8I rtbText Font font = rtbText.Font;
//f85M:Kr:6 B;Ic9;;F :D_5FCH6@6U6 D;895@I?K - @M768K e5M•8K float HeightFont = font.GetHeight (graph);
//E8@65<r:6 9HB9:L?F5 stringformat
//H?I7K StringFormat C?F @MB;Ic9;;F
// W6CI8H6@MS LI5I:985D@ •65:I8K@I;;F 89H78K. StringFormat stringformat = new StringFormat ();
8 n 9 K 9'n,
. A n RectangleF