Exemplo n.º 1
0
        private void FormChartWizard_Load(object sender, EventArgs e)
        {
            #region Tab Chart Type

            foreach (gvChart.gvChartType chartType in gvChart.ChartTypes)
            {
                lstChartTypes.Items.Add(chartType);
            }
            lstChartTypes.SelectedItem = 0;

            Series ser1 = new Series("Serie 1");
            ser1.Points.AddXY("A", 10);
            ser1.Points.AddXY("B", 6);
            ser1.Points.AddXY("C", 8);
            ser1.Points.AddXY("D", 12);
            ser1.Points.AddXY("E", 3);
            ser1.Color     = Color.Red;
            ser1.ChartArea = "Area1";

            Series ser2 = new Series("Serie 2");
            ser2.Points.AddXY("A", 5);
            ser2.Points.AddXY("B", 3);
            ser2.Points.AddXY("C", 7);
            ser2.Points.AddXY("D", 8);
            ser2.Points.AddXY("E", 6);
            ser2.Color     = Color.Blue;
            ser2.ChartArea = "Area1";

            _gvChart.Series.Add(ser1);
            _gvChart.Series.Add(ser2);
            _gvChart.Refresh();

            #endregion

            #region Tab Data

            ITableClass tc = (ITableClass)_layer.Class;
            foreach (IField field in _layer.Fields)
            {
                if (field.type == FieldType.biginteger ||
                    field.type == FieldType.Double ||
                    field.type == FieldType.Float ||
                    field.type == FieldType.integer ||
                    field.type == FieldType.smallinteger)
                {
                    lstSeries.Items.Add(new FieldItem()
                    {
                        Field = field
                    });
                }

                if (field.type != FieldType.binary &&
                    field.type != FieldType.GEOGRAPHY &&
                    field.type != FieldType.GEOMETRY &&
                    field.type != FieldType.Shape)
                {
                    cmbDataFields.Items.Add(new FieldItem()
                    {
                        Field = field
                    });
                }
            }
            if (cmbDataFields.Items.Count > 0)
            {
                cmbDataFields.SelectedIndex = 0;
            }

            #region Filter
            //All Features
            //Selected Features
            //Features in actual extent
            cmbFeatures.Items.Add(new ExportMethodItem("All Features", new QueryFilter()));

            if (_layer is IFeatureSelection &&
                ((IFeatureSelection)_layer).SelectionSet != null &&
                ((IFeatureSelection)_layer).SelectionSet.Count > 0)
            {
                ISelectionSet selectionSet = ((IFeatureSelection)_layer).SelectionSet;
                IQueryFilter  selFilter    = null;
                if (selectionSet is IIDSelectionSet)
                {
                    selFilter = new RowIDFilter(tc.IDFieldName, ((IIDSelectionSet)selectionSet).IDs);
                }
                else if (selectionSet is IGlobalIDSelectionSet)
                {
                    selFilter = new GlobalRowIDFilter(tc.IDFieldName, ((IGlobalIDSelectionSet)selectionSet).IDs);
                }
                else if (selectionSet is IQueryFilteredSelectionSet)
                {
                    selFilter = ((IQueryFilteredSelectionSet)selectionSet).QueryFilter.Clone() as IQueryFilter;
                }

                if (selFilter != null)
                {
                    selFilter.SubFields = "*";
                    ExportMethodItem item = new ExportMethodItem("Selected Features", selFilter);
                    cmbFeatures.Items.Add(item);
                    cmbFeatures.SelectedItem = item;
                }
            }

            if (_display != null && _display.Envelope != null)
            {
                SpatialFilter dispFilter = new SpatialFilter();
                dispFilter.SubFields = "*";

                dispFilter.FilterSpatialReference = _display.SpatialReference;
                dispFilter.Geometry        = _display.Envelope;
                dispFilter.SpatialRelation = spatialRelation.SpatialRelationIntersects;

                cmbFeatures.Items.Add(new ExportMethodItem("Features in actual extent", dispFilter));
            }

            if (cmbFeatures.SelectedIndex == -1)
            {
                cmbFeatures.SelectedIndex = 0;
            }
            #endregion

            #endregion
        }
