12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Printing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace UAS_MES_NEW.SystemSetting
- {
- public partial class SystemSetting_PrinterTest : Form
- {
- public SystemSetting_PrinterTest()
- {
- InitializeComponent();
- }
- private void PrintTest_Click(object sender, EventArgs e)
- {
- PrintDocument print = new PrintDocument();
- print.PrinterSettings.PrinterName = PrinterList.Text;
- print.PrintPage += Print_PrintPage;
- print.Print();
- }
- private void Print_PrintPage(object sender, PrintPageEventArgs e)
- {
- Graphics g = e.Graphics;
- float leftMargin = 10f; //左边距
- SolidBrush myBrush = new SolidBrush(Color.Black);//刷子
- float yPosition = 5f;//行定位
- Font printFont = new Font("微软雅黑", 20f, FontStyle.Bold);//设置字体
- yPosition += printFont.GetHeight(g);//另起一行
- g.DrawString("成功连接此打印机", printFont, myBrush, leftMargin, yPosition, new StringFormat());
- }
- private void Setting_Click(object sender, EventArgs e)
- {
- PrintDialog printd = new PrintDialog();
- printd.PrinterSettings.PrinterName = PrinterList.Text;
- printd.ShowDialog();
- }
- }
- }
|