📄 reportsettings.cs
字号:
}
} catch (Exception e) {
MessageBox.Show (e.Message,"ReportSettings SqlParamsToXml");
}
}
private void SortColumnsToXml(XmlElement xmlSection) {
try {
foreach (AbstractColumn column in this.sortingCollection) {
Type type = column.GetType();
PropertyInfo [] prop = type.GetProperties();
XmlElement ctrl = xmlSection.OwnerDocument.CreateElement ("sorting");
SaveCollectionItems(ctrl,column,prop);
xmlSection.AppendChild(ctrl);
}
} catch (Exception) {
throw;
}
}
private void GroupColumnsToXml (XmlElement xmlSection) {
try {
foreach (AbstractColumn column in this.groupingsCollection) {
Type type = column.GetType();
PropertyInfo [] prop = type.GetProperties();
XmlElement ctrl = xmlSection.OwnerDocument.CreateElement ("grouping");
SaveCollectionItems(ctrl,column,prop);
xmlSection.AppendChild(ctrl);
}
} catch (Exception) {
throw;
}
}
public XmlDocument GetXmlData(){
XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0",null, "yes");
doc.PrependChild ( dec );
XmlElement root = doc.CreateElement ("Sections");
doc.AppendChild(root);
XmlElement section = doc.CreateElement ("section");
if (this.sortingCollection.Count > 0) {
XmlElement xmlSortColumns = doc.CreateElement (GlobalEnums.enmParamCollectionName.Sortings.ToString());
SortColumnsToXml (xmlSortColumns);
section.AppendChild(xmlSortColumns);
}
if (this.groupingsCollection.Count > 0){
XmlElement xmlGroupColumns = doc.CreateElement (GlobalEnums.enmParamCollectionName.Groupings.ToString());
GroupColumnsToXml(xmlGroupColumns);
section.AppendChild(xmlGroupColumns);
}
if (reportParametersCollection.Count > 0) {
XmlElement xmlSqlParams = doc.CreateElement (GlobalEnums.enmParamCollectionName.SqlParams.ToString());
SqlParamsToXml(xmlSqlParams);
section.AppendChild(xmlSqlParams);
}
SectionItemToXml (section);
root.AppendChild(section);
doc.AppendChild(root);
return doc;
}
#endregion
#region SharpReport.DelegatesInterfaces.IRender interface implementation
public void Render(ReportPageEventArgs rpea) {
/*
Font headFont = new Font("Courier New", 20,FontStyle.Bold);
Font printFont = this.DefaultFont;
Brush blackBrush = new SolidBrush(Color.Black);
float i = startAt;
rpea.PrintPageEventArgs.Graphics.DrawString(this.ToString(),
headFont,
blackBrush,
this.DefaultMargins.Left,i);
i += headFont.GetHeight() + 4F;
SizeF size;
Rectangle rect;
Type type = this.GetType();
PropertyInfo [] prop = type.GetProperties();
foreach (PropertyInfo p in prop) {
try {
string s = Convert.ToString(p.GetValue(this,null));
PointF point = new PointF (rpea.PrintPageEventArgs.MarginBounds.Left,i);
rpea.PrintPageEventArgs.Graphics.DrawString(p.Name + " :",
printFont,
Brushes.Black,
point);
size = rpea.PrintPageEventArgs.Graphics.MeasureString (s,
printFont,
rpea.PrintPageEventArgs.PageSettings.PaperSize.Width /2);
if (s.Length != 0) {
rect = new Rectangle(rpea.PrintPageEventArgs.PageSettings.PaperSize.Width /2,
(int)i,
(int)size.Width,
(int)size.Height);
rpea.PrintPageEventArgs.Graphics.DrawString(s,printFont,Brushes.Black,rect);
i += size.Height + 10;
} else {
i += printFont.GetHeight();
}
rpea.LocationAfterDraw = new PointF(rpea.PrintPageEventArgs.PageSettings.PaperSize.Width /2 + size.Width,i);
} catch (Exception e) {
MessageBox.Show (e.ToString() + " / " + e.Message );
}
}
this.areaHeight = i;
headFont.Dispose();
printFont.Dispose();
blackBrush.Dispose();
return;
*/
}
public float DrawAreaHeight (ReportPageEventArgs rpea){
return 0;
}
#endregion
[Browsable(true), Category("Base Settings")]
public GlobalEnums.enmReportType ReportType {
get {
return reportType;
}
set {
if (reportType != value) {
reportType = value;
this.FirePropertyChanged();
}
}
}
/*
///<summary>
/// printout ReportSettings at ReportHeaderPage
/// </summary>
[Browsable(true), Category("Base Settings")]
[DefaultValueAttribute (false)]
public bool IncludeSettings {
get {
return includeSettings;
}
set {
if (includeSettings != value) {
includeSettings = value;
this.FirePropertyChanged();
}
}
}
*/
#region Sorting,grouping and reportparameters
/// <summary>
/// Get/Set a Collection of <see cref="SortColumn">SortColumn</see>
/// </summary>
[Browsable(false)]
[XmlIgnoreAttribute]
public ColumnCollection SortColumnCollection {
get {
return sortingCollection;
}
set {
sortingCollection = value;
}
}
[Browsable(false)]
[XmlIgnoreAttribute]
public ColumnCollection GroupColumnsCollection {
get {
if (this.groupingsCollection == null) {
groupingsCollection = new ColumnCollection();
}
return groupingsCollection;
}
set {
if (this.groupingsCollection == null) {
groupingsCollection = new ColumnCollection();
}
if (groupingsCollection != value) {
groupingsCollection = value;
this.FirePropertyChanged();
}
}
}
[Browsable(false)]
[XmlIgnoreAttribute]
public AbstractParametersCollection SqlParametersCollection
{
get{
if (reportParametersCollection == null) {
reportParametersCollection = new AbstractParametersCollection();
}
return reportParametersCollection;
}
set {
if (reportParametersCollection == null) {
reportParametersCollection = new AbstractParametersCollection();
}
if (reportParametersCollection != value) {
reportParametersCollection = value;
this.FirePropertyChanged();
}
}
}
#endregion
#region DataRelated
[Category("Data")]
[DefaultValueAttribute ("")]
public string ConnectionString {
get {
return connectionString;
}
set {
if (connectionString != value) {
connectionString = value;
this.FirePropertyChanged();
}
}
}
[Category("Data")]
[DefaultValueAttribute ("")]
public string CommandText {
get {
return commandText;
}
set {
if (commandText != value) {
commandText = value;
this.FirePropertyChanged();
}
}
}
[Category("Data")]
public System.Data.CommandType CommandType {
get {
return commandType;
}
set {
if (commandType != value) {
commandType = value;
this.FirePropertyChanged();
}
}
}
[Category("Data")]
public GlobalEnums.enmPushPullModel DataModel {
get {
return dataModel;
}
set {
if (dataModel != value) {
dataModel = value;
this.FirePropertyChanged();
}
}
}
#endregion
#region OutPut Settings
[Category("Output Settings")]
public Font DefaultFont {
get {
return defaultFont;
}
set {
if (defaultFont != value) {
defaultFont = value;
this.FirePropertyChanged();
}
}
}
/*
[Browsable(true), Category("Output Settings")]
public System.Drawing.Printing.Margins DefaultMargins {
get {
return defaultMargins;
}
set {
if (defaultMargins != value) {
defaultMargins = value;
PageSettings.Margins = defaultMargins;
this.FirePropertyChanged();
}
}
}
*/
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -