This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomizeExportControllerWin.vb
74 lines (68 loc) · 3.2 KB
/
CustomizeExportControllerWin.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
Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.ExpressApp.Win.SystemModule
Imports DevExpress.ExpressApp.Win.Editors
Imports DevExpress.ExpressApp.Win
Imports System.Windows.Forms
Imports System.IO
Imports CustomizeExportAction.Module.Controllers
Imports DevExpress.XtraGrid.Views.Grid
Namespace CustomizeExportAction.Module.Win.Controllers
Partial Public Class CustomizeExportControllerWin
Inherits CustomizeExportController
Private winExportController As WinExportController
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
winExportController = Frame.GetController(Of WinExportController)()
AddHandler winExportController.Exported, AddressOf winExportController_Exported
End Sub
Private Sub winExportController_Exported(ByVal sender As Object, ByVal e As DevExpress.ExpressApp.SystemModule.CustomExportEventArgs)
If TypeOf e.Stream Is FileStream Then
Dim fileName As String = CType(e.Stream, FileStream).Name
If File.Exists(fileName) Then
e.Stream.Close()
If WinApplication.Messaging.GetUserChoice("Open the exported file?", GetMessageBoxCaption(), MessageBoxButtons.YesNo) = DialogResult.Yes Then
Process.Start(fileName)
End If
End If
End If
End Sub
Protected Overrides Sub CustomExport(ByVal sender As Object, ByVal e As DevExpress.ExpressApp.SystemModule.CustomExportEventArgs)
MyBase.CustomExport(sender, e)
'Show a message before exporting a Grid List Editor
Dim gridListEditor As GridListEditor = TryCast(CType(View, DevExpress.ExpressApp.ListView).Editor, GridListEditor)
If gridListEditor IsNot Nothing Then
Dim gridView As GridView = gridListEditor.GridView
If HasCollapsedGroups(gridView) Then
Dim message As String = "There are collapsed groups in the grid. Expand all groups in the exported file?"
gridView.OptionsPrint.ExpandAllGroups = WinApplication.Messaging.GetUserChoice(message, GetMessageBoxCaption(), MessageBoxButtons.YesNo) = DialogResult.Yes
End If
End If
End Sub
Private Function HasCollapsedGroups(ByVal gridView As GridView) As Boolean
If gridView.GroupCount > 0 Then
Dim rowHandle As Integer = -1
Do While gridView.IsValidRowHandle(rowHandle)
If Not gridView.GetRowExpanded(rowHandle) Then
Return True
End If
rowHandle -= 1
Loop
End If
Return False
End Function
Private Function GetMessageBoxCaption() As String
Return String.Format("{0} {1}", winExportController.ExportAction.Caption, winExportController.ExportAction.SelectedItem)
End Function
Protected Overrides Sub OnDeactivated()
RemoveHandler winExportController.Exported, AddressOf winExportController_Exported
MyBase.OnDeactivated()
End Sub
End Class
End Namespace