, Visual C#



 

8.1. .

private void Form1_Paint(object sender, PaintEventArgs e)

{

// myString :

string myString = "Visual Studio";

// myFont :

Font myFont = new Font("Arial", 30);

// myBrush :

SolidBrush myBrush = new SolidBrush(Color.Black);

// :

float x = 5.0f;

float y = 50.0f;

// myBrush:

e.Graphics.DrawString(myString, myFont, myBrush, x, y);

// , :

myFont.Dispose();

myBrush.Dispose();

}

8.2. .

// myFormat :

StringFormat myFormat = new StringFormat(

StringFormatFlags.DirectionVertical);

// myBrush:

e.Graphics.DrawString(myString, myFont, myBrush,

x, y, myFormat);

8.3. .

System.IO.StreamReader myPrintFile;

Font myPrintFont;

private void button1_Click(object sender, EventArgs e)

{

string myPrintPath = Environment.GetFolderPath(

Environment.SpecialFolder.Desktop);

myPrintFile =

new System.IO.StreamReader(myPrintPath +

@"\myText.txt");

myPrintFont = new Font("Times New Roman", 12);

printDocument1.Print();

myPrintFile.Close();

}

PrintDocument ( ). Form1.cs , .

8.4. .

private void printDocument1_PrintPage(object sender,

System.Drawing.Printing.PrintPageEventArgs e)

{

float yPos = 0f;