This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomGridView.vb
98 lines (92 loc) · 3.26 KB
/
CustomGridView.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
90
91
92
93
94
95
96
97
98
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraEditors.Repository
Imports EditorDescendant
Imports DevExpress.XtraGrid.Views.Printing
Namespace ImageTextEdit
<System.ComponentModel.DesignerCategory("")> _
Public Class CustomGridView
Inherits GridView
Private nowDrawingCellInfo As GridCellInfo
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal grid As GridControl)
MyBase.New(grid)
End Sub
Private Shared ReadOnly _onSmartIconSelection As Object = New Object()
Public Overrides Sub Assign(ByVal v As BaseView, ByVal copyEvents As Boolean)
If v Is Nothing Then
Return
End If
BeginUpdate()
Try
Dim gv As CustomGridView = TryCast(v, CustomGridView)
If gv IsNot Nothing Then
If copyEvents Then
Events.AddHandler(_onSmartIconSelection, gv.Events(_onSmartIconSelection))
End If
End If
Finally
EndUpdate()
End Try
End Sub
Public Custom Event OnSmartIconSelection As OnSmartIconSelectionEventHandler
AddHandler(ByVal value As OnSmartIconSelectionEventHandler)
Me.Events.AddHandler(_onSmartIconSelection, value)
End AddHandler
RemoveHandler(ByVal value As OnSmartIconSelectionEventHandler)
Me.Events.RemoveHandler(_onSmartIconSelection, value)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As SmartIconSelectionEventArgs)
End RaiseEvent
End Event
Protected Friend Overridable Sub RaiseOnSmartIconSelection(ByVal e As SmartIconSelectionEventArgs)
Dim handler As OnSmartIconSelectionEventHandler = CType(Events(_onSmartIconSelection), OnSmartIconSelectionEventHandler)
If handler IsNot Nothing Then
handler(Me, e)
End If
End Sub
Protected Overrides ReadOnly Property ViewName() As String
Get
Return "CustomGridView"
End Get
End Property
Protected Overrides Sub ActivateEditor(ByVal cell As GridCellInfo)
Dim iconSelector As IIconSelector = TryCast(cell.Editor, IIconSelector)
If iconSelector IsNot Nothing Then
AddHandler iconSelector.OnIconSelection, AddressOf iconSelector_OnIconSelection
nowDrawingCellInfo = cell
End If
MyBase.ActivateEditor(cell)
End Sub
Public Overrides Sub HideEditor()
If (Not IsEditing) OrElse (Not fAllowCloseEditor) Then
Return
End If
If ActiveEditor IsNot Nothing AndAlso GridControl IsNot Nothing Then
Dim iconSelector As IIconSelector = TryCast(ActiveEditor.Properties, IIconSelector)
If iconSelector IsNot Nothing Then
RemoveHandler iconSelector.OnIconSelection, AddressOf iconSelector_OnIconSelection
End If
End If
MyBase.HideEditor()
End Sub
Protected Overrides Function CreatePrintInfoInstance(ByVal args As PrintInfoArgs) As BaseViewPrintInfo
Dim info As BaseViewPrintInfo = New MyGridViewPrintInfo(args)
Return info
End Function
Friend Sub iconSelector_OnIconSelection(ByVal sender As Object, ByVal e As IconSelectionEventArgs)
Dim ee As New SmartIconSelectionEventArgs(e.Image, nowDrawingCellInfo, True)
RaiseOnSmartIconSelection(ee)
e.Image = ee.Image
End Sub
End Class
End Namespace