private float PrintChild(Panel _panel, float _intX, float _intY, int _fullwidth, System.Drawing.Printing.PrintPageEventArgs e) { float _ret, _result = 0; float intX = _intX; float intY = _intY; for (int i = _panel.Controls.Count; i > 0; i--) { _ret = _lineHeight; object _uc = _panel.Controls[i - 1]; if (_uc.GetType() == typeof(SinoSZUC_RecordData)) { //标题栏 SinoSZUC_RecordData _mc = (SinoSZUC_RecordData)_uc; if (++_currentNum > _finishNum) { _ret = _mc.Print(intX, intY, e, _lineHeight, _fullwidth, _lineFont); intY += _ret; _result += _ret; } } if (intY > (e.MarginBounds.Top + e.MarginBounds.Height)) { e.HasMorePages = true; _finishNum = _currentNum; return(_result); } } return(_result); }
private void PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { float _ret; float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; int fullWidth = e.MarginBounds.Width; float intX = leftMargin; float intY = topMargin; _currentNum = 0; for (int i = _panel.Controls.Count; i > 0; i--) { SinoSZUC_RecordData _currentRecordData = null; _ret = _lineHeight; object _uc = _panel.Controls[i - 1]; if (_uc.GetType() == typeof(SinoSZUC_RecordData)) { //标题栏 _currentRecordData = (SinoSZUC_RecordData)_uc; if (++_currentNum > _finishNum) { _ret = _currentRecordData.Print(intX, intY, e, _lineHeight, fullWidth, _lineFont); intY += _ret; } } if (_uc.GetType() == typeof(Panel)) { Panel _pc = (Panel)_uc; if (_pc.Visible) { _ret = PrintChild(_pc, intX, intY, fullWidth, e); intY += _ret; } } if (intY > (e.MarginBounds.Top + e.MarginBounds.Height)) { e.HasMorePages = true; _finishNum = _currentNum; intY = topMargin; return; } } _finishNum = 0; }
private string ExportChild(Panel _panel) { StringBuilder _sb = new StringBuilder(); for (int i = _panel.Controls.Count; i > 0; i--) { object _uc = _panel.Controls[i - 1]; if (_uc.GetType() == typeof(SinoSZUC_RecordData)) { //标题栏 SinoSZUC_RecordData _mc = (SinoSZUC_RecordData)_uc; _sb.Append(_mc.ExportHtml()); } } return(_sb.ToString()); }
public bool Export(string _fname) { ExportFileName = _fname; StringBuilder _sb = new StringBuilder(); _sb.Append("<table border=1>"); for (int i = _panel.Controls.Count; i > 0; i--) { SinoSZUC_RecordData _currentRecordData = null; object _uc = _panel.Controls[i - 1]; if (_uc.GetType() == typeof(SinoSZUC_RecordData)) { //标题栏 _currentRecordData = (SinoSZUC_RecordData)_uc; _sb.Append(_currentRecordData.ExportHtml()); } if (_uc.GetType() == typeof(Panel)) { Panel _pc = (Panel)_uc; if (_pc.Visible) { _sb.Append(ExportChild(_pc)); } } } _sb.Append("</table>"); System.Text.Encoding _encode = System.Text.Encoding.Default; StreamWriter sw = new StreamWriter(ExportFileName, false, _encode); sw.Write(_sb.ToString()); sw.Close(); return(true); }