Ejemplo n.º 1
0
        private void gridDisplay_PushButtonClick(object sender, GridCellPushButtonClickEventArgs e)
        {
            int numTrials = 100;

            int count10 = 0;
            int count20 = 0;
            int count30 = 0;
            int count40 = 0;

            int col        = 4;
            int currentAge = int.Parse(this.gridDisplay[7, 2].Text);
            int retireAge  = int.Parse(this.gridDisplay[21, 2].Text);
            int row        = 2 + retireAge - currentAge;

            double d;
            string s;

            this.gridDisplay.ConfirmChanges();

            GridProgressBarInfo progressBarEx1 = SetProgressBar(row10 + 4, col - 1);

            DateTime start = DateTime.Now;

            this.Cursor = Cursors.WaitCursor;
            for (int i = 0; i < numTrials; ++i)
            {
                this.gridDisplay[e.RowIndex, e.ColIndex].CellValue = 0;
                s = this.gridCalculations[row + 10, col].FormattedText;
                if (double.TryParse(s, NumberStyles.Any, null, out d) && d > 0)
                {
                    count10 += 1;
                }
                s = this.gridCalculations[row + 20, col].FormattedText;
                if (double.TryParse(s, NumberStyles.Any, null, out d) && d > 0)
                {
                    count20 += 1;
                }
                s = this.gridCalculations[row + 30, col].FormattedText;
                if (double.TryParse(s, NumberStyles.Any, null, out d) && d > 0)
                {
                    count30 += 1;
                }
                s = this.gridCalculations[row + 40, col].FormattedText;
                if (double.TryParse(s, NumberStyles.Any, null, out d) && d > 0)
                {
                    count40 += 1;
                }
                //System.Threading.Thread.Sleep(0);
                if (i % 10 == 0)
                {
                    progressBarEx1.ProgressValue = i;
                }
                Application.DoEvents();
            }
            this.Cursor = Cursors.Default;


            this.gridDisplay[row10, col].Text     = string.Format("{0:P2}", ((float)count10) / numTrials);
            this.gridDisplay[row10 + 1, col].Text = string.Format("{0:P2}", ((float)count20) / numTrials);
            this.gridDisplay[row10 + 2, col].Text = string.Format("{0:P2}", ((float)count30) / numTrials);
            this.gridDisplay[row10 + 3, col].Text = string.Format("{0:P2}", ((float)count40) / numTrials);

            this.gridDisplay[row10 + 4, col - 1].CellType  = "Static";
            this.gridDisplay[row10 + 4, col - 1].Font.Bold = true;

            this.gridDisplay[row10 + 4, col - 1].Text = string.Format("{0} runs in {1}", numTrials, DateTime.Now - start);
        }
Ejemplo n.º 2
0
 private void grid_PushButtonClick(object sender, GridCellPushButtonClickEventArgs e)
 {
     TraceUtil.TraceCurrentMethodInfoIf(traceDebug, this, e);
     AppendOutput("PushButtonClick", e);
 }