Ejemplo n.º 1
0
        /// <summary>
        /// Show the dialog for exporting data from a feature layer.
        /// </summary>
        /// <param name="layer">Layer whose data gets exported.</param>
        public void ExportData(IFeatureLayer layer)
        {
            using (var frmExport = new ExportFeature())
            {
                frmExport.Filename = layer.DataSet.Filename;
                if (ShowDialog(frmExport) != DialogResult.OK)
                {
                    return;
                }

                // Create a FeatureSet of features that the client wants exported
                // CGX
                // FeatureSet fs = null;
                IFeatureSet fs = null;
                // FIN CGX
                switch (frmExport.FeaturesIndex)
                {
                case 0:
                    // CGX
                    // fs = (FeatureSet)layer.DataSet;
                    fs = layer.DataSet;
                    // Fin CGX
                    break;

                case 1:
                    fs = layer.Selection.ToFeatureSet();
                    break;

                case 2:
                    var features = layer.DataSet.Select(layer.MapFrame.ViewExtents);
                    fs = new FeatureSet(features)
                    {
                        Projection = layer.Projection
                    };
                    break;
                }

                if (fs == null)
                {
                    return;
                }

                if (fs.Features.Count == 0)
                {
                    fs.CopyTableSchema(layer.DataSet);
                    fs.FeatureType = layer.DataSet.FeatureType;
                }

                fs.SaveAs(frmExport.Filename, true);

                if (MessageBox.Show(Owner, SymbologyFormsMessageStrings.FeatureLayerActions_LoadFeatures, SymbologyFormsMessageStrings.FeatureLayerActions_FeaturesExported, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    LoadFeatureSetAsLayer(layer, fs, Path.GetFileNameWithoutExtension(frmExport.Filename));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show the dialog for exporting data from a feature layer.
        /// </summary>
        /// <param name="e"></param>
        public void ExportData(IFeatureLayer e)
        {
            using (var frmExport = new ExportFeature())
            {
                frmExport.Filename = e.DataSet.Filename;
                if (ShowDialog(frmExport) != DialogResult.OK)
                {
                    return;
                }

                // Create a FeatureSet of features that the client wants exported
                FeatureSet fs = null;
                switch (frmExport.FeaturesIndex)
                {
                case 0:
                    fs = (FeatureSet)e.DataSet;
                    break;

                case 1:
                    fs = e.Selection.ToFeatureSet();
                    break;

                case 2:
                    var features = e.DataSet.Select(e.MapFrame.ViewExtents);
                    fs = new FeatureSet(features)
                    {
                        Projection = e.Projection
                    };
                    break;
                }

                if (fs.Features.Count == 0)
                {
                    fs.CopyTableSchema(e.DataSet);
                    fs.FeatureType = e.DataSet.FeatureType;
                }

                fs.SaveAs(frmExport.Filename, true);

                if (MessageBox.Show(Owner, "Do you want to load the shapefile?",
                                    "The layer was exported.",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    LoadFeatureSetAsLayer(e, fs, Path.GetFileNameWithoutExtension(frmExport.Filename));
                }
            }
        }
Ejemplo n.º 3
0
        private void ExportDataClicked(object sender, FeatureLayerEventArgs e)
        {
            ExportFeature frmExport = new ExportFeature();

            frmExport.Filename = e.FeatureLayer.DataSet.Filename;
            if (frmExport.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            // Create a FeatureSet of features that the client wants exported
            FeatureSet fs = null;

            if (frmExport.FeaturesIndex == 0)
            {
                fs = (FeatureSet)e.FeatureLayer.DataSet;
            }
            else if (frmExport.FeaturesIndex == 1)
            {
                fs = e.FeatureLayer.Selection.ToFeatureSet();
            }
            else if (frmExport.FeaturesIndex == 2)
            {
                List <IFeature> features = e.FeatureLayer.DataSet.Select(e.FeatureLayer.MapFrame.ViewExtents);
                fs            = new FeatureSet(features);
                fs.Projection = e.FeatureLayer.Projection;
            }

            if (fs.Features.Count == 0)
            {
                fs.CopyTableSchema(e.FeatureLayer.DataSet);
                fs.FeatureType = e.FeatureLayer.DataSet.FeatureType;
            }

            fs.SaveAs(frmExport.Filename, true);

            DialogResult result = MessageBox.Show(Owner, "Do you want to load the shapefile?", "The layer was exported.", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                LoadFeatureSetAsLayer(e, fs, Path.GetFileNameWithoutExtension(frmExport.Filename));
            }
        }
        private void ExportDataClicked(object sender, FeatureLayerEventArgs e)
        {
            ExportFeature frmExport = new ExportFeature();
            frmExport.Filename = e.FeatureLayer.DataSet.Filename;
            if (frmExport.ShowDialog() != DialogResult.OK) return;
            // Create a FeatureSet of features that the client wants exported
            FeatureSet fs = null;
            if (frmExport.FeaturesIndex == 0)
            {
                fs = (FeatureSet)e.FeatureLayer.DataSet;
            }
            else if (frmExport.FeaturesIndex == 1)
            {
                fs = e.FeatureLayer.Selection.ToFeatureSet();
            }
            else if (frmExport.FeaturesIndex == 2)
            {
                List<IFeature> features = e.FeatureLayer.DataSet.Select(e.FeatureLayer.MapFrame.ViewExtents);
                fs = new FeatureSet(features);
                fs.Projection = e.FeatureLayer.Projection;
            }

            if (fs.Features.Count == 0)
            {
                fs.CopyTableSchema(e.FeatureLayer.DataSet);
                fs.FeatureType = e.FeatureLayer.DataSet.FeatureType;
            }

            fs.SaveAs(frmExport.Filename, true);

            DialogResult result = MessageBox.Show(Owner, "Do you want to load the shapefile?", "The layer was exported.", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
                LoadFeatureSetAsLayer(e, fs, Path.GetFileNameWithoutExtension(frmExport.Filename));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Show the dialog for exporting data from a feature layer.
        /// </summary>
        /// <param name="e"></param>
        public void ExportData(IFeatureLayer e)
        {
            using (var frmExport = new ExportFeature())
            {
                frmExport.Filename = e.DataSet.Filename;
                if (ShowDialog(frmExport) != DialogResult.OK) return;

                // Create a FeatureSet of features that the client wants exported
                FeatureSet fs = null;
                switch (frmExport.FeaturesIndex)
                {
                    case 0:
                        fs = (FeatureSet) e.DataSet;
                        break;
                    case 1:
                        fs = e.Selection.ToFeatureSet();
                        break;
                    case 2:
                        var features = e.DataSet.Select(e.MapFrame.ViewExtents);
                        fs = new FeatureSet(features) {Projection = e.Projection};
                        break;
                }

                if (fs.Features.Count == 0)
                {
                    fs.CopyTableSchema(e.DataSet);
                    fs.FeatureType = e.DataSet.FeatureType;
                }

                fs.SaveAs(frmExport.Filename, true);

                if (MessageBox.Show(Owner, "Do you want to load the shapefile?",
                                    "The layer was exported.",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    LoadFeatureSetAsLayer(e, fs, Path.GetFileNameWithoutExtension(frmExport.Filename));
                }
            }
        }