Пример #1
0
        /// <exclude />
        public override void MergeWith(Style s)
        {
            if (s != null && IsEmpty)
            {
                CopyFrom(s);
                return;
            }

            base.MergeWith(s);

            MultiViewItemButtonStyle buttonStyle = s as MultiViewItemButtonStyle;

            if (buttonStyle != null && !buttonStyle.IsEmpty)
            {
                if (buttonStyle.IsBackImageUrlSet && !this.IsBackImageUrlSet)
                {
                    this.BackImageUrl = buttonStyle.BackImageUrl;
                }
                if (buttonStyle.IsHorizontalAlignSet && !this.IsHorizontalAlignSet)
                {
                    this.HorizontalAlign = buttonStyle.HorizontalAlign;
                }
                if (buttonStyle.IsWrapSet && !this.IsWrapSet)
                {
                    this.Wrap = buttonStyle.Wrap;
                }
            }
        }
        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();
            }
        }