Exemplo n.º 1
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGC = m_ActiveView.GraphicsContainer;

            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo      = null;
            int       preCount  = 0;
            int       nextCount = 0;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready)
                    {
                        bool haveone = false;
                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                //DFDataConfig.Class.FieldInfo fi;
                                //int indexFusu = 0;
                                ////string nodefcId = null;
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (haveone)
                                    {
                                        break;
                                    }
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry   = pGeo;
                                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pFeatureCursor            = fc.Search(pSpatialFilter, false);
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        pFeature = pFeatureCursor.NextFeature();
                                        if (pFeature == null)
                                        {
                                            continue;
                                        }
                                        IGeometry pGeometry = pFeature.Shape as IGeometry;
                                        if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                                        {
                                            IPolyline pLine = pGeometry as IPolyline;
                                            this._EdgeFCID = fc.FeatureClassID.ToString();
                                            this._EdgeOID  = pFeature.OID;
                                            color          = GetRGBColor(0, 230, 240);
                                            IElement lineElement = LineElementRenderer(pLine, color);
                                            pGC.AddElement(lineElement, 0);
                                        }
                                        haveone = true;
                                        break;
                                    }

                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        IFeatureLayer fl   = dffc.GetFeatureLayer();
                                        if (fc == null || pGeo == null || fl == null)
                                        {
                                            continue;
                                        }
                                        if (!fl.Visible)
                                        {
                                            continue;
                                        }
                                        if (facc.Name != "PipeNode")
                                        {
                                            continue;
                                        }
                                        DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional");
                                        IFields fiCol     = fc.Fields;
                                        int     indexFusu = fiCol.FindField(fi.Name);

                                        WaitForm.Start("正在分析...", "请稍后");
                                        TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc2DId);
                                        if (tc == null)
                                        {
                                            WaitForm.Stop();
                                            return;
                                        }
                                        TopoNetwork net = tc.GetNetwork();
                                        if (net == null)
                                        {
                                            WaitForm.Stop();
                                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                                            return;
                                        }
                                        else
                                        {
                                            HashSet <string> valveIds = new HashSet <string>();
                                            if (!string.IsNullOrEmpty(fc2DId) && ValveManager.Instance.Exists(fc2DId))
                                            {
                                                valveIds = ValveManager.Instance.GetValveIds(fc2DId);
                                            }
                                            else
                                            {
                                                IFeature feature;
                                                string   fusu;
                                                //IQueryFilter filter = new QueryFilter();

                                                //filter.WhereClause = fi.Name + " LIKE '%阀%'";
                                                IFeatureCursor cursor = fc.Search(null, false);
                                                int            n      = fc.FeatureCount(null);
                                                if (indexFusu == 0)
                                                {
                                                    return;
                                                }
                                                while ((feature = cursor.NextFeature()) != null)
                                                {
                                                    //valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    fusu = feature.get_Value(indexFusu).ToString();
                                                    if (fusu == "阀门" || fusu == "阀门井")
                                                    {
                                                        valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    }
                                                }
                                                ValveManager.Instance.Add(fc2DId, valveIds);
                                            }
                                            //string edgeID = this._EdgeFCID + "_" + this._EdgeOID.ToString();
                                            if (EdgeManager.Instance.Exists(this._EdgeFCID, this._EdgeOID.ToString()))
                                            {
                                                edge = EdgeManager.Instance.GetEdgeByID(this._EdgeFCID, this._EdgeOID.ToString());
                                            }
                                            preNode  = edge.PreNode;
                                            nextNode = edge.NextNode;
                                            HashSet <string> recordPre  = new HashSet <string>();
                                            HashSet <string> recordNext = new HashSet <string>();
                                            color = GetRGBColor(255, 0, 0);
                                            net.BGFX(preNode.ID, nextNode.ID, valveIds, ref recordPre, ref recordNext);
                                            if (recordPre.Count <= 0 && recordNext.Count <= 0)
                                            {
                                                continue;
                                            }
                                            preCount  = recordPre.Count;
                                            nextCount = recordNext.Count;
                                            foreach (string s in recordPre)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                //color = GetRGBColor(255, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            foreach (string s in recordNext)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                color = GetRGBColor(0, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            app.Current2DMapControl.MapScale = 500;
                                            app.Current2DMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                                        }
                                        if (haveone)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                WaitForm.Stop();
                XtraMessageBox.Show("上游需关闭阀门:" + preCount + "\n下游需关闭阀门:" + nextCount, "提示");
                SuspendCommand();
            }
        }
