using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using AjaxControlToolkit; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; using CMS.SettingsProvider; public partial class CMSWebParts_Layouts_Zone : CMSAbstractLayoutWebPart { #region "Properties" /// /// Width. /// public string Width { get { return ValidationHelper.GetString(GetValue("Width"), ""); } set { SetValue("Width", value); } } /// /// Height. /// public string Height { get { return ValidationHelper.GetString(GetValue("Height"), ""); } set { SetValue("Height", value); } } /// /// Zone CSS class. /// public string ZoneCSSClass { get { return ValidationHelper.GetString(GetValue("ZoneCSSClass"), ""); } set { SetValue("ZoneCSSClass", value); } } /// /// Location. /// public string Location { get { return ValidationHelper.GetString(GetValue("Location"), ""); } set { SetValue("Location", value); } } /// /// Vertical offset. /// public int VerticalOffset { get { return ValidationHelper.GetInteger(GetValue("VerticalOffset"), 0); } set { SetValue("VerticalOffset", value); } } /// /// Horizontal offset. /// public int HorizontalOffset { get { return ValidationHelper.GetInteger(GetValue("HorizontalOffset"), 0); } set { SetValue("HorizontalOffset", value); } } /// /// Scroll effect duration (ms). /// public int ScrollEffectDuration { get { int result = ValidationHelper.GetInteger(GetValue("ScrollEffectDuration"), 100); if (result <= 0) { result = 100; } return result; } set { SetValue("ScrollEffectDuration", value); } } #endregion #region "Methods" /// /// Prepares the layout of the web part. /// protected override void PrepareLayout() { string location = Location; bool alwaysVisible = !String.IsNullOrEmpty(location); StartLayout(); if (IsDesign) { Append(""); if (ViewMode == ViewModeEnum.Design) { Append(""); } Append(""); // Resizers if (AllowDesignMode) { // Vertical resizer Append(""); // Horizontal resizer Append(""); Append(""); } Append("
"); // Add header container AddHeaderContainer(); Append("
"); } string style = null; // Width string width = Width; if (!String.IsNullOrEmpty(width)) { style += " width: " + width + ";"; } // Height string height = Height; if (!String.IsNullOrEmpty(height)) { style += " height: " + height + ";"; } string cssclass = ZoneCSSClass; // Render the envelope if needed bool renderEnvelope = IsDesign || !String.IsNullOrEmpty(style) || !String.IsNullOrEmpty(cssclass); if (renderEnvelope) { Append(""); } if (alwaysVisible) { // Add the extender AlwaysVisibleControlExtender av = new AlwaysVisibleControlExtender(); av.TargetControlID = "pnlEx"; av.ID = "avExt"; // Horizontal location if (location.EndsWithCSafe("left", true)) { av.HorizontalSide = HorizontalSide.Left; } else if (location.EndsWithCSafe("center", true)) { av.HorizontalSide = HorizontalSide.Center; } else if (location.EndsWithCSafe("right", true)) { av.HorizontalSide = HorizontalSide.Right; } // Horizontal location if (location.StartsWithCSafe("top", true)) { av.VerticalSide = VerticalSide.Top; } else if (location.StartsWithCSafe("middle", true)) { av.VerticalSide = VerticalSide.Middle; } else if (location.StartsWithCSafe("bottom", true)) { av.VerticalSide = VerticalSide.Bottom; } // Offsets av.HorizontalOffset = HorizontalOffset; av.VerticalOffset = VerticalOffset; av.ScrollEffectDuration = ScrollEffectDuration / 1000f; // Add the extender Controls.Add(av); } // Add the zone CMSWebPartZone zone = AddZone(ID + "_zone", ID); if (renderEnvelope) { Append(""); } if (IsDesign) { //zone.CssClass = "ZoneWebPartZone"; //zone.HeaderContainer = this.TitleContainer; Append(" 
  
"); } // Panel for extender PlaceHolder pnlEx = new PlaceHolder(); pnlEx.ID = "pnlEx"; //pnlEx.Visible = false; AddControl(pnlEx); FinishLayout(); } protected override void Render(HtmlTextWriter writer) { if (!String.IsNullOrEmpty(Location)) { // Ensure the envelope for placing elsewhere writer.Write("
"); base.Render(writer); writer.Write("
"); } else { // Standard rendering of single zone base.Render(writer); } } #endregion }