-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPictureProvider.vb
More file actions
40 lines (34 loc) · 1.57 KB
/
MyPictureProvider.vb
File metadata and controls
40 lines (34 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Imports System.IO
Imports DevExpress.Drawing
Imports DevExpress.Office.Utils
Imports DevExpress.Spreadsheet
Namespace SpreadsheetDocumentServerAsDataSourceExample
#Region "#MyPictureProvider"
Public Class MyPictureProvider
Implements IBindingRangeValueConverter
Private pictures As Dictionary(Of String, DXImage)
Public Sub New(ByVal sheet As Worksheet)
pictures = GetPictures(sheet)
End Sub
Public Function ConvertToObject(ByVal value As CellValue, ByVal requiredType As Type, ByVal columnIndex As Integer) As Object Implements IBindingRangeValueConverter.ConvertToObject
If columnIndex = 13 Then
Dim pic As DXImage = Nothing
If pictures.TryGetValue(value.TextValue, pic) Then
Return pic
End If
End If
Return value
End Function
Public Function TryConvertFromObject(ByVal value As Object) As CellValue Implements IBindingRangeValueConverter.TryConvertFromObject
Return CellValue.Empty
End Function
Public Function GetPictures(ByVal sheet As Worksheet) As Dictionary(Of String, DXImage)
Dim employeePictures As Dictionary(Of String, DXImage) = New Dictionary(Of String, DXImage)()
For Each pic As Picture In sheet.Pictures
employeePictures.Add(pic.Name, DXImage.FromStream(New MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))))
Next pic
Return employeePictures
End Function
End Class
#End Region
End Namespace