Example #1
0
        /// <summary>
        /// Registers a webpart zone.
        /// </summary>
        /// <param name="zone"></param>
        internal void RegisterZone(WebPartZone zone)
        {
            if (this.pageLoadComplete)
            {
                throw new InvalidOperationException("Zones must be registered before the completion of the page initialization.");
            }

            if (String.IsNullOrEmpty(zone.ID))
            {
                throw new ArgumentException("The zone does not have an ID.");
            }

            if (this.zoneIDs.ContainsKey(zone.ID))
            {
                throw new ArgumentException("A zone with the same ID was already added.");
            }

            if (this.zones.Contains(zone))
            {
                throw new ArgumentException("The zone was already registered.");
            }

            this.zoneIDs.Add(zone.ID, zone);
            this.zones.Add(zone);

            ((WebPartManagerControlCollection)this.Controls).AddWebPartPanelsFromZone(zone);
        }
Example #2
0
            /// <summary>
            /// Adds the webpart panels in the specified zone to the current collection.
            /// </summary>
            /// <param name="zone"></param>
            internal void AddWebPartPanelsFromZone(WebPartZone zone)
            {
                WebPartPanelCollection panels = zone.GetInitialWebPartPanels();

                foreach (WebPartPanel panel in panels)
                {
                    base.Add(panel);
                }
            }
Example #3
0
        /// <summary>
        /// Programmatically adds a webpart panel to a zone at the specified index.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="zone"></param>
        /// <param name="zoneIndex"></param>
        public void AddWebPartPanel(WebPartPanel panel, WebPartZone zone, int zoneIndex)
        {
            ((WebPartManagerControlCollection)this.Controls).AddWebPartPanel(panel);

            // Only use the move procedure to set the panel's zone ID and zone index if it isn't
            // already set. It could be set if this is a postback, and the panel was added in a
            // previous request. If we would re-add the panel, the panel would be placed at the
            // original specified position.
            if (panel.ZoneID == null && panel.ZoneIndex < 0)
            {
                this.MoveWebPartPanel(panel, zone, zoneIndex);
            }
        }
Example #4
0
        /// <summary>
        /// Moves a webpart panel to the specified zone at the specified index.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="zone"></param>
        /// <param name="zoneIndex"></param>
        public void MoveWebPartPanel(WebPartPanel panel, WebPartZone zone, int zoneIndex)
        {
            WebPartPanelCollection panels = zone.WebPartPanels;

            if (zoneIndex < 0)
            {
                throw new ArgumentOutOfRangeException("zoneIndex");
            }

            // Update the indices of the webpart panels which are placed beneath the moved panel.
            for (int i = zoneIndex; i < panels.Count; i++)
            {
                panels[i].ZoneIndex++;
            }

            panel.ZoneID    = zone.ID;
            panel.ZoneIndex = zoneIndex;
        }
Example #5
0
        /// <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);
        }
Example #6
0
		public override void Initialize(System.ComponentModel.IComponent component)
		{
			base.Initialize(component);
			this.zone = (WebPartZone)component;
		}
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelRenderer"/> class.
 /// </summary>
 /// <param name="zone">The zone for which the renderer will render the webpart panels.</param>
 public WebPartPanelRenderer(WebPartZone zone)
 {
     this.zone = zone;
 }
Example #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelRenderer"/> class.
		/// </summary>
		/// <param name="zone">The zone for which the renderer will render the webpart panels.</param>
		public WebPartPanelRenderer(WebPartZone zone)
		{
			this.zone = zone;
		}