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_CollapsiblePanel : CMSAbstractLayoutWebPart { #region "Properties" /// /// Collapsed text. /// public string CollapsedText { get { return ValidationHelper.GetString(GetValue("CollapsedText"), ""); } set { SetValue("CollapsedText", value); } } /// /// Collapsed image. /// public string CollapsedImage { get { return ValidationHelper.GetString(GetValue("CollapsedImage"), ""); } set { SetValue("CollapsedImage", value); } } /// /// Expanded text. /// public string ExpandedText { get { return ValidationHelper.GetString(GetValue("ExpandedText"), ""); } set { SetValue("ExpandedText", value); } } /// /// Expanded image. /// public string ExpandedImage { get { return ValidationHelper.GetString(GetValue("ExpandedImage"), ""); } set { SetValue("ExpandedImage", value); } } /// /// Header CSS class. /// public string HeaderCSSClass { get { return ValidationHelper.GetString(GetValue("HeaderCSSClass"), ""); } set { SetValue("HeaderCSSClass", value); } } /// /// Title CSS class. /// public string TitleCSSClass { get { return ValidationHelper.GetString(GetValue("TitleCSSClass"), ""); } set { SetValue("TitleCSSClass", value); } } /// /// Image CSS class. /// public string ImageCSSClass { get { return ValidationHelper.GetString(GetValue("ImageCSSClass"), ""); } set { SetValue("ImageCSSClass", value); } } /// /// Content CSS class. /// public string ContentCSSClass { get { return ValidationHelper.GetString(GetValue("ContentCSSClass"), ""); } set { SetValue("ContentCSSClass", value); } } /// /// Collapsed size (px). /// public int CollapsedSize { get { return ValidationHelper.GetInteger(GetValue("CollapsedSize"), -1); } set { SetValue("CollapsedSize", value); } } /// /// Expanded size (px). /// public int ExpandedSize { get { return ValidationHelper.GetInteger(GetValue("ExpandedSize"), -1); } set { SetValue("ExpandedSize", value); } } /// /// Width. /// public string Width { get { return ValidationHelper.GetString(GetValue("Width"), ""); } set { SetValue("Width", value); } } /// /// Collapsed. /// public bool Collapsed { get { return ValidationHelper.GetBoolean(GetValue("Collapsed"), false); } set { SetValue("Collapsed", value); } } /// /// Auto collapse. /// public bool AutoCollapse { get { return ValidationHelper.GetBoolean(GetValue("AutoCollapse"), false); } set { SetValue("AutoCollapse", value); } } /// /// Auto expand. /// public bool AutoExpand { get { return ValidationHelper.GetBoolean(GetValue("AutoExpand"), false); } set { SetValue("AutoExpand", value); } } /// /// Expand direction. /// public string ExpandDirection { get { return ValidationHelper.GetString(GetValue("ExpandDirection"), ""); } set { SetValue("ExpandDirection", value); } } /// /// Scroll content. /// public bool ScrollContent { get { return ValidationHelper.GetBoolean(GetValue("ScrollContent"), false); } set { SetValue("ScrollContent", value); } } #endregion #region "Methods" /// /// Prepares the layout of the web part. /// protected override void PrepareLayout() { StartLayout(); Append(""); Append(""); if (ViewMode == ViewModeEnum.Design) { Append(""); } Append(""); // Width resizer if (AllowDesignMode) { Append(""); } Append("
"); // Add header container AddHeaderContainer(); Append("
"); } else { Append(">"); } // Header panel Panel pnlHeader = new Panel(); pnlHeader.ID = "pnlH"; pnlHeader.CssClass = HeaderCSSClass; pnlHeader.EnableViewState = false; // Header label Label lblHeader = new Label(); lblHeader.CssClass = HeaderCSSClass; lblHeader.ID = "lblH"; pnlHeader.Controls.Add(lblHeader); // Header image Image imgHeader = new Image(); imgHeader.CssClass = ImageCSSClass; imgHeader.ID = "imgH"; pnlHeader.Controls.Add(imgHeader); AddControl(pnlHeader); // Content panel Panel pnlContent = new Panel(); pnlContent.CssClass = ContentCSSClass; pnlContent.ID = "pnlC"; AddControl(pnlContent); // Add the zone CMSWebPartZone zone = AddZone(ID + "_zone", ID, pnlContent); // Add the extender CollapsiblePanelExtender cp = new CollapsiblePanelExtender(); cp.ID = "extCP"; cp.TargetControlID = pnlContent.ID; cp.ExpandControlID = pnlHeader.ID; cp.CollapseControlID = pnlHeader.ID; cp.TextLabelID = lblHeader.ID; cp.ImageControlID = imgHeader.ID; cp.ExpandDirection = (ExpandDirection.EqualsCSafe("horz", true) ? CollapsiblePanelExpandDirection.Horizontal : CollapsiblePanelExpandDirection.Vertical); // Texts string expText = ResHelper.LocalizeString(ExpandedText); string colText = ResHelper.LocalizeString(CollapsedText); cp.ExpandedText = expText; cp.CollapsedText = colText; if (String.IsNullOrEmpty(expText) && String.IsNullOrEmpty(colText)) { lblHeader.Visible = false; } // Images string expImage = ExpandedImage; string colImage = CollapsedImage; if (!String.IsNullOrEmpty(expImage) && !String.IsNullOrEmpty(colImage)) { cp.ExpandedImage = expImage; cp.CollapsedImage = colImage; } else { imgHeader.Visible = false; } // Sizes int expSize = ExpandedSize; if (expSize > 0) { cp.ExpandedSize = expSize; } int collapsed = CollapsedSize; if (collapsed >= 0) { cp.CollapsedSize = CollapsedSize; } cp.Collapsed = Collapsed; if (!IsDesign) { cp.AutoCollapse = AutoCollapse; if (AutoExpand) { cp.AutoExpand = true; // Ensure some collapsed size if (collapsed < 0) { cp.CollapsedSize = 10; } } } cp.ScrollContents = ScrollContent; // Add the extender Controls.Add(cp); if (IsDesign) { Append(" 
"); } Append(""); FinishLayout(); } #endregion }