Graphics.DrawString 방법

4349 단어 C#graphics
MSDN의 설명:
지정된 위치에서 지정된 Brush 및 Font 객체로 지정된 텍스트 문자열을 그립니다.
public void DrawString(
	string s,
	Font font,
	Brush brush,
	float x,
	float y
)

MSDN의 인스턴스:
public void DrawStringFloat(PaintEventArgs e)
{
//Create string to draw
. String drawString = "Sample Text";//Create font and brush.
Font drawFont = new Font("Arial", 16);
 SolidBrush drawBrush = new SolidBrush(Color.Black);//Create point for upper-left corner of drawing.
 float x = 150.0F; float y = 150.0F;//Draw string to screen.
e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);
}
적용된 인스턴스:
          private void Myprintpage1(Graphics formGraphics, int w, int h)         {
            Pen myPen = new Pen(Color.FromArgb(255, Color.Black), 1.0F); Font My Font1 = new Font("송체", 12,Font Style.Bold);Font My Font2 = new Font("송체", 10,Font Style.Bold);
            formGraphics.TranslateTransform(100.0F, 50.0F);//표 가로줄 그리기
//표 세로줄 그리기
            for (int i = 200; i < 360; i += 50)             {                 formGraphics.DrawLine(myPen, new Point(0, i), new Point(600, i));                 formGraphics.DrawLine(myPen,)             }
            for (int i = 0; i < 750; i += 150)             {                 formGraphics.DrawLine(myPen, new Point(i, 200), new Point(i, 350));             }
//표 사선 그리기 formGraphics.DrawLine(myPen, new Point(0, 200), new Point(150, 250));            //formGraphics.DrawLine(myPen, new Point(150, 125), new Point(300, 125));            //formGraphics.DrawLine(myPen, new Point(150, 175), new Point(300, 175));//글씨 formGraphics.DrawString("---데이터 보고서 ---", new Font("송체", 20,FontStyle.Bold), Brushes.DimGray, 100, -10);
            formGraphics.DrawString(시험 날짜(Date):,MyFont1, Brushes.DimGray, 0, 50);             formGraphics.DrawString(Operator):MyFont1, Brushes.DimGray, 0, 75);
            formGraphics.DrawString(Parts Type):MyFont1, Brushes.DimGray, 330, 50);             formGraphics.DrawString(Parts No):MyFont1, Brushes.DimGray, 330, 75);
            formGraphics.DrawString(UP):MyFont1, Brushes.DimGray, 0, 100);             formGraphics.DrawString(아래 번호(DOWN):MyFont1, Brushes.DimGray, 330, 100);
                       formGraphics.DrawString("전압", MyFont1, Brushes. DimGray, 190, 220);
           //formGraphics.DrawString("  (Forward Speed)", MyFont2, Brushes.DimGray, 300, 110);             formGraphics.DrawString("전류", MyFont1, Brushes. DimGray, 340, 220);
           //formGraphics.DrawString("  (Backward Speed)", MyFont2, Brushes.DimGray, 455, 110);             formGraphics.DrawString("대용", MyFont1, Brushes. DimGray, 490, 220);
            formGraphics.DrawString(Date), MyFont1, Brushes.DimGray, 0, 270);             formGraphics.DrawString(Unit), MyFont1, Brushes.DimGray, 0, 320);
            formGraphics.DrawString(운영자(Operator): 검사자(Checker):MyFont1, Brushes.DimGray, 0, 970);
            formGraphics.DrawString(DateTime.Now.ToString("yyyy/MM/dd"), MyFont1, Brushes.DimGray, 180, 50);             formGraphics.DrawString(global.temstr[0], MyFont1, Brushes.DimGray, 180, 75);             formGraphics.DrawString(global.temstr[2], MyFont1, Brushes.DimGray, 510, 50);             formGraphics.DrawString(global.temstr[1], MyFont1, Brushes.DimGray, 510, 75);
            formGraphics.DrawString(global.temstr[3], MyFont1, Brushes.DimGray, 180, 100);             formGraphics.DrawString(global.temstr[4], MyFont1, Brushes.DimGray, 500, 100);
            formGraphics.DrawString("", MyFont1, Brushes.DimGray, 190, 270);//            formGraphics.DrawString("", MyFont1, Brushes.DimGray, 340, 270);//            formGraphics.DrawString("", MyFont1, Brushes.DimGray, 490, 270);
 
            formGraphics.DrawString("V", MyFont1, Brushes.DimGray, 190, 320);
            formGraphics.DrawString("A", MyFont1, Brushes.DimGray, 340, 320);
            formGraphics.DrawString("", MyFont1, Brushes.DimGray, 490, 320);
 }

좋은 웹페이지 즐겨찾기