/// <summary> /// Gets the initial collection of webpart panels. /// </summary> /// <returns></returns> protected internal virtual WebPartPanelCollection GetInitialWebPartPanels() { WebPartPanelCollection panels = new WebPartPanelCollection(); if (this.zoneTemplate != null) { // Create the control which contains the template. NonParentingControl templatedControl = new NonParentingControl(); this.zoneTemplate.InstantiateIn(templatedControl); // Don't do anything with an empty template. if (!templatedControl.HasControls()) { return(panels); } WebPartPanel panel; int zoneIndexCounter = 0; foreach (Control childControl in templatedControl.Controls) { panel = this.CreateWebPartPanel(childControl); if (panel != null) { panel.ZoneIndex = (zoneIndexCounter++); panels.Add(panel); } } } return(panels); }
/// <summary> /// Gets the webparts for the specified zone. /// </summary> /// <param name="zone"></param> /// <returns></returns> internal WebPartPanelCollection GetWebPartsForZone(WebPartZone zone) { WebPartPanelCollection panels = new WebPartPanelCollection(); // Get the webpart panel's in the zone sorted by the the zone index. SortedList <WebPartPanel, object> sortedPanels = new SortedList <WebPartPanel, object>(new WebPartManager.WebPartPanelZoneIndexComparer()); foreach (WebPartPanel panel in this.Controls) { if (panel.ZoneID == zone.ID && !panel.IsRemoved) { sortedPanels.Add(panel, null); } } // Re-organize the zone indices, starting from 0. for (int i = 0; i < sortedPanels.Keys.Count; i++) { sortedPanels.Keys[i].ZoneIndex = i; panels.Add(sortedPanels.Keys[i]); } return(panels); }