日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Graphics.DrawString 方法

發布時間:2023/12/15 综合教程 31 生活家
生活随笔 收集整理的這篇文章主要介紹了 Graphics.DrawString 方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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 MyFont1 = new Font("宋體", 12, FontStyle.Bold);
Font MyFont2 = new Font("宋體", 10, FontStyle.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);

}

總結

以上是生活随笔為你收集整理的Graphics.DrawString 方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。