Browse Source

Create PushModel report with Wizard

pull/505/merge
Peter Forstmeier 11 years ago
parent
commit
e8293448cd
  1. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj
  2. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/BaseSettingsPage.xaml.cs
  3. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/IHasContext.cs
  4. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml
  5. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/ReportWizard.xaml
  6. 23
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/ReportWizard.xaml.cs
  7. 68
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ReportGenerator.cs
  8. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ReportWizardCommand.cs
  9. 24
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ViewModels/PushModelContext.cs
  10. 11
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ViewModels/ReportWizardContext.cs
  11. 20
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/WizardPageType.cs

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj

@ -165,8 +165,10 @@ @@ -165,8 +165,10 @@
<Compile Include="src\ReportWizard\ReportGenerator.cs" />
<Compile Include="src\ReportWizard\ReportWizardCommand.cs" />
<Compile Include="src\ReportWizard\ViewModels\PageOneContext.cs" />
<Compile Include="src\ReportWizard\ViewModels\PushModelContext.cs" />
<Compile Include="src\ReportWizard\ViewModels\ReportWizardContext.cs" />
<Compile Include="src\ReportWizard\WizardHelper.cs" />
<Compile Include="src\ReportWizard\WizardPageType.cs" />
<Compile Include="src\Services\DefaultMemberRelationshipService.cs" />
<Compile Include="src\Services\DesignerSerializationService.cs" />
<Compile Include="src\Services\MenuCommandService.cs" />

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/BaseSettingsPage.xaml.cs

@ -44,8 +44,8 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog{ @@ -44,8 +44,8 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog{
return context;}
}
public int PageNumber {
get {return 1;}
public WizardPageType ReportPageType {
get {return WizardPageType.BaseSettingsPage;}
}

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/IHasContext.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog @@ -17,6 +17,7 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog
public interface IHasContext
{
IWizardContext Context {get;}
int PageNumber {get;}
WizardPageType ReportPageType {get;}
}
}

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
Title="SharpDevelop Reporting"
Description="Welcome to Sharpdevelop Reporting Wizard"
PageType="Interior"
NextButtonVisibility="Visible"
CanFinish="true"
CancelButtonVisibility="Visible">
<Grid ShowGridLines="True">

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/ReportWizard.xaml

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
PageChanged="_wizard_PageChanged"
Finish="_wizard_Finish"
CanHelp="False">
<local:WelcomePage></local:WelcomePage>
<local:BaseSettingsPage></local:BaseSettingsPage>

23
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/ReportWizard.xaml.cs

@ -14,6 +14,7 @@ using System.Windows; @@ -14,6 +14,7 @@ using System.Windows;
using System.Windows.Media.Imaging;
using ICSharpCode.SharpDevelop;
using Xceed.Wpf.Toolkit;
using ICSharpCode.Reporting.Addin.ReportWizard.Dialog;
using ICSharpCode.Reporting.Addin.ReportWizard.ViewModels;
using System.Linq;
@ -48,9 +49,29 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog @@ -48,9 +49,29 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog
void _wizard_Finish(object sender, RoutedEventArgs e)
{
context.PageOneContext = baseSettingsPage.Context;
foreach (WizardPage element in _wizard.Items) {
var hc = element as IHasContext;
if (hc != null) {
UpdateContext(hc);
}
}
}
void UpdateContext(IHasContext hc)
{
switch (hc.ReportPageType) {
case WizardPageType.BaseSettingsPage:{
context.PageOneContext = hc.Context;
break;
}
case WizardPageType.PushModelPage: {
context.PushModelContext = hc.Context;
break;
}
}
}
}
}

68
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ReportGenerator.cs

@ -23,43 +23,65 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard @@ -23,43 +23,65 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard
/// </summary>
public class ReportGenerator
{
ReportWizardContext context;
const int gap = 10;
public ReportGenerator(ReportWizardContext context)
public ReportGenerator()
{
if (context == null)
throw new ArgumentNullException("context");
this.context = context;
ReportModel = ReportModelFactory.Create();
}
public void Generate() {
PageOneGenerate();
CreateReportHeader();
public void Generate(ReportWizardContext context) {
if (context == null)
throw new ArgumentNullException("context");
GenerateBaseSettings(context);
GeneratePushModel(context);
CreateReportHeader(context);
}
void PageOneGenerate()
{
var pageOne = (PageOneContext)context.PageOneContext;
void GenerateBaseSettings (ReportWizardContext context) {
var pageOneContext = (PageOneContext)context.PageOneContext;
var reportSettings = ReportModel.ReportSettings;
reportSettings.DataModel = pageOne.DataModel;
reportSettings.FileName = pageOne.FileName;
if (pageOne.Legal) {
reportSettings.Landscape = false;
} else {
reportSettings.Landscape = true;
reportSettings.DataModel = pageOneContext.DataModel;
reportSettings.FileName = pageOneContext.FileName;
reportSettings.Landscape = !pageOneContext.Legal;
reportSettings.ReportName = pageOneContext.ReportName;
reportSettings.ReportType = pageOneContext.ReportType;
}
void GeneratePushModel(ReportWizardContext context){
var pushModelContext = (PushModelContext)context.PushModelContext;
var xLocation = 5;
foreach (var element in pushModelContext.Items) {
var dataItem = new BaseDataItem(){
Name = element.ColumnName,
Text = element.ColumnName,
ColumnName = element.ColumnName,
DataType = element.DataTypeName
};
var location = new Point(xLocation,4);
dataItem.Location = location;
dataItem.Size = GlobalValues.PreferedSize;
xLocation = xLocation + GlobalValues.PreferedSize.Width + gap;
Console.WriteLine("Create dataItem with {0} - {1}items",dataItem.Location,dataItem.Size);
ReportModel.DetailSection.Items.Add(dataItem);
}
reportSettings.ReportName = pageOne.ReportName;
reportSettings.ReportType = pageOne.ReportType;
}
void CreateReportHeader()
{
void CreateReportHeader(ReportWizardContext context){
var pageOneContext = (PageOneContext)context.PageOneContext;
var headerText = new BaseTextItem();
headerText.Text = "Header";
if (String.IsNullOrEmpty(pageOneContext.ReportName)) {
headerText.Text = GlobalValues.DefaultReportName;
} else {
headerText.Text = pageOneContext.ReportName;
}
headerText.Size = GlobalValues.PreferedSize;
var printableWith = ReportModel.ReportSettings.PageSize.Width - ReportModel.ReportSettings.LeftMargin - ReportModel.ReportSettings.RightMargin;
var x = (int)(printableWith - headerText.Size.Width) / 2;

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ReportWizardCommand.cs

@ -36,9 +36,9 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard @@ -36,9 +36,9 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard
reportWizard.ShowDialog();
if (reportWizard.DialogResult.HasValue && reportWizard.DialogResult.Value){
LoggingService.Info("ReportWizard - CreateReport");
var rg = new ReportGenerator(wizardViewModel);
var rg = new ReportGenerator();
rg.Generate();
rg.Generate(wizardViewModel);
ReportModel = rg.ReportModel;
} else {
Canceled = true;

24
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ViewModels/PushModelContext.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 12.08.2014
* Time: 19:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using ICSharpCode.Reporting.BaseClasses;
namespace ICSharpCode.Reporting.Addin.ReportWizard.ViewModels
{
/// <summary>
/// Description of PushModelContent.
/// </summary>
///
public class PushModelContext:IWizardContext
{
public List<AbstractColumn> Items {get;set;}
}
}

11
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/ViewModels/ReportWizardContext.cs

@ -35,5 +35,16 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.ViewModels @@ -35,5 +35,16 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.ViewModels
pageOneContext = value;
}
}
IWizardContext pushModelContext;
public IWizardContext PushModelContext {
get {
return pushModelContext;
}
set {
pushModelContext = value;
}
}
}
}

20
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/WizardPageType.cs

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 14.08.2014
* Time: 19:27
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace ICSharpCode.Reporting.Addin.ReportWizard
{
/// <summary>
/// Description of WizardPageType.
/// </summary>
public enum WizardPageType {
BaseSettingsPage,
PushModelPage
}
}
Loading…
Cancel
Save