172 lines
3.2 KiB
C#
172 lines
3.2 KiB
C#
using System;
|
||
using System.Drawing;
|
||
|
||
namespace GoldPrinter
|
||
{
|
||
public class Outer : Printer, IDisposable
|
||
{
|
||
private bool _IsAverageColsWidth;
|
||
|
||
protected DrawGrid mdrawGrid;
|
||
|
||
protected bool mblnHadInitialized;
|
||
|
||
public bool IsAverageColsWidth
|
||
{
|
||
get
|
||
{
|
||
return this._IsAverageColsWidth;
|
||
}
|
||
set
|
||
{
|
||
this._IsAverageColsWidth = value;
|
||
}
|
||
}
|
||
|
||
public object DataSource
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.DataSource;
|
||
}
|
||
set
|
||
{
|
||
this.mdrawGrid.DataSource = value;
|
||
if (this.DataSource.GetType().ToString() == "System.String[]" || this.DataSource.GetType().ToString() == "System.String[,]" || this.DataSource.GetType().ToString() == "System.Data.DataTable")
|
||
{
|
||
this.mblnHadInitialized = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
public string[,] Text
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.GridText;
|
||
}
|
||
set
|
||
{
|
||
this.mdrawGrid.GridText = value;
|
||
this.mblnHadInitialized = true;
|
||
}
|
||
}
|
||
|
||
public bool CanDraw
|
||
{
|
||
get
|
||
{
|
||
return this.mblnHadInitialized;
|
||
}
|
||
}
|
||
|
||
public int RowHeight
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.PreferredRowHeight;
|
||
}
|
||
set
|
||
{
|
||
this.mdrawGrid.PreferredRowHeight = value;
|
||
}
|
||
}
|
||
|
||
public int Rows
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.Rows;
|
||
}
|
||
}
|
||
|
||
public int Cols
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.Cols;
|
||
}
|
||
}
|
||
|
||
public int[] ColsWidth
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.ColsWidth;
|
||
}
|
||
set
|
||
{
|
||
this.mdrawGrid.ColsWidth = value;
|
||
}
|
||
}
|
||
|
||
public override int Height
|
||
{
|
||
get
|
||
{
|
||
return this.mdrawGrid.Rows * this.mdrawGrid.PreferredRowHeight;
|
||
}
|
||
}
|
||
|
||
public Outer()
|
||
{
|
||
this._IsAverageColsWidth = true;
|
||
this.mblnHadInitialized = false;
|
||
this.IsDrawAllPage = false;
|
||
this.mdrawGrid = new DrawGrid();
|
||
this.mdrawGrid.AlignMent = AlignFlag.Left;
|
||
this.mdrawGrid.ColsAlignString = "";
|
||
this.mdrawGrid.Border = GridBorderFlag.None;
|
||
this.mdrawGrid.Line = GridLineFlag.None;
|
||
this.mdrawGrid.Merge = GridMergeFlag.None;
|
||
this.Font = new Font("宋体", 11f);
|
||
this.mdrawGrid.PreferredRowHeight = this.Font.Height;
|
||
this.mdrawGrid.Initialize(0, 0);
|
||
}
|
||
|
||
public virtual void Initialize(int rows, int cols)
|
||
{
|
||
this.mblnHadInitialized = true;
|
||
this.mdrawGrid.Initialize(rows, cols);
|
||
}
|
||
|
||
public virtual void SetText(int row, int col, string text)
|
||
{
|
||
this.mdrawGrid.SetText(row, col, text);
|
||
}
|
||
|
||
public virtual void SetText(char rowSplit, char colSplit, string text)
|
||
{
|
||
this.mdrawGrid.SetText((int)rowSplit, (int)colSplit, text);
|
||
}
|
||
|
||
public virtual string GetText(int row, int col)
|
||
{
|
||
return this.mdrawGrid.GetText(row, col);
|
||
}
|
||
|
||
public override void Draw()
|
||
{
|
||
if (this.mblnHadInitialized)
|
||
{
|
||
base.Draw();
|
||
this.mdrawGrid.Rectangle = new Rectangle(base.Rectangle.X + base.MoveX, base.Rectangle.Y + base.MoveY, base.Rectangle.Width, base.Rectangle.Height);
|
||
this.mdrawGrid.Graphics = base.Graphics;
|
||
if (this._IsAverageColsWidth)
|
||
{
|
||
this.mdrawGrid.Width = this.mdrawGrid.Rectangle.Width;
|
||
this.mdrawGrid.ColsWidth = this.mdrawGrid.GetAverageColsWidth();
|
||
}
|
||
this.mdrawGrid.Draw();
|
||
return;
|
||
}
|
||
throw new Exception("对象的行列数还未初始,请用Initialize()进行操作!");
|
||
}
|
||
|
||
public override void Dispose()
|
||
{
|
||
this.mdrawGrid.Dispose();
|
||
}
|
||
}
|
||
}
|