init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
50
KretaWeb/Helpers/ProgressBarExtensions.cs
Normal file
50
KretaWeb/Helpers/ProgressBarExtensions.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
|
||||
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<string, object> htmlAttributes = null)
|
||||
{
|
||||
if (htmlAttributes == null)
|
||||
{
|
||||
htmlAttributes = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
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<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> 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<string, object>();
|
||||
}
|
||||
|
||||
var progressBar = helper.Kendo().ProgressBar()
|
||||
.Name(fieldName)
|
||||
.HtmlAttributes(htmlAttributes)
|
||||
.Type(ProgressBarType.Percent)
|
||||
.Value(value)
|
||||
.Animation(a => a.Duration(600));
|
||||
return progressBar;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue