Ejemplo n.º 1
0
        private static void LoadFeatureSetAsLayer(FeatureLayerEventArgs e, FeatureSet fs, string newLayerName)
        {
            Type layerType = e.FeatureLayer.GetType();
            var  newLayer  = (FeatureLayer)Activator.CreateInstance(layerType, fs);

            IGroup parent = e.FeatureLayer.GetParentItem() as IGroup;

            if (parent != null)
            {
                int index = parent.IndexOf(e.FeatureLayer);
                if (newLayer != null)
                {
                    parent.Insert(index + 1, newLayer);
                    var child = parent[index + 1];
                    child.LegendText = newLayer.DataSet.Name = newLayer.Name = newLayerName;
                }
            }
        }
Ejemplo n.º 2
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 static void LoadFeatureSetAsLayer(FeatureLayerEventArgs e, FeatureSet fs, string newLayerName)
        {
            Type layerType = e.FeatureLayer.GetType();
            var newLayer = (FeatureLayer)Activator.CreateInstance(layerType, fs);

            IGroup parent = e.FeatureLayer.GetParentItem() as IGroup;
            if (parent != null)
            {
                int index = parent.IndexOf(e.FeatureLayer);
                if (newLayer != null)
                {
                    parent.Insert(index + 1, newLayer);
                    var child = parent[index + 1];
                    child.LegendText = newLayer.DataSet.Name = newLayer.Name = newLayerName;
                }
            }
        }
 private void FeatureLayerShowAttributesClicked(object sender, FeatureLayerEventArgs e)
 {
     var attributeDialog = new AttributeDialog(e.FeatureLayer);
     attributeDialog.Show(Owner);
 }
 private void Notifier_ShowPropertiesClicked(object sender, FeatureLayerEventArgs e)
 {
     OnShowPropertiesClicked(sender, e.FeatureLayer);
 }
        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.º 7
0
 private void Notifier_ShowPropertiesClicked(object sender, FeatureLayerEventArgs e)
 {
     OnShowPropertiesClicked(sender, e.FeatureLayer);
 }
Ejemplo n.º 8
0
 private static void FeatureLayerShowAttributesClicked(object sender, FeatureLayerEventArgs e)
 {
     attributeDialog = new AttributeDialog(e.FeatureLayer);
     attributeDialog.Show();
 }