120 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Drawing;
 | |
| 
 | |
| namespace GoldPrinter
 | |
| {
 | |
| 	public class MultiHeader : Header
 | |
| 	{
 | |
| 		private const int CONST_MAX_ROWS = 3;
 | |
| 
 | |
| 		private bool _isDrawDiagonalLine;
 | |
| 
 | |
| 		private float _DiagonalLineRows;
 | |
| 
 | |
| 		public bool IsDrawDiagonalLine
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				return this._isDrawDiagonalLine;
 | |
| 			}
 | |
| 			set
 | |
| 			{
 | |
| 				this._isDrawDiagonalLine = value;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		public float DiagonalLineRows
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				return this._DiagonalLineRows;
 | |
| 			}
 | |
| 			set
 | |
| 			{
 | |
| 				this._DiagonalLineRows = value;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		public string ColsAlign
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				return this.mdrawGrid.ColsAlignString;
 | |
| 			}
 | |
| 			set
 | |
| 			{
 | |
| 				this.mdrawGrid.ColsAlignString = value;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		public MultiHeader()
 | |
| 		{
 | |
| 			this.IsDrawAllPage = true;
 | |
| 			this.mdrawGrid.AlignMent = AlignFlag.Center;
 | |
| 			this.mdrawGrid.Border = GridBorderFlag.Single;
 | |
| 			this.mdrawGrid.Line = GridLineFlag.Both;
 | |
| 			base.IsAverageColsWidth = false;
 | |
| 			this._isDrawDiagonalLine = false;
 | |
| 			this._DiagonalLineRows = 2f;
 | |
| 			this.mdrawGrid.Merge = GridMergeFlag.Any;
 | |
| 			this.Font = new Font("宋体", 12f, FontStyle.Bold);
 | |
| 			this.mdrawGrid.PreferredRowHeight = this.Font.Height + 10;
 | |
| 		}
 | |
| 
 | |
| 		protected override int SetMaxRows()
 | |
| 		{
 | |
| 			return 3;
 | |
| 		}
 | |
| 
 | |
| 		public void SetMergeTextOnRowSel(int row, int startCol, int endCol, string text)
 | |
| 		{
 | |
| 			this.mdrawGrid.SetTextOnRowSel(row, startCol, endCol, text);
 | |
| 		}
 | |
| 
 | |
| 		public void SetMergeTextOnColSel(int col, int startRow, int endRow, string text)
 | |
| 		{
 | |
| 			this.mdrawGrid.SetTextOnColSel(col, startRow, endRow, text);
 | |
| 		}
 | |
| 
 | |
| 		public MultiHeader(int rows, int cols) : this()
 | |
| 		{
 | |
| 			base.Initialize(rows, cols);
 | |
| 			string text = "";
 | |
| 			for (int i = 0; i < cols; i++)
 | |
| 			{
 | |
| 				text += "C";
 | |
| 			}
 | |
| 			this.mdrawGrid.ColsAlignString = text;
 | |
| 		}
 | |
| 
 | |
| 		protected void DrawDiagonalLine(float rows)
 | |
| 		{
 | |
| 			try
 | |
| 			{
 | |
| 				int x = this.mdrawGrid.Rectangle.X;
 | |
| 				int y = this.mdrawGrid.Rectangle.Y;
 | |
| 				int x2 = x + this.mdrawGrid.ColsWidth[0];
 | |
| 				int y2 = y + (int)((float)this.mdrawGrid.PreferredRowHeight * this._DiagonalLineRows);
 | |
| 				base.Graphics.SetClip(new Rectangle(x, y, this.mdrawGrid.ColsWidth[0], this.mdrawGrid.PreferredRowHeight * this.mdrawGrid.Rows));
 | |
| 				base.Graphics.DrawLine(Pens.Black, x, y, x2, y2);
 | |
| 			}
 | |
| 			catch (Exception  )
 | |
| 			{
 | |
| 			}
 | |
| 			finally
 | |
| 			{
 | |
| 				base.Graphics.ResetClip();
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		public override void Draw()
 | |
| 		{
 | |
| 			base.Draw();
 | |
| 			if (this._isDrawDiagonalLine)
 | |
| 			{
 | |
| 				this.DrawDiagonalLine(this._DiagonalLineRows);
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |