private void documentControl1_AfterPaintPage(object sender, ItopVector.Core.PaintMapEventArgs e) { (mapview as MapViewBase).ShowMapInfo = true; int nScale = 0; float nn = 1; nScale = mapview.Getlevel(documentControl1.ScaleRatio); //if(isIn) //nScale = mapview.Getlevel(documentControl1.ScaleRatio, out nn); //else //nScale = mapview.Getlevel2(documentControl1.ScaleRatio, out nn); if (nScale == -1) { return; } LongLat longlat = LongLat.Empty; //计算中心点经纬度 longlat = mapview.OffSet(mapview.ZeroLongLat, nScale, (int)(e.CenterPoint.X / nn), (int)(e.CenterPoint.Y / nn)); //创建地图 System.Drawing.Image image = backbmp; //if (image != null && isdown) { } else if (nn >= 1) { //for (double i=-0.1;i<=0.1;i=i+0.01) //{ // for (double j = -0.1; j <= 0.1; j = j + 0.01) // { // image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude + i, longlat.Latitude+j); // } //} //image = mapview.CreateMap(1000, 1000, nScale, longlat.Longitude, longlat.Latitude); image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude, longlat.Latitude); } else { image = mapview.CreateMap((int)(e.Bounds.Width / nn), (int)(e.Bounds.Height / nn), nScale, longlat.Longitude, longlat.Latitude); } //backbmp = image; ImageAttributes imageAttributes = new ImageAttributes(); ColorMatrix matrix1 = new ColorMatrix(); matrix1.Matrix00 = 1f; matrix1.Matrix11 = 1f; matrix1.Matrix22 = 1f; matrix1.Matrix33 = 0.9f; //地图透明度 matrix1.Matrix44 = 1f; //设置地图透明度 imageAttributes.SetColorMatrix(matrix1, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //int offx = 0; //int offy = 0; //if (isdown) { // offx = Control.MousePosition.X - beginPoint.X; // offy = Control.MousePosition.Y - beginPoint.Y; //} //e.G.TranslateTransform(offx, offy, MatrixOrder.Append); //绘制地图 if (nn > 1) { int w1 = (int)(e.Bounds.Width * ((nn - 1) / 2)); int h1 = (int)(e.Bounds.Height * ((nn - 1) / 2)); Rectangle rt1 = e.Bounds; rt1.Inflate(w1, h1); e.G.CompositingQuality = CompositingQuality.HighQuality; e.G.DrawImage((Bitmap)image, rt1, 0f, 0f, (float)image.Width, (float)image.Height, GraphicsUnit.Pixel, imageAttributes); } else { e.G.DrawImage((Bitmap)image, e.Bounds, 0f, 0f, (float)image.Width, (float)image.Height, GraphicsUnit.Pixel, imageAttributes); } SolidBrush brush = new SolidBrush(Color.FromArgb(220, 75, 75, 75)); //e.G.FillRectangle( brush,e.G.VisibleClipBounds); //绘制中心点 e.G.DrawEllipse(Pens.Red, e.Bounds.Width / 2 - 2, e.Bounds.Height / 2 - 2, 4, 4); e.G.DrawEllipse(Pens.Red, e.Bounds.Width / 2 - 1, e.Bounds.Height / 2 - 1, 2, 2); ///107,159 { //绘制比例尺 Point p1 = new Point(20, e.Bounds.Height - 30); Point p2 = new Point(20, e.Bounds.Height - 20); Point p3 = new Point(80, e.Bounds.Height - 20); Point p4 = new Point(80, e.Bounds.Height - 30); e.G.DrawLines(new Pen(Color.Black, 2), new Point[4] { p1, p2, p3, p4 }); string str1 = string.Format("{0}公里", mapview.GetMiles(nScale)); e.G.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, e.Bounds.Height - 40); } // string s = string.Format("{0}行{1}列", nRows, nCols); string s = string.Format("经{0}:纬{1}", longlat.Longitude, longlat.Latitude); // //显示中心点经纬度 e.G.DrawString(s, new Font("宋体", 10), Brushes.Red, 20, 40); // IntPtr hDC = e.G.GetHdc(); // // // LOGBRUSH brush; // brush.lbColor = 255; // brush.lbHatch = 10; // brush.lbStyle = 1;//BS_NULL // IntPtr hBursh = CreateBrushIndirect(ref brush); // IntPtr hPen = CreatePen(2, 1, 255); // IntPtr nOldPen = SelectObject(hDC, hPen); // IntPtr nOldBrush = SelectObject(hDC, hBursh); // SetROP2(hDC,10); // Rectangle((int)hDC, 100, 100, 50, 50); //// SetROP2(hDC,10); // Rectangle((int)hDC, 150, 150, 50, 50); // // SelectObject(hDC, nOldPen); // SelectObject(hDC, nOldBrush); // e.G.ReleaseHdc(hDC); }
private void tlVectorControl1_AfterPaintPage(object sender, ItopVector.Core.PaintMapEventArgs e) { int nScale = 0; switch ((int)(this.tlVectorControl1.DrawArea.ScaleUnit * 1000)) { case 100: nScale = 8; break; case 200: nScale = 9; break; case 400: nScale = 10; break; case 1000: nScale = 11; break; case 2000: nScale = 12; break; case 4000: nScale = 13; break; default: return; } LongLat longlat = LongLat.Empty; //计算中心点经纬度 int offsetY = (nScale - 10) * 25; longlat = mapview.OffSet(mapview.ZeroLongLat, nScale, -(int)(e.CenterPoint.X), -(int)(e.CenterPoint.Y)); //创建地图 System.Drawing.Image image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude, longlat.Latitude); ImageAttributes imageAttributes = new ImageAttributes(); ColorMatrix matrix1 = new ColorMatrix(); matrix1.Matrix00 = 1f; matrix1.Matrix11 = 1f; matrix1.Matrix22 = 1f; matrix1.Matrix33 = 0.9f; //地图透明度 matrix1.Matrix44 = 1f; //设置地图透明度 imageAttributes.SetColorMatrix(matrix1, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //绘制地图 e.G.DrawImage((Bitmap)image, e.Bounds, 0f, 0f, (float)image.Width, (float)image.Height, GraphicsUnit.Pixel, imageAttributes); //绘制中心点 e.G.DrawEllipse(Pens.Red, e.Bounds.Width / 2 - 2, e.Bounds.Height / 2 - 2, 4, 4); e.G.DrawEllipse(Pens.Red, e.Bounds.Width / 2 - 1, e.Bounds.Height / 2 - 1, 2, 2); { //绘制比例尺 Point p1 = new Point(20, e.Bounds.Height - 30); Point p2 = new Point(20, e.Bounds.Height - 20); Point p3 = new Point(80, e.Bounds.Height - 20); Point p4 = new Point(80, e.Bounds.Height - 30); e.G.DrawLines(new Pen(Color.Black, 2), new Point[4] { p1, p2, p3, p4 }); string str1 = string.Format("{0}公里", mapview.GetMiles(nScale)); e.G.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, e.Bounds.Height - 40); } // string s = string.Format("{0}行{1}列", nRows, nCols); string s = string.Format("经{0}:纬{1}", longlat.Longitude, longlat.Latitude); // //显示中心点经纬度 e.G.DrawString(s, new Font("宋体", 10), Brushes.Red, 20, 40); }