/// <summary> /// Shows a dialog to add a new terrain patch to the world map. /// </summary> /// <param name="sender">The object that raised the event.</param> /// <param name="e">The event arguments.</param> private void AddNewPatchToolStripMenuItem_Click(object sender, EventArgs e) { Helper.EnsureDirectories(); AddNewPatchDialog addPatchForm = new AddNewPatchDialog(this.editorRenderWindow.Engine.CurrentCamera.Target, this.editorRenderWindow.Engine.Terrain.CurrentHeightLevel); if (addPatchForm.ShowDialog() == DialogResult.OK) { TerrainPatch tp = new TerrainPatch(addPatchForm.PatchCoordinates, addPatchForm.DefaultHeight, addPatchForm.DefaultTerrainType); string destinationFilename = Helper.GetPatchFileName(tp.PatchId); if (File.Exists(destinationFilename)) { if (MessageBox.Show("Are you sure you want to overwrite?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, this.RightToLeft == RightToLeft.Yes ? MessageBoxOptions.RtlReading : 0) == DialogResult.Yes) { File.WriteAllBytes(destinationFilename, tp.ToByteArray()); this.editorRenderWindow.Engine.Terrain.ForcePatchReload(addPatchForm.PatchCoordinates); } } else { File.WriteAllBytes(destinationFilename, tp.ToByteArray()); } } }