Exemplo n.º 1
0
        private void btnVerify_Click(object sender, EventArgs e)
        {
            IQueryFilter   pQueryFilter;
            IFeatureClass  pFeatCls;
            IFeatureCursor pFeatCursor;
            IFeature       pFeat;
            IFeatureLayer  pFeatLayer;

            if (this.txtExpress.Text == "")
            {
                //ClsDeclare.g_ErrorHandler.DisplayInformation("请输入表达式", false, "确定",null);
                return;
            }
            pFeatLayer = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap);
            if (pFeatLayer == null)
            {
                return;
            }
            try
            {
                pFeatCls                 = pFeatLayer.FeatureClass;
                pQueryFilter             = new QueryFilterClass();
                pQueryFilter.SubFields   = "*";
                pQueryFilter.WhereClause = this.txtExpress.Text.Trim();
                pFeatCls.Search(pQueryFilter, false);
                pFeatCursor = pFeatCls.Search(pQueryFilter, false);
                pFeat       = pFeatCursor.NextFeature();

                //if (pFeat != null)
                //    ClsDeclare.g_ErrorHandler.DisplayInformation("表达式正确!", false, null, null);
                //else
                //    ClsDeclare.g_ErrorHandler.DisplayInformation("此表达式搜索不到要素,请检查表达式!", false, null, null);
                if (pFeat != null)
                {
                    MessageBox.Show("表达式正确!");
                }
                else
                {
                    MessageBox.Show("此表达式搜索不到要素,请检查表达式!");
                }
                //ClsDeclare.g_ErrorHandler.DisplayInformation("此表达式搜索不到要素,请检查表达式!", false, null, null);
            }
            catch (Exception)
            {
                //ClsDeclare.g_ErrorHandler.DisplayInformation("查询表达式不合法!", false, null, null);
                MessageBoxEx.Show("查询表达式不合法!请修改");
            }
            finally
            {
                pQueryFilter = null;
                pFeatCls     = null;
                pFeatCursor  = null;
                pFeat        = null;
            }
        }
Exemplo n.º 2
0
        private void Verify()
        {
            IQueryFilter   pQueryFilter;
            IFeatureClass  pFeatCls;
            IFeatureCursor pFeatCursor;
            IFeature       pFeat;
            IFeatureLayer  pFeatLayer;


            if (this.txtExpress.Text == "")
            {
                //ClsDeclare.g_ErrorHandler.DisplayInformation("请输入表达式",false,"确定",null);
                return;
            }
            pFeatLayer = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap);
            if (pFeatLayer == null)
            {
                return;
            }
            try
            {
                pFeatCls                 = pFeatLayer.FeatureClass;
                pQueryFilter             = new QueryFilterClass();
                pQueryFilter.SubFields   = "*";
                pQueryFilter.WhereClause = this.txtExpress.Text.Trim();
                pFeatCls.Search(pQueryFilter, false);
                pFeatCursor = pFeatCls.Search(pQueryFilter, false);
                pFeat       = pFeatCursor.NextFeature();

                if (pFeat == null)
                {
                    //ClsDeclare.g_ErrorHandler.DisplayInformation("此表达式搜索不到要素,请检查表达式!", false, null, null);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //ClsDeclare.g_ErrorHandler.HandleError(true, null, 0, null, ex.StackTrace);
                throw;
            }
            finally
            {
                pQueryFilter = null;
                pFeatCls     = null;
                pFeatCursor  = null;
                pFeat        = null;
            }
        }
