Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a generic webpart panel for the specified control.
        /// </summary>
        /// <param name="childControl"></param>
        /// <returns></returns>
        public WebPartPanel CreateWebPartPanel(Control childControl)
        {
            WebPartPanel panel = new WebPartPanel();

            panel.PanelTemplate = new GenericTemplate(new TemplateEventHandler(delegate(object sender, TemplateEventArgs e)
            {
                e.Container.Controls.Add(childControl);
            }));
            panel.ID      = childControl.ID;
            panel.Caption = "Generic panel for " + childControl.ID;

            // TODO: Implement some logic to determine what caption to display.
            return(panel);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a webpart panel for the specified control.
        /// </summary>
        /// <param name="childControl"></param>
        /// <returns></returns>
        private WebPartPanel CreateWebPartPanel(Control childControl)
        {
            WebPartPanel panel = childControl as WebPartPanel;

            // Create a webpart panel for the child control if it is not a webpart panel.
            if (panel == null && (!(childControl is LiteralControl)))
            {
                panel = this.WebPartManager.CreateWebPartPanel(childControl);
            }

            if (panel != null)
            {
                panel.ZoneID = this.ID;
            }

            return(panel);
        }
Esempio n. 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;
        }
Esempio n. 5
0
        /// <summary>
        /// Registers a webpart panel.
        /// </summary>
        /// <param name="panel"></param>
        internal void RegisterWebPartPanel(WebPartPanel panel)
        {
            if (this.pageLoadComplete)
            {
                throw new InvalidOperationException("Webpart panels must be registered before the completion of the page load.");
            }

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

            if (this.webPartPanelIDs.ContainsKey(panel.ID))
            {
                throw new ArgumentException("A webpart panel with the same ID already exists.");
            }

            this.webPartPanelIDs.Add(panel.ID, panel);
        }
