[Quantproject-developers] QuantProject/b5_Presentation/Reporting/WindowsForm SummaryTabPage.cs,1.5,1
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2005-06-19 14:45:52
|
Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8675/b5_Presentation/Reporting/WindowsForm Modified Files: SummaryTabPage.cs Log Message: Reordered the process to populate the summary. Now, to add a summary item, you just need to add a new SummaryRow object to the QuantProject.Business.Financial.Accounting.Reporting.Tables.Summary object. Index: SummaryTabPage.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/SummaryTabPage.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SummaryTabPage.cs 17 Apr 2005 23:05:02 -0000 1.5 --- SummaryTabPage.cs 19 Jun 2005 14:45:43 -0000 1.6 *************** *** 21,28 **** --- 21,31 ---- */ using System; + using System.Collections; using System.Drawing; + using System.Reflection; using System.Windows.Forms; using QuantProject.ADT; using QuantProject.Business.Financial.Accounting.Reporting; + using QuantProject.Business.Financial.Accounting.Reporting.SummaryRows; using QuantProject.Presentation; *************** *** 44,47 **** --- 47,56 ---- private int yStep = 25; + private ArrayList summaryItems; + /// <summary> + /// used just to apply the GetType method + /// </summary> + private SummaryRow summaryRow; + private System.Windows.Forms.Label lblValTotalNetProfit; private System.Windows.Forms.Label lblTotalNetProfit; *************** *** 123,126 **** --- 132,152 ---- } + private void addTextLabel( Label label ) + { + this.Controls.Add( label ); + // label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + label.Location = getPointForTextLabel( ( this.Controls.Count - 1 ) / 2 ); + label.Width = this.textLabelsWidth; + label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + } + private void addValueLabel( Label label ) + { + this.Controls.Add( label ); + // label.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + label.Location = getPointForValueLabel( ( this.Controls.Count / 2 ) - 1 ); + label.Width = this.valueLablesWidth; + label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + } + private Point getPointForValueLabel( int labelPosition ) { *************** *** 129,134 **** return point; } ! private void myInitializeComponent() { this.lblTotalNetProfit = new System.Windows.Forms.Label(); this.lblValTotalNetProfit = new System.Windows.Forms.Label(); --- 155,185 ---- return point; } ! private void myInitializeComponent_addItem( SummaryItem summaryItem ) { + this.addTextLabel( summaryItem.Description ); + this.addValueLabel( summaryItem.Value ); + } + private void myInitializeComponent_addSummaryRow( PropertyInfo propertyInfo ) + { + Object ob = propertyInfo.GetValue( this.accountReport.Summary , null ); + if ( ob is SummaryRow ) + { + this.summaryItems.Add( new SummaryItem( + (SummaryRow)ob ) ); + } + } + private void myInitializeComponent_addSummaryRows() + { + foreach ( PropertyInfo summaryProperty in + this.accountReport.Summary.GetType().GetProperties() ) + myInitializeComponent_addSummaryRow( summaryProperty ); + } + private void myInitializeComponent_old() + { + this.summaryItems = new ArrayList(); + myInitializeComponent_addSummaryRows(); + foreach( SummaryItem summaryItem in this.summaryItems ) + this.myInitializeComponent_addItem( summaryItem ); + this.lblTotalNetProfit = new System.Windows.Forms.Label(); this.lblValTotalNetProfit = new System.Windows.Forms.Label(); *************** *** 344,347 **** --- 395,406 ---- } + private void myInitializeComponent() + { + this.summaryItems = new ArrayList(); + myInitializeComponent_addSummaryRows(); + foreach( SummaryItem summaryItem in this.summaryItems ) + this.myInitializeComponent_addItem( summaryItem ); + } + private void setSummaryValues() { *************** *** 349,361 **** FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalPnl ); this.lblValReturnOnAccount.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.ReturnOnAccount ); this.lblValBenchmarkPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.BenchmarkPercentageReturn ); this.lblValAnnualSystemPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AnnualSystemPercentageReturn ); ! this.lblValMaxEquityDrawDown.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.MaxEquityDrawDown ); this.lblValTotalCommission.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalCommissionAmount ); this.lblValNumberWinningPeriods.Text = this.accountReport.Summary.NumberWinningPeriods.ToString(); --- 408,420 ---- FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalPnl ); this.lblValReturnOnAccount.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.ReturnOnAccount.Value ); this.lblValBenchmarkPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.BenchmarkPercentageReturn.Value ); this.lblValAnnualSystemPercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.AnnualSystemPercentageReturn.Value ); ! // this.lblValMaxEquityDrawDown.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.MaxEquityDrawDown ); this.lblValTotalCommission.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.TotalCommissionAmount.Value ); this.lblValNumberWinningPeriods.Text = this.accountReport.Summary.NumberWinningPeriods.ToString(); *************** *** 363,394 **** this.accountReport.Summary.NumberLosingPeriods.ToString(); this.lblValPercentageWinningPeriods.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.PercentageWinningPeriods ); ! this.lblValTotalNumberOfTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfTrades ); ! this.lblValNumberWinningTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningTrades ); ! this.lblValAverageTradePercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageTradePercentageReturn ); ! this.lblValLargestWinningTrade.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.LargestWinningTradePercentage ); ! this.lblValLargestLosingTrade.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.LargestLosingTradePercentage ); ! this.lblValTotalNumberOfLongTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfLongTrades ); ! this.lblValNumberWinningLongTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningLongTrades ); ! this.lblValAverageLongTradePercReturn.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageLongTradePercentageReturn ); ! this.lblValTotalNumberOfShortTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfShortTrades ); ! this.lblValNumberWinningShortTrades.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningShortTrades ); } public SummaryTabPage( AccountReport accountReport ) { this.accountReport = accountReport; this.myInitializeComponent(); this.Text = "Summary"; ! this.setSummaryValues(); } } --- 422,454 ---- this.accountReport.Summary.NumberLosingPeriods.ToString(); this.lblValPercentageWinningPeriods.Text = ! FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.PercentageWinningPeriods.Value ); ! // this.lblValTotalNumberOfTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.TotalNumberOfTrades ); ! // this.lblValNumberWinningTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.NumberWinningTrades ); ! // this.lblValAverageTradePercReturn.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( this.accountReport.Summary.AverageTradePercentageReturn ); ! // this.lblValLargestWinningTrade.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.LargestWinningTradePercentage.Value ); ! // this.lblValLargestLosingTrade.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.LargestLosingTradePercentage.Value ); ! // this.lblValTotalNumberOfLongTrades.Text = ! // FormatProvider.ConvertToStringWithZeroDecimals( (int)this.accountReport.Summary.TotalNumberOfLongTrades.Value ); ! // this.lblValNumberWinningLongTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.NumberWinningLongTrades.Value ); ! // this.lblValAverageLongTradePercReturn.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.AverageLongTradePercentageReturn.Value ); ! // this.lblValTotalNumberOfShortTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.TotalNumberOfShortTrades.Value ); ! // this.lblValNumberWinningShortTrades.Text = ! // FormatProvider.ConvertToStringWithTwoDecimals( (double)this.accountReport.Summary.NumberWinningShortTrades.Value ); } public SummaryTabPage( AccountReport accountReport ) { this.accountReport = accountReport; + this.summaryRow = new SummaryRow(); this.myInitializeComponent(); this.Text = "Summary"; ! // this.setSummaryValues(); } } |