Browse Source

Rendering: Nested Containers are detected, Format of double, some cleanup

pull/681/head
Peter Forstmeier 10 years ago
parent
commit
1952fc3556
  1. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin
  2. 25
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Commands/FormsCommands.cs
  3. 5
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Commands/ViewCommands.cs
  4. 21
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/DesignerBinding.cs
  5. 18
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/DesignerGlobals.cs
  6. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/GlobalLists.cs
  7. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/TextDrawer.cs
  8. 10
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs
  9. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs
  10. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs
  11. 65
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs
  12. 5
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs
  13. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExporter.cs
  14. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs
  15. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin

@ -106,7 +106,9 @@ @@ -106,7 +106,9 @@
<Path name="/SharpDevelop/ReportDesigner/ContextMenus/SelectionMenu">
<MenuItem id="ViewCode" label="${res:SharpDevelop.FormsDesigner.ContextMenus.ViewCodeCommand}" icon="Icons.16x16.FormsDesigner.ViewCode" class="ICSharpCode.Reporting.Addin.Commands.ViewCode" />
<MenuItem id="ViewCode" label="${res:SharpDevelop.FormsDesigner.ContextMenus.ViewCodeCommand}"
icon="Icons.16x16.FormsDesigner.ViewCode"
class="ICSharpCode.Reporting.Addin.Commands.ViewCode" />
<!-- <MenuItem id="ShowProperties" label="${res:XML.MainMenu.FormatMenu.ShowProperties}" icon="Icons.16x16.Property" class="ICSharpCode.Reports.Addin.Commands.ShowProperties" />-->

25
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Commands/FormsCommands.cs