Esempio n. 6
0
        /// <summary>
        /// Registers the client script.
        /// </summary>
        private void RegisterClientScript()
        {
            // Get the reference to the panel's body which should be minimized/restored.
            Control parentControl = this.NamingContainer;

            while ((parentControl != null) && !(parentControl is WebPartPanel))
            {
                parentControl = parentControl.NamingContainer;
            }

            if (parentControl == null)
            {
                throw new InvalidOperationException("Verbs can only be used in webpart panels.");
            }

            WebPartPanel panel        = (WebPartPanel)parentControl;
            string       bodyClientID = panel.ClientID;

            string minimizeImageUrl = this.ResolveUrl(this.MinimizeImageUrl);
            string restoreImageUrl  = this.ResolveUrl(this.RestoreImageUrl);

            if (panel.AllowMinimize)
            {
                this.Attributes["onclick"] = String.Format("MinimizeRestore('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');",
                                                           bodyClientID, this.ClientID, this.MinimizeToolTip, this.RestoreToolTip,
                                                           minimizeImageUrl, restoreImageUrl);
            }

            if (panel.IsMinimized)
            {
                this.Attributes["title"] = this.RestoreToolTip;
                this.Attributes["src"]   = restoreImageUrl;
            }
            else
            {
                this.Attributes["title"] = this.MinimizeToolTip;
                this.Attributes["src"]   = minimizeImageUrl;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Registers the client script.
        /// </summary>
        private void RegisterClientScript()
        {
            // Get the reference to the panel's body which should be minimized/restored.
            Control parentControl = this.NamingContainer;

            while ((parentControl != null) && !(parentControl is WebPartPanel))
            {
                parentControl = parentControl.NamingContainer;
            }

            if (parentControl == null)
            {
                throw new InvalidOperationException("Verbs can only be used in webpart panels.");
            }

            WebPartPanel panel = (WebPartPanel)parentControl;

            if (panel.AllowDelete)
            {
                this.Attributes["onclick"] = String.Format("RemoveWebPart('{0}', '{1}');", panel.ContainerClientID, this.DeleteConfirmMessage);
            }

            this.Style[HtmlTextWriterStyle.Cursor] = "pointer";
        }
Esempio n. 8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelEventArgs"/> class.
		/// </summary>
		/// <param name="commandName">The command name.</param>
		/// <param name="panel"></param>
		public WebPartPanelEventArgs(string commandName, WebPartPanel panel)
		{
			this.commandName = commandName;
			this.panel = panel;
		}
Esempio n. 9
0
 /// <summary>
 /// Adds a webpart panel to the collection.
 /// </summary>
 /// <param name="panel"></param>
 internal void AddWebPartPanel(WebPartPanel panel)
 {
     base.Add(panel);
 }
Esempio n. 10
0
 /// <summary>
 /// Removes a webpart panel from the page.
 /// </summary>
 /// <param name="panel">The panel to remove.</param>
 public void RemoveWebPartPanel(WebPartPanel panel)
 {
     panel.IsRemoved = true;
 }
Esempio n. 11
0
        /// <summary>
        /// Renders a webpart panel.
        /// </summary>
        /// <param name="writer">The writer to write to.</param>
        /// <param name="panel">The webpart panel to render.</param>
        public void RenderWebPartPanel(HtmlTextWriter writer, WebPartPanel panel)
        {
            if (panel.IsMinimized)
            {
                panel.Style[HtmlTextWriterStyle.Display] = "none";
            }
            else
            {
                panel.Style[HtmlTextWriterStyle.Display] = String.Empty;
            }

            string boxClientID = panel.ContainerClientID;

            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute("relatedWebPart", panel.ClientID);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0px");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            panel.HeaderStyle.AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Title, panel.ToolTip);
            if (WebPartManager.SupportsClientSideDragDrop(this.zone.Page))
            {
                string dragCaption = (panel.DragCaption.Length > 0) ? panel.DragCaption : panel.Caption;
                writer.AddAttribute("onmousedown", String.Format("MoveWebPartStart('{0}', '{1}');", boxClientID, dragCaption));

                writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "move");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            Label titleBarCaption = new Label();

            titleBarCaption.ControlStyle.CopyFrom(panel.CaptionStyle);
            titleBarCaption.Text = panel.Caption;
            titleBarCaption.RenderControl(writer);

            writer.RenderEndTag();

            writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "right");
            panel.Verbs.ControlStyle.AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            foreach (Control verb in panel.Verbs.Controls)
            {
                if (verb.Visible && !(verb is LiteralControl))
                {
                    verb.RenderControl(writer);
                }
            }

            writer.RenderEndTag();

            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddStyleAttribute("vertical-align", "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            panel.RenderControl(writer);

            writer.RenderEndTag();
            writer.RenderEndTag();

            writer.RenderEndTag();
        }
Esempio n. 12
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelMovedEventArgs"/> class.
		/// </summary>
		/// <param name="commandName"></param>
		/// <param name="panel"></param>
		/// <param name="previousZoneID"></param>
		/// <param name="previousZoneIndex"></param>
		public WebPartPanelMovedEventArgs(string commandName, WebPartPanel panel, string previousZoneID, int previousZoneIndex) : base(commandName, panel)
		{
			this.previousZoneID = previousZoneID;
			this.previousZoneIndex = previousZoneIndex;
		}
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelEventArgs"/> class.
 /// </summary>
 /// <param name="commandName">The command name.</param>
 /// <param name="panel"></param>
 public WebPartPanelEventArgs(string commandName, WebPartPanel panel)
 {
     this.commandName = commandName;
     this.panel       = panel;
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Wilco.Web.UI.WebControls.WebParts.WebPartPanelMovedEventArgs"/> class.
 /// </summary>
 /// <param name="commandName"></param>
 /// <param name="panel"></param>
 /// <param name="previousZoneID"></param>
 /// <param name="previousZoneIndex"></param>
 public WebPartPanelMovedEventArgs(string commandName, WebPartPanel panel, string previousZoneID, int previousZoneIndex) : base(commandName, panel)
 {
     this.previousZoneID    = previousZoneID;
     this.previousZoneIndex = previousZoneIndex;
 }
Esempio n. 15
0
		/// <summary>
		/// Renders a webpart panel.
		/// </summary>
		/// <param name="writer">The writer to write to.</param>
		/// <param name="panel">The webpart panel to render.</param>
		public void RenderWebPartPanel(HtmlTextWriter writer, WebPartPanel panel)
		{
			if (panel.IsMinimized)
				panel.Style[HtmlTextWriterStyle.Display] = "none";
			else
				panel.Style[HtmlTextWriterStyle.Display] = String.Empty;

			string boxClientID = panel.ContainerClientID;

			writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
			writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
			writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0px");
			writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
			writer.RenderBeginTag(HtmlTextWriterTag.Table);

			writer.RenderBeginTag(HtmlTextWriterTag.Tr);

			writer.AddAttribute("relatedWebPart", panel.ClientID);
			writer.RenderBeginTag(HtmlTextWriterTag.Td);

			writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
			writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0px");
			writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "0px");
			writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
			writer.RenderBeginTag(HtmlTextWriterTag.Table);

			panel.HeaderStyle.AddAttributesToRender(writer);
			writer.RenderBeginTag(HtmlTextWriterTag.Tr);

			writer.AddAttribute(HtmlTextWriterAttribute.Title, panel.ToolTip);
			if (WebPartManager.SupportsClientSideDragDrop(this.zone.Page))
			{
				string dragCaption = (panel.DragCaption.Length > 0) ? panel.DragCaption : panel.Caption;
				writer.AddAttribute("onmousedown", String.Format("MoveWebPartStart('{0}', '{1}');", boxClientID, dragCaption));

				writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "move");
			}
			writer.RenderBeginTag(HtmlTextWriterTag.Td);

			Label titleBarCaption = new Label();
			titleBarCaption.ControlStyle.CopyFrom(panel.CaptionStyle);
			titleBarCaption.Text = panel.Caption;
			titleBarCaption.RenderControl(writer);

			writer.RenderEndTag();

			writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "right");
			panel.Verbs.ControlStyle.AddAttributesToRender(writer);
			writer.RenderBeginTag(HtmlTextWriterTag.Td);

			foreach (Control verb in panel.Verbs.Controls)
			{
				if (verb.Visible && !(verb is LiteralControl))
				{
					verb.RenderControl(writer);
				}
			}

			writer.RenderEndTag();

			writer.RenderEndTag();
			writer.RenderEndTag();
			writer.RenderEndTag();
			writer.RenderEndTag();

			writer.RenderBeginTag(HtmlTextWriterTag.Tr);

			writer.AddStyleAttribute("vertical-align", "top");
			writer.RenderBeginTag(HtmlTextWriterTag.Td);

			panel.RenderControl(writer);

			writer.RenderEndTag();
			writer.RenderEndTag();

			writer.RenderEndTag();
		}