/// <summary>
        /// 初始化图层下拉菜单
        /// </summary>
        private void InitCtlComboLayer()
        {
            try
            {
                int           i;
                ILayer        pLayer;
                IFeatureLayer pFeatlayer;
                IFeatureClass pFeatCls;
                Collection    pLyrCol;
                Collection    LyrCol = null;
                if (m_FeatClsCln == null)
                {
                    pLyrCol = ClsSelectQuery.FunGetFeaLyrCol(ClsDeclare.g_pMap, null, LyrCol);
                    for (i = 1; i <= pLyrCol.Count; i++)
                    {
                        pLayer = pLyrCol[i] as ILayer;
                        if (pLayer is IFeatureLayer)
                        {
                            IFeatureLayer pFeatureLayer;
                            pFeatureLayer = pLayer as IFeatureLayer;
                            if (pFeatureLayer.Selectable)
                            {
                                cboLayerList.Items.Add(pLayer.Name);
                            }
                        }
                    }
                }
                else
                {
                    for (i = 1; i <= m_FeatClsCln.Count; i++)
                    {
                        pLayer = m_FeatClsCln[i] as ILayer;
                        if (pLayer is IFeatureLayer)
                        {
                            pFeatlayer = pLayer as IFeatureLayer;
                            pFeatCls   = pFeatlayer.FeatureClass;
                            cboLayerList.Items.Add(pFeatCls.AliasName);
                        }
                    }
                }

                if (cboLayerList.Items.Count > 0)
                {
                    cboLayerList.Text = cboLayerList.Items[0].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Example #2
0
        private void PopGrid()
        {
            int               i;
            IFeatureLayer     pFeatureLayer;
            IFeatureSelection pFeatSel;
            int               pRow;
            Collection        pLyrCol;
            Collection        LyrCol = null;

            pLyrCol        = ClsSelectQuery.FunGetFeaLyrCol(ClsDeclare.g_pMap, null, LyrCol);
            m_ChangeSelect = new int[pLyrCol.Count];

            for (i = 1; i <= pLyrCol.Count; i++)
            {
                ILayer pLayer;
                pLayer = pLyrCol[i] as ILayer;

                if (pLayer is IFeatureLayer)
                {
                    pFeatureLayer = pLayer as IFeatureLayer;
                    pFeatSel      = pFeatureLayer as IFeatureSelection;
                    if (pFeatSel.SelectionSet != null)
                    {
                        dgvGridList.Rows.Add();
                        pRow = dgvGridList.RowCount;
                        if (pFeatureLayer.Selectable)
                        {
                            dgvGridList.Rows[pRow - 2].Cells[0].Value = true;
                            m_ChangeSelect[i - 1] = 1;
                        }
                        else
                        {
                            dgvGridList.Rows[pRow - 2].Cells[0].Value = false;
                            m_ChangeSelect[i] = 0;
                        }
                        dgvGridList.Rows[pRow - 2].Cells[1].Value = pFeatureLayer.Name;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// 选择几何图形
        /// </summary>
        /// <param name="blnSelect"></param>
        /// <param name="pGeometry"></param>
        /// <param name="pselecttype"></param>
        /// <param name="m_pQueryResultCln"></param>
        public static void SelectGeometry(ref bool blnSelect, IGeometry pGeometry, esriSelectionResultEnum pselecttype, ref Collection m_pQueryResultCln)
        {
            ClsMapLayer pQueryResult;

            try
            {
                if (pGeometry == null)
                {
                    return;
                }

                if (!(pGeometry is IEnvelope))
                {
                    ITopologicalOperator pTop;
                    pTop = (ITopologicalOperator)pGeometry;
                    pTop.Simplify();
                }
                ILayer                  pLayer;
                IFeatureLayer           pFeatLayer;
                IFeatureClass           pFeatCls;
                int                     i;
                IFeatureLayerDefinition pFeaLyrDefine;

                Collection pLyrCol;
                Collection LyrCol = null;
                pLyrCol = ClsSelectQuery.FunGetFeaLyrCol(ClsDeclare.g_pMap, null, LyrCol);
                if (pLyrCol == null)
                {
                    return;
                }
                for (i = 1; i <= pLyrCol.Count; i++)
                {
                    pLayer = pLyrCol[i] as ILayer;
                    if (pLayer is IFeatureLayer)
                    {
                        pFeatLayer = (IFeatureLayer)pLayer;
                        bool bOutOfRange;
                        bOutOfRange = false;
                        if ((ClsDeclare.g_Sys.MapControl) != null)
                        {
                            IActiveView pActiveView;
                            ESRI.ArcGIS.Display.IDisplayTransformation pDisplayTransform;
                            pActiveView       = ClsDeclare.g_Sys.MapControl.ActiveView.FocusMap as IActiveView;
                            pDisplayTransform = pActiveView.ScreenDisplay.DisplayTransformation;

                            if (pFeatLayer.MaximumScale == 0 && pFeatLayer.MinimumScale == 0)
                            {
                                bOutOfRange = false;
                            }
                            if (pFeatLayer.MaximumScale != 0 && pFeatLayer.MinimumScale != 0)
                            {
                                if (pDisplayTransform.ScaleRatio > pFeatLayer.MaximumScale && pDisplayTransform.ScaleRatio < pFeatLayer.MinimumScale)
                                {
                                    bOutOfRange = false;
                                }
                                else
                                {
                                    bOutOfRange = true;
                                }
                            }
                            if (pFeatLayer.MaximumScale == 0 && pFeatLayer.MinimumScale != 0)
                            {
                                if (pDisplayTransform.ScaleRatio < pFeatLayer.MinimumScale)
                                {
                                    bOutOfRange = false;
                                }
                                else
                                {
                                    bOutOfRange = true;
                                }
                            }
                            if (pFeatLayer.MaximumScale != 0 && pFeatLayer.MinimumScale == 0)
                            {
                                if (pDisplayTransform.ScaleRatio > pFeatLayer.MaximumScale)
                                {
                                    bOutOfRange = false;
                                }
                                else
                                {
                                    bOutOfRange = true;
                                }
                            }
                        }
                        if (bOutOfRange == false && pFeatLayer.Selectable)
                        {
                            ClsSelectQuery.RemoveSelection(pFeatLayer);
                            if (pFeatLayer.Visible == true)
                            {
                                pFeatCls      = pFeatLayer.FeatureClass;
                                pFeaLyrDefine = (IFeatureLayerDefinition)pFeatLayer;

                                if (pFeaLyrDefine.DefinitionSelectionSet != null || pFeaLyrDefine.DefinitionExpression != "")
                                {
                                    blnSelect = true;
                                }
                                else
                                {
                                    blnSelect = false;
                                }
                                pQueryResult = ClsSelectQuery.QueryByGeometry(blnSelect, pGeometry, pFeatCls, pselecttype, pFeatLayer);

                                if (pQueryResult != null)
                                {
                                    m_pQueryResultCln.Add(pQueryResult, null, null, null);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                return;

                throw;
            }
            finally
            {
                IActiveView pActiveView;
                pActiveView = (IActiveView)ClsDeclare.g_pMap;
                //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, pActiveView.Extent);
                pActiveView.Refresh();
            }
        }