Click here to Skip to main content
15,881,281 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 45.8K   1.5K   42  
StarReport: WPF-less GDI+.NET report component.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.ComponentModel.Design;


namespace UniverseReport
{

    public enum PrintPageDisplay { PRINT, PREVIEW };
    public enum ReportType { GeneralList, CardList, Hierachy, FreeForm, MultipleTables, None };
    public enum PrintHeading { No, OnFirstPage, OnAllPages };
    public enum PrintReportDateLocation { None, LeftTop, RightTop, LeftBottom, RightBottom };

    [Serializable()]
    [TypeConverter(typeof(CellFormatConverter))]
  
    public class ReportSettings
    {
        [NonSerializedAttribute]
        Pen summaryLinePen = new Pen(Color.Black, 1);
        //Used for all painting. They are created here so that I don't have to
        //waste time creating them again in this procedure
        [NonSerializedAttribute]
        SolidBrush myBrush = null;

        [NonSerializedAttribute]
        Pen linePen = null;

        private GraphicsUnit graphicsUnit = GraphicsUnit.Inch;
        private Font headerFont = new Font("Tahoma", 15, FontStyle.Bold);
        private Font subHeaderFont = new Font("Tahoma", 9.75f, FontStyle.Regular);
        private Font subscriptFont = new Font("Tahoma", 8.25f, FontStyle.Regular);
        private Font summaryLineFont = new Font("Tahoma", 8.25f, FontStyle.Bold);
        private Font reportNameFont = new Font("Tahoma", 11.75f, FontStyle.Bold | FontStyle.Italic);


        private PrintHeading printHeading = PrintHeading.OnFirstPage;
        private PrintReportDateLocation printDateLocation = PrintReportDateLocation.RightTop;

        private bool printTotalRecords = false;
        private string totalText = String.Empty;
        private bool outlineTable = true;
        private bool printTableGrid = false;
        private bool colorAlternateRows = false;
        private Color alternateRowColor = Color.FromArgb(192, 192, 255);
        private Color alternateRowTextColor = Color.Navy;

        private Header header = new Header();
        private bool printPageNumbers = true;

        private string sumText = "Total:";
        private string averageText = "Average:";
        private string countText = "Count:";
        private string maximumText = "Max:";
        private string minimumText = "Min:";

        private string nullValue = "";

        private bool useTableInFreeForm = false;

        private LineInfo rowSeparatorLine = new LineInfo();
        private bool printRowSeparator = true;

        private ReportType reportType = ReportType.GeneralList;



        private int groupIndentSpace = 0;

        private string calculatedField = String.Empty;


        #region Properties
        [DefaultValue("")]
        public string CalculatedField
        {
            get { return calculatedField; }
            set { calculatedField = value; }
        }

        [Category("Free Form Report"), DefaultValue(false)]
        public bool UseTableInFreeForm
        {
            get { return useTableInFreeForm; }
            set { useTableInFreeForm = value; }
        }

        public Pen SummaryLinePen
        {
            get { return summaryLinePen; }
            set { summaryLinePen = value; }
        }

        internal SolidBrush MyBrush
        {
            get { return myBrush; }
            set { myBrush = value; }
        }

        internal Pen LinePen
        {
            get { return linePen; }
            set { linePen = value; }

        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Category("Appearance")]
        public LineInfo RowSeparatorLine
        {
            get { return rowSeparatorLine; }
            set { rowSeparatorLine = value; }
        }


        [Category("General"), DefaultValue(PrintReportDateLocation.RightTop)]
        public PrintReportDateLocation ReportDate
        {
            get { return printDateLocation; }
            set { printDateLocation = value; }
        }

        [Category("Summary"), DefaultValue("Total:")]
        public string SumText
        {
            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("Max:")]
        public string MaximumText
        {
            get { return maximumText; }
            set { maximumText = value; }
        }

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

        [Category("Summary"), DefaultValue("Min:")]
        public string TotalText
        {
            get { return totalText; }
            set { totalText = value; }
        }



        [Category("Appearance"), DefaultValue(false)]
        public bool PrintTotalRecords
        {
            get { return printTotalRecords; }
            set { printTotalRecords = value; }

        }
        [Category("Appearance"), DefaultValue(false)]
        public int GroupIndentSpace
        {
            get { return groupIndentSpace; }
            set { groupIndentSpace = value; }

        }

        [Category("Appearance"), DefaultValue(false)]
        public bool OutlineTable
        {
            get { return outlineTable; }
            set { outlineTable = value; }
        }

        [Category("Appearance"), DefaultValue(typeof(Color), "White")]
        public Color AlternateRowColor
        {
            get { return alternateRowColor; }
            set { alternateRowColor = value; }

        }

        [Category("Appearance"), DefaultValue(typeof(Color), "White")]
        public Color AlternateRowTextColor
        {
            get { return alternateRowTextColor; }
            set { alternateRowTextColor = value; }
        }


        [Category("Appearance"), DefaultValue(false)]
        public bool ColorAlternateRows
        {
            get { return colorAlternateRows; }
            set { colorAlternateRows = value; }
        }


        [Category("Appearance"), DefaultValue(false)]
        public bool PrintTableGrid
        {
            get { return printTableGrid; }
            set { printTableGrid = value; }
        }

        [Category("Appearance"), DefaultValue(false)]
        public bool PrintPageNumbers
        {
            get { return printPageNumbers; }
            set { printPageNumbers = value; }
        }


        [Category("Data"), DefaultValue("")]
        public string NullValue
        {
            get { return nullValue; }
            set { nullValue = value; }
        }




        [Category("Appearance"), DefaultValue(false)]
        public bool PrintRowSeparator
        {
            get { return printRowSeparator; }
            set { printRowSeparator = value; }
        }

        [Category("General"), DefaultValue("")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public Header Header
        {
            get { return header; }
            set { header = value; }
        }

        [Category("Appearance"), DefaultValue(typeof(Font), "Tahoma,9.75f")]
        public Font SubscriptFont
        {
            get { return subscriptFont; }
            set { subscriptFont = value; }
        }


        [Category("Appearance"), DefaultValue(typeof(Font), "Tahoma,8.25f")]
        public Font SummaryLineFont
        {
            get { return summaryLineFont; }
            set { summaryLineFont = value; }
        }

        [Category("Appearance"), DefaultValue(typeof(Font), "Tahoma,12")]
        public Font ReportNameFont
        {
            get { return reportNameFont; }
            set { reportNameFont = value; }
        }


        [Category("Appearance"), DefaultValue(typeof(Font), "Tahoma,15")]
        public Font HeaderFont
        {
            get { return headerFont; }
            set { headerFont = value; }
        }

        [Category("Appearance"), DefaultValue(typeof(Font), "Tahoma,10")]
        public Font SubHeaderFont
        {
            get { return subHeaderFont; }
            set { subHeaderFont = value; }
        }


        [Category("Appearance"), DefaultValue(PrintHeading.OnFirstPage)]
        public PrintHeading PrintHeading
        {
            get { return printHeading; }
            set { printHeading = value; }
        }

        [Category("General"), DefaultValue(ReportType.GeneralList)]
        public ReportType ReportType
        {
            get { return reportType; }
            set { reportType = value; }

        }

        [Browsable(false)]
        public GraphicsUnit GraphicsUnit
        {
            get { return graphicsUnit; }
            set { graphicsUnit = value; }
        }


        #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