private void AppendImage(HtmlNode node, Paragraph paragraph)
{
//AppendLineBreak(node, paragraph, null, false);
InlineUIContainer inlineContainer = new InlineUIContainer();
Image image = new Image();
image.Margin = new Thickness(0, 0, 0, 10);
image.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
var source = node.Attributes["src"];
if (source != null)
{
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
BitmapImage bitmapImage;
var imageFilePath = ImagesStorageManager.GetImagePath(source.Value, BookmarkViewModel.BookmarkId);
if (!string.IsNullOrEmpty(imageFilePath))
{
using (var imageStream = isoStore.OpenFile(imageFilePath, FileMode.Open, FileAccess.Read))
{
bitmapImage = new BitmapImage();
bitmapImage.SetSource(imageStream);
}
bitmapImage.ImageOpened += delegate
{
double bitmapWidth = bitmapImage.PixelWidth;
double actualWidth = _currentTextBox.ActualWidth;
image.Source = bitmapImage;
if (bitmapWidth < actualWidth)
{
image.Width = bitmapWidth;
}
};
image.Source = bitmapImage;
inlineContainer.Child = image;
image.Stretch = Stretch.Uniform;
}
}
paragraph.Inlines.Add(inlineContainer);
}
RenderChildren(node, paragraph, null);
//AppendLineBreak(node, paragraph, null, false);
}