public override void Reflow(DrawContext dc, BoundingContext bounds, bool incremental) { ReflowStart(dc); if (incremental) { bounds = bounds.Narrow(style.Left, style.Right); } MarkupItem tag = new StartTag(CurrentLine, ElementNode); ReflowMarkup(tag, dc, style, bounds); ImageStyle s = style as ImageStyle; if (s == null) { throw new InvalidOperationException("Expected style for image to be Custom"); } string imgPath = ElementNode.GetAttribute(s.SourceAttribute); if (imgPath == null) { throw new InvalidOperationException("SourceAttribute for image is missing"); } // think about relative to doc Bitmap bm; Uri docUri = new Uri(elementNode.BaseURI); Uri uri = new Uri(docUri, imgPath); if (uri.IsFile && File.Exists(uri.AbsolutePath)) { bm = new Bitmap(uri.AbsolutePath); } else { bm = ErrorBitmap; } ImageLineItem ili = new ImageLineItem(CurrentLine, ElementNode, bm); ReflowMarkup(ili, dc, style, bounds); tag = new EndTag(CurrentLine, ElementNode); ReflowMarkup(tag, dc, style, bounds); ReflowEnd(dc); }
public override void Reflow(DrawContext dc, BoundingContext bounds, bool incremental) { ReflowStart(dc); if ( incremental ) bounds=bounds.Narrow(style.Left, style.Right); MarkupItem tag=new StartTag(CurrentLine, ElementNode); ReflowMarkup(tag, dc, style, bounds); ImageStyle s=style as ImageStyle; if ( s == null ) throw new InvalidOperationException("Expected style for image to be Custom"); string imgPath=ElementNode.GetAttribute(s.SourceAttribute); if ( imgPath == null ) throw new InvalidOperationException("SourceAttribute for image is missing"); // think about relative to doc Bitmap bm; Uri docUri=new Uri(elementNode.BaseURI); Uri uri=new Uri(docUri, imgPath); if ( uri.IsFile && File.Exists(uri.AbsolutePath) ) bm=new Bitmap(uri.AbsolutePath); else bm=ErrorBitmap; ImageLineItem ili=new ImageLineItem(CurrentLine, ElementNode, bm); ReflowMarkup(ili, dc, style, bounds); tag=new EndTag(CurrentLine, ElementNode); ReflowMarkup(tag, dc, style, bounds); ReflowEnd(dc); }