using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; namespace Bowin.Web.Controls.Mvc { public class PostionBar : BaseControl { public List ButtonList { get; set; } public List ToolButtonList { get; set; } public string NavIconUrl { get; set; } private string cssClassName; public string CssClassName { get{return cssClassName;} set { cssClassName=value; if (string.IsNullOrWhiteSpace(cssClassName)) cssClassName = "current_navbar"; } } public string PostionInnerHtml { get; set; } public PostionBar() { ButtonList = new List(); ToolButtonList = new List(); NavIconUrl = "/Content/themes/metro-blue/sysImages/Nav.gif"; } public Dictionary GetAttributesList() { Dictionary attributesList = new Dictionary(); attributesList.Add("id", this.ID); if (!string.IsNullOrEmpty(this.CssClass)) attributesList.Add("class", this.CssClass); else attributesList.Add("class", "style5"); return attributesList; } public static PostionBar CreateControl(PostionBarOptions postionBarOptions, IDictionary attributes = null) { PostionBar postionBar = new PostionBar(); foreach (var button in postionBarOptions.ButtonList) { postionBar.ButtonList.Add(button); } if (postionBarOptions.ToolButtonList != null) { postionBar.ToolButtonList.AddRange(postionBarOptions.ToolButtonList); } postionBar.NavIconUrl = postionBarOptions.NavIconUrl; postionBar.ID = postionBarOptions.ID; postionBar.PostionInnerHtml = postionBarOptions.PostionInnerHtml; postionBar.CssClassName = postionBarOptions.CssClass; return postionBar; } public override string Render() { StringBuilder sb = new StringBuilder(); if (string.IsNullOrEmpty(this.ID)) { sb.AppendLine(string.Concat("
")); } else { //"
" sb.AppendLine(string.Concat("
") ); } sb.AppendLine("
"); sb.AppendLine("
    "); sb.AppendLine((ButtonList != null && ButtonList.Any()) ? "
  • " : ""); sb.AppendLine(string.Join("
  • -->
  • ", ButtonList.Select(x => x.Render()))); sb.AppendLine("
"); sb.AppendLine("
"); sb.AppendLine(string.Format("
{0}
", this.PostionInnerHtml ?? "")); sb.AppendLine("
"); sb.AppendLine(string.Join(" ", ToolButtonList.Select(x => x.Render()))); sb.AppendLine("
"); sb.AppendLine("
"); return sb.ToString(); } } }