Exemplo n.º 2
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            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);
                    WaitForm.Start("正在查询...", "请稍后");

                    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)
                    {
                        WaitForm.Start("正在统计...", "请稍后");
                        DataTable dtResult = RegionAnalysis(geo);//根据所得图形要素分析,得到统计用数据表
                        if (dtResult == null || dtResult.Rows.Count == 0)
                        {
                            WaitForm.Stop();
                            XtraMessageBox.Show("统计结果为空!", "提示");
                            return;
                        }
                        WaitForm.Stop();
                        FrmPipeLineStatsOutput dialog = new FrmPipeLineStatsOutput();
                        dialog.SetData1(dtResult);
                        //dialog.SetData1(dtstats);
                        dialog.ShowDialog();
                        if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            this.RestoreEnv();
                        }
                    }
                }
            }
            catch
            {
            }
        }
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication    app = DF2DApplication.Application;
            IGraphicsContainer gc  = app.Current2DMapControl.Map as IGraphicsContainer;

            gc.DeleteAllElements();
            bool ready = true;

            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 RubberRectangularPolygonClass();
                    IGeometry   geo    = band.TrackNew(m_Display, null);
                    app.Current2DMapControl.DrawShape(geo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");

                    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)
                    {
                        foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                        {
                            if (mc.Alias == "电力" || mc.Alias == "通信" || mc.Alias == "架空")
                            {
                                continue;
                            }
                            string[] arrFc2DId = mc.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    if (fc == null || facc == null || facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    DFDataConfig.Class.FieldInfo fiDirection = facc.GetFieldInfoBySystemName("FlowDirection");
                                    if (fiDirection == null)
                                    {
                                        continue;
                                    }

                                    IFields pFields = fc.Fields;
                                    //string[] name = new string[pFields.FieldCount];
                                    //for (int i = 0; i < pFields.FieldCount; i++)
                                    //{
                                    //    name[i] = pFields.get_Field(i).Name;
                                    //}
                                    int indexDirection = pFields.FindField(fiDirection.Name);
                                    if (indexDirection < 0)
                                    {
                                        continue;
                                    }
                                    IField         pField = pFields.get_Field(indexDirection);
                                    ISpatialFilter filter = new SpatialFilter();
                                    filter.Geometry    = geo;
                                    filter.SubFields   = pField.Name;
                                    filter.WhereClause = mc.ClassifyField + " =  '" + sc.Name + "'";
                                    filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    if (fc == null || geo == null)
                                    {
                                        return;
                                    }

                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;


                                    try
                                    {
                                        pFeatureCursor = fc.Search(filter, false);
                                        esriFlowDirection flowDirection = new esriFlowDirection();
                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            object tempobj = pFeature.get_Value(indexDirection);
                                            int    dtemp;
                                            if (tempobj != null && Int32.TryParse(tempobj.ToString(), out dtemp))
                                            {
                                                switch (dtemp)
                                                {
                                                case 0:
                                                    flowDirection = esriFlowDirection.esriFDWithFlow;
                                                    break;

                                                case 1:
                                                    flowDirection = esriFlowDirection.esriFDAgainstFlow;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                flowDirection = esriFlowDirection.esriFDIndeterminate;
                                            }
                                            IPolyline polyline    = pFeature.Shape as IPolyline;
                                            IPoint    middlePoint = new PointClass();
                                            polyline.QueryPoint(esriSegmentExtension.esriNoExtension, polyline.Length / 2, false, middlePoint);

                                            IArrowMarkerSymbol  arrowMarkerSymbol  = new ArrowMarkerSymbolClass();
                                            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                                            IElement            element            = null;
                                            if (flowDirection == esriFlowDirection.esriFDWithFlow)
                                            {
                                                arrowMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.FromPoint, polyline.ToPoint);
                                                arrowMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size  = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDAgainstFlow)
                                            {
                                                simpleMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.ToPoint, polyline.FromPoint);
                                                arrowMarkerSymbol.Color  = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size   = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDIndeterminate)
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(255, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            gc.AddElement(element, 0);
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                    }
                                }
                            }
                        }
                        WaitForm.Stop();
                        app.Current2DMapControl.ActiveView.Refresh();
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 4
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            this._dict.Clear();
            m_ActiveView = app.Current2DMapControl.ActiveView;
            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready   = false;
            bool haveone = false;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            IGeometry pGeo = null;

            try
            {
                if (button == 1)
                {
                    WaitForm.Start("正在查询...", "请稍后");
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready == true)
                    {
                        //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        //{
                        IFeatureCursor   pFeatureCursor = null;
                        IFeature         pFeature       = null;
                        ISpatialFilter   pSpatialFilter = new SpatialFilter();
                        IFeatureClass    fc;
                        DF2DFeatureClass dffc;
                        //foreach (MajorClass mc in lg.MajorClasses)
                        foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses)
                        {
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }

                                foreach (string fc2DId in arrFc2DId)
                                {
                                    dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    fc = dffc.GetFeatureClass();
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    if (facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    if (fc == null || pGeo == null)
                                    {
                                        continue;
                                    }
                                    pSpatialFilter            = new SpatialFilter();
                                    pSpatialFilter.Geometry   = pGeo;
                                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";
                                    pSpatialFilter.WhereClause = whereClause;
                                    pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    pFeature = pFeatureCursor.NextFeature();
                                    if (pFeature == null)
                                    {
                                        continue;
                                    }
                                    DataTable dt = new DataTable();
                                    dt.TableName = facc.Name;
                                    DataColumn oidcol = new DataColumn();
                                    oidcol.ColumnName = "oid";
                                    oidcol.Caption    = "ID";
                                    dt.Columns.Add(oidcol);
                                    foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection)
                                    {
                                        if (!fitemp.CanQuery)
                                        {
                                            continue;
                                        }
                                        DataColumn col = new DataColumn();
                                        col.ColumnName = fitemp.Name;
                                        col.Caption    = fitemp.Alias;
                                        dt.Columns.Add(col);
                                    }

                                    DataRow dtRow = dt.NewRow();
                                    dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"));
                                    foreach (DataColumn col in dt.Columns)
                                    {
                                        int index1 = pFeature.Fields.FindField(col.ColumnName);
                                        if (index1 < 0)
                                        {
                                            continue;
                                        }
                                        object obj1 = GetFieldValueByIndex(pFeature, index1);
                                        string str  = "";
                                        if (obj1 != null)
                                        {
                                            IField field = pFeature.Fields.get_Field(index1);
                                            switch (field.Type)
                                            {
                                            case esriFieldType.esriFieldTypeBlob:
                                            case esriFieldType.esriFieldTypeGeometry:
                                            case esriFieldType.esriFieldTypeRaster:
                                                continue;

                                            case esriFieldType.esriFieldTypeDouble:

                                                double d;
                                                if (double.TryParse(obj1.ToString(), out d))
                                                {
                                                    str = d.ToString("0.00");
                                                }
                                                break;

                                            default:
                                                str = obj1.ToString();
                                                break;
                                            }
                                        }
                                        dtRow[col.ColumnName] = str;
                                    }
                                    dt.Rows.Add(dtRow);
                                    if (dt.Rows.Count > 0)
                                    {
                                        this._dict[sc.Name] = dt;
                                    }
                                    haveone = true;
                                    break;
                                }
                                if (haveone)
                                {
                                    break;
                                }
                            }
                            if (haveone)
                            {
                                break;
                            }
                        }
                    }
                    #region  查询建筑物
                    if (!haveone)
                    {
                        FacilityClass facBuild = FacilityClassManager.Instance.GetFacilityClassByName("Building");
                        if (facBuild != null)
                        {
                            haveone = HaveOne(facBuild, pGeo);
                        }
                        if (!haveone)
                        {
                            FacilityClass facStruct = FacilityClassManager.Instance.GetFacilityClassByName("Structure");
                            if (facStruct != null)
                            {
                                haveone = HaveOne(facStruct, pGeo);
                            }
                        }
                    }

                    #endregion
                    try
                    {
                        if (!haveone)
                        {
                            WaitForm.Stop();
                            XtraMessageBox.Show("未选中要素,请重新选择", "提示");
                            return;
                        }
                        this._uPanel               = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height);
                        this._dockPanel            = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right);
                        this._dockPanel.Visibility = DockVisibility.Visible;
                        this._dockPanel.FloatSize  = new System.Drawing.Size(this._width, this._height);
                        this._dockPanel.Width      = this._width;
                        this._dockPanel.Height     = this._height;
                        if (this._ucPropInfo2D == null)
                        {
                            this._ucPropInfo2D = new UCPropertyInfo2D();
                        }
                        this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill;
                        this._uPanel.RegisterEvent(new PanelClose(this.Close));
                        this._dockPanel.Controls.Add(this._ucPropInfo2D);
                        this._ucPropInfo2D.Init();
                        this._ucPropInfo2D.SetPropertyInfo(this._dict);
                        WaitForm.Stop();
                    }
                    catch
                    {
                        WaitForm.Stop();
                    }
                }
                //}
            }
            catch
            {
                WaitForm.Stop();
            }
            finally
            {
            }
        }
