-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWizardCustomizationService.vb
58 lines (52 loc) · 3.11 KB
/
WizardCustomizationService.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
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Wizard
Imports DevExpress.DataAccess.Wizard.Model
Imports DevExpress.Xpf.DataAccess.DataSourceWizard
Imports DevExpress.Xpf.Reports.UserDesigner.ReportWizard
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.Wizards
Imports DevExpress.XtraReports.Wizards.Presenters
Imports System
Imports System.Collections.Generic
Imports System.Drawing.Printing
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Namespace CustomReportWizard
Friend Class WizardCustomizationService
Implements IWizardCustomizationService
Private Sub IDataSourceWizardCustomizationService_CustomizeDataSourceWizard(ByVal customization As DataSourceWizardCustomizationModel, ByVal container As ViewModelSourceIntegrityContainer) Implements IDataSourceWizardCustomizationService.CustomizeDataSourceWizard
End Sub
Private Sub IWizardCustomizationService_CustomizeReportWizard(ByVal customization As ReportWizardCustomizationModel, ByVal container As ViewModelSourceIntegrityContainer) Implements IWizardCustomizationService.CustomizeReportWizard
customization.Model = New CustomReportModel()
container.RegisterType(Of ChoosePageSettingsPage(Of CustomReportModel))()
container.RegisterType(Of ChooseReportTypePage(Of XtraReportModel), CustomChooseReportTypePage)()
container.RegisterViewModel(Of IChoosePageSettingsPageView, ChoosePageSettingsPageViewModel)()
End Sub
Private Function IDataSourceWizardCustomizationService_TryCreateDataSource(ByVal model As IDataSourceModel, ByRef dataSource As Object, ByRef dataMember As String) As Boolean Implements IDataSourceWizardCustomizationService.TryCreateDataSource
dataSource = Nothing
dataMember = Nothing
Return False
End Function
Private Function IWizardCustomizationService_TryCreateReport(ByVal model As XtraReportModel, ByRef report As XtraReport) As Boolean Implements IWizardCustomizationService.TryCreateReport
Dim customModel = TryCast(model, CustomReportModel)
If customModel Is Nothing OrElse model.ReportType = ReportType.Template OrElse model.ReportType = ReportType.Label Then
report = Nothing
Return False
End If
Dim dataSource As IDataComponent = Nothing
Dim dataMember As String = Nothing
If customModel.ReportType <> ReportType.Empty Then
Dim dataComponentCreator = New DataComponentCreator()
dataSource = dataComponentCreator.CreateDataComponent(model)
dataMember = dataSource.DataMember
End If
Dim builder = New DevExpress.Xpf.Reports.UserDesigner.ReportWizard.ReportBuilder(dataSource, dataMember)
report = New XtraReport()
report.PaperKind = customModel.PaperKind
report.Margins = customModel.PageMargins
builder.Build(report, customModel)
Return True
End Function
End Class
End Namespace