-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomImageEdit.vb
89 lines (78 loc) · 2.62 KB
/
CustomImageEdit.vb
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports DevExpress.Skins
Imports DevExpress.XtraEditors.Registrator
Imports DevExpress.XtraEditors.Repository
Imports System.Drawing
Imports System.Reflection
Imports DevExpress.XtraEditors.ViewInfo
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Drawing
Imports System.IO
Imports System.ComponentModel
Imports DevExpress.XtraEditors.Controls
Namespace DXSample
Public Class RepositoryItemCustomImageEdit
Inherits RepositoryItemImageEdit
Shared Sub New()
RegisterCustomEdit()
End Sub
Public Sub New()
End Sub
Public Const CustomEditName As String = "CustomImageEdit"
Public Overrides ReadOnly Property EditorTypeName() As String
Get
Return CustomEditName
End Get
End Property
Public Shared Sub RegisterCustomEdit()
EditorRegistrationInfo.Default.Editors.Add(New EditorClassInfo(CustomEditName, _
GetType(CustomImageEdit), GetType(RepositoryItemCustomImageEdit), GetType(ImageEditViewInfo), _
New CustomBlobBaseEditPainter(), True))
End Sub
Public Shared Function GetImage(ByVal array() As Byte) As Image
Return ByteImageConverter.FromByteArray(array)
End Function
End Class
Public Class CustomImageEdit
Inherits ImageEdit
Shared Sub New()
RepositoryItemCustomImageEdit.RegisterCustomEdit()
End Sub
Public Sub New()
End Sub
Public Overrides ReadOnly Property EditorTypeName() As String
Get
Return RepositoryItemCustomImageEdit.CustomEditName
End Get
End Property
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public Shadows ReadOnly Property Properties() As RepositoryItemCustomImageEdit
Get
Return TryCast(MyBase.Properties, RepositoryItemCustomImageEdit)
End Get
End Property
End Class
Public Class CustomBlobBaseEditPainter
Inherits BlobBaseEditPainter
Public Sub New()
MyBase.New()
End Sub
Protected Overrides Sub DrawGlyphCore(ByVal info As ControlGraphicsInfoArgs, ByVal be As ButtonEditViewInfo)
Dim info_ As ImageEditViewInfo = TryCast(be, ImageEditViewInfo)
Dim image As Image = Nothing
If TypeOf info_.EditValue Is Byte() Then
image = New Bitmap(RepositoryItemCustomImageEdit.GetImage(TryCast(info_.EditValue, Byte())), info_.ImageSize)
ElseIf TypeOf info_.EditValue Is Image Then
image = New Bitmap(CType(info_.EditValue, Image), info_.ImageSize)
End If
If image Is Nothing Then
MyBase.DrawGlyphCore(info, be)
Return
End If
info.Cache.Paint.DrawImage(info.Graphics, image, be.GlyphBounds)
End Sub
End Class
End Namespace