/// <summary> /// Fill RowRenderer with relative items data from ItemSource collection. /// It prepares RowRenderer for rendering a whole row to a single image. /// </summary> /// <param name="startIndex">Index in ItemSource collection to start with</param> private async Task <int> FillRowRendererWithItemDataAsync(int startIndex) { int itemsInRow = 0; await Task.Run(() => { RowRenderer.Dispatcher.Invoke(new Action(() => { for (int itemIndex = startIndex, columnIndex = 0; columnIndex < ColumnsCount; columnIndex++, itemIndex++) { bool needToFill = true; if (itemIndex < 0 || itemIndex > ItemSource.Count - 1) // need to check bounds { needToFill = false; } var panel = (StackPanel)RowRenderer.Children[columnIndex]; if (needToFill) { ItemData itemData = ItemSource[itemIndex]; (panel.Children[0] as Image).Source = itemData.ImageData; (panel.Children[1] as TextBlock).Text = itemData.Title; itemsInRow++; } else { (panel.Children[0] as Image).Source = null; (panel.Children[1] as TextBlock).Text = string.Empty; } } RowRenderer.UpdateLayout(); })); }); return(itemsInRow); }
protected override void RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable <ContentAreaItem> contentAreaItems) { bool?result = null; var actualValue = htmlHelper.ViewContext.ViewData["rowsupport"]; if (actualValue is bool) { result = (bool)actualValue; } var isRowSupported = result; var addRowMarkup = ConfigurationContext.Current.RowSupportEnabled && isRowSupported.HasValue && isRowSupported.Value; // there is no need to proceed if row rendering support is disabled if (!addRowMarkup) { CustomizedRenderContentAreaItems(htmlHelper, contentAreaItems); return; } var rowRender = new RowRenderer(); rowRender.Render(contentAreaItems, htmlHelper, GetContentAreaItemTemplateTag, GetColumnWidth, CustomizedRenderContentAreaItems); }
public VerseViewPresenter(VerseViewColorTheme colorTheme, Font font) { if (font == null) { throw new ArgumentNullException(nameof(font)); } this.colorTheme = colorTheme ?? throw new ArgumentNullException(nameof(colorTheme)); this.rowRenderer = new RegularRowRenderer(new Renderer(font), new VerseViewColorTheme()); this.Font = font; }
public static void RenderFormElements( this HtmlHelper html, int currentStepIndex, IEnumerable <IFormElement> elements, FormContainerBlock model, object additionalValues = null) { // this means that somebody else took renderer seat and we need to find way around it // essentially the only thing that is needed is access to renderer instance - we can create one from scratch here also var renderer = ServiceLocator.Current.GetInstance <ContentAreaRenderer>() as BootstrapAwareContentAreaRenderer ?? new BootstrapAwareContentAreaRenderer(SetupBootstrapRenderer.AllDisplayOptions); var additionalParameters = new RouteValueDictionary(additionalValues); var isRowSupported = additionalParameters.GetValueFromDictionary("rowsupport"); var addRowMarkup = ConfigurationContext.Current.RowSupportEnabled && isRowSupported.HasValue && isRowSupported.Value; if (!addRowMarkup) { foreach (var element in elements) { var areaItem = model .ElementsArea .Items .FirstOrDefault(i => i.ContentLink == element.SourceContent.ContentLink); RenderAreaItem(html, areaItem, renderer, element); } } else { var rowRenderer = new RowRenderer(); rowRenderer.Render( model.ElementsArea.Items, html, renderer.ContentAreaItemTemplateTagCore, renderer.GetColumnWidth, (_, items) => RenderItems(html, items, renderer, elements)); } }