private void RecognizeButton_Click(object sender, RoutedEventArgs e) { var colCount = 5; var rowCount = 5; var pattern = new double[colCount * rowCount]; for (var row = 0; row < rowCount; row++) { for (var col = 0; col < colCount; col++) { pattern[row * colCount + col] = ((ToggleButton)_GetControlIn(DrawingGrid, new GridCoordinates(row, col))).IsChecked.Value ? 1.0 : 0.0; } } var hopfieldPattern = new HopfieldPattern(pattern); var recognizedPattern = hopfieldNetwork.Recognize(hopfieldPattern); for (var row = 0; row < rowCount; row++) { for (var col = 0; col < colCount; col++) { ((ToggleButton)_GetControlIn(DrawingGrid, new GridCoordinates(row, col))).IsChecked = recognizedPattern[row * colCount + col] <= 0 ? false : true; } } }