public BsControlPanelBuilder(ViewContext viewContext, HtmlHelper helper) : base(viewContext) { ActionsFactory = new BsControlPanelActionsFactory(); TabsFactory = new BsControlPanelTabsFactory(helper); PanelTheme = BsTheme.Default; this.renderer = new BsControlPanelBaseRenderer(this); }
public FormBuilder(ViewContext viewContext, HtmlHelper helper) : base(viewContext) { ViewContext = viewContext; renderer = new FormEditorBaseRenderer(this, helper); EditorTheme = BsTheme.Default; AvailableControls = GetDefaultControls(); TabsFactory = new FormBuilderTabsFactory(); ControlsFactory = new FormBuilderControlsFactory(AvailableControls, DefaultTabId); ActionsFactory = new FormBuilderControlActionsFactory(); }
private string GetColorClass(BsTheme theme) { switch (theme) { case BsTheme.Black: { return("bg-black"); } case BsTheme.Blue: { return("bg-blue"); } case BsTheme.Default: { return("bg-turquoise"); } case BsTheme.Green: { return("bg-green"); } case BsTheme.Orange: { return("bg-orange"); } case BsTheme.Red: { return("bg-red"); } case BsTheme.Purple: { return("bg-purple"); } } return(String.Empty); }
private void Add <TEditor, TRow>(BsEditorTabAttribute attr, BsEditorTabModel <TRow> model, List <TabGroupConnection> connections, object[] groupIds, BsTheme theme) where TEditor : IBsEditorTabModel where TRow : BsItemModel { var tab = new BsEditorTabBuilder <TEditor>(model, this.viewContext, connections).ConnectsWith(groupIds) .DisplayName(attr.Name) .Id(attr.Id) .Selected(attr.Selected); if (attr.Editable) { tab.Editable(); } tab.InitRenderer <TRow>(theme); if (attr.Selected) { navBuilder.Selected(attr.Id); } InsertTab <TEditor, TRow>(attr.Id, tab); }
/// <summary> /// Sets the global theme /// </summary> /// <param name="theme"></param> public static void Theme(BsTheme theme) { globalTheme = theme; }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme) { var routeValues = htmlHelper.ExtractRouteValues(); return BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, new RouteValueDictionary(), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes, BsTheme theme) { return BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), method, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, BsTheme theme) { return BsBeginForm(htmlHelper, actionName, controllerName, routeValues, method, new RouteValueDictionary(), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues, BsTheme theme) { return BsBeginForm(htmlHelper, null, null, routeValues, FormMethod.Post, new RouteValueDictionary(), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme, object htmlAttributes) { var routeValues = htmlHelper.ExtractRouteValues(); return BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, IDictionary <string, object> htmlAttributes, BsTheme theme) { return(BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), method, htmlAttributes, theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, BsTheme theme) { return(BsBeginForm(htmlHelper, actionName, controllerName, routeValues, method, new RouteValueDictionary(), theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, BsTheme theme) { return(BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary(), theme)); }
public string RenderForm <TFormModel>(TFormModel formModel, BsTheme theme = BsTheme.Default, bool wrapInForm = true, string propertyName = null) where TFormModel : class { if (formModel == null) { throw new Exception("The form model passed as an argument cannot be null"); } var formString = String.Empty; var formButtonsString = String.Empty; var formBuilder = new TagBuilder("form"); var formContainerBuilder = new TagBuilder("div"); formBuilder.MergeAttribute("novalidate", "novalidate"); formContainerBuilder.AddCssClass("form_container " + theme.GetDescription()); var properties = formModel.GetType().GetProperties(); var bsControlProperties = from prop in formModel.GetType().GetProperties() let bsControl = prop.GetCustomAttributes(typeof(BsControlAttribute), true) let required = prop.GetCustomAttributes(typeof(RequiredAttribute), true) let display = prop.GetCustomAttributes(typeof(DisplayAttribute), true) let formGroup = prop.GetCustomAttributes(typeof(FormGroup), true) where bsControl.Length == 1 select new FormControlPropertyMetadata { PropertyInfo = prop, FormGroupAttribute = formGroup.FirstOrDefault() as FormGroup, RequiredAttribute = required.FirstOrDefault() as RequiredAttribute, DisplayAttribute = display.FirstOrDefault() as DisplayAttribute, BsControlAttribute = bsControl.FirstOrDefault() as BsControlAttribute }; foreach (var property in bsControlProperties) { formString += RenderFormGroup(property, formModel); } var buttonsProperties = from prop in formModel.GetType().GetProperties() where prop.GetCustomAttributes(typeof(FormButtons), true).Any() select prop; var buttons = buttonsProperties.Select(prop => prop.GetValue(formModel)).FirstOrDefault(); if (buttons != null) { var buttonsList = buttons as IEnumerable <BsButtonModel>; if (buttonsList == null) { throw new Exception("Properties decorated with the BsButtonModel attribute must be of type IEnumerable<BsButtonModel>"); } formButtonsString = RenderFormButtons(buttonsList); } formContainerBuilder.InnerHtml = formString + formButtonsString; if (wrapInForm) { formBuilder.InnerHtml = formContainerBuilder.ToString(); formBuilder.MergeAttribute("data-property-name", propertyName); return(formBuilder.ToString()); } return(formContainerBuilder.ToString()); }
public BsControlPanelBuilder Theme(BsTheme theme) { PanelTheme = theme; return(this); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes, BsTheme theme) { return(BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), method, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary <string, object> htmlAttributes, BsTheme theme) { var form = htmlHelper.BeginForm(actionName, controllerName, routeValues, method, htmlAttributes); var tag = new TagBuilder("div"); tag.AddCssClass("row"); tag.AddCssClass("form_container"); tag.AddCssClass("loading"); tag.AddCssClass(theme.GetDescription()); var myForm = new BsMvcForm(htmlHelper.ViewContext, form, tag.ToString(TagRenderMode.StartTag), tag.ToString(TagRenderMode.EndTag)); return(myForm); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme, IDictionary<string, object> htmlAttributes) { var routeValues = htmlHelper.ExtractRouteValues(); return BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, htmlAttributes, theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme) { var routeValues = htmlHelper.ExtractRouteValues(); return(BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, new RouteValueDictionary(), theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, BsTheme theme) { return BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary(), theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme, object htmlAttributes) { var routeValues = htmlHelper.ExtractRouteValues(); return(BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, IDictionary<string, object> htmlAttributes, BsTheme theme) { return BsBeginForm(htmlHelper, actionName, controllerName, new RouteValueDictionary(), method, htmlAttributes, theme); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, BsTheme theme, IDictionary <string, object> htmlAttributes) { var routeValues = htmlHelper.ExtractRouteValues(); return(BsBeginForm(htmlHelper, routeValues["action"].ToString(), routeValues["controller"].ToString(), routeValues, FormMethod.Post, htmlAttributes, theme)); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes, BsTheme theme) { var form = htmlHelper.BeginForm(actionName, controllerName, routeValues, method, htmlAttributes); var tag = new TagBuilder("div"); tag.AddCssClass("row"); tag.AddCssClass("form_container"); tag.AddCssClass("loading"); tag.AddCssClass(theme.GetDescription()); var myForm = new BsMvcForm(htmlHelper.ViewContext, form, tag.ToString(TagRenderMode.StartTag), tag.ToString(TagRenderMode.EndTag)); return myForm; }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues, BsTheme theme) { return(BsBeginForm(htmlHelper, null, null, routeValues, FormMethod.Post, new RouteValueDictionary(), theme)); }
/// <summary> /// Sets the global theme /// </summary> /// <param name="theme"></param> public static void Theme(BsTheme theme) { globalTheme = theme; }
public virtual TComponent SetTheme(BsTheme theme) { this.Theme = theme; return((TComponent)this); }