public override string XGetDesignTimeHtml(DesignerRegionCollection regions)
{
designerRegions = regions;
Panel c = (Panel)this.Control;
StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
string width = " width: {0};".FormatWith((c.Width == Unit.Empty) ? "auto" : c.Width.ToString());
string height = " height: {0};".FormatWith((c.Height == Unit.Empty) ? "auto" : (c.Height.Value - 27).ToString() + "px");
string buttons = "";
buttons += (c.Collapsible) ? "<a {0}><div class=\"x-tool x-tool-toggle\"> </div></a>" : "";
if (this.Layout.HasValue && this.Layout.Value != LayoutType.Border || !this.Layout.HasValue)
{
if (buttons.IsNotEmpty())
{
buttons = string.Format(buttons, GetDesignerRegionAttribute(PanelClickAction.Toggle));
}
else
{
// for prevent shifting regions
designerRegions.Add(new DesignerRegion(CurrentDesigner, "Empty", false));
}
}
if (this.Layout.HasValue)
{
if (!Width.IsEmpty)
{
width = " width: {0};".FormatWith((Width == Unit.Empty) ? "auto" : Width.ToString());
}
if (!Height.IsEmpty)
{
if (Height.Type == UnitType.Pixel)
{
height = " height: {0}px;".FormatWith(Height.Value - 27);
}
else
{
height = " height: {0};".FormatWith(Height);
}
}
if (this.Layout.Value == LayoutType.Border)
{
if (BorderRegion.Collapsible && BorderRegion.Region != RegionPosition.Center)
{
buttons = "<a {1}><div class=\"x-tool x-tool-toggle x-tool-collapse-{0}\"> </div></a>".FormatWith(BorderRegion.Region.ToString().ToLower(), GetDesignerRegionAttribute(BorderRegion.Region, BorderLayoutDesigner.BorderLayoutClickAction.Collapse));
}
else
{
// for prevent shifting regions
designerRegions.Add(new DesignerRegion(CurrentDesigner, "Empty", false));
buttons = "";
}
}
}
string iconCls = "";
this.AddIcon(c.Icon);
if (c.IconClsProxy.IsNotEmpty())
{
if (c.Frame)
{
iconCls = "x-panel-icon " + c.IconClsProxy;
}
else
{
iconCls = "<img src=\"{0}\" class=\"x-panel-inline-icon {1}\" />".FormatWith(c.ResourceManager.BLANK_IMAGE_URL, c.IconClsProxy);
}
}
string header = "";
if (c.Header)
{
/*
* 0 - x-panel-header-noborder
* 1 - IconCls
* 2 - Title
* 3 - Buttons
*/
object[] headerArgs = new object[4];
headerArgs[0] = !c.Border ? "x-panel-header-noborder" : "";
headerArgs[1] = iconCls;
headerArgs[2] = c.Title;
headerArgs[3] = buttons;
header = string.Format(this.HtmlHeader, headerArgs);
}
/*
0 - Width
1 - x-panel-noborder
2 - Collapsed style
3 - Collapsed display: block;
4 - BodyStyle
5 - Height
6 - x-panel-body-noborder
7 - HEADER
*/
object[] args = new object[8];
args[0] = width;
args[1] = !c.Border ? "x-panel-noborder" : "";
args[2] = c.Collapsed && c.Collapsible ? "x-panel-collapsed" : "";
args[3] = (c.Collapsed) ? "display: none;" : "display: block;";
args[4] = c.BodyStyle;
args[5] = height;
args[6] = !c.Border ? "x-panel-body-noborder" : "";
args[7] = header;
LiteralControl topCtrl = new LiteralControl(string.Format(this.HtmlBegin, args) + this.GetIconStyleBlock());
topCtrl.RenderControl(htmlWriter);
HtmlGenericControl div = (HtmlGenericControl)c.ContentContainer;
EditableDesignerRegion region = new EditableDesignerRegion(CurrentDesigner, ContentRegionName, false);
designerRegions.Add(region);
if ((!c.Collapsible) || (c.Collapsible && !c.Collapsed) || (this.Layout.HasValue && this.Layout.Value == LayoutType.Border))
{
div.Attributes[DesignerRegion.DesignerRegionAttributeName] = (designerRegions.Count - 1).ToString();
div.Style["height"] = "100%";
div.Style["overflow"] = "hidden";
div.RenderControl(htmlWriter);
}
LiteralControl bottomCtrl = new LiteralControl(this.HtmlEnd);
bottomCtrl.RenderControl(htmlWriter);
return writer.ToString();
}