コード例 #1
0
 public ResultsForm(float loan, float interestRate, float years)
 {
     InitializeComponent(loan, interestRate, years);
     buttonGenerateCSV.Click += new System.EventHandler((sender, e) => {
         GenerateCSV.GenerateFile(InterestRateCalculator.Calculate(loan, interestRate, years));
     });
 }
コード例 #2
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent(float loan, float interestRate, float time)
        {
            //Initialize the ListView control and add columns to it.
            this.listView1         = new ListView();
            this.buttonGenerateCSV = new Button();
            // Set the initial sorting type for the ListView.
            this.listView1.Sorting = SortOrder.None;
            // Disable automatic sorting to enable manual sorting.
            this.listView1.View = View.Details;
            // Add columns and set their text.
            this.listView1.Columns.Add(new ColumnHeader());
            this.listView1.Columns[0].Text  = "Month";
            this.listView1.Columns[0].Width = 150;
            listView1.Columns.Add(new ColumnHeader());
            listView1.Columns[1].Text       = "Current Payment";
            this.listView1.Columns[1].Width = 150;
            listView1.Columns.Add(new ColumnHeader());
            listView1.Columns[2].Text       = "Current Debt";
            this.listView1.Columns[2].Width = 150;


            // Suspend control logic until form is done configuring form.
            this.SuspendLayout();


            // Create ListView items to add to the control.
            // Add Items to the ListView control.

            var my2DList = InterestRateCalculator.Calculate(loan, interestRate, time);

            for (int i = 0; i < my2DList.Count; i++)
            {
                var listViewIt = new ListViewItem(new string[] { my2DList[i][0].ToString("F0"), my2DList[i][1].ToString("F2"), my2DList[i][2].ToString("F2") });
                this.listView1.Items.Add(listViewIt);
            }

            void buttonGenerateCSV_Click(object sender, EventArgs e)
            {
                MessageBox.Show("File saved!");
                this.GenerateWithClick(loan, interestRate, time);
            }

            //button
            this.buttonGenerateCSV.Text     = "Export to CSV";
            this.buttonGenerateCSV.Location = new Point(366, 335);
            this.buttonGenerateCSV.Name     = "buttonGenerateCSV";
            this.buttonGenerateCSV.Size     = new Size(100, 35);
            this.buttonGenerateCSV.TabIndex = 1;
            this.buttonGenerateCSV.TabStop  = true;
            //this.buttonGenerateCSV.Click += new System.EventHandler(buttonGenerateCSV_Click);



            // Set the location and size of the ListView control.
            this.listView1.Location = new Point(10, 10);
            this.listView1.Name     = "listView1";
            this.listView1.Size     = new Size(455, 320);
            this.listView1.TabIndex = 0;
            // Enable editing of the items in the ListView.
            this.listView1.LabelEdit = true;
            // Connect the ListView.ColumnClick event to the ColumnClick event handler.
            this.listView1.ColumnClick += new ColumnClickEventHandler(ColumnClick);

            // Initialize the form.
            this.ClientSize = new Size(480, 380);
            this.Controls.AddRange(new Control[] { this.listView1, this.buttonGenerateCSV });
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Name            = "ListViewSortForm";
            this.Text            = "Results";
            // Resume layout of the form.
            this.ResumeLayout(false);
        }
コード例 #3
0
 public void GenerateWithClick(float loan, float interestRate, float years)
 {
     GenerateCSV.GenerateFile(InterestRateCalculator.Calculate(loan, interestRate, years));
 }