Exemplo n.º 1
0
        private void MarkAllVertices(double curX, double curY)
        {
            try
            {
                int handle;

                if (m_globals.CurrentLayer == null)
                {
                    return;
                }
                handle = m_MapWin.Layers.CurrentLayer;
                MapWinGIS.Shapefile shpFile = m_globals.CurrentLayer;
                int numShp = shpFile.NumShapes;
                int shpIndex;

                if (m_prevShape != -1)
                {
                    if (!m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].VerticesVisible)
                    {
                        m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].HideVertices();
                    }
                }

                if (m_MapWin.Layers[m_MapWin.Layers.CurrentLayer].LayerType == MapWindow.Interfaces.eLayerType.PolygonShapefile)
                {
                    shpFile.BeginPointInShapefile();
                    shpIndex = shpFile.PointInShapefile(curX, curY);
                    shpFile.EndPointInShapefile();
                }
                else
                {
                    MapWinGIS.Extents bounds = new MapWinGIS.ExtentsClass();
                    bounds.SetBounds(curX, curY, 0, curX, curY, 0);
                    object resArray = null;
                    if (shpFile.SelectShapes(bounds, m_globals.CurrentTolerance * 2, MapWinGIS.SelectMode.INTERSECTION, ref resArray))
                    {
                        shpIndex = (int)((System.Array)resArray).GetValue(0);
                    }
                    else
                    {
                        shpIndex = -1;
                    }
                }

                if (shpIndex >= 0)
                {
                    m_MapWin.Layers[handle].Shapes[shpIndex].ShowVertices(System.Drawing.Color.Red, m_globals.VertexSize);
                    m_prevShape = shpIndex;
                }
                else
                {
                    m_prevShape = -1;
                }
            }
            catch (System.Exception ex)
            {
                m_MapWin.ShowErrorDialog(ex);
            }
        }