예제 #1
0
        /// <exclude />
        protected virtual Boolean LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            String hiddenInputValue = postCollection[this.ClientSideCurrentItemTrackerID];

            if (hiddenInputValue != null)
            {
                MultiViewItem postedItem = this.ItemByIndex(hiddenInputValue);
                if (postedItem != null && this.CurrentItem != postedItem.Title)
                {
                    this.CurrentItem = postedItem.Title;
                    return(true);
                }
            }

            foreach (MultiViewItem item in this.Items)
            {
                if (postCollection[postDataKey + ":" + item.Title] != null || postCollection[postDataKey + ":" + item.Title + "_Image.x"] != null)
                {
                    this.CurrentItem = item.Title;
                    return(true);
                }
            }

            return(false);
        }
        protected void RenderDownLevelItemContent(HtmlTextWriter writer, MultiViewItem item)
        {
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                if (!this.Owner.Height.IsEmpty)
                {
                    writer.AddStyleAttribute("height", "100%");
                }
                writer.RenderBeginTag("tr");
                if (!this.Owner.Height.IsEmpty)
                {
                    writer.AddStyleAttribute("height", "100%");
                }
            }
            else
            {
                if (!this.Owner.Width.IsEmpty)
                {
                    writer.AddStyleAttribute("width", "100%");
                }
            }

            writer.RenderBeginTag("td");

            item.RenderControl(writer);

            writer.RenderEndTag();
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderEndTag();
            }
        }
예제 #3
0
        private void RegisterClientScript()
        {
            if (Page == null)
            {
                return;
            }

            String currentItemIndex = "0";

            for (Int32 i = 0; i < this.Items.Count; i++)
            {
                MultiViewItem item = this.Items[i];
                if (item.Title == this.CurrentItem)
                {
                    currentItemIndex = i.ToString(CultureInfo.InvariantCulture);
                    break;
                }
            }

            ClientScriptManager script = this.Page.ClientScript;

            //script.RegisterHiddenField( ClientSideCurrentItemTrackerID, currentItemIndex );
            script.RegisterClientScriptResource(typeof(MultiViewBar), "MetaBuilders.WebControls.Embedded.MultiViewBarScript.js");
            script.RegisterArrayDeclaration(arrayName, "{ ID:'" + this.ClientID + "', Placement:'" + this.ButtonPlacement.ToString() + "', Layout:'" + this.LayoutDirection.ToString() + "', HiddenID:'" + ClientSideCurrentItemTrackerID + "', ItemCount:'" + this.Items.Count.ToString(CultureInfo.InvariantCulture) + "' }");
            script.RegisterStartupScript(typeof(MultiViewBar), "startup", "MetaBuilders_MultiViewBar_Init(); " + String.Format(Resources.AjaxWorkaroundScript, "MetaBuilders_MultiViewBar_Init"), true);
        }
 /// <summary>
 /// Gets the index of the given item.
 /// </summary>
 public int GetItemIndex(MultiViewItem item)
 {
     if (this.owner.HasControls())
     {
         return(this.owner.Controls.IndexOf(item));
     }
     return(-1);
 }
