Beispiel #1
0
        public static MvcHtmlString ThemedPagerFor <VM>(
            this HtmlHelper <VM> htmlHelper,
            Expression <Func <VM, int> > page,
            Expression <Func <VM, int> > prevPage   = null,
            Expression <Func <VM, int> > totalPages = null,
            string name = "SubmitPager"
            )
        {
            if (page == null)
            {
                throw (new ArgumentNullException("page"));
            }

            string themeName = ThemedControlsStrings.GetTheme();

            htmlHelper.ViewData["ThemeParams"] =
                new SubmitPagerDescription
            {
                Page       = page,
                PrevPage   = prevPage,
                TotalPages = totalPages,
                HtmlHelper = htmlHelper
            };
            MvcHtmlString res;

            try
            {
                res = htmlHelper.Partial("Themes/" + themeName + "/" + name, htmlHelper.ViewData);
            }
            finally
            {
                htmlHelper.ViewData["ThemeParams"] = null;
            }
            return(res);
        }
Beispiel #2
0
        public static MvcHtmlString ThemedChoiceListFor <TModel, TChoiceItem, TValue, TDisplay>
        (
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, IEnumerable <TValue> > > expression,
            ChoiceList <TChoiceItem, TValue, TDisplay> choiceList,
            string name = "ChoiceList")
            where TValue : IComparable
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            if (choiceList == null)
            {
                throw (new ArgumentNullException("choiceList"));
            }
            string themeName = ThemedControlsStrings.GetTheme();
            ViewDataDictionary <dynamic> dataDictionary =
                new ViewDataDictionary <dynamic>(htmlHelper.ViewData.Model);

            dataDictionary.TemplateInfo.HtmlFieldPrefix = htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix;
            dataDictionary["ThemeParams"] =
                new ChoiceListDescription
            {
                Expression = expression,
                ChoiceList = choiceList,
                HtmlHelper = htmlHelper
            };
            MvcHtmlString res;


            res = htmlHelper.Partial("Themes/" + themeName + "/" + name, dataDictionary);

            return(res);
        }
        public static MvcHtmlString ThemedSortableListFor <M, TItem>(
            this HtmlHelper <M> htmlHelper,
            Expression <Func <M, IEnumerable <TItem> > > expression,
            SortableListFeatures sortableListFeatures,
            Columns <TItem> fields,
            Expression <Func <M, IEnumerable <KeyValuePair <LambdaExpression, OrderType> > > > orderExpression = null,
            Expression <Func <M, int> > page      = null,
            Expression <Func <M, int> > prevPage  = null,
            Expression <Func <M, int> > pageCount = null,
            Expression <Func <M, Expression <Func <TItem, bool> > > > filter = null,
            string title = null,
            string name  = "SortableList"
            )
            where TItem : class, new()
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("(expression"));
            }

            if (fields == null || fields.Fields == null || fields.Fields.Count == 0)
            {
                throw (new ArgumentNullException("fields"));
            }
            string themeName = ThemedControlsStrings.GetTheme();

            htmlHelper.ViewData["ThemeParams"] =
                new SortableListDescription
            {
                ToShow     = expression,
                ToOrder    = orderExpression,
                Fields     = fields.Fields,
                HtmlHelper = htmlHelper,
                Features   = sortableListFeatures,
                Title      = title,
                Page       = page,
                PrevPage   = prevPage,
                PageCount  = pageCount,
                Filter     = filter
            };
            MvcHtmlString res;

            try
            {
                res = htmlHelper.Partial("Themes/" + themeName + "/" + name, htmlHelper.ViewData);
            }
            finally
            {
                htmlHelper.ViewData["ThemeParams"] = null;
            }
            return(res);
        }
