#pragma warning disable CA1822 // Mark members as static protected void AddBookComments(Document book, DocumentRange range, SaveOptions options) #pragma warning restore CA1822 // Mark members as static { var comment = options.BookComment; if (!string.IsNullOrWhiteSpace(comment)) { var bookComment = book.Comments.Create(range, Environment.UserName); var docComment = bookComment.BeginUpdate(); try { if (options.BookCommentHtml) { docComment.AppendHtmlText(comment, InsertOptions.KeepSourceFormatting); } else { docComment.AppendText(comment); } } finally { bookComment.EndUpdate(docComment); } } var bookmark = options.BookBookmark; if (!string.IsNullOrWhiteSpace(bookmark)) { var oldBookmark = book.Bookmarks[bookmark]; if (oldBookmark != null) { book.Bookmarks.Remove(oldBookmark); } book.Bookmarks.Create(range, bookmark); } var hyperlink = options.BookHyperlink; if (!string.IsNullOrWhiteSpace(hyperlink)) { var hyperlinkBookmark = book.Bookmarks[hyperlink]; var link = book.Hyperlinks.Create(range); if (hyperlinkBookmark != null) { link.Anchor = hyperlinkBookmark.Name; } else { link.NavigateUri = hyperlink; } if (!string.IsNullOrWhiteSpace(options.BookHyperlinkTooltip)) { link.ToolTip = options.BookHyperlinkTooltip; } if (!string.IsNullOrWhiteSpace(options.BookHyperlinkTarget)) { link.Target = options.BookHyperlinkTarget; } } }
protected virtual void DoCopyImageToBook(Image image, Document book, float?scaleX, float?scaleY, SaveOptions options) { using (new UsingProcessor(() => book.BeginUpdate(), () => book.EndUpdate())) { var docImage = book.Images.Append(image); if (scaleX.HasValue) { docImage.ScaleX = scaleX.Value; } if (scaleY.HasValue) { docImage.ScaleY = scaleY.Value; } book.Paragraphs.Append(); AddBookComments(book, docImage.Range, options); book.CaretPosition = docImage.Range.End; Book.SCBook.ResetBookFormatting(book, book.CaretPosition); ScrollToCaret(); } }