This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
ShowImageController.vb
57 lines (55 loc) · 2.18 KB
/
ShowImageController.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
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.SystemModule
Imports DevExpress.ExpressApp.Win.Editors
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraGrid.Views.Grid
Imports System.Drawing
Namespace Solution15.Module.Win
Public Class ShowImageController
Inherits ViewController(Of ListView)
Private controller As ListViewProcessCurrentObjectController
Protected Overrides Overloads Sub OnActivated()
MyBase.OnActivated()
controller = Frame.GetController(Of ListViewProcessCurrentObjectController)()
AddHandler controller.CustomProcessSelectedItem, AddressOf controller_CustomProcessSelectedItem
End Sub
Protected Overrides Overloads Sub OnDeactivated()
RemoveHandler controller.CustomProcessSelectedItem, AddressOf controller_CustomProcessSelectedItem
MyBase.OnDeactivated()
End Sub
Private Sub controller_CustomProcessSelectedItem(ByVal sender As Object, ByVal e As CustomProcessListViewSelectedItemEventArgs)
Dim editor As GridListEditor = TryCast(View.Editor, GridListEditor)
If editor Is Nothing Then
Return
End If
Dim ghi As GridHitInfo = editor.GridView.CalcHitInfo(editor.Grid.PointToClient(System.Windows.Forms.Control.MousePosition))
If ghi.InRowCell Then
Dim data As Object = editor.GridView.GetRowCellValue(ghi.RowHandle, ghi.Column)
If TypeOf data Is Image Then
ShowImageDialog(CType(data, Image))
e.Handled = True
End If
End If
End Sub
Private Sub ShowImageDialog(ByVal image As Image)
Dim form As New System.Windows.Forms.Form()
Dim pbox As New System.Windows.Forms.PictureBox()
pbox.Dock = System.Windows.Forms.DockStyle.Fill
pbox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
pbox.Image = image
form.Controls.Add(pbox)
form.Size = New Size(300, 300)
form.ControlBox = False
AddHandler pbox.DoubleClick, AddressOf pbox_DoubleClick
form.ShowDialog()
form.Dispose()
End Sub
Private Sub pbox_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
CType(sender, System.Windows.Forms.Control).FindForm().Close()
End Sub
End Class
End Namespace