1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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<PostionBarButton> ButtonList { get; set; }
- public List<ToolbarButton> 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<PostionBarButton>();
- ToolButtonList = new List<ToolbarButton>();
- NavIconUrl = "/Content/themes/metro-blue/sysImages/Nav.gif";
- }
- public Dictionary<string, string> GetAttributesList()
- {
- Dictionary<string, string> attributesList = new Dictionary<string, string>();
- 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<string, string> 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("<div class='",this.CssClassName,"'>"));
- }
- else
- {
- //"<div class=\"current_navbar\" id=\"" + this.ID + "\">"
- sb.AppendLine(string.Concat("<div class='",this.CssClassName,"'","id='",this.ID,"'>") );
- }
- sb.AppendLine(" <div class=\"nav_info\">");
- sb.AppendLine(" <ul>");
- sb.AppendLine((ButtonList != null && ButtonList.Any()) ? " <li><img width=\"16\" height=\"16\" src=\"" + (string.Concat("/", this.NavIconUrl)).Replace("//", "/") + "\"></li>" : "");
- sb.AppendLine(string.Join(" <li><span> --> </span></li>", ButtonList.Select(x => x.Render())));
- sb.AppendLine(" </ul>");
- sb.AppendLine(" </div>");
- sb.AppendLine(string.Format("<div class=\"flow_info\" style=\"float: left;\">{0}</div>", this.PostionInnerHtml ?? ""));
- sb.AppendLine(" <div class=\"func_info clearfix\">");
- sb.AppendLine(string.Join(" ", ToolButtonList.Select(x => x.Render())));
- sb.AppendLine(" </div>");
- sb.AppendLine("</div>");
- return sb.ToString();
- }
- }
- }
|