private void btn_start_Click(object sender, EventArgs e) { lbl_resFunc.Text = "Значение функционала: "; alg = new Algorithm(Convert.ToInt32(txtb_stepOfGridX.Text), Convert.ToInt32(txtb_stepOfGridY.Text), cb_centers.Checked ? dgv.RowCount - 1 : centers.Length, (double)nud_gamma.Value, (string)cb_c1.SelectedItem, (string)cb_c2.SelectedItem, (string)cb_ro1.SelectedItem, (string)cb_ro2.SelectedItem, funcs); if (centers != null) { alg.centers = centers; } else { alg.centers = new MyPoint[alg.numberOfCenters]; } if (cb_centers.Checked) { for (int i = 0; i < dgv.RowCount - 1; i++) { alg.centers[i].X = float.Parse(dgv.Rows[i].Cells[0].Value.ToString()); alg.centers[i].Y = float.Parse(dgv.Rows[i].Cells[1].Value.ToString()); } } //rtb_centers.Text += String.Format("\nA1: {0}", alg.A1()); //rtb_centers.Text += String.Format("\nA1i: {0}", alg.A1i()); if (tabControl.SelectedIndex == 0) { lbl_resFunc.Text += alg.A2i().ToString(); } else { lbl_resFunc.Text += alg.A5().ToString(); } if (cb_draw.Checked) { dt = new DrawingTools(); dt.DrawPartitioning(pictureBox, alg.numberOfCenters, alg.M, alg.M1, alg.lambda, alg.centers); } rtb_centers.Enabled = true; }
private void btn_start_Click(object sender, EventArgs e) { alg = new Algorithm(); alg.M = Convert.ToInt32(txtb_stepOfGridX.Text); alg.M1 = Convert.ToInt32(txtb_stepOfGridY.Text); alg.numberOfCenters = cb_centers.Checked ? dgv.RowCount - 1 : Convert.ToInt32(txtb_numberOfCenters.Text); alg.centers = new MyPoint[alg.numberOfCenters]; rtb_centers.Text = null; if (!cb_centers.Checked) { Random r = new Random(); for (int i = 0; i < alg.numberOfCenters; i++) { alg.centers[i].X = (float)r.NextDouble(); alg.centers[i].Y = (float)r.NextDouble(); rtb_centers.Text += String.Format("({0:0.00}; {1:0.00})\n", alg.centers[i].X, alg.centers[i].Y); } } else { for (int i = 0; i < dgv.RowCount - 1; i++) { alg.centers[i].X = float.Parse(dgv.Rows[i].Cells[0].Value.ToString()); alg.centers[i].Y = float.Parse(dgv.Rows[i].Cells[1].Value.ToString()); } } //rtb_centers.Text += String.Format("\nA1: {0}\nTask_A2: {1}", alg.A1(), alg.Task_A2()); rtb_centers.Text += String.Format("\nA1: {0}", alg.A1()); rtb_centers.Text += String.Format("\nA1i: {0}", alg.A1i()); rtb_centers.Text += String.Format("\nA2i: {0}", alg.A2i()); if (cb_draw.Checked) { dt = new DrawingTools(); dt.DrawPartitioning(pictureBox, alg.numberOfCenters, alg.M, alg.M1, alg.lambda, alg.centers); } rtb_centers.Enabled = true; }