protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType)
 {
     if (editorPart == null)
     {
         throw new ArgumentNullException("editorPart");
     }
     if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly))
     {
         throw new ArgumentOutOfRangeException("chromeType");
     }
     if ((chromeType == PartChromeType.BorderOnly) || (chromeType == PartChromeType.TitleAndBorder))
     {
         return this.Zone.PartChromeStyle;
     }
     if (this._chromeStyleNoBorder == null)
     {
         Style style = new Style();
         style.CopyFrom(this.Zone.PartChromeStyle);
         if (style.BorderStyle != BorderStyle.None)
         {
             style.BorderStyle = BorderStyle.None;
         }
         if (style.BorderWidth != Unit.Empty)
         {
             style.BorderWidth = Unit.Empty;
         }
         if (style.BorderColor != Color.Empty)
         {
             style.BorderColor = Color.Empty;
         }
         this._chromeStyleNoBorder = style;
     }
     return this._chromeStyleNoBorder;
 }
 private void CopyStyle(Style toStyle, Style fromStyle)
 {
     if ((fromStyle != null) && fromStyle.IsSet(0x2000))
     {
         toStyle.Font.Underline = fromStyle.Font.Underline;
     }
     toStyle.CopyFrom(fromStyle);
 }
Ejemplo n.º 3
0
 private void CopyStyle(Style toStyle, Style fromStyle)
 {
     if ((fromStyle != null) && fromStyle.IsSet(0x2000))
     {
         toStyle.Font.Underline = fromStyle.Font.Underline;
     }
     toStyle.CopyFrom(fromStyle);
 }
Ejemplo n.º 4
0
        private void CopyStyle(Style toStyle, Style fromStyle)
        {
            Debug.Assert(toStyle != null);

            // Review: How to change the default value of Font.Underline?
            if (fromStyle != null && fromStyle.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
            {
                toStyle.Font.Underline = fromStyle.Font.Underline;
            }

            toStyle.CopyFrom(fromStyle);
        }
Ejemplo n.º 5
0
        public virtual void AddAttributesToRender(HtmlTextWriter writer)
        {
            Menu                   owner              = Owner;
            Page                   page               = owner.Page;
            SubMenuStyle           staticMenuStyle    = owner.StaticMenuStyleInternal;
            SubMenuStyleCollection levelSubMenuStyles = owner.LevelSubMenuStylesInternal;
            bool                   haveSubStyles      = levelSubMenuStyles != null && levelSubMenuStyles.Count > 0;
            Style                  controlStyle       = haveSubStyles || staticMenuStyle != null ? owner.ControlStyle : null;

            if (page != null && page.Header != null)
            {
                // styles are registered
                if (staticMenuStyle != null)
                {
                    AddCssClass(controlStyle, staticMenuStyle.CssClass);
                    AddCssClass(controlStyle, staticMenuStyle.RegisteredCssClass);
                }
                if (haveSubStyles)
                {
                    AddCssClass(controlStyle, levelSubMenuStyles [0].CssClass);
                    AddCssClass(controlStyle, levelSubMenuStyles [0].RegisteredCssClass);
                }
            }
            else
            {
                // styles are not registered
                if (staticMenuStyle != null)
                {
                    controlStyle.CopyFrom(staticMenuStyle);
                }
                if (haveSubStyles)
                {
                    controlStyle.CopyFrom(levelSubMenuStyles [0]);
                }
            }
        }
        protected virtual Style CreateCatalogPartChromeStyle(CatalogPart catalogPart, PartChromeType chromeType) {
            if (catalogPart == null) {
                throw new ArgumentNullException("catalogPart");
            }
            if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) {
                throw new ArgumentOutOfRangeException("chromeType");
            }

            if (chromeType == PartChromeType.BorderOnly || chromeType == PartChromeType.TitleAndBorder) {
                if (_chromeStyleWithBorder == null) {
                    Style style = new Style();
                    style.CopyFrom(Zone.PartChromeStyle);

                    if (style.BorderStyle == BorderStyle.NotSet) {
                        style.BorderStyle = BorderStyle.Solid;
                    }
                    if (style.BorderWidth == Unit.Empty) {
                        style.BorderWidth = Unit.Pixel(1);
                    }
                    if (style.BorderColor == Color.Empty) {
                        style.BorderColor = Color.Black;
                    }

                    _chromeStyleWithBorder = style;
                }
                return _chromeStyleWithBorder;
            }
            else {
                if (_chromeStyleNoBorder == null) {
                    Style style = new Style();
                    style.CopyFrom(Zone.PartChromeStyle);

                    if (style.BorderStyle != BorderStyle.NotSet) {
                        style.BorderStyle = BorderStyle.NotSet;
                    }
                    if (style.BorderWidth != Unit.Empty) {
                        style.BorderWidth = Unit.Empty;
                    }
                    if (style.BorderColor != Color.Empty) {
                        style.BorderColor = Color.Empty;
                    }

                    _chromeStyleNoBorder = style;
                }
                return _chromeStyleNoBorder;
            }
        }
 private Style CreateChromeStyleNoBorder(Style partChromeStyle)
 {
     Style style = new Style();
     style.CopyFrom(this.Zone.PartChromeStyle);
     if (style.BorderStyle != BorderStyle.NotSet)
     {
         style.BorderStyle = BorderStyle.NotSet;
     }
     if (style.BorderWidth != Unit.Empty)
     {
         style.BorderWidth = Unit.Empty;
     }
     if (style.BorderColor != Color.Empty)
     {
         style.BorderColor = Color.Empty;
     }
     return style;
 }
 private Style CreateChromeStyleWithBorder(Style partChromeStyle)
 {
     Style style = new Style();
     style.CopyFrom(partChromeStyle);
     if (style.BorderStyle == BorderStyle.NotSet)
     {
         style.BorderStyle = BorderStyle.Solid;
     }
     if (style.BorderWidth == Unit.Empty)
     {
         style.BorderWidth = Unit.Pixel(1);
     }
     if (style.BorderColor == Color.Empty)
     {
         style.BorderColor = Color.Black;
     }
     return style;
 }
        protected virtual Style CreateEditorPartChromeStyle(EditorPart editorPart, PartChromeType chromeType) {
            if (editorPart == null) {
                throw new ArgumentNullException("editorPart");
            }
            if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) {
                throw new ArgumentOutOfRangeException("chromeType");
            }

            // PERF: Cache these, since they are needed for every EditorPart in the zone.
            if (chromeType == PartChromeType.BorderOnly || chromeType == PartChromeType.TitleAndBorder) {
                // We don't want to set any border styles for ChromeType of TitleAndBorder or BorderOnly,
                // since the FrameSet has a default border, and it will use XP themes as long as no border styles
                // are set.
                // PERF: Just return the Zone.PartChromeStyle directly without making a copy
                return Zone.PartChromeStyle;
            }
            else {
                if (_chromeStyleNoBorder == null) {
                    Style style = new Style();

                    // create copy of PartChromeStyle so we can modify it
                    style.CopyFrom(Zone.PartChromeStyle);

                    if (style.BorderStyle != BorderStyle.None) {
                        style.BorderStyle = BorderStyle.None;
                    }
                    if (style.BorderWidth != Unit.Empty) {
                        style.BorderWidth = Unit.Empty;
                    }
                    if (style.BorderColor != Color.Empty) {
                        style.BorderColor = Color.Empty;
                    }

                    _chromeStyleNoBorder = style;
                }
                return _chromeStyleNoBorder;
            }
        }
Ejemplo n.º 10
0
		public void Style_Copy ()
		{
			Style s = new Style ();
			Style copy = new Style ();

			SetSomeValues(s);

			copy.CopyFrom (s);
			Assert.AreEqual (Color.Red, s.BackColor, "Copy1");
		}
Ejemplo n.º 11
0
            private StyleBlock CreateStyleBlock()
            {
                StyleBlock styleBlock        = new StyleBlock();
                Style      rootMenuItemStyle = Menu.RootMenuItemStyle;

                // drop the font and forecolor from the control style, those are applied
                // to the anchors directly with rootMenuItemStyle.
                Style menuStyle = null;

                if (!Menu.ControlStyle.IsEmpty)
                {
                    menuStyle = new Style();
                    menuStyle.CopyFrom(Menu.ControlStyle);
                    // Relative sizes should not be multiplied (VSWhidbey 457610)
                    menuStyle.Font.Reset();
                    menuStyle.ForeColor = Color.Empty;
                }

                // Menu surrounding DIV style -- without ForeColor or Font,
                // those are applied directly to the '#Menu a' selector.

                styleBlock.AddStyleDefinition("#{0}", Menu.ClientID)
                .AddStyles(menuStyle);

                // Image styles

                styleBlock.AddStyleDefinition("#{0} img.icon", Menu.ClientID)
                .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                .AddStyle(HtmlTextWriterStyle.VerticalAlign, "middle");

                styleBlock.AddStyleDefinition("#{0} img.separator", Menu.ClientID)
                .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                .AddStyle(HtmlTextWriterStyle.Display, "block");

                if (Menu.Orientation == Orientation.Horizontal)
                {
                    styleBlock.AddStyleDefinition("#{0} img.horizontal-separator", Menu.ClientID)
                    .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                    .AddStyle(HtmlTextWriterStyle.VerticalAlign, "middle");
                }

                // Menu styles

                styleBlock.AddStyleDefinition("#{0} ul", Menu.ClientID)
                .AddStyle("list-style", "none")
                .AddStyle(HtmlTextWriterStyle.Margin, "0")
                .AddStyle(HtmlTextWriterStyle.Padding, "0")
                .AddStyle(HtmlTextWriterStyle.Width, "auto");

                styleBlock.AddStyleDefinition("#{0} ul.static", Menu.ClientID)
                .AddStyles(Menu._staticMenuStyle);

                var ulDynamic = styleBlock.AddStyleDefinition("#{0} ul.dynamic", Menu.ClientID)
                                .AddStyles(Menu._dynamicMenuStyle)
                                .AddStyle(HtmlTextWriterStyle.ZIndex, "1");

                if (Menu.DynamicHorizontalOffset != 0)
                {
                    ulDynamic.AddStyle(HtmlTextWriterStyle.MarginLeft, Menu.DynamicHorizontalOffset.ToString(CultureInfo.InvariantCulture) + "px");
                }

                if (Menu.DynamicVerticalOffset != 0)
                {
                    ulDynamic.AddStyle(HtmlTextWriterStyle.MarginTop, Menu.DynamicVerticalOffset.ToString(CultureInfo.InvariantCulture) + "px");
                }

                if (Menu._levelStyles != null)
                {
                    int index = 1;

                    foreach (SubMenuStyle style in Menu._levelStyles)
                    {
                        styleBlock.AddStyleDefinition("#{0} ul.level{1}", Menu.ClientID, index++)
                        .AddStyles(style);
                    }
                }

                // Menu item styles

                // MenuItems have a 14px default right padding.
                // This is necessary to prevent the default (and the typical) popout image from going under
                // the menu item text when it is one of the longer items in the parent menu.
                // It is 'px' based since its based on the image size not font size.
                styleBlock.AddStyleDefinition("#{0} a", Menu.ClientID)
                .AddStyle(HtmlTextWriterStyle.WhiteSpace, "nowrap")
                .AddStyle(HtmlTextWriterStyle.Display, "block")
                .AddStyles(rootMenuItemStyle);

                var menuItemStatic = styleBlock.AddStyleDefinition("#{0} a.static", Menu.ClientID);

                if ((Menu.Orientation == Orientation.Horizontal) &&
                    ((Menu._staticItemStyle == null) || (Menu._staticItemStyle.HorizontalPadding.IsEmpty)))
                {
                    menuItemStatic.AddStyle(HtmlTextWriterStyle.PaddingLeft, "0.15em")
                    .AddStyle(HtmlTextWriterStyle.PaddingRight, "0.15em");
                }
                menuItemStatic.AddStyles(Menu._staticItemStyle);

                if (Menu._staticItemStyle != null)
                {
                    menuItemStatic.AddStyles(Menu._staticItemStyle.HyperLinkStyle);
                }

                if (!String.IsNullOrEmpty(StaticPopOutUrl))
                {
                    styleBlock.AddStyleDefinition("#{0} a.popout", Menu.ClientID)
                    .AddStyle("background-image", "url(\"" + Menu.ResolveClientUrl(StaticPopOutUrl).Replace("\"", "\\\"") + "\")")
                    .AddStyle("background-repeat", "no-repeat")
                    .AddStyle("background-position", "right center")
                    .AddStyle(HtmlTextWriterStyle.PaddingRight, "14px");
                }

                if (!String.IsNullOrEmpty(DynamicPopOutUrl))
                {
                    // Check if dynamic popout is the same as the static one, so there's no need for a separate rule
                    if (DynamicPopOutUrl != StaticPopOutUrl)
                    {
                        styleBlock.AddStyleDefinition("#{0} a.popout-dynamic", Menu.ClientID)
                        .AddStyle("background", "url(\"" + Menu.ResolveClientUrl(DynamicPopOutUrl).Replace("\"", "\\\"") + "\") no-repeat right center")
                        .AddStyle(HtmlTextWriterStyle.PaddingRight, "14px");
                    }
                }

                var styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.dynamic", Menu.ClientID)
                                       .AddStyles(Menu._dynamicItemStyle);

                if (Menu._dynamicItemStyle != null)
                {
                    styleBlockStyles.AddStyles(Menu._dynamicItemStyle.HyperLinkStyle);
                }

                if (Menu._levelMenuItemStyles != null || Menu.StaticDisplayLevels > 1)
                {
                    int lastIndex = Menu.StaticDisplayLevels;
                    if (Menu._levelMenuItemStyles != null)
                    {
                        lastIndex = Math.Max(lastIndex, Menu._levelMenuItemStyles.Count);
                    }

                    for (int index = 0; index < lastIndex; ++index)
                    {
                        var style = styleBlock.AddStyleDefinition("#{0} a.level{1}", Menu.ClientID, index + 1);

                        if (index > 0 && index < Menu.StaticDisplayLevels)
                        {
                            Unit indent = Menu.StaticSubMenuIndent;

                            // The default value of Menu.StaticSubMenuIndent is Unit.Empty, and the effective default value
                            // for list rendering is either 1em (vertical) or empty (horizontal).
                            if (indent.IsEmpty && Menu.Orientation == Orientation.Vertical)
                            {
                                indent = new Unit(1, UnitType.Em);
                            }

                            if (!indent.IsEmpty && indent.Value != 0)
                            {
                                double indentValue = indent.Value * index;
                                if (indentValue < Unit.MaxValue)
                                {
                                    indent = new Unit(indentValue, indent.Type);
                                }
                                else
                                {
                                    indent = new Unit(Unit.MaxValue, indent.Type);
                                }

                                style.AddStyle(HtmlTextWriterStyle.PaddingLeft, indent.ToString(CultureInfo.InvariantCulture));
                            }
                        }

                        if (Menu._levelMenuItemStyles != null && index < Menu._levelMenuItemStyles.Count)
                        {
                            var levelItemStyle = Menu._levelMenuItemStyles[index];
                            style.AddStyles(levelItemStyle).AddStyles(levelItemStyle.HyperLinkStyle);
                        }
                    }
                }

                styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.static.selected", Menu.ClientID)
                                   .AddStyles(Menu._staticSelectedStyle);
                if (Menu._staticSelectedStyle != null)
                {
                    styleBlockStyles.AddStyles(Menu._staticSelectedStyle.HyperLinkStyle);
                }

                styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.dynamic.selected", Menu.ClientID)
                                   .AddStyles(Menu._dynamicSelectedStyle);
                if (Menu._dynamicSelectedStyle != null)
                {
                    styleBlockStyles.AddStyles(Menu._dynamicSelectedStyle.HyperLinkStyle);
                }

                styleBlock.AddStyleDefinition("#{0} a.static.highlighted", Menu.ClientID)
                .AddStyles(Menu._staticHoverStyle);

                styleBlock.AddStyleDefinition("#{0} a.dynamic.highlighted", Menu.ClientID)
                .AddStyles(Menu._dynamicHoverStyle);

                if (Menu._levelSelectedStyles != null)
                {
                    int index = 1;

                    foreach (MenuItemStyle style in Menu._levelSelectedStyles)
                    {
                        styleBlock.AddStyleDefinition("#{0} a.selected.level{1}", Menu.ClientID, index++)
                        .AddStyles(style).AddStyles(style.HyperLinkStyle);
                    }
                }

                return(styleBlock);
            }
Ejemplo n.º 12
0
 private void LoadCurrentTemplate()
 {
     int selectedIndex = this._templateCombo.SelectedIndex;
     int index = this._templateGroupCombo.SelectedIndex;
     if ((index != -1) && (selectedIndex != -1))
     {
         TemplateEditingFrame editingFrame = this._frames[index];
         string templateName = editingFrame.TemplateNames[selectedIndex];
         this._activeTemplateName = templateName;
         string content = (string) editingFrame.ChangeTable[templateName];
         if (content == null)
         {
             bool allowEditing = false;
             content = this._designer.GetTemplateContent(editingFrame, templateName, out allowEditing);
         }
         IDocumentDesignerHost service = (IDocumentDesignerHost) base.ServiceProvider.GetService(typeof(IDocumentDesignerHost));
         ILayeredDesignerHost host2 = (ILayeredDesignerHost) base.ServiceProvider.GetService(typeof(ILayeredDesignerHost));
         string str3 = this.GenerateLayerKey(this._templateGroupCombo.Text, this._templateCombo.Text);
         host2.ActiveLayer = (IDesignLayer) this.Layers[str3];
         service.BeginLoad();
         try
         {
             Style style = new Style();
             style.CopyFrom(editingFrame.ControlStyle);
             if (editingFrame.TemplateStyles != null)
             {
                 style.CopyFrom(editingFrame.TemplateStyles[selectedIndex]);
             }
             string str4 = string.Format("<style>body {{ {0} }}</style>", this.StyleToCss(style));
             string url = this._parentEditor.Url;
             if (content != null)
             {
                 this._designView.Editor.LoadHtml(content, url, str4);
             }
             else
             {
                 this._designView.Editor.LoadHtml(string.Empty, url, str4);
             }
         }
         finally
         {
             service.EndLoad();
         }
     }
 }
Ejemplo n.º 13
0
		void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool notLast, bool isFirst) {
			bool displayChildren = DisplayChildren (item);
			bool dynamicChildren = displayChildren && (item.Depth + 1 >= StaticDisplayLevels);
			bool isDynamicItem = IsDynamicItem (item);
			bool vertical = (Orientation == Orientation.Vertical) || isDynamicItem;
			
			Unit itemSpacing = GetItemSpacing (item, isDynamicItem);

			if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst))
				RenderMenuItemSpacing (writer, itemSpacing, vertical);

			if(!String.IsNullOrEmpty(item.ToolTip))
				writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip);
			if (vertical)
				writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null";
			if (dynamicChildren) {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')");
			} else if (isDynamicItem) {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverDynamicLeafItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "'," + parentId + ")");
			} else {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverStaticLeafItem ('" + ClientID + "','" + item.Path + "')");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + ClientID + "','" + item.Path + "')");
			}

			writer.RenderBeginTag (HtmlTextWriterTag.Td);

			// Top separator image

			if (isDynamicItem && DynamicTopSeparatorImageUrl != "") {
				writer.AddAttribute ("src", ResolveClientUrl (DynamicTopSeparatorImageUrl));
				writer.RenderBeginTag (HtmlTextWriterTag.Img);
				writer.RenderEndTag ();	// IMG
			}
			else if (!isDynamicItem && StaticTopSeparatorImageUrl != "") {
				writer.AddAttribute ("src", ResolveClientUrl (StaticTopSeparatorImageUrl));
				writer.RenderBeginTag (HtmlTextWriterTag.Img);
				writer.RenderEndTag ();	// IMG
			}

			// Menu item box
			
			MenuItemStyle style = new MenuItemStyle ();
			if (Page.Header != null) {
				// styles are registered
				if (!isDynamicItem && staticMenuItemStyle != null) {
					AddCssClass (style, staticMenuItemStyle.CssClass);
					AddCssClass (style, staticMenuItemStyle.RegisteredCssClass);
				}
				if (isDynamicItem && dynamicMenuItemStyle != null) {
					AddCssClass (style, dynamicMenuItemStyle.CssClass);
					AddCssClass (style, dynamicMenuItemStyle.RegisteredCssClass);
				}
				if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) {
					AddCssClass (style, levelMenuItemStyles [item.Depth].CssClass);
					AddCssClass (style, levelMenuItemStyles [item.Depth].RegisteredCssClass);
				}
				if (item == SelectedItem) {
					if (!isDynamicItem && staticSelectedStyle != null) {
						AddCssClass (style, staticSelectedStyle.CssClass);
						AddCssClass (style, staticSelectedStyle.RegisteredCssClass);
					}
					if (isDynamicItem && dynamicSelectedStyle != null) {
						AddCssClass (style, dynamicSelectedStyle.CssClass);
						AddCssClass (style, dynamicSelectedStyle.RegisteredCssClass);
					}
					if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) {
						AddCssClass (style, levelSelectedStyles [item.Depth].CssClass);
						AddCssClass (style, levelSelectedStyles [item.Depth].RegisteredCssClass);
					}
				}
			}
			else {
				// styles are not registered
				if (!isDynamicItem && staticMenuItemStyle != null) {
					style.CopyFrom (staticMenuItemStyle);
				}
				if (isDynamicItem && dynamicMenuItemStyle != null) {
					style.CopyFrom (dynamicMenuItemStyle);
				}
				if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) {
					style.CopyFrom (levelMenuItemStyles [item.Depth]);
				}
				if (item == SelectedItem) {
					if (!isDynamicItem && staticSelectedStyle != null) {
						style.CopyFrom (staticSelectedStyle);
					}
					if (isDynamicItem && dynamicSelectedStyle != null) {
						style.CopyFrom (dynamicSelectedStyle);
					}
					if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) {
						style.CopyFrom (levelSelectedStyles [item.Depth]);
					}
				}
			}
			style.AddAttributesToRender (writer);

			writer.AddAttribute ("id", GetItemClientId (item, "i"));

			writer.AddAttribute ("cellpadding", "0", false);
			writer.AddAttribute ("cellspacing", "0", false);
			writer.AddAttribute ("border", "0", false);
			writer.AddAttribute ("width", "100%", false);
			writer.RenderBeginTag (HtmlTextWriterTag.Table);
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			// Menu item text

			if (vertical)
				writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
			if (!ItemWrap)
				writer.AddStyleAttribute ("white-space", "nowrap");
			writer.RenderBeginTag (HtmlTextWriterTag.Td);

			RenderItemHref (writer, item);
			
			Style linkStyle = new Style ();
			if (Page.Header != null) {
				// styles are registered
				AddCssClass (linkStyle, ControlLinkStyle.RegisteredCssClass);

				if (!isDynamicItem && staticMenuItemStyle != null) {
					AddCssClass (linkStyle, staticMenuItemStyle.CssClass);
					AddCssClass (linkStyle, staticMenuItemLinkStyle.RegisteredCssClass);
				}
				if (isDynamicItem && dynamicMenuItemStyle != null) {
					AddCssClass (linkStyle, dynamicMenuItemStyle.CssClass);
					AddCssClass (linkStyle, dynamicMenuItemLinkStyle.RegisteredCssClass);
				}
				if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) {
					AddCssClass (linkStyle, levelMenuItemStyles [item.Depth].CssClass);
					AddCssClass (linkStyle, levelMenuItemLinkStyles [item.Depth].RegisteredCssClass);
				}
				if (item == SelectedItem) {
					if (!isDynamicItem && staticSelectedStyle != null) {
						AddCssClass (linkStyle, staticSelectedStyle.CssClass);
						AddCssClass (linkStyle, staticSelectedLinkStyle.RegisteredCssClass);
					}
					if (isDynamicItem && dynamicSelectedStyle != null) {
						AddCssClass (linkStyle, dynamicSelectedStyle.CssClass);
						AddCssClass (linkStyle, dynamicSelectedLinkStyle.RegisteredCssClass);
					}
					if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) {
						AddCssClass (linkStyle, levelSelectedStyles [item.Depth].CssClass);
						AddCssClass (linkStyle, levelSelectedLinkStyles [item.Depth].RegisteredCssClass);
					}
				}
			}
			else {
				// styles are not registered
				linkStyle.CopyFrom (ControlLinkStyle);

				if (!isDynamicItem && staticMenuItemStyle != null) {
					linkStyle.CopyFrom (staticMenuItemLinkStyle);
				}
				if (isDynamicItem && dynamicMenuItemStyle != null) {
					linkStyle.CopyFrom (dynamicMenuItemLinkStyle);
				}
				if (levelMenuItemStyles != null && levelMenuItemStyles.Count > item.Depth) {
					linkStyle.CopyFrom (levelMenuItemLinkStyles [item.Depth]);
				}
				if (item == SelectedItem) {
					if (!isDynamicItem && staticSelectedStyle != null) {
						linkStyle.CopyFrom (staticSelectedLinkStyle);
					}
					if (isDynamicItem && dynamicSelectedStyle != null) {
						linkStyle.CopyFrom (dynamicSelectedLinkStyle);
					}
					if (levelSelectedStyles != null && levelSelectedStyles.Count > item.Depth) {
						linkStyle.CopyFrom (levelSelectedLinkStyles [item.Depth]);
					}
				}

				linkStyle.AlwaysRenderTextDecoration = true;
			}
			linkStyle.AddAttributesToRender (writer);

			writer.AddAttribute ("id", GetItemClientId (item, "l"));
			
			if (item.Depth > 0 && !isDynamicItem) {
				Unit indent = new Unit (StaticSubMenuIndent.Value * item.Depth, StaticSubMenuIndent.Type);
				writer.AddStyleAttribute ("margin-left", indent.ToString ());
			}
			writer.RenderBeginTag (HtmlTextWriterTag.A);
			RenderItemContent (writer, item, isDynamicItem);
			writer.RenderEndTag ();	// A

			writer.RenderEndTag ();	// TD

			// Popup image

			if (dynamicChildren) {
				string popOutImage = GetPopOutImage (item, isDynamicItem);
				if (popOutImage != null) {
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
					writer.AddAttribute ("src", ResolveClientUrl (popOutImage));
					writer.AddAttribute ("border", "0");
					string toolTip = String.Format (isDynamicItem ? DynamicPopOutImageTextFormatString : StaticPopOutImageTextFormatString, item.Text);
					writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip);
					writer.RenderBeginTag (HtmlTextWriterTag.Img);
					writer.RenderEndTag ();	// IMG
					writer.RenderEndTag ();	// TD
				}
			}

			writer.RenderEndTag ();	// TR
			writer.RenderEndTag ();	// TABLE
			
			writer.RenderEndTag ();	// TD

			if (!vertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) {
				writer.AddStyleAttribute ("width", "3px");
				writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.RenderEndTag ();
			}
			
			// Bottom separator image
			string separatorImg = item.SeparatorImageUrl;
			if (separatorImg.Length == 0) {
				if (isDynamicItem)
					separatorImg = DynamicBottomSeparatorImageUrl;
				else
					separatorImg = StaticBottomSeparatorImageUrl;
			}
			if (separatorImg.Length > 0) {
				if (!vertical)
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.AddAttribute ("src", ResolveClientUrl (separatorImg));
				writer.RenderBeginTag (HtmlTextWriterTag.Img);
				writer.RenderEndTag ();	// IMG
				if (!vertical)
					writer.RenderEndTag (); // TD
			}

			if (vertical)
				writer.RenderEndTag ();	// TR

			if (itemSpacing != Unit.Empty)
				RenderMenuItemSpacing (writer, itemSpacing, vertical);

			// Submenu

			if (displayChildren && !dynamicChildren) {
				if (vertical)
					writer.RenderBeginTag (HtmlTextWriterTag.Tr);
				writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.AddAttribute ("width", "100%");
				RenderMenu (writer, item.ChildItems, Orientation == Orientation.Vertical, false, item.Depth + 1, notLast);
				if (item.Depth + 2 == StaticDisplayLevels)
					RenderDynamicMenu (writer, item.ChildItems);
				writer.RenderEndTag ();	// TD
				if (vertical)
					writer.RenderEndTag ();	// TR
			}

		}
Ejemplo n.º 14
0
		protected override void RenderMenuItem (HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc)
		{
			Menu owner = Owner;
			string clientID = oc.ClientID;
			bool displayChildren = owner.DisplayChildren (item);
			bool dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels);
			bool isDynamicItem = IsDynamicItem (owner, item);
			bool isVertical = oc.IsVertical || isDynamicItem;
			Unit itemSpacing = owner.GetItemSpacing (item, isDynamicItem);

			if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst))
				RenderMenuItemSpacing (writer, itemSpacing, isVertical);

			if(!String.IsNullOrEmpty(item.ToolTip))
				writer.AddAttribute (HtmlTextWriterAttribute.Title, item.ToolTip);
			if (isVertical)
				writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null";
			if (dynamicChildren) {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')");
			} else if (isDynamicItem) {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
			} else {
				writer.AddAttribute ("onmouseover",
						     "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')");
				writer.AddAttribute ("onmouseout",
						     "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')");
			}

			writer.RenderBeginTag (HtmlTextWriterTag.Td);

			// Top separator image

			if (isDynamicItem)
				RenderSeparatorImage (owner, writer, oc.DynamicTopSeparatorImageUrl, false);
			else
				RenderSeparatorImage (owner, writer, oc.StaticTopSeparatorImageUrl, false);

			// Menu item box
			
			MenuItemStyle style = new MenuItemStyle ();
				
			if (oc.Header != null) {
				// styles are registered
				if (!isDynamicItem && oc.StaticMenuItemStyle != null) {
					AddCssClass (style, oc.StaticMenuItemStyle.CssClass);
					AddCssClass (style, oc.StaticMenuItemStyle.RegisteredCssClass);
				}
				if (isDynamicItem && oc.DynamicMenuItemStyle != null) {
					AddCssClass (style, oc.DynamicMenuItemStyle.CssClass);
					AddCssClass (style, oc.DynamicMenuItemStyle.RegisteredCssClass);
				}
				if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) {
					AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].CssClass);
					AddCssClass (style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass);
				}
				if (item == oc.SelectedItem) {
					if (!isDynamicItem && oc.StaticSelectedStyle != null) {
						AddCssClass (style, oc.StaticSelectedStyle.CssClass);
						AddCssClass (style, oc.StaticSelectedStyle.RegisteredCssClass);
					}
					if (isDynamicItem && oc.DynamicSelectedStyle != null) {
						AddCssClass (style, oc.DynamicSelectedStyle.CssClass);
						AddCssClass (style, oc.DynamicSelectedStyle.RegisteredCssClass);
					}
					if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) {
						AddCssClass (style, oc.LevelSelectedStyles [item.Depth].CssClass);
						AddCssClass (style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass);
					}
				}
			} else {
				// styles are not registered
				if (!isDynamicItem && oc.StaticMenuItemStyle != null)
					style.CopyFrom (oc.StaticMenuItemStyle);
				if (isDynamicItem && oc.DynamicMenuItemStyle != null)
					style.CopyFrom (oc.DynamicMenuItemStyle);
				if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
					style.CopyFrom (oc.LevelMenuItemStyles [item.Depth]);
				if (item == oc.SelectedItem) {
					if (!isDynamicItem && oc.StaticSelectedStyle != null)
						style.CopyFrom (oc.StaticSelectedStyle);
					if (isDynamicItem && oc.DynamicSelectedStyle != null)
						style.CopyFrom (oc.DynamicSelectedStyle);
					if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
						style.CopyFrom (oc.LevelSelectedStyles [item.Depth]);
				}
			}
			style.AddAttributesToRender (writer);

			writer.AddAttribute ("id", GetItemClientId (clientID, item, "i"));
			writer.AddAttribute ("cellpadding", "0", false);
			writer.AddAttribute ("cellspacing", "0", false);
			writer.AddAttribute ("border", "0", false);
			writer.AddAttribute ("width", "100%", false);
			writer.RenderBeginTag (HtmlTextWriterTag.Table);
			writer.RenderBeginTag (HtmlTextWriterTag.Tr);

			// Menu item text

			if (isVertical)
				writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
			if (!owner.ItemWrap)
				writer.AddStyleAttribute ("white-space", "nowrap");
			writer.RenderBeginTag (HtmlTextWriterTag.Td);

			RenderItemHref (owner, writer, item);
			
			Style linkStyle = new Style ();
			if (oc.Header != null) {
				// styles are registered
				AddCssClass (linkStyle, oc.ControlLinkStyle.RegisteredCssClass);

				if (!isDynamicItem && oc.StaticMenuItemStyle != null) {
					AddCssClass (linkStyle, oc.StaticMenuItemStyle.CssClass);
					AddCssClass (linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass);
				}
				if (isDynamicItem && oc.DynamicMenuItemStyle != null) {
					AddCssClass (linkStyle, oc.DynamicMenuItemStyle.CssClass);
					AddCssClass (linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass);
				}
				if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth) {
					AddCssClass (linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass);
					AddCssClass (linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass);
				}
				if (item == oc.SelectedItem) {
					if (!isDynamicItem && oc.StaticSelectedStyle != null) {
						AddCssClass (linkStyle, oc.StaticSelectedStyle.CssClass);
						AddCssClass (linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass);
					}
					if (isDynamicItem && oc.DynamicSelectedStyle != null) {
						AddCssClass (linkStyle, oc.DynamicSelectedStyle.CssClass);
						AddCssClass (linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass);
					}
					if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth) {
						AddCssClass (linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass);
						AddCssClass (linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass);
					}
				}
			} else {
				// styles are not registered
				linkStyle.CopyFrom (oc.ControlLinkStyle);

				if (!isDynamicItem && oc.StaticMenuItemStyle != null)
					linkStyle.CopyFrom (oc.StaticMenuItemLinkStyle);
				if (isDynamicItem && oc.DynamicMenuItemStyle != null)
					linkStyle.CopyFrom (oc.DynamicMenuItemLinkStyle);
				if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
					linkStyle.CopyFrom (oc.LevelMenuItemLinkStyles [item.Depth]);
				if (item == oc.SelectedItem) {
					if (!isDynamicItem && oc.StaticSelectedStyle != null)
						linkStyle.CopyFrom (oc.StaticSelectedLinkStyle);
					if (isDynamicItem && oc.DynamicSelectedStyle != null)
						linkStyle.CopyFrom (oc.DynamicSelectedLinkStyle);
					if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
						linkStyle.CopyFrom (oc.LevelSelectedLinkStyles [item.Depth]);
				}

				linkStyle.AlwaysRenderTextDecoration = true;
			}
			linkStyle.AddAttributesToRender (writer);

			writer.AddAttribute ("id", GetItemClientId (clientID, item, "l"));
			
			if (item.Depth > 0 && !isDynamicItem) {
				double value;
				Unit unit = oc.StaticSubMenuIndent;
				if (unit == Unit.Empty)
					value = 16;
				else
					value = unit.Value;
				Unit indent = new Unit (value * item.Depth, oc.StaticSubMenuIndent.Type);
				writer.AddStyleAttribute (HtmlTextWriterStyle.MarginLeft, indent.ToString ());
			}
			writer.RenderBeginTag (HtmlTextWriterTag.A);
			owner.RenderItemContent (writer, item, isDynamicItem);
			writer.RenderEndTag ();	// A

			writer.RenderEndTag ();	// TD

			// Popup image

			if (dynamicChildren) {
				string popOutImage = GetPopOutImage (owner, item, isDynamicItem);
				if (popOutImage != null) {
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
					writer.AddAttribute ("src", owner.ResolveClientUrl (popOutImage));
					writer.AddAttribute ("border", "0");
					string toolTip = String.Format (isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text);
					writer.AddAttribute (HtmlTextWriterAttribute.Alt, toolTip);
					writer.RenderBeginTag (HtmlTextWriterTag.Img);
					writer.RenderEndTag ();	// IMG
					writer.RenderEndTag ();	// TD
				}
			}

			writer.RenderEndTag ();	// TR
			writer.RenderEndTag ();	// TABLE
			
			writer.RenderEndTag ();	// TD

			if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren))) {
				writer.AddStyleAttribute ("width", "3px");
				writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.RenderEndTag ();
			}
			
			// Bottom separator image
			string separatorImg = item.SeparatorImageUrl;
			if (separatorImg.Length == 0) {
				if (isDynamicItem)
					separatorImg = oc.DynamicBottomSeparatorImageUrl;
				else
					separatorImg = oc.StaticBottomSeparatorImageUrl;
			}
			
			if (separatorImg.Length > 0) {
				if (!isVertical)
					writer.RenderBeginTag (HtmlTextWriterTag.Td);
				RenderSeparatorImage (owner, writer, separatorImg, false);
				if (!isVertical)
					writer.RenderEndTag (); // TD
			}

			if (isVertical)
				writer.RenderEndTag ();	// TR

			if (itemSpacing != Unit.Empty)
				RenderMenuItemSpacing (writer, itemSpacing, isVertical);

			// Submenu

			if (displayChildren && !dynamicChildren) {
				if (isVertical)
					writer.RenderBeginTag (HtmlTextWriterTag.Tr);
				writer.RenderBeginTag (HtmlTextWriterTag.Td);
				writer.AddAttribute ("width", "100%");
				owner.RenderMenu (writer, item.ChildItems, vertical, false, item.Depth + 1, notLast);
				if (item.Depth + 2 == oc.StaticDisplayLevels)
					owner.RenderDynamicMenu (writer, item.ChildItems);
				writer.RenderEndTag ();	// TD
				if (isVertical)
					writer.RenderEndTag ();	// TR
			}
		}
            private StyleBlock CreateStyleBlock() {
                StyleBlock styleBlock = new StyleBlock();
                Style rootMenuItemStyle = Menu.RootMenuItemStyle;

                // drop the font and forecolor from the control style, those are applied
                // to the anchors directly with rootMenuItemStyle.
                Style menuStyle = null;
                if (!Menu.ControlStyle.IsEmpty) {
                    menuStyle = new Style();
                    menuStyle.CopyFrom(Menu.ControlStyle);
                    // Relative sizes should not be multiplied (VSWhidbey 457610)
                    menuStyle.Font.Reset();
                    menuStyle.ForeColor = Color.Empty;
                }

                // Menu surrounding DIV style -- without ForeColor or Font,
                // those are applied directly to the '#Menu a' selector.

                styleBlock.AddStyleDefinition("#{0}", Menu.ClientID)
                          .AddStyles(menuStyle);

                // Image styles

                styleBlock.AddStyleDefinition("#{0} img.icon", Menu.ClientID)
                          .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                          .AddStyle(HtmlTextWriterStyle.VerticalAlign, "middle");

                styleBlock.AddStyleDefinition("#{0} img.separator", Menu.ClientID)
                          .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                          .AddStyle(HtmlTextWriterStyle.Display, "block");

                if (Menu.Orientation == Orientation.Horizontal) {
                    styleBlock.AddStyleDefinition("#{0} img.horizontal-separator", Menu.ClientID)
                              .AddStyle(HtmlTextWriterStyle.BorderStyle, "none")
                              .AddStyle(HtmlTextWriterStyle.VerticalAlign, "middle");
                }

                // Menu styles

                styleBlock.AddStyleDefinition("#{0} ul", Menu.ClientID)
                          .AddStyle("list-style", "none")
                          .AddStyle(HtmlTextWriterStyle.Margin, "0")
                          .AddStyle(HtmlTextWriterStyle.Padding, "0")
                          .AddStyle(HtmlTextWriterStyle.Width, "auto");

                styleBlock.AddStyleDefinition("#{0} ul.static", Menu.ClientID)
                          .AddStyles(Menu._staticMenuStyle);

                var ulDynamic = styleBlock.AddStyleDefinition("#{0} ul.dynamic", Menu.ClientID)
                                          .AddStyles(Menu._dynamicMenuStyle)
                                          .AddStyle(HtmlTextWriterStyle.ZIndex, "1");

                if (Menu.DynamicHorizontalOffset != 0) {
                    ulDynamic.AddStyle(HtmlTextWriterStyle.MarginLeft, Menu.DynamicHorizontalOffset.ToString(CultureInfo.InvariantCulture) + "px");
                }

                if (Menu.DynamicVerticalOffset != 0) {
                    ulDynamic.AddStyle(HtmlTextWriterStyle.MarginTop, Menu.DynamicVerticalOffset.ToString(CultureInfo.InvariantCulture) + "px");
                }

                if (Menu._levelStyles != null) {
                    int index = 1;

                    foreach (SubMenuStyle style in Menu._levelStyles) {
                        styleBlock.AddStyleDefinition("#{0} ul.level{1}", Menu.ClientID, index++)
                                  .AddStyles(style);
                    }
                }

                // Menu item styles

                // MenuItems have a 14px default right padding.
                // This is necessary to prevent the default (and the typical) popout image from going under
                // the menu item text when it is one of the longer items in the parent menu.
                // It is 'px' based since its based on the image size not font size.
                styleBlock.AddStyleDefinition("#{0} a", Menu.ClientID)
                          .AddStyle(HtmlTextWriterStyle.WhiteSpace, "nowrap")
                          .AddStyle(HtmlTextWriterStyle.Display, "block")
                          .AddStyles(rootMenuItemStyle);

                var menuItemStatic = styleBlock.AddStyleDefinition("#{0} a.static", Menu.ClientID);
                if ((Menu.Orientation == Orientation.Horizontal) &&
                    ((Menu._staticItemStyle == null) || (Menu._staticItemStyle.HorizontalPadding.IsEmpty))) {
                    menuItemStatic.AddStyle(HtmlTextWriterStyle.PaddingLeft, "0.15em")
                                  .AddStyle(HtmlTextWriterStyle.PaddingRight, "0.15em");
                }
                menuItemStatic.AddStyles(Menu._staticItemStyle);

                if (Menu._staticItemStyle != null) {
                    menuItemStatic.AddStyles(Menu._staticItemStyle.HyperLinkStyle);
                }

                if (!String.IsNullOrEmpty(StaticPopOutUrl)) {
                    styleBlock.AddStyleDefinition("#{0} a.popout", Menu.ClientID)
                        .AddStyle("background-image", "url(\"" + Menu.ResolveClientUrl(StaticPopOutUrl).Replace("\"", "\\\"") + "\")")
                        .AddStyle("background-repeat", "no-repeat")
                        .AddStyle("background-position", "right center")
                        .AddStyle(HtmlTextWriterStyle.PaddingRight, "14px");
                }

                if (!String.IsNullOrEmpty(DynamicPopOutUrl)) {
                    // Check if dynamic popout is the same as the static one, so there's no need for a separate rule
                    if (DynamicPopOutUrl != StaticPopOutUrl) {
                        styleBlock.AddStyleDefinition("#{0} a.popout-dynamic", Menu.ClientID)
                            .AddStyle("background", "url(\"" + Menu.ResolveClientUrl(DynamicPopOutUrl).Replace("\"", "\\\"") + "\") no-repeat right center")
                            .AddStyle(HtmlTextWriterStyle.PaddingRight, "14px");
                    }
                }

                var styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.dynamic", Menu.ClientID)
                    .AddStyles(Menu._dynamicItemStyle);
                if (Menu._dynamicItemStyle != null) {
                    styleBlockStyles.AddStyles(Menu._dynamicItemStyle.HyperLinkStyle);
                }

                if (Menu._levelMenuItemStyles != null || Menu.StaticDisplayLevels > 1) {
                    int lastIndex = Menu.StaticDisplayLevels;
                    if (Menu._levelMenuItemStyles != null) {
                        lastIndex = Math.Max(lastIndex, Menu._levelMenuItemStyles.Count);
                    }

                    for (int index = 0; index < lastIndex; ++index) {
                        var style = styleBlock.AddStyleDefinition("#{0} a.level{1}", Menu.ClientID, index + 1);

                        if (index > 0 && index < Menu.StaticDisplayLevels) {
                            Unit indent = Menu.StaticSubMenuIndent;
                            
                            // The default value of Menu.StaticSubMenuIndent is Unit.Empty, and the effective default value
                            // for list rendering is either 1em (vertical) or empty (horizontal).
                            if (indent.IsEmpty && Menu.Orientation == Orientation.Vertical) {
                                indent = new Unit(1, UnitType.Em);
                            }

                            if (!indent.IsEmpty && indent.Value != 0) {
                                double indentValue = indent.Value * index;
                                if (indentValue < Unit.MaxValue) {
                                    indent = new Unit(indentValue, indent.Type);
                                }
                                else {
                                    indent = new Unit(Unit.MaxValue, indent.Type);
                                }

                                style.AddStyle(HtmlTextWriterStyle.PaddingLeft, indent.ToString(CultureInfo.InvariantCulture));
                            }
                        }

                        if (Menu._levelMenuItemStyles != null && index < Menu._levelMenuItemStyles.Count) {
                            var levelItemStyle = Menu._levelMenuItemStyles[index];
                            style.AddStyles(levelItemStyle).AddStyles(levelItemStyle.HyperLinkStyle);
                        }
                    }
                }

                styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.static.selected", Menu.ClientID)
                          .AddStyles(Menu._staticSelectedStyle);
                if (Menu._staticSelectedStyle != null) {
                    styleBlockStyles.AddStyles(Menu._staticSelectedStyle.HyperLinkStyle);
                }

                styleBlockStyles = styleBlock.AddStyleDefinition("#{0} a.dynamic.selected", Menu.ClientID)
                          .AddStyles(Menu._dynamicSelectedStyle);
                if (Menu._dynamicSelectedStyle != null) {
                    styleBlockStyles.AddStyles(Menu._dynamicSelectedStyle.HyperLinkStyle);
                }

                styleBlock.AddStyleDefinition("#{0} a.static.highlighted", Menu.ClientID)
                          .AddStyles(Menu._staticHoverStyle);

                styleBlock.AddStyleDefinition("#{0} a.dynamic.highlighted", Menu.ClientID)
                          .AddStyles(Menu._dynamicHoverStyle);

                if (Menu._levelSelectedStyles != null) {
                    int index = 1;

                    foreach (MenuItemStyle style in Menu._levelSelectedStyles) {
                        styleBlock.AddStyleDefinition("#{0} a.selected.level{1}", Menu.ClientID, index++)
                                  .AddStyles(style).AddStyles(style.HyperLinkStyle);
                    }
                }

                return styleBlock;
            }
Ejemplo n.º 16
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (DesignMode)
            {
                writer.Write(String.Format(System.Globalization.CultureInfo.InvariantCulture,
                "<div><table width=\"{0}\" height=\"{1}\" bgcolor=\"#f5f5f5\" bordercolor=\"#c7c7c7\" cellpadding=\"0\" cellspacing=\"0\" border=\"1\"><tr><td valign=\"middle\" align=\"center\">IZWebFileManager - <b>{2}</b></td></tr></table></div>",
                    Width,
                    Height,
                    ID));
                return;
            }

            AddAttributesToRender(writer);
            RenderBeginOuterTable(writer);
            if (ShowAddressBar)
                RenderAddressBar(writer);
            if (ShowToolBar)
                RenderToolBar(writer);

            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            RenderFolderTree(writer);

            writer.RenderEndTag();

            // splitter
            writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "col-resize");
            writer.AddAttribute("onmousedown", ClientID + "SplitterDragStart(event)");
            writer.AddAttribute("onselectstart", "return false");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (SplitterImageUrl.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveClientUrl(SplitterImageUrl));
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Width, "3px");
                writer.AddAttribute(HtmlTextWriterAttribute.Height, "3px");
                writer.AddAttribute(HtmlTextWriterAttribute.Src, Page.ClientScript.GetWebResourceUrl(typeof(FileManagerController), "IZ.WebFileManager.resources.Empty.gif"));
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, "");
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();
            writer.RenderEndTag();

            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            RenderFileView(writer);

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

            if (ShowFileUploadBar)
                RenderFileUploadBar(writer);
            RenderEndOuterTable(writer);

            var style = new Style();
            style.CopyFrom(ControlStyle);
            style.Width = Unit.Empty;
            style.Height = Unit.Empty;

            writer.Div(attr => attr.Id(ClientID + "_SelectFolderPanel").Position("fixed").Display("none").ZIndex(100).BackgroundColor("rgba(0,0,0, 0.2)").Style("filter", "progid:DXImageTransform.Microsoft.gradient(startColorstr=#33000000,endColorstr=#33000000)"))
                .Div(attr => attr.Style(style).Display("inline-block").Position("relative").Left("30%").Top("10%").Padding(2).Direction(Controller.IsRightToLeft))
                    .Div(attr => attr.Padding(5))
                        .Text(GetResourceString("SelectDestination", "Select destination directory"), true)
                    .EndTag()
                    .RenderControl(_selectFolderTree)
                    .Div(attr => attr.Align(Controller.IsRightToLeft ? "left" : "right"))
                        .Button(attr => attr.Id(ClientID + "_SelectFolderOK").Attr("type", "button"))
                            .Text(GetResourceString("Select", "Select"), true)
                        .EndTag()
                        .Button(attr => attr.Id(ClientID + "_SelectFolderCancel").Attr("type", "button"))
                            .Text(GetResourceString("Cancel", "Cancel"), true)
                        .EndTag()
                    .EndTag()
                .EndTag()
            .EndTag();
        }
 private void RenderTitle(HtmlTextWriter writer, EditorPart editorPart)
 {
     string displayTitle = editorPart.DisplayTitle;
     if (!string.IsNullOrEmpty(displayTitle))
     {
         TableItemStyle partTitleStyle = this.Zone.PartTitleStyle;
         if (this._titleTextStyle == null)
         {
             Style style2 = new Style();
             style2.CopyFrom(partTitleStyle);
             this._titleTextStyle = style2;
         }
         if (!this._titleTextStyle.IsEmpty)
         {
             this._titleTextStyle.AddAttributesToRender(writer, this.Zone);
         }
         string description = editorPart.Description;
         if (!string.IsNullOrEmpty(description))
         {
             writer.AddAttribute(HtmlTextWriterAttribute.Title, description);
         }
         string accessKey = editorPart.AccessKey;
         if (!string.IsNullOrEmpty(accessKey))
         {
             writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey);
         }
         writer.RenderBeginTag(HtmlTextWriterTag.Legend);
         writer.Write(displayTitle);
         writer.RenderEndTag();
     }
 }
Ejemplo n.º 18
0
        protected override void RenderMenuItem(HtmlTextWriter writer, MenuItem item, bool vertical, bool notLast, bool isFirst, OwnerContext oc)
        {
            Menu   owner           = Owner;
            string clientID        = oc.ClientID;
            bool   displayChildren = owner.DisplayChildren(item);
            bool   dynamicChildren = displayChildren && (item.Depth + 1 >= oc.StaticDisplayLevels);
            bool   isDynamicItem   = IsDynamicItem(owner, item);
            bool   isVertical      = oc.IsVertical || isDynamicItem;
            Unit   itemSpacing     = owner.GetItemSpacing(item, isDynamicItem);

            if (itemSpacing != Unit.Empty && (item.Depth > 0 || !isFirst))
            {
                RenderMenuItemSpacing(writer, itemSpacing, isVertical);
            }

            if (!String.IsNullOrEmpty(item.ToolTip))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, item.ToolTip);
            }
            if (isVertical)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            }

            string parentId = isDynamicItem ? "'" + item.Parent.Path + "'" : "null";

            if (dynamicChildren)
            {
                writer.AddAttribute("onmouseover",
                                    "javascript:Menu_OverItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
                writer.AddAttribute("onmouseout",
                                    "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')");
            }
            else if (isDynamicItem)
            {
                writer.AddAttribute("onmouseover",
                                    "javascript:Menu_OverDynamicLeafItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
                writer.AddAttribute("onmouseout",
                                    "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "'," + parentId + ")");
            }
            else
            {
                writer.AddAttribute("onmouseover",
                                    "javascript:Menu_OverStaticLeafItem ('" + clientID + "','" + item.Path + "')");
                writer.AddAttribute("onmouseout",
                                    "javascript:Menu_OutItem ('" + clientID + "','" + item.Path + "')");
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Top separator image

            if (isDynamicItem)
            {
                RenderSeparatorImage(owner, writer, oc.DynamicTopSeparatorImageUrl, false);
            }
            else
            {
                RenderSeparatorImage(owner, writer, oc.StaticTopSeparatorImageUrl, false);
            }

            // Menu item box

            MenuItemStyle style = new MenuItemStyle();

            if (oc.Header != null)
            {
                // styles are registered
                if (!isDynamicItem && oc.StaticMenuItemStyle != null)
                {
                    AddCssClass(style, oc.StaticMenuItemStyle.CssClass);
                    AddCssClass(style, oc.StaticMenuItemStyle.RegisteredCssClass);
                }
                if (isDynamicItem && oc.DynamicMenuItemStyle != null)
                {
                    AddCssClass(style, oc.DynamicMenuItemStyle.CssClass);
                    AddCssClass(style, oc.DynamicMenuItemStyle.RegisteredCssClass);
                }
                if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
                {
                    AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].CssClass);
                    AddCssClass(style, oc.LevelMenuItemStyles [item.Depth].RegisteredCssClass);
                }
                if (item == oc.SelectedItem)
                {
                    if (!isDynamicItem && oc.StaticSelectedStyle != null)
                    {
                        AddCssClass(style, oc.StaticSelectedStyle.CssClass);
                        AddCssClass(style, oc.StaticSelectedStyle.RegisteredCssClass);
                    }
                    if (isDynamicItem && oc.DynamicSelectedStyle != null)
                    {
                        AddCssClass(style, oc.DynamicSelectedStyle.CssClass);
                        AddCssClass(style, oc.DynamicSelectedStyle.RegisteredCssClass);
                    }
                    if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
                    {
                        AddCssClass(style, oc.LevelSelectedStyles [item.Depth].CssClass);
                        AddCssClass(style, oc.LevelSelectedStyles [item.Depth].RegisteredCssClass);
                    }
                }
            }
            else
            {
                // styles are not registered
                if (!isDynamicItem && oc.StaticMenuItemStyle != null)
                {
                    style.CopyFrom(oc.StaticMenuItemStyle);
                }
                if (isDynamicItem && oc.DynamicMenuItemStyle != null)
                {
                    style.CopyFrom(oc.DynamicMenuItemStyle);
                }
                if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
                {
                    style.CopyFrom(oc.LevelMenuItemStyles [item.Depth]);
                }
                if (item == oc.SelectedItem)
                {
                    if (!isDynamicItem && oc.StaticSelectedStyle != null)
                    {
                        style.CopyFrom(oc.StaticSelectedStyle);
                    }
                    if (isDynamicItem && oc.DynamicSelectedStyle != null)
                    {
                        style.CopyFrom(oc.DynamicSelectedStyle);
                    }
                    if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
                    {
                        style.CopyFrom(oc.LevelSelectedStyles [item.Depth]);
                    }
                }
            }
            style.AddAttributesToRender(writer);

            writer.AddAttribute("id", GetItemClientId(clientID, item, "i"));
            writer.AddAttribute("cellpadding", "0", false);
            writer.AddAttribute("cellspacing", "0", false);
            writer.AddAttribute("border", "0", false);
            writer.AddAttribute("width", "100%", false);
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Menu item text

            if (isVertical)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
            }
            if (!owner.ItemWrap)
            {
                writer.AddStyleAttribute("white-space", "nowrap");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            RenderItemHref(owner, writer, item);

            Style linkStyle = new Style();

            if (oc.Header != null)
            {
                // styles are registered
                AddCssClass(linkStyle, oc.ControlLinkStyle.RegisteredCssClass);

                if (!isDynamicItem && oc.StaticMenuItemStyle != null)
                {
                    AddCssClass(linkStyle, oc.StaticMenuItemStyle.CssClass);
                    AddCssClass(linkStyle, oc.StaticMenuItemLinkStyle.RegisteredCssClass);
                }
                if (isDynamicItem && oc.DynamicMenuItemStyle != null)
                {
                    AddCssClass(linkStyle, oc.DynamicMenuItemStyle.CssClass);
                    AddCssClass(linkStyle, oc.DynamicMenuItemLinkStyle.RegisteredCssClass);
                }
                if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
                {
                    AddCssClass(linkStyle, oc.LevelMenuItemStyles [item.Depth].CssClass);
                    AddCssClass(linkStyle, oc.LevelMenuItemLinkStyles [item.Depth].RegisteredCssClass);
                }
                if (item == oc.SelectedItem)
                {
                    if (!isDynamicItem && oc.StaticSelectedStyle != null)
                    {
                        AddCssClass(linkStyle, oc.StaticSelectedStyle.CssClass);
                        AddCssClass(linkStyle, oc.StaticSelectedLinkStyle.RegisteredCssClass);
                    }
                    if (isDynamicItem && oc.DynamicSelectedStyle != null)
                    {
                        AddCssClass(linkStyle, oc.DynamicSelectedStyle.CssClass);
                        AddCssClass(linkStyle, oc.DynamicSelectedLinkStyle.RegisteredCssClass);
                    }
                    if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
                    {
                        AddCssClass(linkStyle, oc.LevelSelectedStyles [item.Depth].CssClass);
                        AddCssClass(linkStyle, oc.LevelSelectedLinkStyles [item.Depth].RegisteredCssClass);
                    }
                }
            }
            else
            {
                // styles are not registered
                linkStyle.CopyFrom(oc.ControlLinkStyle);

                if (!isDynamicItem && oc.StaticMenuItemStyle != null)
                {
                    linkStyle.CopyFrom(oc.StaticMenuItemLinkStyle);
                }
                if (isDynamicItem && oc.DynamicMenuItemStyle != null)
                {
                    linkStyle.CopyFrom(oc.DynamicMenuItemLinkStyle);
                }
                if (oc.LevelMenuItemStyles != null && oc.LevelMenuItemStyles.Count > item.Depth)
                {
                    linkStyle.CopyFrom(oc.LevelMenuItemLinkStyles [item.Depth]);
                }
                if (item == oc.SelectedItem)
                {
                    if (!isDynamicItem && oc.StaticSelectedStyle != null)
                    {
                        linkStyle.CopyFrom(oc.StaticSelectedLinkStyle);
                    }
                    if (isDynamicItem && oc.DynamicSelectedStyle != null)
                    {
                        linkStyle.CopyFrom(oc.DynamicSelectedLinkStyle);
                    }
                    if (oc.LevelSelectedStyles != null && oc.LevelSelectedStyles.Count > item.Depth)
                    {
                        linkStyle.CopyFrom(oc.LevelSelectedLinkStyles [item.Depth]);
                    }
                }

                linkStyle.AlwaysRenderTextDecoration = true;
            }
            linkStyle.AddAttributesToRender(writer);

            writer.AddAttribute("id", GetItemClientId(clientID, item, "l"));

            if (item.Depth > 0 && !isDynamicItem)
            {
                double value;
#if NET_4_0
                Unit unit = oc.StaticSubMenuIndent;
                if (unit == Unit.Empty)
                {
                    value = 16;
                }
                else
                {
                    value = unit.Value;
                }
#else
                value = oc.StaticSubMenuIndent.Value;
#endif
                Unit indent = new Unit(value * item.Depth, oc.StaticSubMenuIndent.Type);
                writer.AddStyleAttribute(HtmlTextWriterStyle.MarginLeft, indent.ToString());
            }
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            owner.RenderItemContent(writer, item, isDynamicItem);
            writer.RenderEndTag();              // A

            writer.RenderEndTag();              // TD

            // Popup image

            if (dynamicChildren)
            {
                string popOutImage = GetPopOutImage(owner, item, isDynamicItem);
                if (popOutImage != null)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.AddAttribute("src", owner.ResolveClientUrl(popOutImage));
                    writer.AddAttribute("border", "0");
                    string toolTip = String.Format(isDynamicItem ? oc.DynamicPopOutImageTextFormatString : oc.StaticPopOutImageTextFormatString, item.Text);
                    writer.AddAttribute(HtmlTextWriterAttribute.Alt, toolTip);
                    writer.RenderBeginTag(HtmlTextWriterTag.Img);
                    writer.RenderEndTag();                      // IMG
                    writer.RenderEndTag();                      // TD
                }
            }

            writer.RenderEndTag();              // TR
            writer.RenderEndTag();              // TABLE

            writer.RenderEndTag();              // TD

            if (!isVertical && itemSpacing == Unit.Empty && (notLast || (displayChildren && !dynamicChildren)))
            {
                writer.AddStyleAttribute("width", "3px");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.RenderEndTag();
            }

            // Bottom separator image
            string separatorImg = item.SeparatorImageUrl;
            if (separatorImg.Length == 0)
            {
                if (isDynamicItem)
                {
                    separatorImg = oc.DynamicBottomSeparatorImageUrl;
                }
                else
                {
                    separatorImg = oc.StaticBottomSeparatorImageUrl;
                }
            }

            if (separatorImg.Length > 0)
            {
                if (!isVertical)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                }
                RenderSeparatorImage(owner, writer, separatorImg, false);
                if (!isVertical)
                {
                    writer.RenderEndTag();                      // TD
                }
            }

            if (isVertical)
            {
                writer.RenderEndTag();                  // TR
            }
            if (itemSpacing != Unit.Empty)
            {
                RenderMenuItemSpacing(writer, itemSpacing, isVertical);
            }

            // Submenu

            if (displayChildren && !dynamicChildren)
            {
                if (isVertical)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.AddAttribute("width", "100%");
                owner.RenderMenu(writer, item.ChildItems, vertical, false, item.Depth + 1, notLast);
                if (item.Depth + 2 == oc.StaticDisplayLevels)
                {
                    owner.RenderDynamicMenu(writer, item.ChildItems);
                }
                writer.RenderEndTag();                  // TD
                if (isVertical)
                {
                    writer.RenderEndTag();                      // TR
                }
            }
        }
Ejemplo n.º 19
0
        protected virtual Style CreateWebPartChromeStyle(WebPart webPart, PartChromeType chromeType) {
            if (webPart == null) {
                throw new ArgumentNullException("webPart");
            }
            if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly)) {
                throw new ArgumentOutOfRangeException("chromeType");
            }

            // PERF: Cache these, since they are needed for every WebPart in the zone, and only vary
            // if one of the WebParts is selected
            Style webPartChromeStyle;
            if (chromeType == PartChromeType.BorderOnly || chromeType == PartChromeType.TitleAndBorder) {
                if (_chromeStyleWithBorder == null) {
                    _chromeStyleWithBorder = CreateChromeStyleWithBorder(Zone.PartChromeStyle);
                }
                webPartChromeStyle = _chromeStyleWithBorder;
            }
            else {
                if (_chromeStyleNoBorder == null) {
                    _chromeStyleNoBorder = CreateChromeStyleNoBorder(Zone.PartChromeStyle);
                }
                webPartChromeStyle = _chromeStyleNoBorder;
            }

            // add SelectedPartChromeStyle
            if (WebPartManager != null && webPart == WebPartManager.SelectedWebPart) {
                Style style = new Style();
                style.CopyFrom(webPartChromeStyle);
                style.CopyFrom(Zone.SelectedPartChromeStyle);
                return style;
            }
            else {
                return webPartChromeStyle;
            }
        }
 protected virtual Style CreateWebPartChromeStyle(WebPart webPart, PartChromeType chromeType)
 {
     Style style;
     if (webPart == null)
     {
         throw new ArgumentNullException("webPart");
     }
     if ((chromeType < PartChromeType.Default) || (chromeType > PartChromeType.BorderOnly))
     {
         throw new ArgumentOutOfRangeException("chromeType");
     }
     if ((chromeType == PartChromeType.BorderOnly) || (chromeType == PartChromeType.TitleAndBorder))
     {
         if (this._chromeStyleWithBorder == null)
         {
             this._chromeStyleWithBorder = this.CreateChromeStyleWithBorder(this.Zone.PartChromeStyle);
         }
         style = this._chromeStyleWithBorder;
     }
     else
     {
         if (this._chromeStyleNoBorder == null)
         {
             this._chromeStyleNoBorder = this.CreateChromeStyleNoBorder(this.Zone.PartChromeStyle);
         }
         style = this._chromeStyleNoBorder;
     }
     if ((this.WebPartManager != null) && (webPart == this.WebPartManager.SelectedWebPart))
     {
         Style style2 = new Style();
         style2.CopyFrom(style);
         style2.CopyFrom(this.Zone.SelectedPartChromeStyle);
         return style2;
     }
     return style;
 }
Ejemplo n.º 21
0
		void AddNodeLinkStyle (HtmlTextWriter writer, TreeNode node, int level, bool nodeIsSelected)
		{
			Style style = new Style ();
			if (Page.Header != null) {
				// styles are registered
				style.AddCssClass (ControlLinkStyle.RegisteredCssClass);

				if (nodeStyle != null) {
					style.AddCssClass (nodeLinkStyle.CssClass);
					style.AddCssClass (nodeLinkStyle.RegisteredCssClass);
				}

				if (levelLinkStyles != null && levelLinkStyles.Count > level) {
					style.AddCssClass (levelLinkStyles [level].CssClass);
					style.AddCssClass (levelLinkStyles [level].RegisteredCssClass);
				}
				
				if (node.IsLeafNode) {
					if (leafNodeStyle != null) {
						style.AddCssClass (leafNodeLinkStyle.CssClass);
						style.AddCssClass (leafNodeLinkStyle.RegisteredCssClass);
					}
				} else if (node.IsRootNode) {
					if (rootNodeStyle != null) {
						style.AddCssClass (rootNodeLinkStyle.CssClass);
						style.AddCssClass (rootNodeLinkStyle.RegisteredCssClass);
					}
				} else if (node.IsParentNode) {
					if (parentNodeStyle != null) {
						style.AddCssClass (parentNodeLinkStyle.CssClass);
						style.AddCssClass (parentNodeLinkStyle.RegisteredCssClass);
					}
				}
				
				if (nodeIsSelected) {
					style.AddCssClass (selectedNodeLinkStyle.CssClass);
					style.AddCssClass (selectedNodeLinkStyle.RegisteredCssClass);
				}
			} else {
				// styles are not registered
				style.CopyFrom (ControlLinkStyle);
				if (nodeStyle != null)
					style.CopyFrom (nodeLinkStyle);

				if (levelLinkStyles != null && levelLinkStyles.Count > level)
					style.CopyFrom (levelLinkStyles [level]);
				
				if (node.IsLeafNode) {
					if (node.IsLeafNode && leafNodeStyle != null) {
						style.CopyFrom (leafNodeLinkStyle);
					}
				} else if (node.IsRootNode) {
					if (node.IsRootNode && rootNodeStyle != null) {
						style.CopyFrom (rootNodeLinkStyle);
					}
				} else if (node.IsParentNode) {
					if (node.IsParentNode && parentNodeStyle != null) {
						style.CopyFrom (parentNodeLinkStyle);
					}
				}
				
				if (nodeIsSelected)
					style.CopyFrom (selectedNodeLinkStyle);
				style.AlwaysRenderTextDecoration = true;
			}
			style.AddAttributesToRender (writer);
		}
        private Style GetTemplateStyle(int templateIndex, TemplateField templateField)
        {
            Style style = new Style();
            style.CopyFrom(((GridView) base.ViewControl).ControlStyle);
            switch (templateIndex)
            {
                case 0:
                    style.CopyFrom(((GridView) base.ViewControl).EmptyDataRowStyle);
                    return style;

                case 1:
                    style.CopyFrom(((GridView) base.ViewControl).PagerStyle);
                    return style;

                case 0x3e8:
                    style.CopyFrom(((GridView) base.ViewControl).RowStyle);
                    style.CopyFrom(templateField.ItemStyle);
                    return style;

                case 0x3e9:
                    style.CopyFrom(((GridView) base.ViewControl).RowStyle);
                    style.CopyFrom(((GridView) base.ViewControl).AlternatingRowStyle);
                    style.CopyFrom(templateField.ItemStyle);
                    return style;

                case 0x3ea:
                    style.CopyFrom(((GridView) base.ViewControl).RowStyle);
                    style.CopyFrom(((GridView) base.ViewControl).EditRowStyle);
                    style.CopyFrom(templateField.ItemStyle);
                    return style;

                case 0x3eb:
                    style.CopyFrom(((GridView) base.ViewControl).HeaderStyle);
                    style.CopyFrom(templateField.HeaderStyle);
                    return style;

                case 0x3ec:
                    style.CopyFrom(((GridView) base.ViewControl).FooterStyle);
                    style.CopyFrom(templateField.FooterStyle);
                    return style;
            }
            return style;
        }
Ejemplo n.º 23
0
 /// <devdoc>
 ///    <para>Push style on stack, but do not open it.  Used for pending styles, as in the panel and page adapters.</para>
 /// </devdoc>
 internal void PushPanelStyle(Style style) {
     Style stackStyle = new Style();
     if (_panelStyleStack.Count == 0) {
         stackStyle.CopyFrom(style);
         _panelStyleStack.Push(stackStyle);
         return;
     }
     stackStyle.CopyFrom((Style)_panelStyleStack.Peek());
     stackStyle.MergeWith(style);
     _panelStyleStack.Push(stackStyle);
 }
Ejemplo n.º 24
0
 private Style CreateTitleStyleWithoutFontOrAlign(Style partTitleStyle) {
     // Need to remove font info from TitleStyle.  We only want the font
     // info to apply to the title text, not the whole title bar table.
     // (NDPWhidbey 27755)
     // Use plain style so we don't copy alignment or wrap from TableItemStyle
     Style style = new Style();
     style.CopyFrom(partTitleStyle);
     style.Font.Reset();
     if (style.ForeColor != Color.Empty) {
         style.ForeColor = Color.Empty;
     }
     return style;
 }
        private Style GetTemplateStyle(int templateIndex)
        {
            Style style = new Style();
            style.CopyFrom(((FormView) base.ViewControl).ControlStyle);
            switch (templateIndex)
            {
                case 0:
                    style.CopyFrom(((FormView) base.ViewControl).RowStyle);
                    return style;

                case 1:
                    style.CopyFrom(((FormView) base.ViewControl).FooterStyle);
                    return style;

                case 2:
                    style.CopyFrom(((FormView) base.ViewControl).RowStyle);
                    style.CopyFrom(((FormView) base.ViewControl).EditRowStyle);
                    return style;

                case 3:
                    style.CopyFrom(((FormView) base.ViewControl).RowStyle);
                    style.CopyFrom(((FormView) base.ViewControl).InsertRowStyle);
                    return style;

                case 4:
                    style.CopyFrom(((FormView) base.ViewControl).HeaderStyle);
                    return style;

                case 5:
                    style.CopyFrom(((FormView) base.ViewControl).EmptyDataRowStyle);
                    return style;

                case 6:
                    style.CopyFrom(((FormView) base.ViewControl).PagerStyle);
                    return style;
            }
            return style;
        }
Ejemplo n.º 26
0
		void AddNodeLinkStyle (HtmlTextWriter writer, TreeNode node, int level, bool nodeIsSelected)
		{
			Style style = new Style ();
#if NET_4_0
			bool addBorderStyle = false;
#endif
			if (Page.Header != null) {
				// styles are registered
				style.AddCssClass (ControlLinkStyle.RegisteredCssClass);

				if (nodeStyle != null) {
					style.AddCssClass (nodeLinkStyle.CssClass);
					style.AddCssClass (nodeLinkStyle.RegisteredCssClass);
				}

				if (levelLinkStyles != null && levelLinkStyles.Count > level) {
					style.AddCssClass (levelLinkStyles [level].CssClass);
					style.AddCssClass (levelLinkStyles [level].RegisteredCssClass);
#if NET_4_0
					addBorderStyle = true;
#endif
				}
				
				if (node.IsLeafNode) {
					if (leafNodeStyle != null) {
						style.AddCssClass (leafNodeLinkStyle.CssClass);
						style.AddCssClass (leafNodeLinkStyle.RegisteredCssClass);
					}
				} else if (node.IsRootNode) {
					if (rootNodeStyle != null) {
						style.AddCssClass (rootNodeLinkStyle.CssClass);
						style.AddCssClass (rootNodeLinkStyle.RegisteredCssClass);
					}
				} else if (node.IsParentNode) {
					if (parentNodeStyle != null) {
						style.AddCssClass (parentNodeLinkStyle.CssClass);
						style.AddCssClass (parentNodeLinkStyle.RegisteredCssClass);
					}
				}
				
				if (nodeIsSelected) {
					style.AddCssClass (selectedNodeLinkStyle.CssClass);
					style.AddCssClass (selectedNodeLinkStyle.RegisteredCssClass);
				}
			} else {
				// styles are not registered
				style.CopyFrom (ControlLinkStyle);
				if (nodeStyle != null)
					style.CopyFrom (nodeLinkStyle);
				
				if (levelLinkStyles != null && levelLinkStyles.Count > level) {
					style.CopyFrom (levelLinkStyles [level]);
#if NET_4_0
					addBorderStyle = true;
#endif
				}
				
				if (node.IsLeafNode) {
					if (node.IsLeafNode && leafNodeStyle != null)
						style.CopyFrom (leafNodeLinkStyle);
				} else if (node.IsRootNode) {
					if (node.IsRootNode && rootNodeStyle != null)
						style.CopyFrom (rootNodeLinkStyle);
				} else if (node.IsParentNode) {
					if (node.IsParentNode && parentNodeStyle != null)
						style.CopyFrom (parentNodeLinkStyle);
				}
				
				if (nodeIsSelected)
					style.CopyFrom (selectedNodeLinkStyle);
				
				style.AlwaysRenderTextDecoration = true;
			}
#if NET_4_0
			if (addBorderStyle) {
				// This appears not to come from any style. Instead, it's added
				// whenever a level style is present.
				writer.AddStyleAttribute (HtmlTextWriterStyle.BorderStyle, "none");
				writer.AddStyleAttribute (HtmlTextWriterStyle.FontSize, "1em");
			}		
#endif
			style.AddAttributesToRender (writer);
		}
 private Style CreateTitleStyleWithoutFontOrAlign(Style partTitleStyle)
 {
     Style style = new Style();
     style.CopyFrom(partTitleStyle);
     style.Font.Reset();
     if (style.ForeColor != Color.Empty)
     {
         style.ForeColor = Color.Empty;
     }
     return style;
 }
Ejemplo n.º 28
0
        private void RenderTitle(HtmlTextWriter writer, EditorPart editorPart) {
            string displayTitle = editorPart.DisplayTitle;

            if (String.IsNullOrEmpty(displayTitle)) {
                return;
            }

            // Apply TitleStyle to the Legend
            TableItemStyle titleTableItemStyle = Zone.PartTitleStyle;

            // PERF: Cache this, since it is needed for every EditorPart in the zone
            if (_titleTextStyle == null) {
                // Need to copy the TableItemStyle to a plain Style, since we are going to apply it to
                // the <legend> tag, which is not a table item.  We ignore the horizontal align,
                // vertical align, and nowrap properties.
                Style style = new Style();
                style.CopyFrom(titleTableItemStyle);
                _titleTextStyle = style;
            }

            if (!_titleTextStyle.IsEmpty) {
                _titleTextStyle.AddAttributesToRender(writer, Zone);
            }

            string description = editorPart.Description;
            if (!String.IsNullOrEmpty(description)) {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, description);
            }

            string accessKey = editorPart.AccessKey;
            if (!String.IsNullOrEmpty(accessKey)) {
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey);
            }

            writer.RenderBeginTag(HtmlTextWriterTag.Legend);
            writer.Write(displayTitle);
            writer.RenderEndTag();  // Legend
        }
Ejemplo n.º 29
0
        /// <devdoc>
        /// <para>[To be supplied.]</para>
        /// </devdoc>
        public override void EnterStyle(Style style, HtmlTextWriterTag tag) {
            // Ignore tag for wml.
            if (AnalyzeMode) {
                return;
            }

            // All "block level controls" (controls that render using block level elements in HTML) call enterStyle
            // using a div.  Here we ensure that a new p is open for these controls to ensure line breaking behavior.
            if (tag == HtmlTextWriterTag.Div) {
                BeginBlockLevelControl();
            }

            Style stackStyle = new Style();
            stackStyle.CopyFrom(style);
            stackStyle.MergeWith(CurrentStyle);
            if (_panelStyleStack.Count > 0) {
                stackStyle.MergeWith((Style)_panelStyleStack.Peek());
            }
            _styleStack.Push(stackStyle); // updates CurrentStyle

            if (_paragraphOpen) {
                OpenCurrentStyleTags();
            }
        }
Ejemplo n.º 30
0
        private void CopyStyle(Style toStyle, Style fromStyle) {
            Debug.Assert(toStyle != null);

            // Review: How to change the default value of Font.Underline?
            if (fromStyle != null && fromStyle.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                toStyle.Font.Underline = fromStyle.Font.Underline;

            toStyle.CopyFrom(fromStyle);
        }
Ejemplo n.º 31
0
		protected override void CreateChildControls() 
		{
			Controls.Clear();
				
			if ((RepeatCount > 0) && (itemTemplate!=null))
			{
				// Start by outputing the header template (if supplied).
				if(headerTemplate != null)
				{
					SimpleRepeaterItem headerContainer = new SimpleRepeaterItem(0, RepeatCount);
					headerTemplate.InstantiateIn(headerContainer);		
					Controls.Add(headerContainer);

					if (headerStyle!=null)
						headerContainer.ApplyStyle(headerStyle);
				}

				// Output the content the specified number of times.
				for (int i = 0; i<RepeatCount; i++)
				{
					SimpleRepeaterItem container = new SimpleRepeaterItem(i+1, RepeatCount);
					
					// Create a style for alternate items.
					Style altStyle = new Style();
					altStyle.MergeWith(itemStyle);
					altStyle.CopyFrom(alternatingItemStyle);

					if ((i%2 == 0) && (alternatingItemTemplate != null))
					{
						// This is an alternating item and there is an alternating template.
						alternatingItemTemplate.InstantiateIn(container);
						container.ApplyStyle(altStyle);
					}
					else
					{
						itemTemplate.InstantiateIn(container);
						if (itemStyle != null)
							container.ApplyStyle(itemStyle);
					}
					
					Controls.Add(container);
				}

				// Once all of the items have been rendered,
				// add the footer template if specified.
				if (footerTemplate != null)
				{
					SimpleRepeaterItem footerContainer = new SimpleRepeaterItem(RepeatCount, RepeatCount);
					footerTemplate.InstantiateIn(footerContainer);
					Controls.Add(footerContainer);
					if (footerStyle != null)
						footerContainer.ApplyStyle(footerStyle);
				}
			}
			else
			{
				// Show an error message.
				Controls.Add(new LiteralControl("Specify the record count and an item template"));
			}
		}