Exemplo n.º 5
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            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   pGeo   = band.TrackNew(m_Display, null);
                    app.Current2DMapControl.DrawShape(pGeo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");
                    if (pGeo.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    if (ready)
                    {
                        WaitForm.Start("正在准备导出,请稍后...");
                        IFeatureClass fc = GetUpdateRegionFC();
                        if (fc == null)
                        {
                            XtraMessageBox.Show("当前地图中没有找到\"修测范围\"图层,无法绘制修测范围!", "修测范围确定");
                            return;
                        }


                        IMap pMap = app.Current2DMapControl.Map;
                        if (pMap == null)
                        {
                            WaitForm.Stop(); return;
                        }
                        //ISelectionEnvironment selEnv = new SelectionEnvironmentClass();
                        //pMap.SelectByShape(pGeo, selEnv, false);

                        //ISelection pSelection = pMap.FeatureSelection;

                        FolderBrowserDialog sfd = new FolderBrowserDialog();
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            string strRegionName = string.Format("{0}{1}点{2}分", DateTime.Now.ToLongDateString(), DateTime.Now.Hour, DateTime.Now.Minute);
                            //存储范围线
                            WaitForm.SetCaption("正在存储范围线,请稍后...");
                            SaveFanWei(pGeo, strRegionName, fc);
                            string strPath = String.Format(@"{0}\{1}.dxf", sfd.SelectedPath, strRegionName);
                            if (this.m_Workspace == null)
                            {
                                XtraMessageBox.Show("获得数据工作空间失败");
                                WaitForm.Stop();
                                return;
                            }
                            WaitForm.SetCaption("开始导出数据,请稍后...");
                            ExportData(strPath, pGeo, pMap, this.m_Workspace);
                            WaitForm.SetCaption("数据导出成功!");
                            XtraMessageBox.Show("数据导出成功!");
                            RestoreEnv();

                            //CreateFeature(pGeo, pMap, fc);
                        }

                        WaitForm.Stop();
                    }
                }
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
                return;
            }
        }
Exemplo n.º 6
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGC = m_ActiveView.GraphicsContainer;

            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo = null;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready)
                    {
                        bool haveone = false;

                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;

                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    if (facc.Name != "PipeNode")
                                    {
                                        continue;
                                    }
                                    IFeatureLayer fl = dffc.GetFeatureLayer();
                                    if (fc == null || pGeo == null || fl == null)
                                    {
                                        continue;
                                    }
                                    if (!fl.Visible)
                                    {
                                        continue;
                                    }

                                    ISpatialFilter pSpatialFilter = new SpatialFilter();
                                    pSpatialFilter.Geometry   = pGeo;
                                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    pFeatureCursor            = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    pFeature = pFeatureCursor.NextFeature();
                                    if (pFeature == null)
                                    {
                                        continue;
                                    }
                                    haveone = true;

                                    IGeometry pGeometry = pFeature.Shape as IGeometry;
                                    if (pGeometry.GeometryType == esriGeometryType.esriGeometryPoint)
                                    {
                                        IPoint pPoint = pGeometry as IPoint;
                                        if (this._bFinished)
                                        {
                                            this._bFinished = false;
                                            this._startFCID = fc.FeatureClassID.ToString();
                                            this._startOid  = pFeature.OID;
                                            AddCallout(pPoint, "起点");
                                            app.Current2DMapControl.ActiveView.Refresh();
                                        }
                                        else
                                        {
                                            if (this._startFCID == fc.FeatureClassID.ToString() && this._startOid == pFeature.OID)
                                            {
                                                XtraMessageBox.Show("您选中的是同一个管点设施。", "提示");
                                                return;
                                            }
                                            this._bFinished = true;
                                            AddCallout(pPoint, "终点");
                                            app.Current2DMapControl.ActiveView.Refresh();
                                            if (this._startFCID != fc.FeatureClassID.ToString())
                                            {
                                                XtraMessageBox.Show("您选中的不是同一类管点设施。", "提示");
                                                return;
                                            }
                                            else
                                            {
                                                WaitForm.Start("正在分析...", "请稍后");
                                                TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc.FeatureClassID.ToString());
                                                if (tc == null)
                                                {
                                                    return;
                                                }
                                                TopoNetwork net = tc.GetNetwork();
                                                if (net == null)
                                                {
                                                    WaitForm.Stop();
                                                    XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                                                    return;
                                                }
                                                else
                                                {
                                                    string        startId = this._startFCID + "_" + this._startOid.ToString();
                                                    string        endId   = fc.FeatureClassID.ToString() + "_" + pFeature.OID.ToString();
                                                    List <string> path;
                                                    double        shortestLength = net.SPFA(startId, endId, out path);
                                                    if ((shortestLength > 0.0 && shortestLength != double.MaxValue) || (path != null && path.Count > 0))
                                                    {
                                                        List <IPoint>    listPt   = new List <IPoint>();
                                                        IPointCollection pointCol = new PolylineClass();
                                                        foreach (string nodeId in path)
                                                        {
                                                            int              index    = nodeId.LastIndexOf("_");
                                                            string           fcID     = nodeId.Substring(0, index);
                                                            string           oid      = nodeId.Substring(index + 1, nodeId.Length - index - 1);
                                                            DF2DFeatureClass dffcTemp = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID);
                                                            if (dffcTemp == null || dffcTemp.GetFeatureClass() == null)
                                                            {
                                                                continue;
                                                            }
                                                            if (dffcTemp.GetFacilityClassName() != "PipeNode")
                                                            {
                                                                continue;
                                                            }
                                                            IQueryFilter filter = new QueryFilter();
                                                            filter.WhereClause = "OBJECTID =" + oid;
                                                            filter.SubFields   = "OBJECTID ,SHAPE";
                                                            IFeature       feature = null;
                                                            IFeatureCursor cursor  = null;
                                                            try
                                                            {
                                                                cursor = dffcTemp.GetFeatureClass().Search(filter, false);
                                                                while ((feature = cursor.NextFeature()) != null)
                                                                {
                                                                    if (feature.Shape != null && feature.Shape is IGeometry)
                                                                    {
                                                                        IGeometry geo = feature.Shape as IGeometry;
                                                                        switch (geo.GeometryType)
                                                                        {
                                                                        case esriGeometryType.esriGeometryPoint:
                                                                            IPoint pt = geo as IPoint;
                                                                            //pt.Z = pt.Z + 1;
                                                                            listPt.Add(pt);
                                                                            pointCol.AddPoint(pt);
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            catch (System.Exception ex)
                                                            {
                                                            }
                                                            finally
                                                            {
                                                                if (cursor != null)
                                                                {
                                                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                                                                    cursor = null;
                                                                }
                                                                if (feature != null)
                                                                {
                                                                    System.Runtime.InteropServices.Marshal.ReleaseComObject(feature);
                                                                    feature = null;
                                                                }
                                                            }
                                                        }
                                                        if (listPt.Count > 0)
                                                        {
                                                            IPolyline         polyline    = pointCol as IPolyline;
                                                            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbol();
                                                            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                                                            pLineSymbol.Width = 5;
                                                            pLineSymbol.Color = GetRGBColor(0, 230, 240);
                                                            IElement elementL = new LineElement();
                                                            elementL.Geometry = polyline;
                                                            ILineElement pLineElement = elementL as ILineElement;
                                                            pLineElement.Symbol = pLineSymbol;
                                                            pGC.AddElement(elementL, 0);

                                                            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol();
                                                            simpleMarkerSymbol.Color   = GetRGBColor(255, 0, 0);
                                                            simpleMarkerSymbol.Outline = false;
                                                            simpleMarkerSymbol.Size    = 5;
                                                            simpleMarkerSymbol.Style   = esriSimpleMarkerStyle.esriSMSCircle;

                                                            foreach (IPoint pt in listPt)
                                                            {
                                                                try
                                                                {
                                                                    IMarkerElement pMarkerElement = new MarkerElementClass();
                                                                    pMarkerElement.Symbol = simpleMarkerSymbol;
                                                                    IElement pElement = pMarkerElement as IElement;
                                                                    pElement.Geometry = pt;
                                                                    pGC.AddElement(pElement, 0);
                                                                }
                                                                catch (System.Exception ex)
                                                                {
                                                                    continue;
                                                                }
                                                            }
                                                        }

                                                        app.Current2DMapControl.ActiveView.Refresh();
                                                    }
                                                    else
                                                    {
                                                        WaitForm.Stop();
                                                        XtraMessageBox.Show("两点不连通!", "提示");
                                                        pGC.DeleteAllElements();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (haveone)
                                {
                                    break;
                                }
                            }
                            if (haveone)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraMessageBox.Show("分析出错!", "提示");
            }
            finally
            {
                WaitForm.Stop();
            }
        }
Exemplo n.º 7
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            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   pGeo   = band.TrackNew(m_Display, null);
                    app.Current2DMapControl.DrawShape(pGeo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");
                    if (pGeo.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    if (ready)
                    {
                        IMap pMap = app.Current2DMapControl.Map;
                        ISelectionEnvironment selEnv = new SelectionEnvironmentClass();
                        pMap.SelectByShape(pGeo, selEnv, false);
                        ISelection      pSelection = pMap.FeatureSelection;
                        FrmCoordConvert dialog     = new FrmCoordConvert(pMap);
                        WaitForm.Stop();
                        dialog.ShowDialog();
                        if (dialog.DialogResult == DialogResult.Cancel)
                        {
                            RestoreEnv();
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 8
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo = null;

            _featureList = new List <IFeature>();
            _vertiPoints = new List <VerticalPoint>();
            string mapNum      = "";
            string mapName     = Config.GetConfigValue("SystemName") + "纵断面图";
            double totalLength = 0;

            try
            {
                if (button == 1)
                {
                    WaitForm.Start("正在查询...", "请稍后");
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;

                    if (ready)
                    {
                        bool haveone = false;
                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (haveone)
                                    {
                                        break;
                                    }
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    string[] arrFc2DId = mc.Fc2D.Split(';');
                                    if (arrFc2DId == null)
                                    {
                                        continue;
                                    }
                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;
                                    string         fcName         = mc.Name;
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        if (haveone)
                                        {
                                            break;
                                        }
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        if (fc == null || pGeo == null)
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry    = pGeo;
                                        pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pSpatialFilter.WhereClause = sc.Parent.ClassifyField + " =  '" + sc.Name + "'";
                                        pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            if (pFeature.Shape is IPolyline)
                                            {
                                                string diameter;
                                                string road;
                                                string startZ;
                                                string endZ;
                                                string startH;
                                                string endH;
                                                int    indexdia  = pFeature.Fields.FindField("STANDARD");
                                                int    indexroad = pFeature.Fields.FindField("PROAD");
                                                int    indexSZ   = pFeature.Fields.FindField("STARTTOPGC");
                                                int    indexEZ   = pFeature.Fields.FindField("ENDTOPGC");
                                                int    indexSH   = pFeature.Fields.FindField("START_SURF_H");
                                                int    indexEH   = pFeature.Fields.FindField("END_SURF_H");

                                                diameter = pFeature.get_Value(indexdia).ToString();
                                                road     = pFeature.get_Value(indexroad).ToString();
                                                startZ   = pFeature.get_Value(indexSZ).ToString();
                                                endZ     = pFeature.get_Value(indexEZ).ToString();
                                                startH   = pFeature.get_Value(indexSH).ToString();
                                                endH     = pFeature.get_Value(indexEH).ToString();

                                                IPolyline pline  = pFeature.Shape as IPolyline;
                                                IPoint    fPoint = pline.FromPoint;
                                                IPoint    tPoint = pline.ToPoint;
                                                totalLength += pline.Length;
                                                mapNum       = getMapNumforPnt(fPoint);
                                                VerticalPoint vertiPoint1 = new VerticalPoint(fcName, pFeature, fPoint, diameter, road, startZ, startH, true);
                                                _vertiPoints.Add(vertiPoint1);
                                                VerticalPoint vertiPoint2 = new VerticalPoint(fcName, pFeature, tPoint, diameter, road, endZ, endH, false);
                                                _vertiPoints.Add(vertiPoint2);
                                                haveone = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                DrawPipeVerticalSection(_vertiPoints, mapNum, mapName, totalLength);
            }
            catch
            {
            }
        }
        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)
            {
            }
        }
Exemplo n.º 10
0
 public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
 {
     try
     {
         IRubberBand band = new RubberRectangularPolygonClass();
         IGeometry   pGeo = band.TrackNew(m_Display, null);
         if (pGeo.IsEmpty)
         {
             IPoint searchPoint = new PointClass();
             searchPoint.PutCoords(mapX, mapY);
             pGeo = DF2DPipe.Class.PublicFunction.DoBuffer(searchPoint, DF2DPipe.Class.PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
             //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
         }
         WaitForm.Start("正在查询,请稍后...");
         foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
         {
             foreach (MajorClass mc in lg.MajorClasses)
             {
                 foreach (SubClass sc in mc.SubClasses)
                 {
                     if (!sc.Visible2D)
                     {
                         continue;
                     }
                     string[] arrFc2DId = mc.Fc2D.Split(';');
                     if (arrFc2DId == null)
                     {
                         continue;
                     }
                     IFeatureCursor pFeatureCursor = null;
                     IFeature       pFeature       = null;
                     foreach (string fc2DId in arrFc2DId)
                     {
                         DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                         if (dffc == null)
                         {
                             continue;
                         }
                         IFeatureClass fc   = dffc.GetFeatureClass();
                         FacilityClass facc = dffc.GetFacilityClass();
                         if (facc.Name != "PipeNode")
                         {
                             continue;
                         }
                         if (fc == null || pGeo == null)
                         {
                             continue;
                         }
                         ISpatialFilter pSpatialFilter = new SpatialFilter();
                         pSpatialFilter.Geometry   = pGeo;
                         pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                         pFeatureCursor            = fc.Search(pSpatialFilter, false);
                         if (pFeatureCursor == null)
                         {
                             continue;
                         }
                         while ((pFeature = pFeatureCursor.NextFeature()) != null)
                         {
                             IPoint pPoint  = (IPoint)pFeature.Shape;
                             string strText = "X:" + pPoint.Y.ToString("F2") + "\n" + "Y:" + pPoint.X.ToString("F2");
                             AddCallout(pPoint, strText);
                         }
                     }
                 }
             }
         }
         app.Current2DMapControl.ActiveView.Refresh();
         WaitForm.Stop();
     }
     catch (System.Exception ex)
     {
         WaitForm.Stop();
     }
 }
Exemplo n.º 11
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication    app = DF2DApplication.Application;
            IGraphicsContainer gc  = app.Current2DMapControl.Map as IGraphicsContainer;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_pActiveView = app.Current2DMapControl.ActiveView;
            m_Display     = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IFeatureCursor pFeaCur;
            IFeature       pFeature;
            string         classify   = "";
            string         startNo    = "";
            string         endNo      = "";
            string         material   = "";
            string         coverstyle = "";
            string         diameter   = "";
            string         road       = "";
            bool           have       = false;

            try
            {
                if (button == 1)
                {
                    IRubberBand band = new RubberRectangularPolygonClass();
                    m_pGeoTrack = band.TrackNew(m_Display, null);

                    if (m_pGeoTrack.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        m_pGeoTrack = DF2DPipe.Class.PublicFunction.DoBuffer(searchPoint, DF2DPipe.Class.PublicFunction.ConvertPixelsToMapUnits(m_pActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    WaitForm.Start("正在查询...", "请稍后");
                    foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                    {
                        if (have)
                        {
                            break;
                        }
                        string[] arrFc2DId = mc.Fc2D.Split(';');//将二级大类所对应的要素类ID转换为数组
                        if (arrFc2DId == null)
                        {
                            continue;
                        }
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (have)
                            {
                                break;
                            }
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)                                                      //遍历二级子类所对应的要素类ID
                            {
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC
                                if (dffc == null)
                                {
                                    continue;
                                }
                                FacilityClass fcc = dffc.GetFacilityClass();
                                if (fcc.Name != "PipeLine")
                                {
                                    continue;
                                }
                                IFeatureLayer  fl             = dffc.GetFeatureLayer();
                                IFeatureClass  fc             = dffc.GetFeatureClass();
                                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                                pSpatialFilter.Geometry    = m_pGeoTrack;
                                pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                pSpatialFilter.WhereClause = "SMSCODE =  '" + sc.Name + "'";
                                pFeaCur  = fc.Search(pSpatialFilter, false);
                                pFeature = pFeaCur.NextFeature();
                                if (pFeature == null)
                                {
                                    continue;
                                }
                                foreach (string field in sysFields)
                                {
                                    DFDataConfig.Class.FieldInfo fi = fcc.GetFieldInfoBySystemName(field);
                                    if (fi == null)
                                    {
                                        continue;
                                    }
                                    int    index = fc.Fields.FindField(fi.Name);
                                    object obj   = pFeature.get_Value(index);
                                    switch (field)
                                    {
                                    case "Classify":
                                        classify = obj.ToString();
                                        break;

                                    case "StartNo":
                                        startNo = obj.ToString();
                                        break;

                                    case "EndNo":
                                        endNo = obj.ToString();
                                        break;

                                    case "Material":
                                        material = obj.ToString();
                                        break;

                                    case "CoverStyle":
                                        coverstyle = obj.ToString();
                                        break;

                                    case "Diameter":
                                        diameter = obj.ToString();
                                        break;

                                    case "Road":
                                        road = obj.ToString();
                                        break;
                                    }
                                }
                                m_IntersectPipe = new IntersectPipe(pFeature, fl, 0, classify, startNo, endNo, material, coverstyle, diameter, road);
                                have            = true;
                            }
                        }
                    }
                }
                if (m_IntersectPipe == null)
                {
                    XtraMessageBox.Show("请重新获取单个管线");
                    WaitForm.Stop();
                }
                WaitForm.SetCaption("正在输出属性,请稍后...");
                DrawNodeLabels(m_IntersectPipe.Feature, m_IntersectPipe);
                WaitForm.Stop();
            }
            catch (System.Exception ex)
            {
            }
        }
Exemplo n.º 12
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            this._dict.Clear();
            bool ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IGeometry      pGeo      = null;

            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;

                    //pColor = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                    IRubberBand pRubberBand;
                    pRubberBand = new RubberLineClass();
                    IGeometry pLine;
                    pLine = pRubberBand.TrackNew(m_Display, null);
                    //IPolyline pLine = app.Current2DMapControl.TrackLine() as IPolyline;

                    object symbol = pLineSym as object;
                    app.Current2DMapControl.DrawShape(pLine, ref symbol);

                    WaitForm.Start("正在查询...", "请稍后");
                    //if (GlobalValue.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection
                    //{
                    //    this.m_ActiveView.FocusMap.ClearSelection();
                    //}
                    pGeo = PublicFunction.DoBuffer(pLine,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    //m_ActiveView.FocusMap.SelectByShape(pGeo, GlobalValue.System_Selection_Environment(m_ActiveView), false);

                    //if (m_ActiveView.FocusMap.SelectionCount > 0)
                    //{

                    //    ready = true;
                    //    m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    //}
                    //else
                    //{
                    //    m_ActiveView.Refresh();
                    //}


                    if (ready)
                    {
                        //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        //{
                        foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses)
                        {
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    if (facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    if (fc == null || pGeo == null)
                                    {
                                        continue;
                                    }
                                    ISpatialFilter pSpatialFilter = new SpatialFilter();
                                    pSpatialFilter.Geometry   = pGeo;
                                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";

                                    pSpatialFilter.WhereClause = whereClause;
                                    pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    DataTable dt = new DataTable();
                                    dt.TableName = facc.Name;
                                    DataColumn oidcol = new DataColumn();
                                    oidcol.ColumnName = "oid";
                                    oidcol.Caption    = "ID";
                                    dt.Columns.Add(oidcol);
                                    foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection)
                                    {
                                        if (!fitemp.CanQuery)
                                        {
                                            continue;
                                        }
                                        DataColumn col = new DataColumn();
                                        col.ColumnName = fitemp.Name;
                                        col.Caption    = fitemp.Alias;
                                        dt.Columns.Add(col);
                                    }
                                    while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                    {
                                        DataRow dtRow = dt.NewRow();
                                        dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"));
                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            int index1 = pFeature.Fields.FindField(col.ColumnName);
                                            if (index1 < 0)
                                            {
                                                continue;
                                            }
                                            object obj1 = pFeature.get_Value(index1);
                                            string str  = "";
                                            if (obj1 != null)
                                            {
                                                IField field = pFeature.Fields.get_Field(index1);
                                                switch (field.Type)
                                                {
                                                case esriFieldType.esriFieldTypeBlob:
                                                case esriFieldType.esriFieldTypeGeometry:
                                                case esriFieldType.esriFieldTypeRaster:
                                                    continue;

                                                case esriFieldType.esriFieldTypeDouble:
                                                    double d;
                                                    if (double.TryParse(obj1.ToString(), out d))
                                                    {
                                                        str = d.ToString("0.00");
                                                    }
                                                    break;

                                                default:
                                                    str = obj1.ToString();
                                                    break;
                                                }
                                            }
                                            dtRow[col.ColumnName] = str;
                                        }
                                        dt.Rows.Add(dtRow);
                                    }
                                    if (dt.Rows.Count > 0)
                                    {
                                        this._dict.Add(sc.Name, dt);
                                    }
                                }
                            }
                        }
                    }
                }
                WaitForm.Stop();
                try
                {
                    this._uPanel               = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height);
                    this._dockPanel            = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right);
                    this._dockPanel.Visibility = DockVisibility.Visible;
                    this._dockPanel.FloatSize  = new System.Drawing.Size(this._width, this._height);
                    this._dockPanel.Width      = this._width;
                    this._dockPanel.Height     = this._height;
                    if (this._ucPropInfo2D == null)
                    {
                        this._ucPropInfo2D = new UCPropertyInfo2D();
                    }
                    this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill;
                    this._uPanel.RegisterEvent(new PanelClose(this.Close));
                    this._dockPanel.Controls.Add(this._ucPropInfo2D);
                    this._ucPropInfo2D.Init();
                    this._ucPropInfo2D.SetPropertyInfo(this._dict);
                }
                catch
                {
                }

                //}
            }
            catch
            {
            }
        }
Exemplo n.º 13
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            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);
                    WaitForm.Start("正在查询...", "请稍后");

                    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);
                    }
                    _geo         = geo;
                    spatialQuery = true;
                    if (spatialQuery)
                    {
                        FrmCompoundConditionQuery dialog = new FrmCompoundConditionQuery();
                        dialog.SetData(LogicDataStructureManage2D.Instance.RootLogicGroups, LogicDataStructureManage2D.Instance.RootMajorClasses, _geo);
                        WaitForm.Stop();
                        IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
                        mapView.UnBind(this);
                        if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            return;
                        }
                        this._uPanel               = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height);
                        this._dockPanel            = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right);
                        this._dockPanel.Visibility = DockVisibility.Visible;
                        this._dockPanel.FloatSize  = new System.Drawing.Size(this._width, this._height);
                        this._dockPanel.Width      = this._width;
                        this._dockPanel.Height     = this._height;
                        this._uc      = new UCPropertyInfo2D();
                        this._uc.Dock = System.Windows.Forms.DockStyle.Fill;
                        this._uPanel.RegisterEvent(new PanelClose(this.Close));
                        this._dockPanel.Controls.Add(this._uc);
                        this._uc.SetPropertyInfo(dialog.Dict);
                    }
                }
            }


            catch
            {
                this.RestoreEnv();
            }
        }
