christian@0: /* christian@0: * Postarc christian@0: * christian@0: * Author: christian@0: * Christian Lins christian@0: * christian@0: * Copyright: christian@0: * Copyright (C) 2012 Intevation GmbH christian@0: * christian@0: * This program is free software: you can redistribute it and/or modify christian@0: * it under the terms of the GNU Lesser General Public License as published by christian@0: * the Free Software Foundation, either version 3 of the License, or christian@0: * (at your option) any later version. christian@0: * christian@0: * This program is distributed in the hope that it will be useful, christian@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of christian@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the christian@0: * GNU General Public License for more details. christian@0: * christian@0: * You should have received a copy of the GNU Lesser General Public License christian@0: * along with this program. If not, see . christian@0: */ christian@0: christian@0: using System; christian@0: using System.Collections.Generic; christian@0: using System.ComponentModel; christian@0: using System.Data; christian@0: using System.Drawing; christian@0: using System.Linq; christian@0: using System.Text; christian@0: using System.Windows.Forms; christian@0: using ESRI.ArcGIS.Carto; christian@0: using Postarc.Catalog; christian@0: christian@0: namespace Postarc.GUI christian@0: { christian@0: public partial class FormExportToPostGIS : Form christian@0: { christian@0: protected IFeatureLayer layer; christian@0: christian@0: public FormExportToPostGIS(IFeatureLayer layer) christian@0: { christian@0: this.layer = layer; christian@0: InitializeComponent(); christian@0: christian@0: // Fill the database connections to the combo box and preselect one christian@0: int selIndex = this.cmbDatabaseConnections.SelectedIndex; christian@0: this.cmbDatabaseConnections.Items.Clear(); christian@0: this.cmbDatabaseConnections.Items.AddRange(Settings.LoadSavedProfiles().ToArray()); christian@0: this.cmbDatabaseConnections.Items.Add(new PostGISConnection()); christian@0: this.cmbDatabaseConnections.SelectedIndex = 0; christian@0: if (selIndex >= 0) christian@0: { christian@0: this.cmbDatabaseConnections.SelectedIndex = selIndex; christian@0: } christian@0: christian@0: this.lblDocumentLayer.Text = "Layer to export: " + layer.Name; christian@0: } christian@0: christian@0: private void FormExportToPostGIS_FormClosing(object sender, FormClosingEventArgs e) christian@0: { christian@0: e.Cancel = true; christian@0: Visible = false; christian@0: } christian@0: christian@0: private void btnExport_Click(object sender, EventArgs e) christian@0: { christian@0: PostGISConnection conn = this.cmbDatabaseConnections.SelectedItem as PostGISConnection; christian@0: christian@0: FeatureClassExporter exp = new FeatureClassExporter(layer.FeatureClass); christian@0: int numExported = exp.ExportFeatureClass(null, conn, cmbGeometryTable.Text); christian@0: christian@0: MessageBox.Show(numExported + " features exported!", "Export successful", MessageBoxButtons.OK, MessageBoxIcon.Information); christian@0: Visible = false; christian@0: } christian@0: } christian@0: }