using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.GlobalHelper;
using CMS.PortalControls;
using CMS.PortalEngine;
using CMS.SettingsProvider;
public partial class CMSWebParts_Layouts_Table : CMSAbstractLayoutWebPart
{
#region "Public properties"
///
/// Total width.
///
public string TableWidth
{
get
{
return ValidationHelper.GetString(GetValue("TableWidth"), "");
}
set
{
SetValue("TableWidth", value);
}
}
///
/// Number of columns.
///
public int Columns
{
get
{
return ValidationHelper.GetInteger(GetValue("Columns"), 2);
}
set
{
SetValue("Columns", value);
}
}
///
/// Number of rows.
///
public int Rows
{
get
{
return ValidationHelper.GetInteger(GetValue("Rows"), 1);
}
set
{
SetValue("Rows", value);
}
}
///
/// Table CSS class.
///
public string TableCSSClass
{
get
{
return ValidationHelper.GetString(GetValue("TableCSSClass"), "");
}
set
{
SetValue("TableCSSClass", value);
}
}
///
/// Vertical align.
///
public string VerticalAlign
{
get
{
return ValidationHelper.GetString(GetValue("VerticalAlign"), "");
}
set
{
SetValue("VerticalAlign", value);
}
}
///
/// First column width.
///
public string Column1Width
{
get
{
return ValidationHelper.GetString(GetValue("Column1Width"), "");
}
set
{
SetValue("Column1Width", value);
}
}
///
/// First column CSS class.
///
public string Column1CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Column1CSSClass"), "");
}
set
{
SetValue("Column1CSSClass", value);
}
}
///
/// Second column width.
///
public string Column2Width
{
get
{
return ValidationHelper.GetString(GetValue("Column2Width"), "");
}
set
{
SetValue("Column2Width", value);
}
}
///
/// Second column CSS class.
///
public string Column2CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Column2CSSClass"), "");
}
set
{
SetValue("Column2CSSClass", value);
}
}
///
/// Third column width.
///
public string Column3Width
{
get
{
return ValidationHelper.GetString(GetValue("Column3Width"), "");
}
set
{
SetValue("Column3Width", value);
}
}
///
/// Third column CSS class.
///
public string Column3CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Column3CSSClass"), "");
}
set
{
SetValue("Column3CSSClass", value);
}
}
///
/// Fourth column width.
///
public string Column4Width
{
get
{
return ValidationHelper.GetString(GetValue("Column4Width"), "");
}
set
{
SetValue("Column4Width", value);
}
}
///
/// Fourth column CSS class.
///
public string Column4CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Column4CSSClass"), "");
}
set
{
SetValue("Column4CSSClass", value);
}
}
///
/// Fifth column width.
///
public string Column5Width
{
get
{
return ValidationHelper.GetString(GetValue("Column5Width"), "");
}
set
{
SetValue("Column5Width", value);
}
}
///
/// Fifth column CSS class.
///
public string Column5CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Column5CSSClass"), "");
}
set
{
SetValue("Column5CSSClass", value);
}
}
///
/// First row height.
///
public string Row1Height
{
get
{
return ValidationHelper.GetString(GetValue("Row1Height"), "");
}
set
{
SetValue("Row1Height", value);
}
}
///
/// First row CSS class.
///
public string Row1CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Row1CSSClass"), "");
}
set
{
SetValue("Row1CSSClass", value);
}
}
///
/// Second row height.
///
public string Row2Height
{
get
{
return ValidationHelper.GetString(GetValue("Row2Height"), "");
}
set
{
SetValue("Row2Height", value);
}
}
///
/// Second row CSS class.
///
public string Row2CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Row2CSSClass"), "");
}
set
{
SetValue("Row2CSSClass", value);
}
}
///
/// Third row height.
///
public string Row3Height
{
get
{
return ValidationHelper.GetString(GetValue("Row3Height"), "");
}
set
{
SetValue("Row3Height", value);
}
}
///
/// Third row CSS class.
///
public string Row3CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Row3CSSClass"), "");
}
set
{
SetValue("Row3CSSClass", value);
}
}
///
/// Fourth row height.
///
public string Row4Height
{
get
{
return ValidationHelper.GetString(GetValue("Row4Height"), "");
}
set
{
SetValue("Row4Height", value);
}
}
///
/// Fourth row CSS class.
///
public string Row4CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Row4CSSClass"), "");
}
set
{
SetValue("Row4CSSClass", value);
}
}
///
/// Fifth row height.
///
public string Row5Height
{
get
{
return ValidationHelper.GetString(GetValue("Row5Height"), "");
}
set
{
SetValue("Row5Height", value);
}
}
///
/// Fifth row CSS class.
///
public string Row5CSSClass
{
get
{
return ValidationHelper.GetString(GetValue("Row5CSSClass"), "");
}
set
{
SetValue("Row5CSSClass", value);
}
}
#endregion
#region "Methods"
///
/// Prepares the layout of the web part.
///
protected override void PrepareLayout()
{
// Prepare the main markup
StartLayout();
string style = null;
// Table width
string width = TableWidth;
bool hasTableWidth = false;
if (!String.IsNullOrEmpty(width))
{
style += "width: " + width;
hasTableWidth = true;
}
if (IsDesign)
{
Append("
");
if (ViewMode == ViewModeEnum.Design)
{
Append("
");
}
Append("");
}
Append("");
string heightPropertyName = null;
string widthPropertyName = null;
// Prepare vertical alignment
string valign = null;
switch (VerticalAlign.ToLowerCSafe())
{
case "top":
case "middle":
case "bottom":
valign = VerticalAlign.ToLowerCSafe();
break;
}
bool hasEmptyColumn = false;
// Add the rows
for (int j = 1; j <= Rows; j++)
{
// Set the height property
heightPropertyName = "Row" + j + "Height";
Append("");
// Add the columns
int cols = Columns;
for (int i = 1; i <= cols; i++)
{
// Set the width property
widthPropertyName = "Column" + i + "Width";
Append("| ");
// Add the zone
AddZone(ID + "_" + j + "_" + i, "[" + j + "," + i + "]");
Append(" | ");
if (IsDesign && AllowDesignMode)
{
Append(" | ");
}
}
Append(" ");
if (IsDesign && AllowDesignMode)
{
Append("");
// Add the columns
for (int i = 1; i <= Columns; i++)
{
// Set the width property
widthPropertyName = "Column" + i + "Width";
Append("| | ");
Append(" | ");
}
Append(" ");
}
}
Append(" ");
if (IsDesign)
{
Append(" |
");
// Footer
if (AllowDesignMode)
{
Append("
");
}
Append("
");
}
// Finalize
FinishLayout();
}
#endregion
}