public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; bool ready = true; //cross = new Dictionary<string, string>(); if (app == null || app.Current2DMapControl == null) { return; } m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol();//设置线样式 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; ISimpleFillSymbol pFillSym = new SimpleFillSymbol();//设置平面填充样式 pFillSym.Color = pColor; pFillSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSym.Outline = pLineSym; object symbol = pFillSym as object; IRubberBand band = new RubberPolygonClass(); IGeometry geo = band.TrackNew(m_Display, null);//在地图上画多边形 app.Current2DMapControl.DrawShape(geo, ref symbol); if (geo.IsEmpty)//如果多边形为空,则以点的缓冲区为图形要素 { IPoint searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); geo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); //m_ActiveView.FocusMap.SelectByShape(geo, s, false); } if (ready) { Dictionary <string, List <IFeature> > lines = GetPipeLines(geo); if (lines == null) { return; } WaitForm.Start("正在查询...", "请稍后"); int n = 0; foreach (List <IFeature> l in lines.Values) { n += l.Count; } if (n > 500) { XtraMessageBox.Show("区域内管线大于500条,请重新选择区域", "提示"); WaitForm.Stop(); return; } FrmPipelineCross dialog = new FrmPipelineCross(geo, diameter, sysName, lines); WaitForm.Stop(); UnBind(); dialog.Show(); if (dialog.DialogResult == DialogResult.Cancel || dialog.DialogResult == DialogResult.OK) { RestoreEnv(); } //DataTable dt = CrossAnalysis(lines); //FrmPipelineCross2D dialog = new FrmPipelineCross2D(dt); //WaitForm.Stop(); //dialog.ShowDialog(); } } } catch (System.Exception ex) { } }
private void OnFinishedDraw() { if (this._drawTool != null && this._drawTool.GeoType == DrawType.Polygon && this._drawTool.GetGeo() != null) { try { WaitForm.Start("正在空间查询...", "请稍后"); List <MajorClass> listMCs = LogicDataStructureManage3D.Instance.GetAllMajorClass(); if (listMCs != null) { ISpatialFilter filter = new SpatialFilterClass(); filter.Geometry = this._drawTool.GetGeo(); filter.GeometryField = "FootPrint"; filter.SpatialRel = gviSpatialRel.gviSpatialRelContains; Dictionary <MajorClass, List <IRowBuffer> > dict = new Dictionary <MajorClass, List <IRowBuffer> >(); foreach (MajorClass mc in listMCs) { IRowBuffer row = null; IFdeCursor cursor = null; try { string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl == null || fc == null || facc == null || facc.Name != "PipeLine") { continue; } if (fl.VisibleMask == gviViewportMask.gviViewNone) { continue; } int count = fc.GetCount(filter); if (count == 0) { break; } List <IRowBuffer> list = new List <IRowBuffer>(); cursor = fc.Search(filter, false); while ((row = cursor.NextRow()) != null) { list.Add(row); } dict[mc] = list; } } catch (Exception ex) { } finally { if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } } } WaitForm.Stop(); if (dict.Count == 0) { XtraMessageBox.Show("该区域内没有管线", "提示"); return; } FrmPipelineCross dlg = new FrmPipelineCross(dict); dlg.Show(); } } catch (Exception ex) { WaitForm.Stop(); } finally { } } }