/// Constructs an element at the specified offset. /// May return null if no element should be constructed. protected override InlineObjectElement ConstructMainElement(int offset) { Match m = FindMatch(offset); // check whether there's a match exactly at offset if (m.Success && m.Index == 0) { string scale = m.Groups[1].Value; string laTex = m.Groups[2].Value; BitmapImage bitmap = LaTexImageCache.Instance.LoadImage(laTex, scale); if (bitmap != null) { CustomImageControl image = new CustomImageControl(offset, TextEditor); image.Source = bitmap; image.Width = bitmap.PixelWidth; image.Height = bitmap.PixelHeight; image.Cursor = Cursors.Arrow; // Pass the length of the match to the 'documentLength' parameter // of InlineObjectElement. return(new InlineObjectElement(m.Length, image)); } } return(null); }
private Image CreateImageControl(int offset, string scale, BitmapImage bitmap) { CustomImageControl image = new CustomImageControl(offset, TextEditor); image.Source = bitmap; double zoom = CalcZoom(bitmap, scale); image.Width = bitmap.PixelWidth * zoom; image.Height = bitmap.PixelHeight * zoom; image.Cursor = Cursors.Arrow; return(image); }