Exemplo n.º 3
0
        private void ListField()
        {
            try
            {
                ILayer        pLayer;
                IFeatureLayer pFeatlayer;
                IFeatureClass pFeatCls;
                int           i;

                if (m_FeatClsCln == null)
                {
                    m_pCurrentLayer   = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap);
                    m_pCurrentFeatCls = m_pCurrentLayer.FeatureClass;
                }
                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;
                            if (pFeatCls.AliasName == cboLayerList.Text)
                            {
                                m_pCurrentFeatCls = pFeatCls;
                                break;
                            }
                        }
                    }
                }
                lstField.Items.Clear();
                for (i = 0; i < m_pCurrentFeatCls.Fields.FieldCount; i++)
                {
                    if (Convert.ToUInt32(m_pCurrentFeatCls.Fields.get_Field(i).Type) < 5 && m_pCurrentFeatCls.Fields.get_Field(i).Editable == true)
                    {
                        lstField.Items.Add(m_pCurrentFeatCls.Fields.get_Field(i).AliasName + "【" + m_pCurrentFeatCls.Fields.get_Field(i).Name + "】");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Exemplo n.º 4
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                Verify();
                string strQuery;
                strQuery = this.txtExpress.Text;
                if (strQuery == "")
                {
                    return;
                }
                ILayer pLayer;
                pLayer = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap);
                if (pLayer == null)
                {
                    return;
                }
                IFeatureLayer pFeatLayer;
                pFeatLayer = pLayer as IFeatureLayer;

                if (pFeatLayer.Visible == false)
                {
                }
                //ClsDeclare.g_ErrorHandler.DisplayInformation("请选择可见图层",false,"确定",null);
                IFeatureSelection pFeatureSelection;
                pFeatureSelection = pFeatLayer as IFeatureSelection;

                IQueryFilter pQueryFilter = new QueryFilterClass();
                pQueryFilter.WhereClause = strQuery;

                esriSelectionResultEnum SelType;
                SelType = esriSelectionResultEnum.esriSelectionResultNew;

                switch (this.cboSelectMethod.Text)
                {
                case "创建一个新的选择结果":
                {
                    if (ClsDeclare.g_pMap.SelectionCount > 0)
                    {
                        ClsDeclare.g_pMap.ClearSelection();
                    }
                    SelType = esriSelectionResultEnum.esriSelectionResultNew;
                }
                break;

                case "添加到当前选择集中":
                    SelType = esriSelectionResultEnum.esriSelectionResultAdd;
                    break;

                case "从当前选择结果中移除":
                    SelType = esriSelectionResultEnum.esriSelectionResultSubtract;
                    break;

                case "从当前选择结果中选择":
                    SelType = esriSelectionResultEnum.esriSelectionResultAnd;
                    break;
                }
                if (pFeatLayer.Selectable)
                {
                    pFeatureSelection.SelectFeatures(pQueryFilter, SelType, false);
                }

                IActiveView pActiveView;
                pActiveView = ClsDeclare.g_pMap as IActiveView;
                pActiveView.Refresh();

                IFeatureClass       pFeatCls;
                IGeometryCollection pGeometryCol;
                IGeometryBag        pGeometryBag;
                IEnumIDs            pEnumIDs;
                IFeature            pFeature;
                int iOBJID;

                pGeometryCol = new GeometryBagClass();
                pGeometryBag = pGeometryCol as IGeometryBag;
                pFeatCls     = pFeatLayer.FeatureClass;
                pEnumIDs     = pFeatureSelection.SelectionSet.IDs;
                iOBJID       = pEnumIDs.Next();
                object Missing  = Type.Missing;
                object Missing1 = Type.Missing;
                while (iOBJID != -1)
                {
                    pFeature = pFeatCls.GetFeature(iOBJID);
                    pGeometryCol.AddGeometry(pFeature.Shape, ref Missing, ref Missing1);
                    iOBJID = pEnumIDs.Next();
                }

                IHookActions pHookActions;
                IHookHelper  pHookHelper;
                pHookHelper      = new HookHelperClass();
                pHookHelper.Hook = ClsDeclare.g_Sys.MapControl.Object;
                pHookActions     = pHookHelper as IHookActions;
                if (pHookActions.get_ActionSupported(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan))
                {
                    pHookActions.DoAction(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan);
                }
                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //ClsDeclare.g_ErrorHandler.HandleError(true,null,0,null,ex.StackTrace);
                throw;
            }
        }
Exemplo n.º 5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int           i;
            IFeatureLayer pFeatureLayer;
            bool          bClearSelect;
            IActiveView   pActiveView;

            m_pSelectEnv = new SelectionEnvironmentClass();
            bClearSelect = false;
            for (i = 0; i < dgvGridList.RowCount; i++)
            {
                pFeatureLayer = ClsSelectQuery.FunFindFeatureLayerByName(dgvGridList.Rows[i].Cells[1].Value.ToString(), ClsDeclare.g_pMap);
                if (pFeatureLayer is IFeatureLayer)
                {
                    if (this.dgvGridList.Rows[i].Cells[0].Value != null)
                    {
                        pFeatureLayer.Selectable = true;
                    }
                    else
                    {
                        pFeatureLayer.Selectable = false;
                    }
                    if (pFeatureLayer.Selectable == false && m_ChangeSelect[i] == 1)
                    {
                        bClearSelect = true;
                    }
                }
            }
            IRgbColor pRGBColor = new RgbColorClass();

            pRGBColor.Red             = cColorPicker.SelectedColor.R;
            pRGBColor.Green           = cColorPicker.SelectedColor.G;
            pRGBColor.Blue            = cColorPicker.SelectedColor.B;
            m_pSelectEnv.DefaultColor = pRGBColor;

            if (txtTolerance != null)
            {
                m_pSelectEnv.SearchTolerance = Convert.ToInt32(txtTolerance.Text);
            }

            if (this.txtSelectCount != null)
            {
                if (this.txtSelectCount.Text == "")
                {
                    m_MaxSelectCount = 0;
                }
                else
                {
                    m_MaxSelectCount = Convert.ToInt64(this.txtSelectCount.Text);
                }
                ClsDeclare.g_Sys.MaxSelectCount = m_MaxSelectCount;
            }
            if (bClearSelect == true)
            {
                pActiveView = ClsDeclare.g_pMap as IActiveView;
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                ClsDeclare.g_pMap.ClearSelection();
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            this.Close();
        }