This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
/
WizardCustomizationService.cs
65 lines (60 loc) · 3.02 KB
/
WizardCustomizationService.cs
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
using System.ComponentModel.Design;
using CustomWizardExample.Wizard.Presenters;
using CustomWizardExample.Wizard.Views;
using DevExpress.DataAccess.ObjectBinding;
using DevExpress.DataAccess.UI.Wizard;
using DevExpress.DataAccess.Wizard.Model;
using DevExpress.XtraReports.Wizards;
using DevExpress.XtraReports.Wizards.Presenters;
namespace CustomWizardExample.Wizard {
class WizardCustomizationService : IWizardCustomizationService {
void IWizardCustomizationService.CustomizeDataSourceWizard(IWizardCustomization<XtraReportModel> tool) {
// Set the start page.
tool.StartPage = typeof(ChoosePersonsPage2<DataSourceModel>);
// Register the custom page.
tool.RegisterPage<ChoosePersonsPage2<XtraReportModel>, ChoosePersonsPage2<XtraReportModel>>();
// Register the custom page view.
tool.RegisterPageView<IChoosePersonsPageView, ChoosePersonsPageView2>();
}
void IWizardCustomizationService.CustomizeReportWizard(IWizardCustomization<XtraReportModel> tool) {
// Redefine the start page.
tool.RegisterPage<ChooseReportTypePage<XtraReportModel>, ChoosePersonsPage>();
// Register the custom page.
tool.RegisterPage<ChoosePersonsPage2<XtraReportModel>, ChoosePersonsPage3>();
// Register the custom page view.
tool.RegisterPageView<IChoosePersonsPageView, ChoosePersonsPageView2>();
}
bool IWizardCustomizationService.TryCreateReport(IDesignerHost designerHost, XtraReportModel model, object dataSource, string dataMember) {
return false;
}
bool IWizardCustomizationService.TryCreateDataSource(IDataSourceModel model, out object dataSource, out string dataMember) {
if (model.DataSourceType == CustomDataSourceType.StaticPersons) {
dataMember = string.Empty;
dataSource = CreateObjectDataSource("GetStaticPersons");
return true;
}
else if (model.DataSourceType == CustomDataSourceType.XmlPersons) {
dataMember = string.Empty;
dataSource = CreateObjectDataSource("GetXmlPersons");
return true;
}
else {
dataMember = string.Empty;
dataSource = null;
return false;
}
}
static ObjectDataSource CreateObjectDataSource(string dataMember) {
var objectDataSource = new ObjectDataSource();
objectDataSource.Constructor = new ObjectConstructorInfo();
objectDataSource.DataMember = dataMember;
objectDataSource.DataSource = typeof(PersonsSource);
objectDataSource.Name = "objectDataSource1";
return objectDataSource;
}
}
public class CustomDataSourceType : DataSourceType {
public static readonly DataSourceType StaticPersons = new CustomDataSourceType();
public static readonly DataSourceType XmlPersons = new CustomDataSourceType();
}
}