private void Zc1_MouseClick(object sender, MouseEventArgs e) { CurveItem curve = null; int index = -1; Point mouseScreenPoint = PointToScreen(e.Location); zc1.GraphPane.FindNearestPoint(mouseScreenPoint, out curve, out index); if (curve != null && index >= 0) { var ind = GetNearestIndividual(new double[] { curve[index].X, curve[index].Y }); var clone = new Individual(ind.Genes, ind.Fitness); if (OnIndividualSelected != null) { OnIndividualSelected.Invoke(clone); } } }
private void Dgv_CellClick(object sender, DataGridViewCellEventArgs e) { var rIndex = e.RowIndex; if (rIndex < 0) { return; } double[] fitness = new double[dgv.ColumnCount]; for (int i = 0; i < fitness.Length; i++) { fitness[i] = (double)dgv.Rows[rIndex].Cells[i].Value; } var ind = GetNearestIndividual(fitness); var clone = new Individual(ind.Genes, ind.Fitness); if (OnIndividualSelected != null) { OnIndividualSelected.Invoke(clone); } }