Ejemplo n.º 1
0
        /// <summary>
        /// Builds an image tab menu item control.
        /// </summary>
        /// <param name="styleTemplate">The style template.</param>
        /// <returns></returns>
        private Control CreateImageLinkItem(StyleTemplate styleTemplate)
        {
            LinkButton linkButton = new LinkButton();
            DynamicImage dynamicImage = new DynamicImage();

            // Copy the image styles from the level style
            if (styleTemplate != null)
            {
                dynamicImage.NormalStyle = CopyImageStyle(styleTemplate.ImageNormalStyle);
                dynamicImage.SelectedStyle = CopyImageStyle(styleTemplate.ImageSelectedStyle);
                dynamicImage.HoverStyle = CopyImageStyle(styleTemplate.ImageHoverStyle);
            }

            linkButton.CssClass = this.CssClass;

            dynamicImage.EnableTheming = false;

            linkButton.Click += this.OnLinkButtonClick;
            linkButton.Controls.Add(dynamicImage);

            return linkButton;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds the menu item control.
        /// </summary>
        /// <param name="styleTemplate">The style template.</param>
        public void BuildMenuItemControl(StyleTemplate styleTemplate)
        {
            // If this item has a style template defined, do
            // not inherit it from the menu's LevelStyles
            if (this.StyleTemplate != null)
            {
                // Inherit the display type if none has been defined.
                if (!this.StyleTemplate.DisplayType.HasValue && styleTemplate.DisplayType.HasValue)
                {
                    this.StyleTemplate.DisplayType = styleTemplate.DisplayType;
                }

                styleTemplate = this.StyleTemplate;
            }

            switch (styleTemplate.DisplayType.Value)
            {
                case LevelDisplayType.Text:
                    this._MenuItemControl = this.CreateLinkItem();
                    this.SetUpLinkItem();
                    this.SetUpTextLinkItem();
                    break;

                case LevelDisplayType.Image:
                    this._MenuItemControl = this.CreateImageLinkItem(styleTemplate);
                    this.SetUpLinkItem();
                    this.SetUpImageLinkItem();
                    break;

                default:
                    throw new NotImplementedException("The specified level display type has not been implemented.");
            }

            this._MenuItemControl.EnableViewState = false;
        }