Click here to Skip to main content
15,886,137 members
Articles / Desktop Programming / WPF

WPF-Less GDI+.NET Report Component: Star Report

Rate me:
Please Sign up or sign in to vote.
5.00/5 (15 votes)
25 Jan 2013CPOL8 min read 46K   1.5K   42  
StarReport: WPF-less GDI+.NET report component.
using System;
using System.Runtime.Serialization;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.ComponentModel;
using System.Data;
using System.Collections;

using System.Text;
using System.Drawing;



namespace UniverseReport
{

	public enum FunctionType{Summary,Average,Maximum,Minimum,Count,None};
	
	/// <summary>
	/// Summary description for RowCellInfo.
	/// </summary>
	[TypeConverter(typeof(RowCellInfoConverter))]
	
	[Serializable()]
	public class RowCellInfo
	{

        #region My Declarations
        private FunctionType functionType = FunctionType.None;
        private string summaryFormatString = String.Empty;
        private bool suppressSummaryPrinting;

        private string name = "RowCellInfo";
        private RowCell text = new RowCell();
        private RowCell rowCell = new RowCell();

        private LineInfo summaryLine = new LineInfo();
        private bool printSummaryLine;

        private string databaseField = String.Empty;
        private DataTable lookupTable;
        private string lookupKeyColumn = String.Empty;
        private string[] mappedColumns = new string[0];
        private string columnSeparatorString = String.Empty;
        private string sumText = "Total: ";
        private string averageText = "Average: ";
        private string countText = "Count: ";
        private string maximumText = "Maximum: ";
        private string minimumText = "Minimum: ";

        private NumberCollection nc;
        private NumberCollection totalNumberCollection;

        private bool delta = false;

        private float x = 0.0f;
        private float y = 0.0f;

        private GrandSummaryCell gsc = new GrandSummaryCell(); 
        #endregion

        #region Constructors
        public RowCellInfo(float x, float y)
        {
            this.x = x;
            this.y = y;
            Init();
        }

        public RowCellInfo()
        {
            text.Font = new Font("Tahoma", 8.25f);
            rowCell.Font = new Font("Tahoma", 8.25f);
            Init();
        }

        public RowCellInfo(RowCell text, RowCell rowCell)
        {
            this.text = text;
            this.rowCell = rowCell;
            Init();
        }

        public RowCellInfo(string databaseField)
        {
            this.databaseField = databaseField;
            Init();
        }

        public RowCellInfo(string databaseField, DataType type)
        {
            this.databaseField = databaseField;
            this.rowCell.DataType = type;
            Init();
        }

        public RowCellInfo(string databaseField, int rowCellWidth)
        {
            this.databaseField = databaseField;
            this.rowCell.Width = rowCellWidth;
            Init();
        }

        public RowCellInfo(string databaseField, int rowCellWidth, bool outLine)
        {
            this.databaseField = databaseField;
            this.rowCell.Width = rowCellWidth;
            this.RowCell.Outline = outLine;
            Init();
        }

        public RowCellInfo(string databaseField, int rowCellWidth, bool outLine, bool extendToMargins)
        {
            this.databaseField = databaseField;
            this.rowCell.Width = rowCellWidth;
            this.RowCell.Outline = outLine;
            this.RowCell.ExtendToMargin = extendToMargins;
            Init();
        }
        
        #endregion

        #region Init
        private void Init()
        {
            text.Width = 0;
            summaryLine.Thickness = 2;
        } 
        #endregion

        #region Properties
        [DefaultValue("RowCellInfo")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }


        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("Summary")]
        public GrandSummaryCell GrandSummaryCell
        {
            get { return gsc; }
            set { gsc = value; }
        }

        [DefaultValue(false)]
        public bool SuppressSummaryPrinting
        {
            get { return suppressSummaryPrinting; }
            set { suppressSummaryPrinting = value; }
        }



        [DefaultValue(0f)]
        public float X
        {
            get { return x; }
            set { x = value; }
        }

        [DefaultValue(0f)]
        public float Y
        {
            get { return y; }
            set { y = value; }
        }

        [Category("Summary"), DefaultValue(false)]
        public bool PrintSummaryLine
        {
            get { return printSummaryLine; }
            set { printSummaryLine = value; }

        }

        [DefaultValue(false)]
        public bool Delta
        {
            get { return delta; }
            set { delta = value; }
        }

