⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 previewdialog.cs

📁 为湖北省教委、湖北省就业指导中心订做的学历查询系统
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication3
{
	/// <summary>
	/// PreviewDialog 的摘要说明。
	/// </summary>
	public class PreviewDialog : System.Windows.Forms.Form
	{
		private float fontSize = 12;

		private System.Windows.Forms.PrintPreviewControl printPreviewControl1;
		private System.Drawing.Printing.PrintDocument printDocument1;
		private System.Windows.Forms.ComboBox comboBox1;
		private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.PictureBox pictureBox2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public PreviewDialog()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PreviewDialog));
			this.printPreviewControl1 = new System.Windows.Forms.PrintPreviewControl();
			this.printDocument1 = new System.Drawing.Printing.PrintDocument();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.pictureBox2 = new System.Windows.Forms.PictureBox();
			this.SuspendLayout();
			// 
			// printPreviewControl1
			// 
			this.printPreviewControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.printPreviewControl1.AutoZoom = false;
			this.printPreviewControl1.Document = this.printDocument1;
			this.printPreviewControl1.Location = new System.Drawing.Point(8, 8);
			this.printPreviewControl1.Name = "printPreviewControl1";
			this.printPreviewControl1.Size = new System.Drawing.Size(658, 488);
			this.printPreviewControl1.TabIndex = 0;
			this.printPreviewControl1.Zoom = 0.75;
			// 
			// printDocument1
			// 
			this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
			// 
			// comboBox1
			// 
			this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.comboBox1.Items.AddRange(new object[] {
														   "200%",
														   "150%",
														   "100%",
														   "75%",
														   "50%",
														   "30%",
														   "25%"});
			this.comboBox1.Location = new System.Drawing.Point(64, 512);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(88, 20);
			this.comboBox1.TabIndex = 2;
			this.comboBox1.Text = "预览比例";
			this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
			// 
			// pageSetupDialog1
			// 
			this.pageSetupDialog1.Document = this.printDocument1;
			// 
			// pictureBox1
			// 
			this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(288, 512);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(56, 24);
			this.pictureBox1.TabIndex = 5;
			this.pictureBox1.TabStop = false;
			this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
			this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter);
			this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
			// 
			// pictureBox2
			// 
			this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
			this.pictureBox2.Location = new System.Drawing.Point(184, 512);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(72, 24);
			this.pictureBox2.TabIndex = 6;
			this.pictureBox2.TabStop = false;
			this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
			this.pictureBox2.MouseEnter += new System.EventHandler(this.pictureBox2_MouseEnter);
			this.pictureBox2.MouseLeave += new System.EventHandler(this.pictureBox2_MouseLeave);
			// 
			// PreviewDialog
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.ClientSize = new System.Drawing.Size(672, 558);
			this.Controls.Add(this.pictureBox2);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.printPreviewControl1);
			this.Name = "PreviewDialog";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "打印预览";
			//this.Load += new System.EventHandler(this.PreviewDialog_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			if(InputPrint.reportKind == "yes")
			{
				int textStartY = e.PageBounds.Height / 4;	//打印文本的垂直位置
				int textStartX = 20;	//打印文本的横向位置/////////////////////////////////
                int notifyInfoTextY = e.PageBounds.Height /5;


				int textFirstStartX = 1;//第一行左上角X 左上角坐标偏移量/////////////////
				int textFirstStartY = e.PageBounds.Height/9;
				int noticeStartX = e.PageBounds.Width/5;
				int noticeStartY = e.PageBounds.Height/3;
			
				//设置文本各部分的字体
				Font firstLineFont = new Font("宋体",fontSize+9,System.Drawing.FontStyle.Bold);////////////////////////

				Font notifyFont = new Font("宋体", fontSize+4);	
				Font notifyMsgFont = new Font("宋体", fontSize +4);
				Font notifyResultFont = new Font("隶书", fontSize + 3);
				Font noticeFont = new Font("宋体",fontSize +3,System.Drawing.FontStyle.Bold);
				Font noticeTextFont = new Font("宋体",12);
			
			
			
				//设置文本的内容
			
	
				string notifyInfoText = "           " + InputPrint.reportNum ;
				string notifyInfoText2 = "           " +  InputPrint.reportData;
				
			
				string notifyText ="  "+ "姓名:" + InputData.trans.name  + ",性别:"+InputData.trans.sex + ",生于"+ InputData.trans.birthYear+ "年" +InputData.trans.birthMonth + "月" + InputData.trans.birthDay +"日,"+InputData.trans.schYear+" 年就读";
					

			 
				string notifyText2 = "于" + InputData.trans.schName +","+ InputData.trans.schCourse +"专业,学制"+ InputData.trans.termYear+"年," ;
                string notifyText3 ="于"+InputData.trans.graYear +"年获得"+ InputData.trans.degreeKind + InputData.trans.degree +"毕业证";
				string notifyText4 = "书,证书编号:"+ InputData.trans.degreeNum + "。" + "(报告编号:" + InputPrint.reportNum + ")";
			
			
				//获取文本所占区域的大小
			

				SizeF notifyInfoSize = e.Graphics.MeasureString(notifyInfoText, notifyFont);
                SizeF notifyInfoText2Size = e.Graphics.MeasureString(notifyInfoText2, notifyFont);////////

				SizeF notifyMsgSize = e.Graphics.MeasureString(notifyText, notifyMsgFont, e.MarginBounds.Width);			     
			
				//设置文本绘制的区域
				
			 
                
				RectangleF notifyInfoTextRect  = new RectangleF(e.MarginBounds.X + textStartX, notifyInfoTextY + notifyInfoText2Size.Height +72  + 40-5, e.MarginBounds.Width, 400);//---
				RectangleF notifyInfoText2Rect = new RectangleF(e.MarginBounds.X + textStartX, notifyInfoTextY + notifyInfoText2Size.Height +114 + 40-5, e.MarginBounds.Width, 400);//---
				
		    	RectangleF msgRect = new RectangleF(e.MarginBounds.X + textStartX, textStartY + notifyInfoSize.Height +108+87, e.MarginBounds.Width, 400);
				RectangleF msgRect2 = new RectangleF(e.MarginBounds.X + textStartX, textStartY + notifyInfoSize.Height +108+87+44, e.MarginBounds.Width, 400);
				RectangleF msgRect3 = new RectangleF(e.MarginBounds.X + textStartX, textStartY + notifyInfoSize.Height +108+87+44+44, e.MarginBounds.Width, 400);
				RectangleF msgRect4 = new RectangleF(e.MarginBounds.X + textStartX, textStartY + notifyInfoSize.Height +108+87+44+44+44, e.MarginBounds.Width, 400);
				
				RectangleF ResultRect = new RectangleF(e.MarginBounds.X + textStartX, textStartY + notifyMsgSize.Height + notifyInfoSize.Height + 20, e.MarginBounds.Width, 100);







				//设置文本的字体颜色
				SolidBrush textColor = new SolidBrush(Color.Black);
			
				//绘制文本
			
			
				e.Graphics.DrawString(notifyInfoText, notifyFont, textColor, notifyInfoTextRect);//---
				e.Graphics.DrawString(notifyInfoText2, notifyFont, textColor, notifyInfoText2Rect);//---
				

				
				e.Graphics.DrawString(notifyText, notifyMsgFont, textColor, msgRect);
				
				e.Graphics.DrawString(notifyText2, notifyMsgFont, textColor, msgRect2);
				e.Graphics.DrawString(notifyText3, notifyMsgFont, textColor, msgRect3);
				e.Graphics.DrawString(notifyText4, notifyMsgFont, textColor, msgRect4);

				

			}
	
			
		
			
		///////////////////////////////////////////////////////////////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////////////
		///////////////////////////////////////////////////////////////////////////////////////////////////////////
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////	
			
			
			
			if(InputPrint.reportKind == "no")//选择打印无此人的情况
			{
				if((InputData.trans.degreeKind.Length == 8)||(InputData.trans.degree.Length == 9))
				{
					int textStartY = e.PageBounds.Height / 4;	//打印文本的垂直位置
					int textStartX = 20;	//打印文本的横向位置/////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -