Beispiel #1
0
        public static async Task ViewRender(FrontContext context, string NameOrId, Dictionary <string, string> Parameters)
        {
            var action = Parameters.GetValue("action");

            if (string.IsNullOrEmpty(action) || action == "render")
            {
                System.Guid viewid = default(Guid);
                System.Guid.TryParse(NameOrId, out viewid);
                if (viewid == default(Guid))
                {
                    viewid = Kooboo.Data.IDGenerator.Generate(NameOrId, ConstObjectType.View);
                }
                context.Route.DestinationConstType = ConstObjectType.View;
                context.Route.objectId             = viewid;
                await ViewRenderer.Render(context);
            }
            else
            {
                var view = context.SiteDb.Views.GetByNameOrId(NameOrId);
                if (view != null)
                {
                    context.RenderContext.Response.ContentType = "text/html;charset=utf-8";
                    context.RenderContext.Response.Body        = DataConstants.DefaultEncoding.GetBytes(view.Body);
                }
            }
        }
        public virtual void RenderError(string viewName, ErrorRenderingModel errorRenderingModel, RenderRenderingArgs args)
        {
            var vr = new ViewRenderer {
                ViewPath = viewName, Model = errorRenderingModel
            };

            vr.Render(args.Writer);
        }
        protected virtual IEnumerable <SearchAutocompleteResultViewModel> GetAutocompleteResultModels(IEnumerable <SearchableBase> searchResults)
        {
            var result = searchResults.Select(d =>
            {
                var model = d.Map <SearchAutocompleteResultViewModel>();

                var searchAutocompleteItem = new SearchBoxAutocompleteItemViewModel
                {
                    Title = model.Title,
                    Type  = _localizationService.Translate($"{SearchTranslationPrefix}{_searchableTypeProvider[d.Type].ToString()}")
                };

                model.Html = _viewRenderer.Render(SearchBoxAutocompleteItemViewPath, searchAutocompleteItem);

                return(model);
            });

            return(result);
        }
Beispiel #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphicsObj = e.Graphics;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            graphicsObj.Clear(Color.Blue);

            view.Render(graphicsObj);
            base.OnPaint(e);
        }
Beispiel #5
0
        public void Render(Graphics graphics)
        {
            if (Parent.Model is null)
            {
                return;
            }

            renderer.Render(this);
            RenderTarget.Flush(graphics);
        }
Beispiel #6
0
        protected override IEnumerable <SearchAutocompleteResultViewModel> GetAutocompleteResultModels(IEnumerable <SearchableBase> searchResults)
        {
            var result = searchResults.Select(searchResult =>
            {
                var model = searchResult.Map <SearchAutocompleteResultViewModel>();

                var searchAutocompleteItem = new SearchBoxAutocompleteItemExtendedViewModel
                {
                    Title = model.Title,
                    Type  = _localizationService.Translate($"{SearchTranslationPrefix}{_searchableTypeProvider[searchResult.Type].ToString()}")
                };

                if (searchResult is SearchableUser user)
                {
                    searchAutocompleteItem.Email = user.Email;
                    searchAutocompleteItem.Photo = user.Photo;
                }

                model.Html = _viewRenderer.Render(SearchBoxAutocompleteItemViewPath, searchAutocompleteItem);
                return(model);
            });

            return(result);
        }
Beispiel #7
0
        private async Task <string> RenderAccountHtml(int accountID, int?updatedCategoryID = null)
        {
            var parameters = new {
                UserID,
                AccountID = accountID
            };

            var model = Db.Query(conn => {
                using var reader = conn.QueryMultipleSP("DashboardAccount", parameters);

                var account    = reader.ReadSingle <AccountViewModel>();
                var categories = reader.Read <CategoryViewModel>();

                return(new AccountViewModel {
                    ID = account.ID,
                    Name = account.Name,
                    CurrentBalance = account.CurrentBalance,
                    Categories = categories,
                    UpdatedCategoryID = updatedCategoryID
                });
            });

            return(await _viewRenderer.Render("_Account", model));
        }