Esempio n. 1
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 RubberRectangularPolygonClass();
                    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;
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Esempio n. 2
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            if (button == 1)
            {
                int         dis;
                IGeometry   pGeoSel;
                IRubberBand band            = new RubberRectangularPolygonClass();
                IGeometry   geo             = band.TrackNew(m_Display, null);
                SelectionEnvironmentClass s = Class.SelectionEnv.System_Selection_Environment(m_ActiveView);
                dis = Class.SelectionEnv.System_Selection_Environment(m_ActiveView).SearchTolerance;
                IFeatureSelection pFeaSel = m_pCurEditLayer as IFeatureSelection;

                if (shift == 1)
                {
                    pFeaSel.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;
                    //s.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;
                }
                else
                {
                    pFeaSel.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
                    this.m_ActiveView.FocusMap.ClearSelection();
                }

                if (geo.IsEmpty)
                {
                    IPoint searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeoSel = Class.Common.DoBuffer(searchPoint, dis);
                    //m_ActiveView.FocusMap.SelectByShape(Class.Common.DoBuffer(searchPoint, dis), s, false);
                }
                else
                {
                    pGeoSel = Class.Common.DoBuffer(geo, dis);
                    //m_ActiveView.FocusMap.SelectByShape(Class.Common.DoBuffer(geo, dis), s, false);
                }
                ISpatialFilter pSpaFilter = new SpatialFilter();
                pSpaFilter.Geometry   = pGeoSel;
                pSpaFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pFeaSel.SelectFeatures(pSpaFilter, pFeaSel.CombinationMethod, false);
                m_App.Workbench.UpdateMenu();

                if (m_ActiveView.FocusMap.SelectionCount > 0)
                {
                    m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                }
                else
                {
                    m_ActiveView.Refresh();
                }
            }
        }
        /// <summary>
        /// The draw rectangle.
        /// </summary>
        /// <param name="elm">
        /// The elm.
        /// </param>
        /// <returns>
        /// The <see cref="IPolygon"/>.
        /// </returns>
        public static IPolygon DrawRectangle(out IElement elm)
        {
            var activeView    = ArcMap.Document.ActiveView;
            var screenDisplay = activeView.ScreenDisplay;

            IRubberBand rubberBand = new RubberRectangularPolygonClass();
            var         geometry   = rubberBand.TrackNew(screenDisplay, null);

            var polygon = (IPolygon)geometry;

            IRgbColor rgbColor = VectorIndexColor();

            //Add the user's drawn graphics as persistent on the map.
            elm = AddGraphicToMap(activeView.FocusMap, polygon, rgbColor, rgbColor);

            //Best practice: Redraw only the portion of the active view that contains graphics.
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, elm.Geometry.Envelope);
            return(polygon);
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_ActiveView = m_hookHelper.ActiveView;
            m_Map        = m_hookHelper.FocusMap;
            IScreenDisplay    pScreenDisplay = m_ActiveView.ScreenDisplay;
            IRubberBand       pRubberPolygon = new RubberRectangularPolygonClass();
            ISimpleFillSymbol pFillSymbol    = new SimpleFillSymbolClass();

            pFillSymbol.Color = getRGB(255, 255, 0);
            IPolygon pPolygon = pRubberPolygon.TrackNew(pScreenDisplay, (ISymbol)pFillSymbol) as IPolygon;

            pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
            pFillSymbol.Color = getRGB(0, 255, 0);
            IFillShapeElement pPolygonEle = new PolygonElementClass();

            pPolygonEle.Symbol = pFillSymbol;
            IElement pEle = pPolygonEle as IElement;

            pEle.Geometry = pPolygon;
            IGraphicsContainer pGraphicsContainer = m_Map as IGraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 5
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add selectAddByRectangle.OnMouseDown implementation
            IRubberBand    ipRubberRec     = new RubberRectangularPolygonClass();
            IPolygon       polygon         = ipRubberRec.TrackNew(m_hookHelper.ActiveView.ScreenDisplay, null) as IPolygon;
            ISpatialFilter ipSpatialFilter = new SpatialFilterClass();

            ipSpatialFilter.Geometry   = polygon;
            ipSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureSelection ipFeatSelect = m_hookHelper.FocusMap.get_Layer(1) as IFeatureSelection;

            ipFeatSelect.Clear();
            ipFeatSelect.SelectFeatures(ipSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            ipFeatSelect.SelectionSet.Refresh();
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

            ICursor cur = null;

            ipFeatSelect.SelectionSet.Search(null, true, out cur);
            IFeature      feature = cur.NextRow() as IFeature;
            IFeatureLayer fl      = m_hookHelper.FocusMap.get_Layer(0) as IFeatureLayer;

            while (feature != null)
            {
                ITopologicalOperator to   = feature.Shape as ITopologicalOperator;
                IPolygon             poly = to.Buffer(0.01) as IPolygon;


                IFeature polyFeature = fl.FeatureClass.CreateFeature();
                polyFeature.Shape = poly;
                feature           = cur.NextRow() as IFeature;
                polyFeature.Store();
            }

            m_hookHelper.ActiveView.Refresh();
        }
        /// <summary>
        /// The draw rectangle.
        /// </summary>
        /// <param name="elm">
        /// The elm.
        /// </param>
        /// <returns>
        /// The <see cref="IPolygon"/>.
        /// </returns>
        public static IPolygon DrawRectangle(out IElement elm)
        {
            var activeView = ArcMap.Document.ActiveView;
            var screenDisplay = activeView.ScreenDisplay;

            IRubberBand rubberBand = new RubberRectangularPolygonClass();
            var geometry = rubberBand.TrackNew(screenDisplay, null);

            var polygon = (IPolygon)geometry;

            IRgbColor rgbColor = VectorIndexColor();

            //Add the user's drawn graphics as persistent on the map.
            elm = AddGraphicToMap(activeView.FocusMap, polygon, rgbColor, rgbColor);

            //Best practice: Redraw only the portion of the active view that contains graphics.
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, elm.Geometry.Envelope);
            return polygon;
        }
        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)
            {
            }
        }
Esempio n. 8
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();
     }
 }
        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)
            {
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 屏幕上绘画几何形状
        /// </summary>
        /// <param name="screenDisplay">ESRI屏幕显示接口</param>
        /// <param name="geomType">几何形状类型的枚举类</param>
        /// <returns>ESRI几何形状接口</returns>
        public static IGeometry ScreenTrackGeometry(IScreenDisplay screenDisplay, dsGeometryType geomType)
        {
            IGeometry trackGeom = null;

            if (screenDisplay != null)
            {
                IRubberBand rubberBand = null;
                switch (geomType)
                {
                case dsGeometryType.dsGTPoint:
                    rubberBand = new RubberPointClass();
                    break;

                case dsGeometryType.dsGTLine:
                    rubberBand = new RubberLineClass();
                    break;

                case dsGeometryType.dsGTPolyline:
                    rubberBand = new RubberLineClass();
                    break;

                case dsGeometryType.dsGTRectangle:
                    rubberBand = new RubberEnvelopeClass();
                    break;

                case dsGeometryType.dsGTCircle:
                    rubberBand = new RubberCircleClass();
                    break;

                case dsGeometryType.dsGTEllipse:
                    rubberBand = new RubberEnvelopeClass();
                    break;

                case dsGeometryType.dsGTPolygon:
                    rubberBand = new RubberPolygonClass();
                    break;

                case dsGeometryType.dsGTRectangularPolygon:
                    rubberBand = new RubberRectangularPolygonClass();
                    break;

                default:
                    break;
                }
                if (rubberBand != null)
                {
                    trackGeom = rubberBand.TrackNew(screenDisplay, null);
                }
                if (geomType == dsGeometryType.dsGTEllipse)
                {
                    trackGeom = ConvertEnvelopeToEllipticArc(trackGeom);
                }
                else if ((geomType == dsGeometryType.dsGTLine) ||
                         (geomType == dsGeometryType.dsGTPolyline) ||
                         (geomType == dsGeometryType.dsGTPolygon))
                {
                    if (trackGeom is ITopologicalOperator)
                    {
                        (trackGeom as ITopologicalOperator).Simplify();
                    }
                }
            }
            return(trackGeom);
        }
Esempio n. 11
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;

            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   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)
                    {
                        //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
            {
            }
            finally
            {
                WaitForm.Stop();
            }
        }