📄 styledtable.cs
字号:
{
for (int j=0;j<colNumber;j++)
{
if (Data.Columns.Contains( Columns[j].Name) )
{
tmpData[i+1][j] = Data.Rows[i][j].ToString();
}
else
{
tmpData[i+1][j] = "";
}
}
}
return tmpData;
}
else
{
int colNumber = Columns.Length;
string[][] tmpData = new string[1][];
tmpData[0] = new string[colNumber];
for (int j=0;j<colNumber;j++)
{
tmpData[0][j] = Columns[j].Name;
}
return tmpData;
}
}
set
{
DataTable dataTable = new DataTable();
for (int i=0;i<this.Columns.Length;i++)
{
dataTable.Columns.Add(new DataColumn(this.Columns[i].Name));
}
for (int i=0;i<value.Length;i++)
{
string[] theRow = new string[this.Columns.Length];
for (int j=0;j<value[i].Length;j++)
{
theRow[j] = value[i][j];
}
dataTable.Rows.Add(theRow);
}
this.Data = dataTable;
}
}
#endregion
#region Public Overrides
/// <summary>
/// This function adds the current objects information to the XmlTextWriter
/// </summary>
/// <param name="CurrentWriter">Current XmlTextWriter to append object information to</param>
public override void AddXMLToWriter(ref System.Xml.XmlTextWriter CurrentWriter)
{
CurrentWriter.WriteStartElement("table");
CurrentWriter.WriteAttributeString("x", this.X.ToString());
CurrentWriter.WriteAttributeString("y", this.Y.ToString());
CurrentWriter.WriteAttributeString("width", this.Width.ToString());
CurrentWriter.WriteAttributeString("height", this.Height.ToString());
CurrentWriter.WriteAttributeString("borderColor", this.mBorderColor.Name);
CurrentWriter.WriteAttributeString("drawEmptyRows", this.mDrawEmptyRows.ToString());
CurrentWriter.WriteAttributeString("cellHeight", this.mCellHeight.ToString());
CurrentWriter.WriteAttributeString("dataSource", this.mDataSource);
CurrentWriter.WriteAttributeString("horAlignment", this.horizontalAlignment.ToString());
CurrentWriter.WriteAttributeString("verAlignment", this.verticalAlignment.ToString());
CurrentWriter.WriteAttributeString("selectable", this.mSelectable.ToString());
CurrentWriter.WriteAttributeString("groupByField", Helpers.TextSafeForXML(this.mGroupByField));
CurrentWriter.WriteAttributeString("blankLineBeforeNewGroup", mBlankLineBeforeNewGroup.ToString());
CurrentWriter.WriteAttributeString("lineUnderNewGroup", this.mLineUnderNewGroup.ToString());
CurrentWriter.WriteAttributeString("displayGroupTitle", this.mDisplayGroupTitle.ToString());
CurrentWriter.WriteAttributeString("displayGridLines", this.mDisplayGridLines.ToString());
CurrentWriter.WriteAttributeString("ObjectRepeatability", this.objectRepeatability.ToString());
CurrentWriter.WriteStartElement("header");
CurrentWriter.WriteAttributeString("headerColor", this.mHeaderBackgroundColor.Name);
CurrentWriter.WriteAttributeString("headerFontColor", this.HeaderFontColor.Name);
CurrentWriter.WriteStartElement("font");
CurrentWriter.WriteAttributeString("family", this.mHeaderFont.FontFamily.Name);
CurrentWriter.WriteAttributeString("size", this.mHeaderFont.Size.ToString());
CurrentWriter.WriteAttributeString("style", this.mHeaderFont.Style.ToString());
CurrentWriter.WriteEndElement(); //end of font element
CurrentWriter.WriteEndElement(); //end of header element
CurrentWriter.WriteStartElement("BorderSettings");
CurrentWriter.WriteAttributeString("DisplayTopBorder", this.mTableBorders.DisplayTopBorder.ToString());
CurrentWriter.WriteAttributeString("DisplayBottomBorder", this.mTableBorders.DisplayBottomBorder.ToString());
CurrentWriter.WriteAttributeString("DisplayLeftBorder", this.mTableBorders.DisplayLeftBorder.ToString());
CurrentWriter.WriteAttributeString("DisplayRightBorder", this.mTableBorders.DisplayRightBorder.ToString());
CurrentWriter.WriteEndElement(); //end of BorderSettings element
CurrentWriter.WriteStartElement("dataRows");
CurrentWriter.WriteAttributeString("dataFontColor", this.mDataFontColor.Name);
CurrentWriter.WriteStartElement("font");
CurrentWriter.WriteAttributeString("family", this.mDataFont.FontFamily.Name);
CurrentWriter.WriteAttributeString("size", this.mDataFont.Size.ToString());
CurrentWriter.WriteAttributeString("style", this.mDataFont.Style.ToString());
CurrentWriter.WriteEndElement(); //end of font element
CurrentWriter.WriteEndElement(); //end of dataRows element
if (this.mColumns.Length>0)
{
CurrentWriter.WriteStartElement("columns");
for (int i=0;i<this.mColumns.Length;i++)
{
CurrentWriter.WriteStartElement("column");
CurrentWriter.WriteAttributeString("name", Helpers.TextSafeForXML(this.mColumns[i].Name));
CurrentWriter.WriteAttributeString("label", Helpers.TextSafeForXML(this.mColumns[i].Label));
CurrentWriter.WriteAttributeString("width", this.mColumns[i].Width.ToString());
CurrentWriter.WriteAttributeString("align", this.mColumns[i].Alignment.ToString());
CurrentWriter.WriteAttributeString("formatMask", Helpers.TextSafeForXML(this.mColumns[i].FormatMask));
CurrentWriter.WriteAttributeString("calculateTotal", this.mColumns[i].CalculateTotal.ToString());
CurrentWriter.WriteAttributeString("visible", this.mColumns[i].Visible.ToString());
CurrentWriter.WriteEndElement(); //end of column element
}
CurrentWriter.WriteEndElement(); //end of columns element
}
CurrentWriter.WriteEndElement(); //end of table element
}
/// <summary>
/// Loads the current objects information from the XmlNode passed
/// </summary>
/// <param name="CurrentNode">XmlNode with objects information</param>
public override void LoadFromXMLNode(System.Xml.XmlNode CurrentNode)
{
this.X = Convert.ToInt32( CurrentNode.Attributes["x"].Value );
this.Y = Convert.ToInt32( CurrentNode.Attributes["y"].Value );
this.Width= Convert.ToInt32( CurrentNode.Attributes["width"].Value );
this.Height = Convert.ToInt32( CurrentNode.Attributes["height"].Value );
if (CurrentNode.Attributes["horAlignment"] != null)
this.horizontalAlignment = ICustomPaint.ResolveHorizontalAlignment(CurrentNode.Attributes["horAlignment"].Value);
if (CurrentNode.Attributes["verAlignment"] != null)
this.verticalAlignment = ICustomPaint.ResolveVerticalAlignment(CurrentNode.Attributes["verAlignment"].Value);
if (CurrentNode.Attributes["borderColor"] != null)
this.mBorderColor = Color.FromName(CurrentNode.Attributes["borderColor"].Value);
if (CurrentNode.Attributes["Selectable"] != null)
this.mSelectable = Convert.ToBoolean(CurrentNode.Attributes["Selectable"].Value);
if (CurrentNode.Attributes["ObjectRepeatability"] != null)
this.objectRepeatability = ICustomPaint.ResolveObjectRepeatability(CurrentNode.Attributes["ObjectRepeatability"].Value);
if (CurrentNode.Attributes["GroupByField"] != null || CurrentNode.Attributes["groupByField"] != null)
{
if (CurrentNode.Attributes["GroupByField"] != null)
{
this.mGroupByField = CurrentNode.Attributes["GroupByField"].Value;
}
else
{
this.mGroupByField = CurrentNode.Attributes["groupByField"].Value;
}
}
if (CurrentNode.Attributes["blankLineBeforeNewGroup"] != null)
mBlankLineBeforeNewGroup= Convert.ToBoolean(CurrentNode.Attributes["blankLineBeforeNewGroup"].Value);
if (CurrentNode.Attributes["lineUnderNewGroup"] != null)
this.mLineUnderNewGroup = Convert.ToBoolean(CurrentNode.Attributes["lineUnderNewGroup"].Value);
if (CurrentNode.Attributes["displayGroupTitle"] != null)
this.mDisplayGroupTitle = Convert.ToBoolean(CurrentNode.Attributes["displayGroupTitle"].Value);
if (CurrentNode.Attributes["displayGridLines"] != null)
this.mDisplayGridLines = Convert.ToBoolean(CurrentNode.Attributes["displayGridLines"].Value);
bool hasDataSource = false;
if ( CurrentNode.Attributes["dataSource"] != null )
{
this.mDataSource = CurrentNode.Attributes["dataSource"].Value;
hasDataSource = true;
}
try
{
this.mDrawHeader = CurrentNode.Attributes["showHeader"]==null ? true : Convert.ToBoolean(CurrentNode.Attributes["showHeader"].Value);
}
catch (Exception){}
try
{
this.mDrawEmptyRows = CurrentNode.Attributes["drawEmptyRows"]==null ? false : Convert.ToBoolean(CurrentNode.Attributes["drawEmptyRows"].Value);
}
catch (Exception){}
try
{
this.mCellHeight = CurrentNode.Attributes["cellHeight"]==null ? 18 : Convert.ToInt32(CurrentNode.Attributes["cellHeight"].Value);
}
catch (Exception){}
string[] columnLabels = new string[0];
XmlNodeList childNodes = CurrentNode.ChildNodes;
for (int i=0;i<childNodes.Count;i++)
{
switch (childNodes[i].Name)
{
case "BorderSettings":
this.mTableBorders.DisplayTopBorder = Convert.ToBoolean(childNodes[i].Attributes["DisplayTopBorder"].Value);
this.mTableBorders.DisplayBottomBorder = Convert.ToBoolean(childNodes[i].Attributes["DisplayBottomBorder"].Value);
this.mTableBorders.DisplayLeftBorder = Convert.ToBoolean(childNodes[i].Attributes["DisplayLeftBorder"].Value);
this.mTableBorders.DisplayRightBorder = Convert.ToBoolean(childNodes[i].Attributes["DisplayRightBorder"].Value);
break;
case "columns":
this.mColumns = this.resolveColumns(childNodes[i]);
break;
case "header":
try
{
this.mHeaderBackgroundColor = Color.FromName( childNodes[i].Attributes["headerColor"].Value);
}
catch (Exception){}
try
{
this.mHeaderFontColor = Color.FromName( childNodes[i].Attributes["headerFontColor"].Value);
}
catch (Exception){}
XmlNodeList headerNodes = childNodes[i].ChildNodes;
for (int j=0;j<headerNodes.Count;j++)
{
switch (headerNodes[j].Name)
{
case "font":
this.mHeaderFont = Helpers.ResolveFont(headerNodes[j]);
break;
}
}
break;
case "dataRows":
try
{
this.mDataFontColor = Color.FromName(childNodes[i].Attributes["dataFontColor"].Value);
}
catch (Exception){}
XmlNodeList dataNodes = childNodes[i].ChildNodes;
for (int j=0;j<dataNodes.Count;j++)
{
switch (dataNodes[j].Name)
{
case "font":
this.mDataFont = Helpers.ResolveFont(dataNodes[j]);
break;
}
}
break;
case "font":
this.mDataFont = Helpers.ResolveFont(childNodes[i]);
break;
case "data":
if (!hasDataSource)
this.mData = resolveStaticTableData(childNodes[i]);
break;
}
}
if (this.mColumns.Length == 0)
{
if (hasDataSource && document.DataTables.Contains(this.mDataSource) )
this.mColumns = createColumns ((DataTable)document.DataTables[this.mDataSource]);
else
{
StyledTableColumn[] kolone = new StyledTableColumn[1];
kolone[0] = new StyledTableColumn();
kolone[0].Label = "Wrong dataSource name";
this.mColumns = kolone;
}
}
}
/// <summary>
/// Gets or sets the height of the StyledTable
/// </summary>
[Category("Layout"), Description("The height of the element.")]
public override int Height
{
get {return mRegion.Height;}
set
{
if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.None || this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Top)
mRegion.Height = value;
else if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Bottom)
{
mRegion.Y = mRegion.Y - value + mRegion.Height;
mRegion.Height = value;
}
else if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Middle)
{
mRegion.Y = mRegion.Y - value/2 + mRegion.Height/2;
mRegion.Height = value;
}
}
}
/// <summary>
/// Gets or sets the horizontal alignment of the StyledTable
/// </summary>
[Category("Layout"), Description("Horizontal alignment in the page, relative to margins. This property overrides element coordinates.")]
public override ICustomPaint.HorizontalAlignmentTypes HorizontalAlignment
{
get {return horizontalAlignment;}
set
{
horizontalAlignment = value;
switch (horizontalAlignment)
{
case ICustomPaint.HorizontalAlignmentTypes.Center:
mRegion.X = (document.DefaultPageSettings.Bounds.Width-document.Margins.Right+document.Margins.Left)/2 - Width/2;
break;
case ICustomPaint.HorizontalAlignmentTypes.Right:
mRegion.X = document.DefaultPageSettings.Bounds.Right - document.Margins.Right - Width;
break;
case ICustomPaint.HorizontalAlignmentTypes.Left:
mRegion.X = document.Margins.Left;
break;
}
}
}
/// <summary>
/// Gets or sets the TextField repeatability over multiple pages
/// </summary>
/// <remarks>
/// The TextField's repeatability setting governs how whether it is repeated
/// over multiple pages, only on the first page, or only on the last page.
/// </remarks>
[Description("This controls repeatability of the TextField over multiple pages.")]
public override ICustomPaint.ObjectRepeatabilityTypes ObjectRepeatability
{
get
{
return this.objectRepeatability;
}
set
{
this.objectRepeatability = value;
}
}
/// <summary>
/// Gets/Sets whether the StyledTable is selectable in the design pane of the DaReport Designer
/// </summary>
/// <remarks>If set to true, then the StyledTable is not selectable in the DaReport Designer application
/// design pane. It is still selectable in the tree view listing of objects.
/// </remarks>
[Category("Appearance"), Description("Sets whether the StyledTable can be selected in the design pane.")]
public override bool Selectable
{
get { return this.mSelectable; }
set { this.mSelectable=value; }
}
/// <summary>
/// Gets or sets the vertical alignment of the StyledTable
/// </summary>
[Category("Layout"), Description("Vertical alignment in the page, relative to margins. This property overrides element coordinates.")]
public override ICustomPaint.VerticalAlignmentTypes VerticalAlignment
{
get {return verticalAlignment;}
set
{
verticalAlignment = value;
switch (verticalAlignment)
{
case ICustomPaint.VerticalAlignmentTypes.Middle:
mRegion.Y = (document.DefaultPageSettings.Bounds.Height-document.Margins.Bottom+document.Margins.Top)/2 - Height/2;
break;
case ICustomPaint.VerticalAlignmentTypes.Bottom:
mRegion.Y = document.DefaultPageSettings.Bounds.Bottom - document.Margins.Bottom - Height;
break;
case ICustomPaint.VerticalAlignmentTypes.Top:
mRegion.Y = document.Margins.Top;
break;
}
}
}
/// <summary>
/// Gets or sets the width of the StyledTable.
/// </summary>
[Category("Layout"), Description("The width of the element.")]
public override int Width
{
get {return mRegion.Width;}
set
{
if (this.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.None || this.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.Left)
mRegion.Width = value;
else if (this.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.Right)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -