Exemplo n.º 1
0
            /// <summary>
            /// Internal method used by CreateMenuHierarchy to create HTML menus.
            /// </summary>
            /// <param name="menu">The menu.</param>
            /// <param name="childCode">The child code.</param>
            /// <param name="rootCode">The root code.</param>
            /// <param name="rewriteFilter">Rewrite Match Pattern.</param>
            /// <param name="rewriteReplace">Rewrite Replace.</param>
            /// <param name="recursive">if set to <c>true</c> child menus will be rendered.</param>
            /// <returns>
            /// built string
            /// </returns>
            private string BuildMenu( Commerce.Menu menu, MenuCollectionCode childCode, MenuCollectionCode rootCode,
				string rewriteFilter, string rewriteReplace, bool recursive = true )
            {
                /* empty root menus should return nothing */
                if(menu.Id==Guid.Empty){return "";};
                StringBuilder sb = new StringBuilder();
                MenuCollectionCode s = childCode;
                if( rootCode != null ) {
                    s = rootCode;
                }
                string id = Guid.NewGuid().ToBase64DomId();
                sb.Append( s.MenuItem[ 0 ] );
                sb.Append( " id=\"" + id + "\" " );
                sb.Append( s.MenuItemClassName );
                sb.Append( s.MenuItemMouseOver );
                sb.Append( s.MenuItemMouseOut );
                sb.Append( s.MenuItemClick );
                sb.Append( s.MenuItemMouseDown );
                sb.Append( s.MenuItemMouseUp );
                sb.Append( s.MenuItem[ 1 ] );
                sb.Append( s.MenuLink[ 0 ] );
                sb.Append( " href=\"" + menu.Href + "\" " );
                sb.Append( s.MenuLink[ 1 ] );
                sb.Append( menu.Name );
                sb.Append( s.MenuLink[ 2 ] );
                if( menu.Menus.Count > 0 ) {
                    id = Guid.NewGuid().ToBase64DomId();
                    sb.Append( childCode.Menu[ 0 ] );
                    sb.Append( " id=\"" + id + "\" " );
                    sb.Append( childCode.MenuClassName );
                    sb.Append( childCode.MenuMouseOver );
                    sb.Append( childCode.MenuMouseOut );
                    sb.Append( childCode.MenuClick );
                    sb.Append( childCode.MenuMouseDown );
                    sb.Append( childCode.MenuMouseUp );
                    sb.Append( childCode.Menu[ 1 ] );
                    foreach( Commerce.Menu m in menu.Menus ) {
                        sb.Append( BuildMenu( m, childCode, null, rewriteFilter, rewriteReplace ) );
                    }
                    sb.Append( childCode.Menu[ 2 ] );
                }
                sb.Append( s.MenuItem[ 2 ] );
                if( rewriteFilter.Length > 0 ) {
                    return Regex.Replace( sb.ToString(), rewriteFilter, rewriteReplace );
                } else {
                    return sb.ToString();
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Creates a HTML menu hierarchy by creating list using the MenuCollectionCode specified.
            /// </summary>
            /// <param name="rootCode">The root code.</param>
            /// <param name="childCode">The child code.</param>
            /// <param name="rewriteFilter">The rewrite filter.</param>
            /// <param name="rewriteReplace">The rewrite replace string.</param>
            /// <returns>HTML UL/LI list based on this menu.</returns>
            public string CreateMenuHierarchy(MenuCollectionCode rootCode, MenuCollectionCode childCode,
			string rewriteFilter, string rewriteReplace )
            {
                StringBuilder sb = new StringBuilder();
                if( rootCode == null ) {
                    rootCode = new MenuCollectionCode();
                }
                if( childCode == null ) {
                    childCode = new MenuCollectionCode();
                }
                string id = Guid.NewGuid().ToBase64DomId();
                sb.Append( rootCode.Menu[ 0 ] );
                sb.Append( " id=\"" + id + "\" " );
                sb.Append( rootCode.MenuClassName );
                sb.Append( rootCode.MenuMouseOver );
                sb.Append( rootCode.MenuMouseOut );
                sb.Append( rootCode.MenuClick );
                sb.Append( rootCode.MenuMouseDown );
                sb.Append( rootCode.MenuMouseUp );
                sb.Append( rootCode.Menu[ 1 ] );
                foreach( Commerce.Menu menu in Menus ) {
                    sb.Append( BuildMenu( menu, childCode, rootCode, rewriteFilter, rewriteReplace ) );
                }
                sb.Append( rootCode.Menu[ 2 ] );
                return sb.ToString();
            }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a simple navigation menu using a default MenuCollectionCode.
 /// </summary>
 /// <returns>HTML String</returns>
 public string CreateNavigationMenu()
 {
     MenuCollectionCode rootCode = new MenuCollectionCode();
     rootCode.MenuItemMouseOver = " onmouseover=\"try{Rendition.Merchant.openMenu({ source:$('#'+this.id+' ul')[0], target:this, revealSpeed:0, slide:['down'] });}catch(e){};\"";
     rootCode.MenuItemClassName = " class=\"menu\" ";
     MenuCollectionCode childCode = new MenuCollectionCode();
     childCode.MenuItemMouseOver = " onmouseover=\"try{Rendition.Merchant.openMenu({ source:$('#'+this.id+' ul')[0], target:this, revealSpeed:0, slide:['down'] });}catch(e){};\"";
     childCode.MenuClassName = " style=\"visibility:hidden;display:none;\" ";
     return CreateMenuHierarchy(rootCode, childCode);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a HTML menu hierarchy by creating list using the MenuCollectionCode specified.
 /// </summary>
 /// <param name="rootCode">The root code.</param>
 /// <param name="childCode">The child code.</param>
 /// <returns>HTML UL/LI list based on this menu.</returns>
 public string CreateMenuHierarchy(MenuCollectionCode rootCode, MenuCollectionCode childCode)
 {
     return CreateMenuHierarchy(rootCode, childCode, "", "");
 }