Exemplo n.º 14
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IActiveView    m_ActiveView   = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display      = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IGeometry      pGeo           = null;
            IFeatureCursor pFeatureCursor = null;
            IFeature       pFeature       = null;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }

                    WaitForm.Start("正在进行纵断面分析...", "请稍后");
                    string          road1   = "";
                    string          road2   = "";
                    bool            bAlert  = false;
                    double          hmax    = double.MinValue;
                    double          hmin    = double.MaxValue;
                    List <PPLine2D> pplines = new List <PPLine2D>();

                    bool haveone             = false;
                    List <MajorClass> listMC = LogicDataStructureManage2D.Instance.GetAllMajorClass();
                    foreach (MajorClass mc in listMC)
                    {
                        if (haveone)
                        {
                            break;
                        }
                        foreach (SubClass sc in mc.SubClasses)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            if (!sc.Visible2D)
                            {
                                continue;
                            }
                            string[] arrFc2DId = mc.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }
                            foreach (string fc2DId in arrFc2DId)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                if (dffc == null)
                                {
                                    continue;
                                }
                                IFeatureClass fc   = dffc.GetFeatureClass();
                                FacilityClass facc = dffc.GetFacilityClass();
                                if (facc.Name != "PipeLine")
                                {
                                    continue;
                                }
                                if (fc == null || pGeo == null)
                                {
                                    continue;
                                }
                                ISpatialFilter pSpatialFilter = new SpatialFilter();
                                pSpatialFilter.Geometry    = pGeo;
                                pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                pSpatialFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + sc.Parent.ClassifyField + " =  '" + sc.Name + "'";
                                pFeatureCursor             = fc.Search(pSpatialFilter, true);
                                if (pFeatureCursor == null)
                                {
                                    continue;
                                }
                                pFeature = pFeatureCursor.NextFeature();
                                if (pFeature == null)
                                {
                                    continue;
                                }

                                //查找管径长宽字段,获得该要素类下字段索引值,若为圆管,则长宽相等
                                DFDataConfig.Class.FieldInfo fiDia  = facc.GetFieldInfoBySystemName("Diameter");
                                DFDataConfig.Class.FieldInfo fiDia1 = facc.GetFieldInfoBySystemName("Diameter1");
                                DFDataConfig.Class.FieldInfo fiDia2 = facc.GetFieldInfoBySystemName("Diameter2");
                                int indexDia       = fc.Fields.FindField(fiDia.Name);
                                int indexDiaWith   = fc.Fields.FindField(fiDia1.Name);
                                int indexDiaHeight = fc.Fields.FindField(fiDia2.Name);
                                if (indexDiaWith == -1 || indexDiaHeight == -1 || indexDia == -1)
                                {
                                    continue;
                                }
                                //查找道路字段索引
                                DFDataConfig.Class.FieldInfo fiRoad = facc.GetFieldInfoBySystemName("Road");
                                int indexRoad = fc.Fields.FindField(fiRoad.Name);
                                //查找管线高类别索引
                                DFDataConfig.Class.FieldInfo fiHLB = facc.GetFieldInfoBySystemName("HLB");
                                int indexHLB = fc.Fields.FindField(fiHLB.Name);
                                //二级分类名索引
                                int indexClassify = fc.Fields.FindField(mc.ClassifyField);

                                if (indexRoad != -1)
                                {
                                    if (road2 == "")
                                    {
                                        road1 = pFeature.get_Value(indexRoad).ToString();
                                        road2 = pFeature.get_Value(indexRoad).ToString();
                                    }
                                    else
                                    {
                                        road1 = pFeature.get_Value(indexRoad).ToString();
                                        if (road1 != road2)
                                        {
                                            if (!bAlert)
                                            {
                                                XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线纵断面图。", "提示");
                                                bAlert = true;
                                            }
                                            continue;
                                        }
                                    }
                                }

                                //查找管线的起点终点地面高
                                double startSurfHeight = double.MaxValue;
                                double endSurfHeight   = double.MaxValue;
                                DFDataConfig.Class.FieldInfo fiStartSurfHeight = facc.GetFieldInfoBySystemName("StartSurfH");
                                if (fiStartSurfHeight == null)
                                {
                                    continue;
                                }
                                int indexStartSurfHeight = pFeature.Fields.FindField(fiStartSurfHeight.Name);
                                if (indexStartSurfHeight == -1)
                                {
                                    continue;
                                }

                                DFDataConfig.Class.FieldInfo fiEndSurfHeight = facc.GetFieldInfoBySystemName("EndSurfH");
                                if (fiEndSurfHeight == null)
                                {
                                    continue;
                                }
                                int indexEndSurfHeight = pFeature.Fields.FindField(fiEndSurfHeight.Name);
                                if (indexEndSurfHeight == -1)
                                {
                                    continue;
                                }
                                //若管线属性地面高字段为null,则从DEM取值
                                if (pFeature.get_Value(indexStartSurfHeight).ToString() == "" || pFeature.get_Value(indexEndSurfHeight).ToString() == "")
                                {
                                    startSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).FromPoint);
                                    endSurfHeight   = ReadDemRaster.GetH((pFeature.Shape as IPolyline).ToPoint);
                                }
                                else
                                {
                                    startSurfHeight = Convert.ToDouble(pFeature.get_Value(indexStartSurfHeight).ToString());
                                    endSurfHeight   = Convert.ToDouble(pFeature.get_Value(indexEndSurfHeight).ToString());
                                }

                                //查找管线起点高程和终点高程
                                double startDepthHeight = double.MaxValue;
                                double endDepthHeight   = double.MaxValue;
                                DFDataConfig.Class.FieldInfo fiStartDepthHeight = facc.GetFieldInfoBySystemName("StartHeight2D");
                                if (fiStartDepthHeight == null)
                                {
                                    continue;
                                }
                                int indexStartDepthHeight = pFeature.Fields.FindField(fiStartDepthHeight.Name);
                                if (indexStartDepthHeight == -1)
                                {
                                    continue;
                                }

                                DFDataConfig.Class.FieldInfo fiEndDepthHeight = facc.GetFieldInfoBySystemName("EndHeight");
                                if (fiEndDepthHeight == null)
                                {
                                    continue;
                                }
                                int indexEndDepthHeight = pFeature.Fields.FindField(fiEndDepthHeight.Name);
                                if (indexEndDepthHeight == -1)
                                {
                                    continue;
                                }

                                startDepthHeight = Convert.ToDouble(pFeature.get_Value(indexStartDepthHeight).ToString());
                                endDepthHeight   = Convert.ToDouble(pFeature.get_Value(indexEndDepthHeight).ToString());


                                //查找管线的管径,判断其是方管还是圆管
                                string diameter  = pFeature.get_Value(indexDia).ToString();
                                string diameter1 = pFeature.get_Value(indexDiaWith).ToString();
                                string diameter2 = pFeature.get_Value(indexDiaHeight).ToString();

                                IPolyline pline      = pFeature.Shape as IPolyline;
                                IPoint    startpoint = pline.FromPoint;
                                IPoint    endpoint   = pline.ToPoint;
                                IPoint[]  points     = new IPoint[] { startpoint, endpoint };
                                for (int i = 0; i < points.Length; i++)
                                {
                                    PPLine2D ppline = new PPLine2D();
                                    if (indexClassify == -1)
                                    {
                                        ppline.facType = mc.Name;
                                    }
                                    else
                                    {
                                        ppline.facType = pFeature.get_Value(indexClassify).ToString();
                                    }
                                    if (diameter.Trim() == "")
                                    {
                                        continue;
                                    }
                                    ppline.dia = diameter;
                                    int indexSplit = diameter.IndexOf('*');
                                    if (indexSplit != -1)
                                    {
                                        ppline.isrect = true;
                                        int  iDia1;
                                        bool bDia1 = int.TryParse(diameter.Substring(0, indexSplit), out iDia1);
                                        if (!bDia1)
                                        {
                                            continue;
                                        }
                                        int  iDia2;
                                        bool bDia2 = int.TryParse(diameter.Substring(indexSplit + 1, diameter.Length - indexDia - 1), out iDia2);
                                        if (!bDia2)
                                        {
                                            continue;
                                        }
                                        ppline.gj.Add(iDia1);
                                        ppline.gj.Add(iDia2);
                                    }
                                    else
                                    {
                                        ppline.isrect = false;
                                        int  iDia;
                                        bool bDia = int.TryParse(diameter, out iDia);
                                        if (!bDia)
                                        {
                                            continue;
                                        }
                                        ppline.gj.Add(iDia);
                                        ppline.gj.Add(iDia);
                                    }
                                    //判断管线高方式
                                    int hlb = 0;
                                    if (indexHLB != -1)
                                    {
                                        string strhlb = pFeature.get_Value(indexHLB).ToString();
                                        if (strhlb.Contains("内"))
                                        {
                                            hlb = 1;
                                        }
                                        else if (strhlb.Contains("外"))
                                        {
                                            hlb = -1;
                                        }
                                        else
                                        {
                                            hlb = 0;
                                        }
                                        ppline.hlb = hlb;
                                    }
                                    ppline.interPoint = new PPPoint(points[i].X, points[i].Y);
                                    if (i == 0)
                                    {
                                        ppline.clh = startDepthHeight;
                                        UpdateH(ppline.clh, ref hmax, ref hmin);
                                        ppline.cgh = startSurfHeight;
                                        UpdateH(ppline.cgh, ref hmax, ref hmin);
                                    }
                                    else
                                    {
                                        ppline.clh = endDepthHeight;
                                        UpdateH(ppline.clh, ref hmax, ref hmin);
                                        ppline.cgh = endSurfHeight;
                                        UpdateH(ppline.cgh, ref hmax, ref hmin);
                                    }
                                    // 辅助画图
                                    double deltaX = points[1].X - points[0].X;
                                    double deltaY = points[1].Y - points[0].Y;
                                    ppline.startPt = new PPPoint(points[0].X - deltaX, points[0].Y - deltaY);
                                    pplines.Add(ppline);
                                }
                            }
                        }
                    }
                    WaitForm.Stop();
                    pplines.Sort(new PPLineCompare2D());
                    double spacesum = 0.0;
                    for (int i = 1; i < pplines.Count; i++)
                    {
                        PPLine2D line1 = pplines[i - 1];
                        PPLine2D line2 = pplines[i];
                        line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X)
                                                + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y));
                        spacesum += line2.space;
                    }
                    ;
                    var                str1    = (pplines[0].interPoint.X / 1000).ToString("0.00");
                    var                str2    = (pplines[0].interPoint.Y / 1000).ToString("0.00");
                    string             mapNum  = str2 + "-" + str1;
                    string             mapName = SystemInfo.Instance.SystemFullName + "纵断面图";
                    FrmSectionAnalysis dialog  = new FrmSectionAnalysis("纵断面分析结果", 1);
                    dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2);
                    dialog.Show();
                }
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
            }
            finally
            {
                if (pFeatureCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                    pFeatureCursor = null;
                }
                if (pFeature != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature);
                    pFeature = null;
                }
            }
        }
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            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);
                    WaitForm.Start("正在查询...", "请稍后");

                    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);
                    }
                    _geo         = geo;
                    spatialStats = true;
                    if (spatialStats)
                    {
                        FrmCompoundConditionStats2D dialog = new FrmCompoundConditionStats2D();
                        dialog.SetData(LogicDataStructureManage2D.Instance.RootLogicGroups, LogicDataStructureManage2D.Instance.RootMajorClasses, _geo);
                        WaitForm.Stop();
                        dialog.ShowDialog();
                        if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            this.RestoreEnv();
                        }
                    }
                }
            }
            catch
            {
            }
        }