Exemplo n.º 1
0
 /// <summary>
 /// 根据提供的shape的索引,添加到存储以选择shape的集合中
 /// </summary>
 /// <param name="ShapeIndex">要添加的shape的索引.</param>
 /// <param name="SelectColor">不用的参数.</param>
 public void AddByIndex(int ShapeIndex, System.Drawing.Color SelectColor)
 {
     MainProgram.SelectedShape newShp = new SelectedShape();
     if (Program.frmMain.MapMain.ShapeDrawingMethod != tkShapeDrawingMethod.dmNewSymbology)
     {
         if (Program.frmMain.MapMain.get_ShapeVisible(Program.frmMain.Legend.SelectedLayer, ShapeIndex) != false)
         {
             newShp.Add(ShapeIndex, SelectColor);
             AddSelectedShape(newShp);
         }
     }
     else
     {
         newShp.Add(ShapeIndex, SelectColor);
         AddSelectedShape(newShp);
     }
     newShp = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据给定的shapefile、范围、容差来将选择的shape存入shapeInfo集合中
        /// </summary>
        internal MapWinGIS.Interfaces.SelectInfo PerformSelection(MapWinGIS.Shapefile sf, MapWinGIS.Extents bounds, double tolerance)
        {
            SelectInfo m_SelectedShapes = new SelectInfo(this.LegendControl.SelectedLayer);

            if (m_SelectedShapes == null)
            {
                m_SelectedShapes = new MainProgram.SelectInfo(this.LegendControl.SelectedLayer);
            }
            m_SelectedShapes.ClearSelectedShapesTemp();

            object arr = null;

            System.Array results = null;
            if (sf.SelectShapes(bounds, tolerance, m_Selectmethod, ref arr))
            {
                results = (System.Array)arr;
            }

            if (m_SelectionOperation == Interfaces.SelectionOperation.SelectNew)
            {
                sf.SelectNone();
            }

            int i;

            //设置选择的shape
            if (results != null && results.Length > 0)
            {
                int len = results.Length;

                if (m_SelectionOperation == Interfaces.SelectionOperation.SelectNew)
                {
                    for (i = 0; i < len; i++)
                    {
                        sf.ShapeSelected[((int)results.GetValue(i))] = true;
                    }
                }
                else if (m_SelectionOperation == Interfaces.SelectionOperation.SelectAdd)
                {
                    for (i = 0; i < len; i++)
                    {
                        sf.ShapeSelected[((int)results.GetValue(i))] = true;
                    }
                }
                else if (m_SelectionOperation == Interfaces.SelectionOperation.SelectExclude)
                {
                    for (i = 0; i < len; i++)
                    {
                        sf.ShapeSelected[((int)results.GetValue(i))] = false;
                    }
                }
                else if (m_SelectionOperation == Interfaces.SelectionOperation.SelectInvert)
                {
                    for (i = 0; i < len; i++)
                    {
                        sf.ShapeSelected[((int)results.GetValue(i))] = !sf.ShapeSelected[((int)results.GetValue(i))];
                    }
                }
            }
            else
            {
                if (m_SelectionOperation == Interfaces.SelectionOperation.SelectNew)
                {
                    sf.SelectNone();
                }
            }

            // 将选择的shape添加到shapeInfo集合中
            for (i = 0; i < sf.NumShapes; i++)
            {
                if (sf.ShapeSelected[i])
                {
                    SelectedShape shape = new SelectedShape();
                    shape.Add(i);
                    m_SelectedShapes.AddSelectedShape(shape);
                }
            }

            m_selection = null;

            this.Redraw();
            return(m_SelectedShapes);
        }