Example #1
0
 /// <summary>
 /// 将指定索引的图层移动到另一指定索引
 /// </summary>
 /// <param name="fromIndex"></param>
 /// <param name="toIndex"></param>
 public void MoveTo(Int32 fromIndex, Int32 toIndex)
 {
     if (fromIndex == toIndex)
     {
         return;
     }
     else
     {
         moMapLayer sLayer = _Layers[fromIndex];
         _Layers.RemoveAt(fromIndex);
         _Layers.Insert(toIndex, sLayer);
     }
 }
Example #2
0
        private void DrawBufferMap2()
        {
            //(1)获取地图窗口的范围
            moRectangle sExtent = GetExtent();

            if (sExtent.IsEmpty == true)
            {
                return;
            }
            //(2)绘制缓冲位图1
            Graphics g = Graphics.FromImage(mBufferMap2);

            g.Clear(Color.White);
            Rectangle sRect = new Rectangle(0, 0, mBufferMap1.Width, mBufferMap1.Height);

            g.DrawImage(mBufferMap1, sRect, sRect, GraphicsUnit.Pixel);
            //(3)绘制所有图层的选择要素,采用倒序
            double sMapScale   = mMapDrawingReference.MapScale;
            double dpm         = mMapDrawingReference.dpm;
            double mpu         = mMapDrawingReference.mpu;
            Int32  sLayerCount = _Layers.Count;

            for (Int32 i = sLayerCount - 1; i >= 0; i--)
            {
                moMapLayer sLayer = _Layers.GetItem(i);
                if (sLayer.ShapeType == moGeometryTypeConstant.Point)
                {
                    sLayer.DrawSelectedFeatures(g, sExtent, sMapScale, dpm, mpu, mSelectedPointSymbol);
                }
                else if (sLayer.ShapeType == moGeometryTypeConstant.MultiPolyline)
                {
                    sLayer.DrawSelectedFeatures(g, sExtent, sMapScale, dpm, mpu, mSelectedLineSymbol);
                }
                else if (sLayer.ShapeType == moGeometryTypeConstant.MultiPolygon)
                {
                    sLayer.DrawSelectedFeatures(g, sExtent, sMapScale, dpm, mpu, mSelectedFillSymbol);
                }
            }
            //(4)触发事件,以便用户程序继续绘图
            if (AfterTrackingLayerDraw != null)
            {
                //新建绘图工具
                moUserDrawingTool sDrawingTool = CreateDrawingTool(g);
                AfterTrackingLayerDraw(this, sDrawingTool);
            }
            g.Dispose();
        }
Example #3
0
        /// <summary>
        /// 根据指定的选择盒与选择方法执行选择
        /// </summary>
        /// <param name="selectingBox"></param>
        /// <param name="tolerance"></param>
        /// <param name="selectMethod"></param>
        public void SelectByBox(moRectangle selectingBox, double tolerance, Int32 selectMethod)
        {
            Int32 sLayerCount = _Layers.Count;

            for (Int32 i = 0; i < sLayerCount; i++)
            {
                moMapLayer sLayer = _Layers.GetItem(i);
                if (sLayer.Visible == true && sLayer.Selectable == true)
                {
                    moFeatures sFeatures = sLayer.SearchByBox(selectingBox, tolerance);
                    sLayer.ExecuteSelect(sFeatures, selectMethod);
                }
                else
                {
                    sLayer.SelectedFeatures.Clear();
                }
            }
        }
Example #4
0
        /// <summary>
        /// 获取地图范围
        /// </summary>
        /// <returns></returns>
        public moRectangle GetFullExtent()
        {
            //(1)新建一个空矩形
            double      sMinX = double.MaxValue, sMaxX = double.MinValue;
            double      sMinY = double.MaxValue, sMaxY = double.MinValue;
            moRectangle sFullExtent;
            //(2)如果图层数量为0,则返回空矩形
            Int32 sLayerCount = _Layers.Count;

            if (sLayerCount == 0)
            {
                sFullExtent = new moRectangle(sMinX, sMaxX, sMinY, sMaxY);
                return(sFullExtent);
            }
            //(3)计算范围矩形
            for (Int32 i = 0; i <= sLayerCount - 1; i++)
            {
                moMapLayer  sLayer  = _Layers.GetItem(i);
                moRectangle sExtent = sLayer.Extent;
                if (sExtent.IsEmpty == false)
                {
                    if (sExtent.MinX < sMinX)
                    {
                        sMinX = sExtent.MinX;
                    }
                    if (sExtent.MaxX > sMaxX)
                    {
                        sMaxX = sExtent.MaxX;
                    }
                    if (sExtent.MinY < sMinY)
                    {
                        sMinY = sExtent.MinY;
                    }
                    if (sExtent.MaxY > sMaxY)
                    {
                        sMaxY = sExtent.MaxY;
                    }
                }
            }
            sFullExtent = new moRectangle(sMinX, sMaxX, sMinY, sMaxY);
            return(sFullExtent);
        }
Example #5
0
        private void DrawBufferMap1()
        {
            //(1)获取地图窗口的范围
            moRectangle sExtent = GetExtent();

            if (sExtent.IsEmpty == true)
            {
                return;
            }
            //(2)绘制所有图层的要素,采用倒序
            double   sMapScale = mMapDrawingReference.MapScale;
            double   dpm       = mMapDrawingReference.dpm;
            double   mpu       = mMapDrawingReference.mpu;
            Graphics g         = Graphics.FromImage(mBufferMap1);

            g.Clear(Color.White);
            Int32 sLayerCount = _Layers.Count;

            for (Int32 i = sLayerCount - 1; i >= 0; i--)
            {
                moMapLayer sLayer = _Layers.GetItem(i);
                if (sLayer.Visible == true)
                {
                    sLayer.DrawFeatures(g, sExtent, sMapScale, dpm, mpu);
                }
            }
            //(3)绘制所有图层的注记,依然倒序
            List <RectangleF> sPlacedLabelExtents = new List <RectangleF>();

            for (Int32 i = sLayerCount - 1; i >= 0; i--)
            {
                moMapLayer sLayer = _Layers.GetItem(i);
                if (sLayer.Visible == true)
                {
                    sLayer.DrawLabels(g, sExtent, sMapScale, dpm, mpu, sPlacedLabelExtents);
                }
            }
            g.Dispose();
        }
Example #6
0
 /// <summary>
 /// 移除指定图层
 /// </summary>
 /// <param name="mapLayer"></param>
 public void Remove(moMapLayer mapLayer)
 {
     _Layers.Remove(mapLayer);
 }
Example #7
0
 /// <summary>
 /// 在图层序列末尾增加一个图层
 /// </summary>
 /// <param name="mapLayer"></param>
 public void Add(moMapLayer mapLayer)
 {
     _Layers.Add(mapLayer);
 }