Exemplo n.º 2
0
        public ExportFeatureClassDialog(IDisplay display, IFeatureLayer sourceFeatureLayer)
        {
            InitializeComponent();

            _sourceFeatureClass = sourceFeatureLayer.Class as IFeatureClass;

            #region Filter
            //All Features
            //Selected Features
            //Features in actual extent
            cmbExport.Items.Add(new ExportMethodItem("All Features", null));

            if (sourceFeatureLayer is IFeatureSelection &&
                ((IFeatureSelection)sourceFeatureLayer).SelectionSet != null &&
                ((IFeatureSelection)sourceFeatureLayer).SelectionSet.Count > 0)
            {
                ISelectionSet selectionSet = ((IFeatureSelection)sourceFeatureLayer).SelectionSet;
                IQueryFilter  selFilter    = null;
                if (selectionSet is IIDSelectionSet)
                {
                    selFilter = new RowIDFilter(_sourceFeatureClass.IDFieldName, ((IIDSelectionSet)selectionSet).IDs);
                }
                else if (selectionSet is IGlobalIDSelectionSet)
                {
                    selFilter = new GlobalRowIDFilter(_sourceFeatureClass.IDFieldName, ((IGlobalIDSelectionSet)selectionSet).IDs);
                }
                else if (selectionSet is IQueryFilteredSelectionSet)
                {
                    selFilter = ((IQueryFilteredSelectionSet)selectionSet).QueryFilter.Clone() as IQueryFilter;
                }

                if (selFilter != null)
                {
                    selFilter.SubFields = "*";
                    ExportMethodItem item = new ExportMethodItem("Selected Features", selFilter);
                    cmbExport.Items.Add(item);
                    cmbExport.SelectedItem = item;
                }
            }

            if (display != null && display.Envelope != null)
            {
                SpatialFilter dispFilter = new SpatialFilter();
                dispFilter.SubFields = "*";

                dispFilter.FilterSpatialReference = display.SpatialReference;
                dispFilter.Geometry        = display.Envelope;
                dispFilter.SpatialRelation = spatialRelation.SpatialRelationIntersects;

                cmbExport.Items.Add(new ExportMethodItem("Features in actual extent", dispFilter));
            }

            if (cmbExport.SelectedIndex == -1)
            {
                cmbExport.SelectedIndex = 0;
            }
            #endregion

            _listViewItem       = new FeatureClassListViewItem(_sourceFeatureClass, 255);
            gvFields.DataSource = _listViewItem.Fields;

            panelStep1.Dock = panelStep2.Dock = DockStyle.Fill;
            SetPanelVisibity();
        }
        async public Task Render()
        {
            if (_layer == null)
            {
                return;
            }

            if (_layer.SelectionRenderer == null)
            {
                return;
            }

            if (!(_layer is IFeatureSelection))
            {
                return;
            }

            IFeatureClass fClass = _layer.FeatureClass;

            if (fClass == null)
            {
                return;
            }

            ISelectionSet selectionSet = ((IFeatureSelection)_layer).SelectionSet;

            if (selectionSet == null)
            {
                return;
            }

            IDataset dataset = _map[_layer];

            if (dataset == null)
            {
                return;
            }

            if (!(dataset is IFeatureDataset))
            {
                return;
            }

            IGeometry filterGeom = _map.Display.Envelope;

            if (_map.Display.GeometricTransformer != null)
            {
                filterGeom = MapHelper.Project(fClass, _map.Display);
                //filterGeom = (IGeometry)_map.Display.GeometricTransformer.InvTransform2D(filterGeom);
            }

            IQueryFilter filter = null;

            //List<int> IDs=new List<int>();  // Sollte nicht null sein...
            if (selectionSet is ISpatialIndexedIDSelectionSet)
            {
                List <int> IDs = ((ISpatialIndexedIDSelectionSet)selectionSet).IDsInEnvelope(filterGeom.Envelope);
                filter = new RowIDFilter(fClass.IDFieldName, IDs);
            }
            else if (selectionSet is IIDSelectionSet)
            {
                List <int> IDs = ((IIDSelectionSet)selectionSet).IDs;
                filter = new RowIDFilter(fClass.IDFieldName, IDs);
            }
            else if (selectionSet is ISpatialIndexedGlobalIDSelectionSet)
            {
                List <long> IDs = ((ISpatialIndexedGlobalIDSelectionSet)selectionSet).IDsInEnvelope(filterGeom.Envelope);
                filter = new GlobalRowIDFilter(fClass.IDFieldName, IDs);
            }
            else if (selectionSet is IGlobalIDSelectionSet)
            {
                List <long> IDs = ((IGlobalIDSelectionSet)selectionSet).IDs;
                filter = new GlobalRowIDFilter(fClass.IDFieldName, IDs);
            }
            else if (selectionSet is IQueryFilteredSelectionSet)
            {
                filter = ((IQueryFilteredSelectionSet)selectionSet).QueryFilter.Clone() as IQueryFilter;
            }

            if (filter == null)
            {
                return;
            }

            filter.AddField(fClass.ShapeFieldName);

            #region Clone Layer

            IFeatureRenderer selectionRenderer = null;

            lock (lockThis)
            {
                // Beim Clonen sprerren...
                // Da sonst bei der Servicemap bei gleichzeitigen Requests
                // Exception "Objekt wird bereits an anderer Stelle verwendet" auftreten kann!
                selectionRenderer = (IFeatureRenderer)_layer.SelectionRenderer.Clone(new CloneOptions(_map,
                                                                                                      false,
                                                                                                      maxLabelRefscaleFactor: _layer.MaxRefScaleFactor));
            }

            #endregion

            selectionRenderer.PrepareQueryFilter(_layer, filter);

            using (IFeatureCursor fCursor = (fClass is ISelectionCache) ? ((ISelectionCache)fClass).GetSelectedFeatures(_map.Display) : await fClass.GetFeatures(filter))
            {
                if (fCursor != null)
                {
                    //_layer.SelectionRenderer.Draw(_map, fCursor, DrawPhase.Geography, _cancelTracker);
                    IFeature feature;
                    while ((feature = await fCursor.NextFeature()) != null)
                    {
                        if (_cancelTracker != null)
                        {
                            if (!_cancelTracker.Continue)
                            {
                                break;
                            }
                        }

                        selectionRenderer.Draw(_map, feature);
                    }
                    fCursor.Dispose();
                }
            }
        }