private void btnOK_Click(object sender, EventArgs e) { try { if (this.txtExpress.Text == "") { //ClsDeclare.g_ErrorHandler.DisplayInformation("请选择查询表达式", false, "确定", null); return; } if (m_frmQuery != null) { if (m_frmQuery.IsDisposed == false) { m_frmQuery.Close(); m_frmQuery = null; } } esriSelectionResultEnum pResult; pResult = esriSelectionResultEnum.esriSelectionResultAdd; switch (this.cboSelectMethod.Text) { case "创建一个新的选择结果": pResult = esriSelectionResultEnum.esriSelectionResultNew; break; case "添加到当前选择集中": pResult = esriSelectionResultEnum.esriSelectionResultAdd; break; case "从当前选择结果中移除": pResult = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "从当前选择结果中选择": pResult = esriSelectionResultEnum.esriSelectionResultAnd; break; } if (m_pCurrentFeatCls == null) { return; } m_blnSelect = true; m_pQueryResult = ClsSelectQuery.QueryByAttribute(m_blnSelect, txtExpress.Text.Trim(), pResult, m_pCurrentFeatCls, m_pCurrentLayer); m_pQueryResultCln.Clear(); m_pQueryResultCln.Add(m_pQueryResult, null, null, null); m_frmQuery = new FrmQuery(); m_frmQuery.QueryResultCln = m_pQueryResultCln; m_frmQuery.Show(); ClsDeclare.g_Sys.MapControl.ActiveView.Refresh(); } catch (Exception) { //ClsDeclare.g_ErrorHandler.DisplayInformation("可能表达式有误,请先验证表达式", false, "确定",null); //throw; MessageBoxEx.Show("可能表达式有误,请先验证表达式"); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_hookHelper != null) { ClsMapLayer pConvert = new ClsMapLayer(); IGeometry pGeometry; IActiveView pActiveView = m_hookHelper.ActiveView; IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pGeometry = (IGeometry)pPoint; if (ClsDeclare.g_pMap.SelectionCount != 0) { ClsDeclare.g_pMap.ClearSelection(); } pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); ISelectionEnvironment pSelectEnv = new SelectionEnvironment(); double Length; Length = pConvert.ConvertPixelDistanceToMapDistance(pActiveView, pSelectEnv.SearchTolerance); ITopologicalOperator pTopoOpera; IGeometry pBuffer; pTopoOpera = (ITopologicalOperator)pGeometry; pBuffer = pTopoOpera.Buffer(Length); pGeometry = (IGeometry)m_pMapControl.TrackCircle(); Application.DoEvents(); m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass; if (pGeometry != null) { if (pGeometry.Envelope.IsEmpty) { pGeometry = pBuffer.Envelope; } } esriSelectionResultEnum pselecttype = new esriSelectionResultEnum(); switch (Shift) { case 0: { pselecttype = esriSelectionResultEnum.esriSelectionResultNew; switch (mvarSelectMethod) { case "New": pselecttype = esriSelectionResultEnum.esriSelectionResultNew; break; case "Add": pselecttype = esriSelectionResultEnum.esriSelectionResultAnd; break; case "Sub": pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "Xor": pselecttype = esriSelectionResultEnum.esriSelectionResultXOR; break; } break; } case 1: pselecttype = esriSelectionResultEnum.esriSelectionResultAdd; break; case 2: pselecttype = esriSelectionResultEnum.esriSelectionResultXOR; break; case 3: pselecttype = esriSelectionResultEnum.esriSelectionResultNew; break; case 4: pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract; break; } if (m_FeatClsCln == null) { bool blntemp = false; m_pQueryResultCln = new Collection(); ClsSelectQuery.SelectGeometry(ref blntemp, pGeometry, pselecttype, ref m_pQueryResultCln); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); if (m_frmQuery == null) { m_frmQuery = new FrmQuery(); } if (m_frmQuery.IsDisposed) { m_frmQuery = new FrmQuery(); } m_frmQuery.QueryResultCln = m_pQueryResultCln; m_frmQuery.ReLoadQueryResult(); m_frmQuery.Visible = false; m_frmQuery.Show((Form)(ClsDeclare.g_Sys.FrmMain)); } m_pQueryResultCln = null; m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault; } else if (m_sceneHookHelper != null) { } else if (m_globeHookHelper != null) { } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { try { //if (ClsDeclare.g_pMap.SelectionCount != 0) // ClsDeclare.g_pMap.ClearSelection(); ClsMapLayer pConvert = new ClsMapLayer(); IActiveView pActiveView; pActiveView = m_hookHelper.ActiveView; IPoint pPoint; pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass(); double Length; Length = pConvert.ConvertPixelDistanceToMapDistance(pActiveView, pSelectEnv.SearchTolerance); ITopologicalOperator pTopoOpera; IGeometry pBuffer; pTopoOpera = (ITopologicalOperator)pPoint; pBuffer = pTopoOpera.Buffer(Length); m_pGeometry = pBuffer.Envelope; esriSelectionResultEnum pSelectType = new esriSelectionResultEnum(); switch (Shift) { case 0: { pSelectType = esriSelectionResultEnum.esriSelectionResultNew; switch (mvarSelectMethod) { case "New": //新建选择结果集 pSelectType = esriSelectionResultEnum.esriSelectionResultNew; break; case "Add": //增加选择结果集 按下Shift键 pSelectType = esriSelectionResultEnum.esriSelectionResultAnd; break; case "Sub": //减少选择结果集 按下Alt键 pSelectType = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "Xor": //对已有的选择集做异或 按下Ctrl键 pSelectType = esriSelectionResultEnum.esriSelectionResultXOR; break; } break; } case 1: pSelectType = esriSelectionResultEnum.esriSelectionResultAdd; break; case 2: pSelectType = esriSelectionResultEnum.esriSelectionResultXOR; break; case 3: pSelectType = esriSelectionResultEnum.esriSelectionResultNew; break; case 4: pSelectType = esriSelectionResultEnum.esriSelectionResultSubtract; break; } if (m_FeatClsCln == null) { bool blntemp = true; m_pQueryResultCln = new Collection(); ClsSelectQuery.SelectGeometry(ref blntemp, m_pGeometry, pSelectType, ref m_pQueryResultCln); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //TODO: FrmQuery的用法 if (m_frmQuery == null) { m_frmQuery = new FrmQuery(); } if (m_frmQuery.IsDisposed) { m_frmQuery = new FrmQuery(); } m_frmQuery.QueryResultCln = m_pQueryResultCln; m_frmQuery.ReLoadQueryResult(); m_frmQuery.Visible = false; m_frmQuery.Show((Form)(ClsDeclare.g_Sys.FrmMain)); } m_pQueryResultCln = null; if ((ClsDeclare.g_pMap.SelectionCount > ClsDeclare.g_Sys.MaxSelectCount) && (ClsDeclare.g_Sys.MaxSelectCount != 0)) { //if (ClsDeclare.g_ErrorHandler.DisplayInformation("你选择的结果大于" + Convert.ToString(ClsDeclare.g_Sys.MaxSelectCount) + "个地物,是否继续选择操作?", true, "确定", "取消") == false) { pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); ClsDeclare.g_pMap.ClearSelection(); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } } } catch (Exception) { //ClsDeclare.g_ErrorHandler.HandleError(true, null, 0, null, ex.StackTrace); throw; } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_hookHelper != null) { try { IActiveView pActiveView; pActiveView = m_hookHelper.ActiveView; IEnvelope pEnv; pEnv = m_pMapControl.TrackRectangle(); m_pGeometry = (IGeometry)pEnv; esriSelectionResultEnum pselecttype = new esriSelectionResultEnum(); switch (Shift) { case 0: { pselecttype = esriSelectionResultEnum.esriSelectionResultNew; switch (mvarSelectMethod) { case "New": pselecttype = esriSelectionResultEnum.esriSelectionResultNew; break; case "Add": pselecttype = esriSelectionResultEnum.esriSelectionResultAnd; break; case "Sub": pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "Xor": pselecttype = esriSelectionResultEnum.esriSelectionResultXOR; break; } break; } case 1: pselecttype = esriSelectionResultEnum.esriSelectionResultAdd; break; case 2: pselecttype = esriSelectionResultEnum.esriSelectionResultXOR; break; case 3: pselecttype = esriSelectionResultEnum.esriSelectionResultNew; break; case 4: pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract; break; } if (m_FeatClsCln == null) { bool blntemp = true; m_pQueryResultCln = new Collection(); ClsSelectQuery.SelectGeometry(ref blntemp, m_pGeometry, pselecttype, ref m_pQueryResultCln); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); if (m_frmQuery == null) { m_frmQuery = new FrmQuery(); } if (m_frmQuery.IsDisposed) { m_frmQuery = new FrmQuery(); } m_frmQuery.QueryResultCln = m_pQueryResultCln; m_frmQuery.ReLoadQueryResult(); m_frmQuery.Visible = false; m_frmQuery.Show((Form)(ClsDeclare.g_Sys.FrmMain)); } m_pQueryResultCln = null; if (ClsDeclare.g_pMap.SelectionCount > ClsDeclare.g_Sys.MaxSelectCount && ClsDeclare.g_Sys.MaxSelectCount != 0) { //if ((ClsDeclare.g_ErrorHandler.DisplayInformation("你选择的结果大于" + Convert.ToString(ClsDeclare.g_Sys.MaxSelectCount) + "个地物,是否继续选择操作?", true, "确定", "取消"))==false) { pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); ClsDeclare.g_pMap.ClearSelection(); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } } } catch (Exception) { //ClsDeclare.g_ErrorHandler.HandleError(true, null, 0, null, ex.StackTrace); throw; } } else if (m_sceneHookHelper != null) { } else if (m_globeHookHelper != null) { } }