예제 #5
0
        /// <exclude />
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            String currentItemIndex = "0";

            for (Int32 i = 0; i < this.Items.Count; i++)
            {
                MultiViewItem item = this.Items[i];
                if (item.Title == this.CurrentItem)
                {
                    currentItemIndex = i.ToString(CultureInfo.InvariantCulture);
                    break;
                }
            }

            writer.WriteBeginTag("input");
            writer.WriteAttribute("type", "hidden");
            writer.WriteAttribute("value", currentItemIndex);
            writer.WriteAttribute("id", ClientSideCurrentItemTrackerID);
            writer.WriteAttribute("name", ClientSideCurrentItemTrackerID);
            writer.Write(" />");

            base.RenderBeginTag(writer);
        }
        protected void RenderUplevelItemButton(HtmlTextWriter writer, MultiViewItem item)
        {
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderBeginTag("tr");
            }

            Boolean itemIsCurrent = (item.Title == this.ActiveItem);

            if (!itemIsCurrent)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.Owner.Page.ClientScript.GetPostBackEventReference(this.Owner, item.Title));
                writer.AddStyleAttribute("cursor", "pointer");
            }

            MultiViewItemButtonStyle itemStyle = new MultiViewItemButtonStyle();

            if (itemIsCurrent)
            {
                itemStyle.CopyFrom(this.Owner.CurrentButtonStyle);
            }
            itemStyle.MergeWith(this.Owner.ButtonStyle);
            itemStyle.AddAttributesToRender(writer);
            writer.AddStyleAttribute("padding", "5px");
            writer.RenderBeginTag("td");

            if (item.ImageUrl.Length != 0)
            {
                Image itemImageButton = new Image();
                if (!itemIsCurrent)
                {
                    itemImageButton.Attributes["onclick"] = this.Owner.Page.ClientScript.GetPostBackEventReference(this.Owner, item.Title);
                }
                itemImageButton.ImageUrl      = item.ImageUrl;
                itemImageButton.ImageAlign    = ImageAlign.Middle;
                itemImageButton.BorderWidth   = Unit.Pixel(0);
                itemImageButton.ToolTip       = item.Title;
                itemImageButton.AlternateText = item.Title;
                itemImageButton.RenderControl(writer);
                writer.Write("&nbsp;");
            }

            HyperLink buttonControl = new HyperLink();

            if (!itemIsCurrent && this.Owner.Page != null)
            {
                buttonControl.NavigateUrl = this.Owner.Page.ClientScript.GetPostBackClientHyperlink(this.Owner, item.Title);
            }
            else
            {
                buttonControl.NavigateUrl = "";
            }
            buttonControl.BorderWidth = Unit.Pixel(0);
            buttonControl.ForeColor   = itemStyle.ForeColor;
            buttonControl.Text        = item.Title;
            buttonControl.RenderControl(writer);

            writer.RenderEndTag();
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderEndTag();
            }
        }
        protected void RenderDownLevelItemButton(HtmlTextWriter writer, MultiViewItem item)
        {
            Boolean itemIsCurrent = (item.Title == this.ActiveItem);

            MultiViewItemButtonStyle itemStyle = new MultiViewItemButtonStyle();

            if (itemIsCurrent)
            {
                itemStyle.CopyFrom(this.Owner.CurrentButtonStyle);
            }
            itemStyle.MergeWith(this.Owner.ButtonStyle);

            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderBeginTag("tr");
            }

            itemStyle.AddAttributesToRender(writer);
            writer.AddStyleAttribute("padding", "5px");
            writer.RenderBeginTag("td");


            if (item.ImageUrl.Length != 0)
            {
                Image itemImageButton;
                if (itemIsCurrent)
                {
                    itemImageButton = new Image();
                }
                else
                {
                    itemImageButton    = new ImageButton();
                    itemImageButton.ID = this.Owner.UniqueID + ":" + item.Title + "_Image";
                }

                itemImageButton.ImageUrl      = item.ImageUrl;
                itemImageButton.ImageAlign    = ImageAlign.Middle;
                itemImageButton.BorderWidth   = Unit.Pixel(0);
                itemImageButton.ToolTip       = item.Title;
                itemImageButton.AlternateText = item.Title;
                itemImageButton.RenderControl(writer);
                writer.Write("&nbsp;");
            }

            if (itemIsCurrent)
            {
                writer.Write(item.Title);
            }
            else
            {
                Button itemButton = new Button();
                itemButton.ID        = this.Owner.UniqueID + ":" + item.Title;
                itemButton.Text      = item.Title;
                itemButton.ForeColor = itemStyle.ForeColor;
                itemButton.BackColor = itemStyle.BackColor;
                itemButton.RenderControl(writer);
            }

            writer.RenderEndTag();
            if (this.Owner.LayoutDirection == MultiViewLayoutDirection.Vertical)
            {
                writer.RenderEndTag();
            }
        }
 /// <summary>
 /// Removes the given <see cref="MultiViewItem"/> from the collection.
 /// </summary>
 public void Remove(MultiViewItem item)
 {
     this.owner.Controls.Remove(item);
 }
 /// <summary>
 /// Adds the given <see cref="MultiViewItem"/> to the collection at the given index.
 /// </summary>
 public void AddAt(int index, MultiViewItem item)
 {
     this.owner.Controls.AddAt(index, item);
 }
 /// <summary>
 /// Adds the given <see cref="MultiViewItem"/> to the collection.
 /// </summary>
 /// <returns>Returns the index of the item in the collection.</returns>
 public Int32 Add(MultiViewItem item)
 {
     this.AddAt(-1, item);
     return(this.owner.Controls.Count - 1);
 }