private void buttonGenerate_Click(object sender, RoutedEventArgs e) { if (MinX > MaxX || MinY > MaxY) { MessageBox.Show("Coordinates of the lower left corner must be smaller than upper right ones"); return; } if (SizeX < 1 || SizeY < 1) { MessageBox.Show("Array Size must be grater than zero"); return; } OutputMap = new HeightMap(SizeX, SizeY, new Vector2(MinX, MinY), new Vector2(MaxX, MaxY)); if (GenerateTestPattern) { DataTable t = new DataTable(); try { for (int x = 0; x < SizeX; x++) { for (int y = 0; y < SizeY; y++) { double X = (x * (MaxX - MinX)) / (SizeX - 1) + MinX; double Y = (y * (MaxY - MinY)) / (SizeY - 1) + MinY; decimal d = (decimal)t.Compute(TestPattern.Replace("x", X.ToString()).Replace("y", Y.ToString()), ""); OutputMap.AddPoint(x, y, (double)d); } } } catch (Exception ex) { MessageBox.Show("Error while evaluating expression:\n" + ex.Message); return; } } DialogResult = true; Close(); }