@ -10,7 +10,6 @@ using System; @@ -10,7 +10,6 @@ using System;
using System.ComponentModel.Design;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Reporting.Addin.Views;
namespace ICSharpCode.Reporting.Addin.Commands
@ -19,16 +18,16 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -19,16 +18,16 @@ namespace ICSharpCode.Reporting.Addin.Commands
/// Description of FormsCommands.
/// </summary>
public abstract class AbstractFormsDesignerCommand : AbstractMenuCommand
{
public abstract class AbstractFormsDesignerCommand : AbstractMenuCommand{
public abstract CommandID CommandID {
get;
}
protected virtual bool CanExecuteCommand(IDesignerHost host)
{
return true;
}
{return true;}
protected static DesignerView ReportDesigner {
get {
@ -41,8 +40,7 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -41,8 +40,7 @@ namespace ICSharpCode.Reporting.Addin.Commands
}
public override void Run()
{
public override void Run(){
var formDesigner = ReportDesigner;
if (formDesigner != null && CanExecuteCommand(formDesigner.Host)) {
var menuCommandService = (IMenuCommandService)formDesigner.Host.GetService(typeof(IMenuCommandService));
@ -50,8 +48,7 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -50,8 +48,7 @@ namespace ICSharpCode.Reporting.Addin.Commands
}
}
internal virtual void CommandCallBack(object sender, EventArgs e)
{
internal virtual void CommandCallBack(object sender, EventArgs e){
Run();
}
}
@ -61,14 +58,10 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -61,14 +58,10 @@ namespace ICSharpCode.Reporting.Addin.Commands
public class ViewCode : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
get {
return StandardCommands.ViewCode;
}
get {return StandardCommands.ViewCode;}
}
public override void Run()
{
// var window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
public override void Run(){
var window = SD.Workbench;
if (window == null) {
return;

5
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Commands/ViewCommands.cs

@ -17,8 +17,8 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -17,8 +17,8 @@ namespace ICSharpCode.Reporting.Addin.Commands
/// <summary>
/// Description of ViewCommands.
/// </summary>
public class CreateDesignerCommand : AbstractMenuCommand
{
public class CreateDesignerCommand : AbstractMenuCommand{
readonly OpenedFile openedFile;
public CreateDesignerCommand (OpenedFile openedFile) {
@ -29,7 +29,6 @@ namespace ICSharpCode.Reporting.Addin.Commands @@ -29,7 +29,6 @@ namespace ICSharpCode.Reporting.Addin.Commands
public override void Run(){
var generator = new DesignerGenerator();
DesignerView = new DesignerView(openedFile, generator);
}

21
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/DesignerBinding.cs

@ -11,8 +11,6 @@ using System; @@ -11,8 +11,6 @@ using System;
using System.IO;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.Reporting.Factories;
using ICSharpCode.Reporting.Items;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.Reporting.Addin.Commands;
using ICSharpCode.Reporting.Addin.Factory;
@ -20,30 +18,24 @@ using ICSharpCode.Reporting.Addin.ReportWizard; @@ -20,30 +18,24 @@ using ICSharpCode.Reporting.Addin.ReportWizard;
namespace ICSharpCode.Reporting.Addin.DesignerBinding {
public class ReportDesignerBinding:IDisplayBinding {
public bool IsPreferredBindingForFile(FileName fileName)
{
public bool IsPreferredBindingForFile(FileName fileName){
return true;
}
public bool CanCreateContentForFile(FileName fileName)
{
public bool CanCreateContentForFile(FileName fileName){
return Path.GetExtension(fileName).Equals(".srd", StringComparison.OrdinalIgnoreCase);
}
public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType)
{
throw new System.NotImplementedException();
public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType){
throw new NotImplementedException();
}
public IViewContent CreateContentForFile(OpenedFile file)
{
public IViewContent CreateContentForFile(OpenedFile file){
if (file.IsDirty) {
var cmd = new ReportWizardCommand();
cmd.Run();
@ -67,8 +59,7 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding { @@ -67,8 +59,7 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding {
}
static byte[] XmlToArray(XmlDocument doc)
{
static byte[] XmlToArray(XmlDocument doc){
using (var stream = new MemoryStream()) {
doc.Save(stream);
return stream.ToArray();

18
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/DesignerGlobals.cs

@ -29,23 +29,5 @@ namespace ICSharpCode.Reporting.Addin.Globals @@ -29,23 +29,5 @@ namespace ICSharpCode.Reporting.Addin.Globals
public static int GabBetweenSection{
get {return 15;}
}
/*
public static void DrawString(Graphics graphics,string text,
Font font,Brush brush,
RectangleF rectangle,
StringFormat format)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
graphics.DrawString(text,
font,
brush,
rectangle,
format);
}
*/
}
}

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/GlobalLists.cs

@ -17,8 +17,7 @@ namespace ICSharpCode.Reporting.Addin.Globals @@ -17,8 +17,7 @@ namespace ICSharpCode.Reporting.Addin.Globals
{
#region DataTypes
public static string[] DataTypeList ()
{
public static string[] DataTypeList (){
return (string[])dataTypeList.Clone();
}

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/TextDrawer.cs

@ -34,7 +34,8 @@ namespace ICSharpCode.Reporting.BaseClasses @@ -34,7 +34,8 @@ namespace ICSharpCode.Reporting.BaseClasses
format);
}
// http://stackoverflow.com/questions/14932063/convert-code-of-a-user-control-from-vb-net-to-c-sharp
//https://mightycoco.wordpress.com/2009/09/22/getstringformatfromcontentallignment-converting-contentallignment-data-into-stringformat-data/
public static StringFormat BuildStringFormat(StringTrimming stringTrimming,TextAlignment alignment){
StringFormat format = StringFormat.GenericTypographic;
format.Trimming = stringTrimming;
@ -65,6 +66,7 @@ namespace ICSharpCode.Reporting.BaseClasses @@ -65,6 +66,7 @@ namespace ICSharpCode.Reporting.BaseClasses
}
return format;
}
/*
public static StringFormat BuildStringFormat(StringTrimming stringTrimming,ContentAlignment alignment)

10
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs

@ -191,8 +191,14 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -191,8 +191,14 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
string ReadValueFromProperty (string columnName) {
var propertyPath = Current.ParsePropertyPath(columnName);
var val = propertyPath.Evaluate(Current);
return val.ToString();
try {
var val = propertyPath.Evaluate(Current);
return val.ToString();
} catch (Exception e) {
Console.WriteLine(" Cant' find <{0}",columnName);
// throw e;
}
return String.Empty;
}

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs

@ -22,13 +22,7 @@ using System.Reflection; @@ -22,13 +22,7 @@ using System.Reflection;
namespace ICSharpCode.Reporting.DataSource
{
/// <summary>
/// Description of ReflectionExtension.
/// </summary>
///
public static class ReflectionExtensions
{
public static PropertyPath ParsePropertyPath(this object target,string propertyPath)

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs

@ -33,6 +33,11 @@ namespace ICSharpCode.Reporting.Exporter.Visitors @@ -33,6 +33,11 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
public override void Visit(ExportContainer exportContainer)
{
foreach (var element in exportContainer.ExportedItems) {
var container = element as ExportContainer;
if (container != null) {
Visit(container);
}
var te = element as ExportText;
if (te != null) {
Visit(te);
@ -43,6 +48,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors @@ -43,6 +48,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
public override void Visit(ExportText exportColumn)
{
Console.WriteLine(exportColumn.Text);
if (!String.IsNullOrEmpty(exportColumn.FormatString)) {
StandardFormatter.FormatOutput(exportColumn);
}

65
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs

@ -25,39 +25,22 @@ namespace ICSharpCode.Reporting.Globals @@ -25,39 +25,22 @@ namespace ICSharpCode.Reporting.Globals
/// <summary>
/// Description of StandardFormatter.
/// </summary>
class StandardFormatter
static class StandardFormatter
{
public static void FormatOutput (IExportText textColumn) {
if (String.IsNullOrWhiteSpace(textColumn.Text)) {
return;
}
if (!String.IsNullOrEmpty(textColumn.FormatString)) {
TypeCode typeCode = TypeHelper.TypeCodeFromString(textColumn.DataType);
textColumn.Text = FormatItem(textColumn.Text,textColumn.FormatString,typeCode);
}
}
/*
public static string FormatOutput(string valueToFormat,string format,
string dataType, string nullValue )
{
if (String.IsNullOrEmpty(format)) {
return valueToFormat;
}
if (String.IsNullOrEmpty(valueToFormat)) {
return nullValue;
}
TypeCode typeCode = TypeHelper.TypeCodeFromString(dataType);
return FormatItem(valueToFormat,format,typeCode,nullValue);
}
*/
static string FormatItem (string valueToFormat,string format,TypeCode typeCode) {
// private static string FormatItem (string valueToFormat,string format,
// TypeCode typeCode,string nullValue)
static string FormatItem (string valueToFormat,string format,
TypeCode typeCode)
{
string retValue = String.Empty;
switch (typeCode) {
case TypeCode.Int16:
case TypeCode.Int32:
@ -74,6 +57,8 @@ namespace ICSharpCode.Reporting.Globals @@ -74,6 +57,8 @@ namespace ICSharpCode.Reporting.Globals
break;
case TypeCode.Double:
retValue = FormatDecimal (valueToFormat,format);
break;
case TypeCode.Single:
break;
@ -85,13 +70,12 @@ namespace ICSharpCode.Reporting.Globals @@ -85,13 +70,12 @@ namespace ICSharpCode.Reporting.Globals
retValue = valueToFormat;
break;
}
return retValue;
}
static string FormatBool (string toFormat)
{
static string FormatBool (string toFormat){
if (CheckValue(toFormat)) {
bool b = bool.Parse (toFormat);
return b.ToString (CultureInfo.CurrentCulture);
@ -100,11 +84,11 @@ namespace ICSharpCode.Reporting.Globals @@ -100,11 +84,11 @@ namespace ICSharpCode.Reporting.Globals
}
static string FormatIntegers(string toFormat, string format)
{
static string FormatIntegers(string toFormat, string format){
string str = String.Empty;
if (CheckValue (toFormat)) {
int number = Int32.Parse(toFormat, System.Globalization.NumberStyles.Any, CultureInfo.CurrentCulture.NumberFormat);
int number = Int32.Parse(toFormat, NumberStyles.Any, CultureInfo.CurrentCulture.NumberFormat);
str = number.ToString(format, CultureInfo.CurrentCulture);
return str;
} else {
@ -114,15 +98,15 @@ namespace ICSharpCode.Reporting.Globals @@ -114,15 +98,15 @@ namespace ICSharpCode.Reporting.Globals
}
static string FormatDecimal(string toFormat, string format)
{
static string FormatDecimal(string toFormat, string format){
string str = String.Empty;
if (CheckValue (toFormat)) {
try {
decimal dec = Decimal.Parse(toFormat,
System.Globalization.NumberStyles.Any,
decimal number = Decimal.Parse(toFormat,
NumberStyles.Any,
CultureInfo.CurrentCulture.NumberFormat);
str = dec.ToString (format,CultureInfo.CurrentCulture);
str = number.ToString (format,CultureInfo.CurrentCulture);
} catch (FormatException) {
throw ;
@ -136,8 +120,8 @@ namespace ICSharpCode.Reporting.Globals @@ -136,8 +120,8 @@ namespace ICSharpCode.Reporting.Globals
// http://stackoverflow.com/questions/4710455/i-need-code-to-validate-any-time-in-c-sharp-in-hhmmss-format
static string FormatDate(string toFormat, string format)
{
static string FormatDate(string toFormat, string format){
DateTime date;
if (DateTime.TryParse(toFormat, out date))
{
@ -158,12 +142,9 @@ namespace ICSharpCode.Reporting.Globals @@ -158,12 +142,9 @@ namespace ICSharpCode.Reporting.Globals
}
static bool CheckValue (string toFormat)
{
if (String.IsNullOrEmpty(toFormat)) {
return false;
}
return true;
static bool CheckValue (string toFormat){
return String.IsNullOrEmpty(toFormat) ? false : true;
}
}
}

5
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs

@ -55,6 +55,11 @@ namespace ICSharpCode.Reporting.Items @@ -55,6 +55,11 @@ namespace ICSharpCode.Reporting.Items
{
this.pageSize = GlobalValues.DefaultPageSize;
BaseValues();
var x = PdfSharp.PageSizeConverter.ToSize(PdfSharp.PageSize.A4);
//http://www.sizepaper.com/a-series/a4
// http://www.sizepaper.com/american-loose
System.Drawing.Printing.PageSettings paperProp = new System.Drawing.Printing.PageSettings();
var p = paperProp.PaperSize.PaperName.ToString();
}

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfExporter.cs

@ -49,6 +49,7 @@ namespace ICSharpCode.Reporting.Pdf @@ -49,6 +49,7 @@ namespace ICSharpCode.Reporting.Pdf
if (show) {
Process.Start(fileName);
}
}

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer @@ -46,7 +46,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer
var wpfExporter = new WpfExporter(pages);
wpfExporter.Run();
this.document = wpfExporter.Document;
this.Document = wpfExporter.Document;
}
static FixedDocument CreateFixedDocument(ReportSettings reportSettings)

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs

@ -115,7 +115,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -115,7 +115,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
return graphCanvas;
}
// http://stackoverflow.com/questions/25308612/vertical-alignment-with-drawingcontext-drawtext
public override void Visit(ExportText exportColumn){
var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);

Loading…
Cancel
Save