using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Web.Mvc; using Kendo.Mvc.UI; using Kendo.Mvc.UI.Fluent; namespace Kreta.Web.Helpers { public static class ProgressBarExtensions { public static ProgressBarBuilder KretaProgressBar(this HtmlHelper helper, string name, IDictionary htmlAttributes = null) { if (htmlAttributes == null) { htmlAttributes = new Dictionary(); } var progressBar = helper.Kendo().ProgressBar() .Name(name) .HtmlAttributes(htmlAttributes) .Type(ProgressBarType.Percent) .Animation(true) .Animation(a => a.Duration(600)); return progressBar; } public static ProgressBarBuilder KretaProgressBarFor(this HtmlHelper helper, Expression> expression, IDictionary htmlAttributes = null) { var fieldName = ExpressionHelper.GetExpressionText(expression); var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName); var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData); var value = (int)metadata.Model; if (htmlAttributes == null) { htmlAttributes = new Dictionary(); } var progressBar = helper.Kendo().ProgressBar() .Name(fieldName) .HtmlAttributes(htmlAttributes) .Type(ProgressBarType.Percent) .Value(value) .Animation(a => a.Duration(600)); return progressBar; } } }