        [Browsable(false)]
        internal NumberCollection NumberCollection
        {
            get { return nc; }
            set { nc = value; }
        }

        [Browsable(false)]
        internal NumberCollection TotalNumberCollection
        {
            get { return totalNumberCollection; }
            set { totalNumberCollection = value; }
        }

        [Category("Summary"), DefaultValue("")]
        public String SummaryFormatString
        {
            get { return summaryFormatString; }
            set { summaryFormatString = value; }
        }

        [Category("Summary"), DefaultValue("Total:")]
        public String SummaryText
        {
            get { return sumText; }
            set { sumText = value; }
        }

        [Category("Summary"), DefaultValue("Average:")]
        public String AverageText
        {
            get { return averageText; }
            set { averageText = value; }
        }

        [Category("Summary"), DefaultValue("Count:")]
        public String CountText
        {
            get { return countText; }
            set { countText = value; }
        }

        [Category("Summary"), DefaultValue("Minimum:")]
        public String MinimumText
        {
            get { return minimumText; }
            set { minimumText = value; }
        }

        [Category("Summary"), DefaultValue("Maximum:")]
        public String MaximumText
        {
            get { return maximumText; }
            set { maximumText = value; }
        }


        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("Summary")]
        public LineInfo SummaryLine
        {
            get { return summaryLine; }
            set { summaryLine = value; }
        }

        [DefaultValue(FunctionType.None)]
        [Description("The type of arithmetic function to perform on the data")]
        [Category("Summary")]
        public FunctionType FunctionType
        {
            get { return functionType; }
            set { functionType = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Description("The names of the columns in the lookup table to display on the report")]
        [Category("Lookup Table")]
        public string[] MappedColumns
        {
            get { return mappedColumns; }
            set { mappedColumns = value; }
        }

        [DefaultValue("")]
        [Description("The string that will separate the values in the cell values return from the lookup table")]
        [Category("Lookup Table")]
        public string ColumnSeparatorString
        {
            get { return columnSeparatorString; }
            set { columnSeparatorString = value; }
        }

        [Category("Lookup Table")]
        [Description("The name of data table used to link to this table on the LookupKeyColumn property.")]
        public DataTable LookupTable
        {
            get { return lookupTable; }
            set { lookupTable = value; }
        }

        [DefaultValue("")]
        [Description("The name of the column in the lookup table.")]
        [Category("Lookup Table")]
        public string LookupKeyColumn
        {
            get { return lookupKeyColumn; }
            set { lookupKeyColumn = value; }
        }

        [DefaultValue("")]
        [Description("The name of the column in the data table that this row will take the value of.")]
        public string DatabaseField
        {
            get { return databaseField; }
            set { databaseField = value; }
        }


        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public RowCell Text
        {
            get { return text; }
            set { text = value; }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public RowCell RowCell
        {
            get { return rowCell; }
            set { rowCell = value; }
        } 
        #endregion

        #region Procedures
        public void SetFunction(FunctionType functionType, DataType dataType)
        {
            this.functionType = functionType;
            this.rowCell.DataType = dataType;
        }

        public void SetFunction(FunctionType functionType, DataType dataType, string format)
        {
            this.functionType = functionType;
            this.rowCell.DataType = dataType;
            this.summaryFormatString = format;
        } 
        #endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Finance Industry
United States United States
Currently pursuing 'Programming Nirvana' (The ineffable ultimate in which one has attained disinterested wisdom and compassion as it relates to programming)

Respected Technologies
1. Confusor (https://confuser.codeplex.com/)
2. Power Threading (http://www.wintellect.com/Resources/visit-the-power-threading-library)
3. EDI Parsers (http://www.rdpcrystal.com)


Acknowledgements:

Microsoft Certified Technologist for WPF and .Net 3.5 (MCTS)
Microsoft Certified Technologist for WCF and .Net 3.5 (MCTS)
Microsoft Certified Application Developer for .Net (MCAD)
Microsoft Certified Systems Engineer (MCSE)
Microsoft Certified Professional (MCP)

Sun Certified Developer for Java 2 Platform (SCD)
Sun Certified Programmer for Java 2 Platform (SCP)
Sun Certified Web Component Developer (SCWCD)

CompTIA A+ Certified Professional

Registered Business School Teacher for Computer Programming and Computer Applications (2004)
(University of the State of New York Education Department)

Graduated from University At Stony Brook

Comments and Discussions