private void btnProject_Click(object sender, EventArgs e)
{
if (kda == null || dgvProjectionSource.DataSource == null)
{
MessageBox.Show("Please compute the analysis first.");
return;
}
// Save any pending changes
dgvProjectionSource.EndEdit();
// Creates a matrix from the source data table
double[,] sourceMatrix = (dgvProjectionSource.DataSource as DataTable).ToMatrix(out columnNames);
// Gets only the X and Y
double[,] data = sourceMatrix.Submatrix(0, sourceMatrix.GetLength(0) - 1, 0, 1);
// Perform the transformation of the data using two components
double[,] result = kda.Transform(data, 2);
// Create a new plot with the original Z column
double[,] graph = new double[sourceMatrix.GetLength(0), 3];
for (int i = 0; i < graph.GetLength(0); i++)
{
graph[i, 0] = result[i, 0];
graph[i, 1] = result[i, 1];
graph[i, 2] = sourceMatrix[i, 2];
}
// Create output scatter plot
outputScatterplot.DataSource = graph;
createMappingScatterplot(graphMapFeature, graph);
// Create output table
dgvProjectionResult.DataSource = new ArrayDataView(graph, columnNames);
}