Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version

Race to Linux - Race 3: Reports Starter Kit using Mono SqlServer/Firebird

, 30 Sep 2005
Reports Starter Kit port to Linux using Mono
RaceToLinuxRace3_src.zip
RaceToLinuxRace3_src
bin
ASPNET.StarterKit.Reports.dll
FirebirdSql.Data.Firebird.dll
Components
BLL
DAL
docs
images
1x1.gif
crosstabnestedcontrols.png
crosstabtotals.png
customers.gif
drilldownnestedcontrols.png
employees.gif
getorderdetails.gif
getorders.gif
hierarchicalpaging.gif
hierarchicalreport.gif
hierarchicalschema.gif
hierarchicalsorting.gif
masterdetaildetails.png
masterdetailsummary.png
masterdetailtables.png
querysample.gif
querysample2.gif
simpleoverview.png
simplesp.png
tabdetail.png
tabheader.gif
tabheader.png
tabnestedcontrols.png
tabularcolorcode.png
tabularextendedprice.png
tabularsorting.png
textshot.gif
viscategorysales.gif
viscategorysales.png
vischartstructure.png
xtabsql.png
global.asax
images
asp.net-reports.gif
background.gif
crosstab.gif
drilldown.gif
grid_background.gif
hierarchical.gif
logo-neg.gif
logo.gif
masterdetail.gif
masterdetails.gif
report-table-bg.gif
simple.gif
spacer.gif
tabular.gif
textalternate.gif
textreport.gif
visual.gif
ReportsCSVS.csproj.webinfo
SourceViewer
1x1.gif
crosstab.src
drilldown.src
grid_background.gif
hierarchical.src
masterdetail.src
simple.src
tabular.src
textreport.src
visual.src
REPORTS.BKP
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
<font color= "blue">using</font> System;
<font color= "blue">using</font> System.Collections;
<font color= "blue">using</font> System.Drawing;
<font color= "blue">using</font> System.Drawing.Imaging;
<font color= "blue">using</font> System.Drawing.Drawing2D;
<font color= "blue"></font>
<font color= "blue">namespace</font> ASPNET.StarterKit.Chart
<font color= "blue"></font>{
<font color= "green">    //*********************************************************************</font>
<font color= "green">    //</font>
<font color= "green">    // PieChart Class</font>
<font color= "green">    //</font>
<font color= "green">    // This class uses GDI+ to render Pie Chart.</font>
<font color= "green">    //</font>
<font color= "green">    //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">    public class</font> PieChart : Chart
<font color= "blue">    </font>{
<font color= "blue">        private const </font>int    _bufferSpace = 125;
<font color= "blue">        private </font>ArrayList    _chartItems;
<font color= "blue">        private </font>int            _perimeter;
<font color= "blue">        private </font>Color        _backgroundColor;
<font color= "blue">        private </font>Color        _borderColor;
<font color= "blue">        private </font>float        _total;
<font color= "blue">        private </font>int            _legendWidth;
<font color= "blue">        private </font>int            _legendHeight;
<font color= "blue">        private </font>int            _legendFontHeight;
<font color= "blue">        private </font>string        _legendFontStyle;
<font color= "blue">        private </font>float        _legendFontSize;
<font color= "blue"></font>
<font color= "blue">        public </font>PieChart()
<font color= "blue">        </font>{
<font color= "blue">            </font>_chartItems = new ArrayList();
<font color= "blue">            </font>_perimeter = 250;
<font color= "blue">            </font>_backgroundColor = Color.White;
<font color= "blue">            </font>_borderColor = Color.FromArgb(63,63,63);
<font color= "blue">            </font>_legendFontSize = 8;
<font color= "blue">            </font>_legendFontStyle = "Verdana";
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "blue">        public </font>PieChart(Color bgColor)
<font color= "blue">        </font>{
<font color= "blue">            </font>_chartItems = new ArrayList();
<font color= "blue">            </font>_perimeter = 250;
<font color= "blue">            </font>_backgroundColor = bgColor;
<font color= "blue">            </font>_borderColor = Color.FromArgb(63,63,63);
<font color= "blue">            </font>_legendFontSize = 8;
<font color= "blue">            </font>_legendFontStyle = "Verdana";
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        //*********************************************************************</font>
<font color= "green">        //</font>
<font color= "green">        // This method collects all data points and calculate all the necessary dimensions </font>
<font color= "green">        // to draw the chart.  It is the first method called before invoking the Draw() method.</font>
<font color= "green">        //</font>
<font color= "green">        //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        public void</font> CollectDataPoints(string[] xValues, string[] yValues)
<font color= "blue">        </font>{
<font color= "blue">            </font>_total = 0.0f;
<font color= "blue">            </font>
<font color= "blue">            for</font> (int i = 0;i < xValues.Length;i++)
<font color= "blue">            </font>{
<font color= "blue">                </font>float ftemp = Convert.ToSingle(yValues[i]);
<font color= "blue">                </font>_chartItems.Add(new ChartItem(xValues[i], xValues.ToString(), ftemp, 0, 0, Color.AliceBlue));
<font color= "blue">                </font>_total += ftemp;
<font color= "blue">            </font>}
<font color= "blue">            </font>
<font color= "blue">            </font>float nextStartPos = 0.0f;
<font color= "blue">            </font>int counter = 0;
<font color= "blue">            </font>foreach (ChartItem item in _chartItems)
<font color= "blue">            </font>{
<font color= "blue">                </font>item.StartPos = nextStartPos;
<font color= "blue">                </font>item.SweepSize = item.Value / _total * 360;
<font color= "blue">                </font>nextStartPos = item.StartPos + item.SweepSize;
<font color= "blue">                </font>item.ItemColor = GetColor(counter++);
<font color= "blue">            </font>}
<font color= "blue"></font>
<font color= "blue">            </font>CalculateLegendWidthHeight();
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        //*********************************************************************</font>
<font color= "green">        //</font>
<font color= "green">        // This method returns a bitmap to the calling function.  This is the method</font>
<font color= "green">        // that actually draws the pie chart and the legend with it.</font>
<font color= "green">        //</font>
<font color= "green">        //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue">        public </font>override Bitmap Draw()
<font color= "blue">        </font>{
<font color= "blue">            </font>int perimeter = _perimeter;
<font color= "blue">            </font>Rectangle pieRect = new Rectangle(0, 0, perimeter, perimeter-1);
<font color= "blue">            </font>Bitmap bmp = new Bitmap(perimeter + _legendWidth, perimeter);
<font color= "blue">            </font>Graphics grp = Graphics.FromImage(bmp);
<font color= "blue">        </font>
<font color= "green">            //Paint Back ground</font>
<font color= "blue">            </font>grp.FillRectangle(new SolidBrush(_backgroundColor), 0, 0, perimeter + _legendWidth, perimeter);
<font color= "blue"></font>
<font color= "green">            //Align text to the right</font>
<font color= "blue">            </font>StringFormat sf = new StringFormat();
<font color= "blue">            </font>sf.Alignment = StringAlignment.Far; 
<font color= "blue">            </font>
<font color= "green">            //Draw all wedges and legends</font>
<font color= "blue">            </font>for(int i=0; i<_chartItems.Count; i++)
<font color= "blue">            </font>{
<font color= "blue">                </font>ChartItem item = (ChartItem) _chartItems[i];
<font color= "blue">                </font>SolidBrush brs = new SolidBrush(item.ItemColor);
<font color= "blue">                </font>grp.FillPie(brs, pieRect, item.StartPos, item.SweepSize);
<font color= "blue">                </font>grp.FillRectangle(brs, perimeter + _bufferSpace, i * _legendFontHeight + 15, 10, 10);
<font color= "blue">                </font>grp.DrawString(item.Label, new Font(_legendFontStyle, _legendFontSize), 
<font color= "blue">                    </font>new SolidBrush(Color.Black), perimeter + _bufferSpace + 20, i * _legendFontHeight + 13);
<font color= "blue"></font>
<font color= "blue">                </font>grp.DrawString(item.Value.ToString("C"), new Font(_legendFontStyle, _legendFontSize), 
<font color= "blue">                    </font>new SolidBrush(Color.Black), perimeter + _bufferSpace + 200, i * _legendFontHeight + 13,sf);
<font color= "blue">            </font>}
<font color= "blue">            </font>
<font color= "green">            //draws the border around Pie</font>
<font color= "blue">            </font>grp.DrawEllipse(new Pen(_borderColor, 2), pieRect);  
<font color= "blue"></font>
<font color= "green">            //draw border around legend</font>
<font color= "blue">            </font>grp.DrawRectangle(new Pen(_borderColor, 1), perimeter + _bufferSpace - 10, 10, 220, _chartItems.Count * _legendFontHeight + 25);
<font color= "blue"></font>
<font color= "green">            //Draw Total under legend</font>
<font color= "blue">            </font>grp.DrawString("Total", new Font(_legendFontStyle, _legendFontSize, FontStyle.Bold), 
<font color= "blue">                </font>new SolidBrush(Color.Black), perimeter + _bufferSpace + 30, (_chartItems.Count+1) * _legendFontHeight,sf);
<font color= "blue">            </font>grp.DrawString(_total.ToString("C"), new Font(_legendFontStyle, _legendFontSize, FontStyle.Bold), 
<font color= "blue">                </font>new SolidBrush(Color.Black), perimeter + _bufferSpace + 200, (_chartItems.Count+1) * _legendFontHeight,sf);
<font color= "blue">            </font>
<font color= "blue">            </font>grp.SmoothingMode = SmoothingMode.AntiAlias;
<font color= "blue">            </font>grp.Dispose();
<font color= "blue">            return</font> bmp;
<font color= "blue">        </font>}
<font color= "blue"></font>
<font color= "green">        //*********************************************************************</font>
<font color= "green">        //</font>
<font color= "green">        //    This method calculates the space required to draw the chart legend.</font>
<font color= "green">        //</font>
<font color= "green">        //*********************************************************************</font>
<font color= "blue">        </font>
<font color= "blue">        private void</font> CalculateLegendWidthHeight()
<font color= "blue">        </font>{
<font color= "blue">            </font>Font fontLegend = new Font(_legendFontStyle, _legendFontSize);
<font color= "blue">            </font>_legendFontHeight = fontLegend.Height+5;
<font color= "blue">            </font>_legendHeight = fontLegend.Height * (_chartItems.Count + 1);
<font color= "blue"></font><font color= "blue">            if </font>(_legendHeight > _perimeter) _perimeter = _legendHeight;<font color= "blue"></font>
<font color= "blue"></font>
<font color= "blue">            </font>_legendWidth = _perimeter + _bufferSpace;
<font color= "blue">        </font>}
<font color= "blue">    </font>}
<font color= "blue"></font>}
</pre>

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

idepaula
Web Developer
Uruguay Uruguay
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141030.1 | Last Updated 1 Oct 2005
Article Copyright 2005 by idepaula
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid