i'm trying to get a thumbnail of the active layout of each of the drawings i have actively open. right now i'm doing:
{code}
Public Sub Refresh()
If Doc IsNot Nothing Then
_DocName = Doc.Name
Dim tn As LayoutThumbnailEnumerator = LayoutThumbnailEnumerator.EnumerateLayoutThumbnails(Doc, LayoutThumbnailEnumerator.ThumbnailCaptureFlags.CaptureAll)
For ii = 0 To tn.Count - 1
If tn.Thumbnail IsNot Nothing Then
BeginCBitmap(tn.Thumbnail)
Exit For
End If
tn.MoveNext()
Next
Dim sp As String() = Doc.Name.Split("\")
myLabel.Text = sp(sp.Count - 1)
End If
End Sub
Sub BeginCBitmap(ByVal Img As System.Drawing.Bitmap)
_BitMap = Img.GetHbitmap
_Height = Img.Height
_Width = Img.Width
Dim op As DispatcherOperation = Dispatcher.BeginInvoke(DispatcherPriority.Background, New Action(AddressOf cBitmap))
AddHandler op.Completed, AddressOf opCompleted
End Sub
Private _BitMap As System.IntPtr
Private _Width As Integer
Private _Height As Integer
Private _DocName As String
Private _BitmapSource As BitmapSource
Private ConvertBitmapThread As New System.Threading.Thread(AddressOf cBitmap)
Private Event BitmapConverted(ByVal bmp As BitmapSource)
Private Sub cBitmap()
If Not _BitMap = Nothing _
AndAlso Not _Width = Nothing _
AndAlso Not _Height = Nothing Then
_BitmapSource = Imaging.CreateBitmapSourceFromHBitmap(_BitMap, _
IntPtr.Zero, _
System.Windows.Int32Rect.Empty, _
BitmapSizeOptions.FromWidthAndHeight(_Width, _Height))
End If
End Sub
Private Sub opCompleted()
Try
myThumb = New Image
AddHandler myThumb.SizeChanged, AddressOf myThumb_SizeChanged
myThumb.Source = _BitmapSource
InteractionRectangle.ToolTip = _DocName
myPresenter.Content = myThumb
Catch ex As Exception
End Try
End Sub
{code}
But that only gives me a modelspace thumbnail, which is usually fine, but when i'm working in paperspace it's still the modelspace of that drawing, and modelspace doesn't always have objects in it, what i would really like is a thumbnail of whatever is active, any suggestions would be greatly appreciated B) thanks!