Toolbar.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Bowin.Web.Controls.Mvc
  6. {
  7. public class Toolbar:BaseControl
  8. {
  9. public Toolbar()
  10. {
  11. ButtonList = new List<ToolbarButton>();
  12. }
  13. public IList<ToolbarButton> ButtonList { get; private set; }
  14. public override string Render()
  15. {
  16. StringBuilder htmlBuilder = new StringBuilder();
  17. htmlBuilder.AppendLine("<div class=\"current_navbar toolbar\"> <div class=\"func_info\">");
  18. foreach (var button in ButtonList)
  19. {
  20. htmlBuilder.AppendLine(button.Render());
  21. }
  22. htmlBuilder.AppendLine("</div></div>");
  23. return htmlBuilder.ToString();
  24. }
  25. public static Toolbar CreateControl(ToolbarOptions toolbarOptions, IDictionary<string, string> attributes = null)
  26. {
  27. Toolbar toolbar = new Toolbar();
  28. foreach (var b in toolbarOptions.ButtonList)
  29. {
  30. toolbar.ButtonList.Add(b);
  31. }
  32. return toolbar;
  33. }
  34. }
  35. }