protected override void OnClick() { IRasterLayer rasterLayer = Painter.ActiveLayer; RasterFileDialog saveFileDialog = new RasterFileDialog(FileDialogType.Save); saveFileDialog.InitialDirectory = Path.GetDirectoryName(rasterLayer.FilePath); saveFileDialog.InitialFileName = Path.GetFileNameWithoutExtension(rasterLayer.FilePath) + "_edited"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { Painter.SaveEditsAs(saveFileDialog.FileName); Display.ClearElement(Painter.Paints.GetAllGraphicElements()); Painter.Paints.Clear(); } try { } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); } }
/// <summary> /// Prompts the user to a file dialog and select the input raster file. /// </summary> private void openInputRasterBbutton_Click(object sender, EventArgs e) { RasterFileDialog openFileDialog = new RasterFileDialog(FileDialogType.Open); openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { inputRasterComboBox.Text = openFileDialog.FileName; editLayer = new RasterLayerClass(); editLayer.CreateFromFilePath(openFileDialog.FileName); ShowExtent(editLayer); } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); inputRasterComboBox.Text = ""; editLayer = null; } } this.BringToFront(); }
/// <summary> /// Open a file dialog and select the output raster file. /// </summary> private void openOutputRasterButton_Click(object sender, EventArgs e) { RasterFileDialog openFileDialog = new RasterFileDialog(FileDialogType.Save); if (openFileDialog.ShowDialog() == DialogResult.OK) { outputRasterTextBox.Text = openFileDialog.FileName; } this.BringToFront(); }
/// <summary> /// Opens a file dialog and select the reference raster file. /// </summary> private void openOutputExtentButton_Click(object sender, EventArgs e) { RasterFileDialog openFileDialog = new RasterFileDialog(FileDialogType.Open); openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { outputExtentComboBox.Text = openFileDialog.FileName; try { IRasterLayer rasterLayer = new RasterLayerClass(); rasterLayer.CreateFromFilePath(openFileDialog.FileName); ShowExtent(rasterLayer); } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); outputExtentComboBox.Text = ""; } } this.BringToFront(); }