Beispiel #4
0
        public static MvcHtmlString FilterClauseSelect <VM, T, F>(
            HtmlHelper <VM> htmlHelper,
            FilterCondition value,
            Expression <Func <T, F> > field,
            IDictionary <string, object> htmlAttributes = null)
        {
            if (field == null)
            {
                throw new ArgumentNullException("field");
            }
            var items = new List <FilterOptions>();

            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.Equal), FilterName = ThemedControlsStrings.Get("FilterCondition_Equal", string.Empty)
            });
            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.LessThan), FilterName = ThemedControlsStrings.Get("FilterCondition_LessThan", string.Empty)
            });
            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.LessThanOrEqual), FilterName = ThemedControlsStrings.Get("FilterCondition_LessThanOrEqual", string.Empty)
            });
            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.GreaterThan), FilterName = ThemedControlsStrings.Get("FilterCondition_GreaterThan", string.Empty)
            });
            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.GreaterThanOrEqual), FilterName = ThemedControlsStrings.Get("FilterCondition_GreaterThanOrEqual", string.Empty)
            });
            items.Add(new FilterOptions {
                FilterCode = Convert.ToInt32(FilterCondition.NotEqual), FilterName = ThemedControlsStrings.Get("FilterCondition_NotEqual", string.Empty)
            });

            if (typeof(F) == typeof(string))
            {
                items.Add(new FilterOptions {
                    FilterCode = Convert.ToInt32(FilterCondition.StartsWith), FilterName = ThemedControlsStrings.Get("FilterCondition_StartsWith", string.Empty)
                });
                items.Add(new FilterOptions {
                    FilterCode = Convert.ToInt32(FilterCondition.EndsWith), FilterName = ThemedControlsStrings.Get("FilterCondition_EndsWith", string.Empty)
                });
            }
            return
                (htmlHelper.DropDownList(
                     "Condition",
                     Convert.ToInt32(value),
                     htmlAttributes,
                     ChoiceListHelper.Create(items, m => m.FilterCode, m => m.FilterName)
                     ));
        }
Beispiel #5
0
        public static MvcHtmlString ThemedPager <VM>(
            this HtmlHelper <VM> htmlHelper,
            int currPage,
            string parameterName,
            string actionName,
            System.Web.Routing.RouteValueDictionary otherParameters,
            int?totPages          = null,
            string targetIdName   = "",
            string controllerName = null,
            string routeName      = null,
            string protocol       = null,
            string hostname       = null,
            string fragment       = null,
            string name           = "GetPager")
        {
            string themeName = ThemedControlsStrings.GetTheme();

            htmlHelper.ViewData["ThemeParams"] =
                new LinkPagerDescription
            {
                CurrPage        = currPage,
                ParameterName   = parameterName,
                ActionName      = actionName,
                HtmlHelper      = htmlHelper,
                TotPages        = totPages,
                TargetIdName    = targetIdName,
                ControllerName  = controllerName,
                OtherParameters = otherParameters,
                RouteName       = routeName,
                Protocol        = protocol,
                Hostname        = hostname,
                Fragment        = fragment
            };
            MvcHtmlString res;

            try
            {
                res = htmlHelper.Partial("Themes/" + themeName + "/" + name, htmlHelper.ViewData);
            }
            finally
            {
                htmlHelper.ViewData["ThemeParams"] = null;
            }
            return(res);
        }
Beispiel #6
0
        public static MvcHtmlString ThemedClientPager <VM>(
            this HtmlHelper <VM> htmlHelper,
            string pagerName,
            int initialPage       = 1,
            string totalPagesName = null,
            int?totalPages        = null,
            string pagePrefix     = null,
            string pagePostfix    = null,
            bool causeSubmit      = false,
            string name           = "ClientPager")
        {
            if (string.IsNullOrWhiteSpace(pagerName))
            {
                throw (new ArgumentNullException("pagerName"));
            }
            string themeName = ThemedControlsStrings.GetTheme();

            htmlHelper.ViewData["ThemeParams"] =
                new ClientPagerDescription
            {
                PagerName      = pagerName,
                InitialPage    = initialPage,
                TotalPagesName = totalPagesName,
                TotalPages     = totalPages,
                HtmlHelper     = htmlHelper,
                PagePrefix     = pagePrefix,
                PagePostfix    = pagePostfix,
                CauseSubmit    = causeSubmit
            };
            MvcHtmlString res;

            try
            {
                res = htmlHelper.Partial("Themes/" + themeName + "/" + name, htmlHelper.ViewData);
            }
            finally
            {
                htmlHelper.ViewData["ThemeParams"] = null;
            }
            return(res);
        }