void tlVectorControl1_AfterPaintPage(object sender, PaintMapEventArgs e) { try { if (LoadImage) { int nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio); if (nScale == -1) return; LongLat longlat = LongLat.Empty; float nn = 1; if (isIn) nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio, out nn); else nScale = mapview.Getlevel2(tlVectorControl1.ScaleRatio, out nn); if (nScale == -1) return; //计算中心点经纬度 Color color3 = ColorTranslator.FromHtml("#FFFFFF"); e.G.Clear(color3); longlat = mapview.OffSet(mapview.ZeroLongLat, nScale, (int)(e.CenterPoint.X), (int)(e.CenterPoint.Y)); System.Drawing.Image image = backbmp; //创建地图 // System.Drawing.Image image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude, longlat.Latitude); if (nn >= 1) 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; string newnScale = mapview.GetMiles(nScale); ImageAttributes imageAttributes = new ImageAttributes(); ColorMatrix matrix1 = new ColorMatrix(); matrix1.Matrix00 = 1f; matrix1.Matrix11 = 1f; matrix1.Matrix22 = 1f; matrix1.Matrix33 = this.mapOpacity / 100f;//地图透明度 matrix1.Matrix44 = 1f; //设置地图透明度 imageAttributes.SetColorMatrix(matrix1, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //Color color = ColorTranslator.FromHtml("#F4F4FB"); //Color color2 = ColorTranslator.FromHtml("#EFF0F1");//EFF0F1 ////imageAttributes2.SetColorKey(color, color); ////imageAttributes2.SetColorKey(color2, color2); //imageAttributes.SetColorKey(color2, color); int chose = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("chose")); string Transparent = ConfigurationSettings.AppSettings.Get("Transparent"); if (string.IsNullOrEmpty(Transparent)) Transparent = "#EBEAE8"; if (chose == 1) { Color color = ColorTranslator.FromHtml(Transparent);//旧Mapbar新Mapbar#F4F1EC imageAttributes.SetColorKey(color, color); } else if (chose == 2) { Color color = ColorTranslator.FromHtml("#F4F4FB"); Color color2 = ColorTranslator.FromHtml("#EFF0F1"); imageAttributes.SetColorKey(color2, color); } //绘制地图 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); if (tlVectorControl1.CurrentOperation != ToolOperation.Roam) { e.G.DrawLines(new Pen(Color.Black, 2), new Point[4] { p1, p2, p3, p4 }); string str1 = string.Format("{0}公里", newnScale); e.G.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, e.Bounds.Height - 40); } } } catch (Exception e1) { } //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); }
void tlVectorControl1_AfterPaintPage(object sender, PaintMapEventArgs e) { try { if (LoadImage) { int nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio); LongLat longlat = LongLat.Empty; float nn = 1; if (mapview is MapViewObj) { if (isIn) nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio, out nn); else nScale = mapview.Getlevel2(tlVectorControl1.ScaleRatio, out nn); } if (nScale == -1) return; //LongLat longlat = LongLat.Empty; //计算中心点经纬度 //int offsetY = (nScale - 10) * 25; longlat = mapview.OffSet(mapview.ZeroLongLat, nScale, (int)(e.CenterPoint.X), (int)(e.CenterPoint.Y)); //Color color3 = ColorTranslator.FromHtml("#FFFFFF"); //e.G.Clear(color3); //创建地图 System.Drawing.Image image = backbmp; if (nn >= 1) 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 //System.Drawing.Image image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude, longlat.Latitude); string newnScale = mapview.GetMiles(nScale); 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); Color color = ColorTranslator.FromHtml("#F4F4FB"); Color color2 = ColorTranslator.FromHtml("#EFF0F1");//EFF0F1 //imageAttributes2.SetColorKey(color, color); //imageAttributes2.SetColorKey(color2, color2); imageAttributes.SetColorKey(color2, color); //绘制地图 // e.G.DrawImage((Bitmap)image, e.Bounds, 0f, 0f, (float)image.Width, (float)image.Height, GraphicsUnit.Pixel, imageAttributes); 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.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}公里", newnScale); e.G.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, e.Bounds.Height - 40); } } catch (Exception e1) { } //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); }
private void drawArea1_PaintMap(object sender, PaintMapEventArgs e) { if (this.PaintMap !=null) PaintMap(sender,e); }
void DrawArea_OnBeforeRenderTo(object sender, PaintMapEventArgs e) { PointF pf = tlVectorControl1.DrawArea.ContentBounds.Location; Rectangle rt = Rectangle.Round(e.G.VisibleClipBounds); int offsetX = (int)(rt.Width / 2 + pf.X); int offsetY = (int)(rt.Height / 2 + pf.Y); LongLat longlat = mapview.OffSet(mapview.ZeroLongLat, mapview.Getlevel(1), -offsetX, -offsetY); e.G.Clear(ColorTranslator.FromHtml("#EBEAE8")); ImageAttributes imageA = new ImageAttributes(); int chose = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("chose")); string Transparent = ConfigurationSettings.AppSettings.Get("Transparent"); if (string.IsNullOrEmpty(Transparent)) Transparent = "#EBEAE8"; if (chose == 1) { Color color = ColorTranslator.FromHtml(Transparent); imageA.SetColorKey(color, color); } else if (chose == 2) { Color color = ColorTranslator.FromHtml("#F4F4FB"); Color color2 = ColorTranslator.FromHtml("#EFF0F1"); imageA.SetColorKey(color2, color); } mapview.Paint(e.G, (int)rt.Width, (int)rt.Height, 11, longlat.Longitude, longlat.Latitude, imageA); }
private void drawArea1_AfterPaintPage(object sender, PaintMapEventArgs e) { if (this.AfterPaintPage !=null) AfterPaintPage(sender,e); }
void tlVectorControl1_AfterPaintPage(object sender, PaintMapEventArgs e) { try { if (LoadImage) { int nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio); //if (nScale == -1) // return; LongLat longlat = LongLat.Empty; float nn = 1; if (mapview is MapViewObj) { if (isIn) nScale = mapview.Getlevel(tlVectorControl1.ScaleRatio, out nn); else nScale = mapview.Getlevel2(tlVectorControl1.ScaleRatio, out nn); } if (nScale == -1) return; //计算中心点经纬度 e.G.Clear(Color.White); longlat = mapview.OffSet(mapview.ZeroLongLat, nScale, (int)(e.CenterPoint.X / nn), (int)(e.CenterPoint.Y / nn)); //创建地图 //System.Drawing.Image image = mapview.CreateMap(e.Bounds.Width, e.Bounds.Height, nScale, longlat.Longitude, longlat.Latitude); System.Drawing.Image image = backbmp; if (nn >= 1) 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 string newnScale = mapview.GetMiles(nScale); ImageAttributes imageAttributes = new ImageAttributes(); ColorMatrix matrix1 = new ColorMatrix(); matrix1.Matrix00 = 1f; matrix1.Matrix11 = 1f; matrix1.Matrix22 = 1f; matrix1.Matrix33 = this.mapOpacity / 100f;//地图透明度 matrix1.Matrix44 = 1f; //设置地图透明度 imageAttributes.SetColorMatrix(matrix1, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //e.G.FillRectangle( brush,e.G.VisibleClipBounds); int chose = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("chose")); string Transparent = ConfigurationSettings.AppSettings.Get("Transparent"); if (string.IsNullOrEmpty(Transparent)) Transparent = "#EBEAE8"; if (chose == 1) { Color color = ColorTranslator.FromHtml(Transparent);//旧Mapbar新Mapbar#F4F1EC imageAttributes.SetColorKey(color, color); } else if (chose == 2) { Color color = ColorTranslator.FromHtml("#F4F4FB"); Color color2 = ColorTranslator.FromHtml("#EFF0F1"); imageAttributes.SetColorKey(color2, color); } //绘制地图 //e.G.DrawImage((Bitmap)image, e.Bounds, 0f, 0f, (float)image.Width, (float)image.Height, GraphicsUnit.Pixel, imageAttributes); 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.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); //绘制比例尺 if (tlVectorControl1.CurrentOperation != ToolOperation.Roam) { 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 }); //if (mapview is MapViewGoogle) { // PointF pf1 = new PointF(0, 0); // PointF pf2 = new PointF((float)100 / tlVectorControl1.ScaleRatio, 0); // newnScale +="\t"+ Math.Round(mapview.CountLength(pf1, pf2), 3) + ""; //} string str1 = string.Format("{0}公里", newnScale); e.G.DrawString(str1, new Font("宋体", 10), Brushes.Black, 30, e.Bounds.Height - 40); } } } catch (Exception e1) { } //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); }
protected override void OnPaint(PaintEventArgs e) { if (this.svgDocument != null) { if (this.firstload) { this.FitWindow(); this.firstload = false; } SizeF ef1 = this.ViewSize; float single1 = ef1.Width; float single2 = ef1.Height; if (single1 == 0f) { single1 = base.Width; } if (single2 == 0f) { single2 = base.Height; } PointF[] tfArray2 = new PointF[3] {new PointF(0f, 0f), new PointF(single1, single2),new PointF(Width/2f,Height/2f)}; PointF[] tfArray1 = tfArray2; { this.coordTransform.Reset(); this.coordTransform.Translate(-this.virtualLeft, -this.virtualTop); this.coordTransform.Translate((float) this.margin.Width, (float) this.margin.Height); this.coordTransform.Scale(this.scale, this.scale); this.coordTransform.TransformPoints(tfArray1); } RectangleF rf1 = new RectangleF(tfArray1[0].X, tfArray1[0].Y, tfArray1[1].X - tfArray1[0].X, tfArray1[1].Y - tfArray1[0].Y); RectangleF rf2 = rf1; PaintMapEventArgs paintMapEventArgs = new PaintMapEventArgs(e.Graphics,new PointF(rf1.X,rf1.Y),this.Bounds); paintMapEventArgs.CenterPoint = new PointF(-(Width/2f - ( tfArray1[0].X)),-(Height/2f -(tfArray1[0].Y)) ); if(PaintMap !=null) PaintMap(this,paintMapEventArgs); if(!fullDrawMode) { rf2.Offset(6,6); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(108,114,130)),rf2); if(BkColor!=null) { e.Graphics.FillRectangle(BkColor,rf1); } else { e.Graphics.FillRectangle(Brushes.White,rf1); } if (this.showGrid) { this.PaintGrid(e.Graphics, rf1, new SizeF(this.GridSize.Width*this.coordTransform.Elements[0], this.GridSize.Height*this.coordTransform.Elements[3])); } e.Graphics.DrawRectangle(Pens.Black, tfArray1[0].X, tfArray1[0].Y, tfArray1[1].X - tfArray1[0].X, tfArray1[1].Y - tfArray1[0].Y); } if(fullDrawMode) { // e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(108,114,130)),0,0,this.mouseAreaControl.Width,this.mouseAreaControl.Height); if(BkColor!=null) { e.Graphics.FillRectangle(BkColor,0,0,this.mouseAreaControl.Width,this.mouseAreaControl.Height); } else { e.Graphics.FillRectangle(Brushes.White,0,0,this.mouseAreaControl.Width,this.mouseAreaControl.Height); } if (this.showGrid) { this.PaintGrid(e.Graphics, rf1, new SizeF(this.GridSize.Width*this.coordTransform.Elements[0], this.GridSize.Height*this.coordTransform.Elements[3])); e.Graphics.DrawRectangle(Pens.Black, tfArray1[0].X, tfArray1[0].Y, tfArray1[1].X - tfArray1[0].X, tfArray1[1].Y - tfArray1[0].Y); } } if(AfterPaintPage !=null) AfterPaintPage(this,paintMapEventArgs); } }
void tlVectorControl1_AfterPaintPage(object sender, PaintMapEventArgs e) { try { if (LoadImage) { int nScale = 0; switch ((int)(decimal)(this.tlVectorControl2.DrawArea.ScaleUnit * 1000)) { case 10: nScale = 5; break; case 20: nScale = 6; break; case 40: nScale = 7; break; 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; //计算中心点经纬度 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 = 1f;//地图透明度 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); if (tlVectorControl2.CurrentOperation != ToolOperation.Roam) { 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); } } } catch (Exception e1) { } //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); }
void DrawArea_OnBeforeRenderTo(object sender, PaintMapEventArgs e) { PointF pf = tlVectorControl2.DrawArea.ContentBounds.Location; Rectangle rt = Rectangle.Round(e.G.VisibleClipBounds); int offsetX = (int)(rt.Width / 2 + pf.X); int offsetY = (int)(rt.Height / 2 + pf.Y); LongLat longlat = mapview.OffSet(mapview.ZeroLongLat, mapview.Getlevel(1), -offsetX, -offsetY); e.G.Clear(ColorTranslator.FromHtml("#EBEAE8")); ImageAttributes imageA=new ImageAttributes(); mapview.Paint(e.G, (int)rt.Width, (int)rt.Height, mapview.Getlevel(1), longlat.Longitude, longlat.Latitude, imageA); }