internal BlogPreviewInfo(string blogId, string[] elementIds, bool isRtl, TemplateHtmlDelegate templateHtmlDelegate, string postBodyHtml)
            {
                IsRtl                   = isRtl;
                _blogId                 = blogId;
                _elementIds             = elementIds;
                _templateHtmlLazyLoader = new LazyLoader <string>(delegate
                {
                    return(templateHtmlDelegate());
                });

                string style = isRtl ? "dir=\"rtl\" style=\"direction: rtl; text-align: right" : "dir=\"ltr\" style=\"direction: ltr; text-align: left";

                style        += "; width: 500px; text-indent: 0px; margin: 0px; overflow: visible; vertical-align: baseline; white-space: nowrap; line-height: normal; position: static\"";
                _postBodyHtml = postBodyHtml.Replace("{style}", style);

                _bitmaps = new Dictionary <string, Bitmap>(elementIds.Length);
            }
        internal SemanticHtmlPreviewManager(IBlogPostEditingSite editingSite, TemplateHtmlDelegate templateHtmlDelegate, int width, int height)
        {
            _previewLock          = new object();
            _editingSite          = editingSite;
            _templateHtmlDelegate = templateHtmlDelegate;
            _width  = width;
            _height = height;

            string previewText = HtmlServices.HtmlEncode(Res.Get(StringId.SemanticHtmlPreviewText));

            _postBodyHtml =
                @"<h1 {style} id=" + PreviewId_H1 + @">" + previewText + @"</h1>
                 <h2 {style} id=" + PreviewId_H2 + @">" + previewText + @"</h2>
                 <h3 {style} id=" + PreviewId_H3 + @">" + previewText + @"</h3>
                 <h4 {style} id=" + PreviewId_H4 + @">" + previewText + @"</h4>
                 <h5 {style} id=" + PreviewId_H5 + @">" + previewText + @"</h5>
                 <h6 {style} id=" + PreviewId_H6 + @">" + previewText + @"</h6>
                 <p  {style} id=" + PreviewId_P + @">" + previewText + @"</p>";
        }
        public SemanticHtmlGalleryCommand(CommandId commandId, IBlogPostEditingSite editingSite, TemplateHtmlDelegate templateHtmlDelegate, CommandManager commandManager, IHtmlEditorComponentContext componentContext)
            : base(commandId)
        {
            _editingSite      = editingSite;
            _componentContext = componentContext;

            _elements = new List <SemanticHtmlElementInfo>(7);
            _elements.Add(new SemanticHtmlElementInfo("p", _ELEMENT_TAG_ID.TAGID_P, Res.Get(StringId.Paragraph), SemanticHtmlPreviewManager.PreviewId_P, CommandId.ApplySemanticParagraph));
            _elements.Add(new SemanticHtmlElementInfo("h1", _ELEMENT_TAG_ID.TAGID_H1, Res.Get(StringId.Heading1), SemanticHtmlPreviewManager.PreviewId_H1, CommandId.ApplySemanticHeader1));
            _elements.Add(new SemanticHtmlElementInfo("h2", _ELEMENT_TAG_ID.TAGID_H2, Res.Get(StringId.Heading2), SemanticHtmlPreviewManager.PreviewId_H2, CommandId.ApplySemanticHeader2));
            _elements.Add(new SemanticHtmlElementInfo("h3", _ELEMENT_TAG_ID.TAGID_H3, Res.Get(StringId.Heading3), SemanticHtmlPreviewManager.PreviewId_H3, CommandId.ApplySemanticHeader3));
            _elements.Add(new SemanticHtmlElementInfo("h4", _ELEMENT_TAG_ID.TAGID_H4, Res.Get(StringId.Heading4), SemanticHtmlPreviewManager.PreviewId_H4, CommandId.ApplySemanticHeader4));
            _elements.Add(new SemanticHtmlElementInfo("h5", _ELEMENT_TAG_ID.TAGID_H5, Res.Get(StringId.Heading5), SemanticHtmlPreviewManager.PreviewId_H5, CommandId.ApplySemanticHeader5));
            _elements.Add(new SemanticHtmlElementInfo("h6", _ELEMENT_TAG_ID.TAGID_H6, Res.Get(StringId.Heading6), SemanticHtmlPreviewManager.PreviewId_H6, CommandId.ApplySemanticHeader6));

            _previewManager = new SemanticHtmlPreviewManager(_editingSite, templateHtmlDelegate, RibbonHelper.InGalleryImageWidth, RibbonHelper.InGalleryImageHeightWithoutLabel);

            _ids = new string[_elements.Count];
            for (int i = 0; i < _ids.Length; i++)
            {
                _ids[i] = _elements[i].HtmlId;

                int index = i;
                OverridableCommand command = new OverridableCommand(_elements[i].CommandId);
                command.Execute += (sender, e) => SelectedIndex = index;
                commandManager.Add(command);
            }
        }