-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPictureProvider.cs
More file actions
47 lines (42 loc) · 1.41 KB
/
MyPictureProvider.cs
File metadata and controls
47 lines (42 loc) · 1.41 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
41
42
43
44
45
46
47
using System;
using DevExpress.Spreadsheet;
using System.Collections.Generic;
using System.IO;
using DevExpress.Office.Utils;
using DevExpress.Drawing;
namespace SpreadsheetDocumentServerAsDataSourceExample
{
#region #MyPictureProvider
public class MyPictureProvider : IBindingRangeValueConverter
{
Dictionary<string, DXImage> pictures;
public MyPictureProvider(Worksheet sheet)
{
pictures = GetPictures(sheet);
}
public object ConvertToObject(CellValue value, Type requiredType, int columnIndex)
{
if (columnIndex == 13)
{
DXImage pic;
if (pictures.TryGetValue(value.TextValue, out pic))
return pic;
}
return value;
}
public CellValue TryConvertFromObject(object value)
{
return CellValue.Empty;
}
public Dictionary<string, DXImage> GetPictures(Worksheet sheet)
{
Dictionary<string, DevExpress.Drawing.DXImage> employeePictures = new Dictionary<string, DevExpress.Drawing.DXImage>();
foreach (Picture pic in sheet.Pictures)
{
employeePictures.Add(pic.Name, DXImage.FromStream(new MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))));
}
return employeePictures;
}
}
#endregion #MyPictureProvider
}