private void hydroErodeRunButton_Click(object sender, EventArgs e) { // extract relevant values from the form solubility = (double)solubilityNum.Value; depositionRate = (double)depRateNum.Value; waterCapacity = (double)waterCapNum.Value; rainChance = (double)rainChanceNum.Value; rainAmount = (double)rainAmountNum.Value; evaporation = (double)evapConstNum.Value; timeStep = (double)timeStepNum.Value; hydroErodePasses = (int)hydroPassesNum.Value; // make sure the terrain has been generated or imported if (terrain != null) { // create a new modal dialog that will execute the erosion process, with progress bar ProgressDialog progress = new ProgressDialog("Running Hydraulic Erosion", HydroErosion); progress.ShowDialog(); heightMapPicture.Image = terrain.getHeightBitmap(); colorMapPicture.Image = terrain.getTexture(); waterMapPicture.Image = terrain.getWaterMap(0.0f); } else { MessageBox.Show("Please generate a terrain before running erosion."); } }