Пример #1
0
        private ulong ConvertSectionImage(ImageItem sectionImage, Div content, IList <IHTMLItem> resList, ulong documentSize)
        {
            ulong docSize = documentSize;

            if (sectionImage.HRef != null)
            {
                if (Settings.Images.IsImageIdReal(sectionImage.HRef))
                {
                    var container        = new Div(HTMLElementType.HTML5);
                    var sectionImagemage = new Image(HTMLElementType.HTML5);
                    sectionImagemage.Alt.Value    = sectionImage.AltText ?? string.Empty;
                    sectionImagemage.Source.Value = Settings.ReferencesManager.AddImageRefferenced(sectionImage, sectionImagemage);
                    sectionImagemage.GlobalAttributes.ID.Value = Settings.ReferencesManager.AddIdUsed(sectionImage.ID,
                                                                                                      sectionImagemage);
                    if (sectionImage.Title != null)
                    {
                        sectionImagemage.GlobalAttributes.Title.Value = sectionImage.Title;
                    }
                    SetClassType(container, ElementStylesV3.SectionImage);
                    container.Add(sectionImagemage);
                    ulong itemSize = container.EstimateSize();
                    if (_checker.ExceedSizeLimit(documentSize + itemSize))
                    {
                        var oldContent = content;
                        resList.Add(content);
                        content = new Div(HTMLElementType.HTML5);
                        content.GlobalAttributes.Class.Value    = oldContent.GlobalAttributes.Class.Value;
                        content.GlobalAttributes.Language.Value = oldContent.GlobalAttributes.Language.Value;
                        docSize = 0;
                    }
                    docSize += itemSize;
                    content.Add(container);
                    Settings.Images.ImageIdUsed(sectionImage.HRef);
                }
            }
            return(docSize);
        }