| | |
| | | |
| | | partial class MapViewer |
| | | { |
| | | void DrawBackGroud(Graphics bufferG,Template template) |
| | | { |
| | | if (template == null) return; |
| | | var _Nodes = template.network.Nodes.ViewNodes; |
| | | var _Links = template.network.Links.ViewLinks; |
| | | |
| | | var Cpoints = getCurclePoints(64).ToList(); |
| | | |
| | | var r = 1.73f / zoom; |
| | | var rt = r; |
| | | |
| | | float minElve = float.MinValue; |
| | | float maxElve = float.MaxValue; |
| | | |
| | | r = r * Link_multiply; |
| | | List<PointF> diametersZoom = new List<PointF>() { new PointF(0, 0.08f), new PointF(150, 0.03f), new PointF(300, 0.001f), new PointF(800, 0.0001f) }; |
| | | |
| | | Pen penN = new Pen(Color.FromArgb(0, 0, 255), 1 * r); |
| | | |
| | | |
| | | //背景图绘制 |
| | | if (this.mapOption.isShowPic && template != null && File.Exists(template.BackGroundImg_FullPath)) |
| | | |
| | | |
| | | { |
| | | //var gs = bufferG.Save(); |
| | | // 应用矩阵变换以抵消之前的翻转效果 |
| | | //bufferG.ScaleTransform(1 / Zoom.X, 1 / Zoom.Y); |
| | | List<PointF> p = new List<PointF>(); |
| | | |
| | | if (!this.mapOption.isAutoBackgroundImage) |
| | | { |
| | | var Cps = new List<PointF> |
| | | { |
| | | template.BackGroundPoint1, |
| | | new PointF(template.BackGroundPoint2.X,template.BackGroundPoint1.Y), |
| | | new PointF(template.BackGroundPoint1.X,template.BackGroundPoint2.Y), |
| | | //template.BackGroundPoint2, |
| | | |
| | | |
| | | }; |
| | | Cps.ForEach(cp => p.Add(WorldPointToMapPoint(cp, template.BackGroundElev, template.OffSet))); |
| | | } |
| | | else |
| | | { |
| | | |
| | | // 恢复之前保存的绘图状态 |
| | | |
| | | //var Cps = new List<PointF> |
| | | //{ |
| | | // template.BackGroundPoint1, |
| | | // new PointF(template.BackGroundPoint2.X,template.BackGroundPoint1.Y), |
| | | // new PointF(template.BackGroundPoint1.X,template.BackGroundPoint2.Y), |
| | | // //template.BackGroundPoint2, |
| | | |
| | | |
| | | //}; |
| | | var p1 = new PointF(template.BackGroundImgX, template.BackGroundImgY); |
| | | var p2 = new PointF(template.BackGroundImgX + template.BackGroundImgWidth, template.BackGroundImgY + template.BackGroundImgHeight); |
| | | |
| | | var f = template.BackGroundImgRotaAngle / 180 * Math.PI; |
| | | var djx = Math.Sqrt((Math.Pow(template.BackGroundImgWidth, 2) + Math.Pow(template.BackGroundImgHeight, 2))); |
| | | var p3 = new PointF(p1.X + (float)(Math.Cos(f) * template.BackGroundImgWidth), p1.Y + (float)(Math.Sin(f) * template.BackGroundImgWidth)); |
| | | var p4 = new PointF(p1.X - (float)(Math.Sin(f) * template.BackGroundImgHeight), p1.Y + (float)(Math.Cos(f) * template.BackGroundImgHeight)); |
| | | p3.Y = p4.Y; |
| | | //p4.Y = -p4.Y; |
| | | var Cps = new List<PointF> |
| | | { |
| | | //template.BackGroundPoint1, |
| | | //new PointF(template.BackGroundImgX,template.BackGroundImgY), |
| | | p4, |
| | | p3,p1 |
| | | //template.BackGroundPoint2, |
| | | |
| | | |
| | | }; |
| | | template.BackGroundPoint1 = p4; |
| | | template.BackGroundPoint2 = new PointF(p3.X, p1.Y); |
| | | |
| | | |
| | | |
| | | //List<PointF> p = new List<PointF>(); |
| | | Cps.ForEach(cp => p.Add(WorldPointToMapPoint(cp, template.BackGroundElev, template.OffSet))); |
| | | } |
| | | |
| | | //bufferG.DrawImage(System.Drawing.Image.FromFile(@"C:\Users\cloud\Pictures\GenshinImpactCloudGame\QQ截图20230919105637.png"), p[0]); |
| | | try |
| | | { |
| | | var img = System.Drawing.Image.FromFile(template.BackGroundImg_FullPath); |
| | | if (img != null) |
| | | { |
| | | bufferG.FillPolygon(penN.Brush, p.ToArray()); |
| | | bufferG.DrawImage(img, p.ToArray()); |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | |
| | | //bufferG.Restore(gs); |
| | | } |
| | | } |
| | | |
| | | void Draw(Graphics bufferG, Template template) |
| | | { |
| | | if (template == null) return; |
| | |
| | | |
| | | Pen penClosed = new Pen(Color.OrangeRed, 2 * r); |
| | | Pen penHovered = new Pen(Color.DeepSkyBlue, 5 * r); |
| | | //背景图绘制 |
| | | if (this.mapOption.isShowPic && template != null && File.Exists(template.BackGroundImg_FullPath)) |
| | | |
| | | |
| | | { |
| | | //var gs = bufferG.Save(); |
| | | // 应用矩阵变换以抵消之前的翻转效果 |
| | | //bufferG.ScaleTransform(1 / Zoom.X, 1 / Zoom.Y); |
| | | |
| | | |
| | | |
| | | // 恢复之前保存的绘图状态 |
| | | |
| | | var Cps = new List<PointF> |
| | | { |
| | | template.BackGroundPoint1, |
| | | new PointF(template.BackGroundPoint2.X,template.BackGroundPoint1.Y), |
| | | new PointF(template.BackGroundPoint1.X,template.BackGroundPoint2.Y), |
| | | //template.BackGroundPoint2, |
| | | |
| | | |
| | | }; |
| | | |
| | | |
| | | |
| | | List<PointF> p = new List<PointF>(); |
| | | Cps.ForEach(cp => p.Add(WorldPointToMapPoint(cp, template.BackGroundElev, template.OffSet))); |
| | | |
| | | //bufferG.DrawImage(System.Drawing.Image.FromFile(@"C:\Users\cloud\Pictures\GenshinImpactCloudGame\QQ截图20230919105637.png"), p[0]); |
| | | try |
| | | { |
| | | var img = System.Drawing.Image.FromFile(template.BackGroundImg_FullPath); |
| | | if (img != null) |
| | | { |
| | | bufferG.FillPolygon(penN.Brush, p.ToArray()); |
| | | bufferG.DrawImage(img, p.ToArray()); |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | |
| | | //bufferG.Restore(gs); |
| | | } |
| | | |
| | | |
| | | |
| | | // 绘制线 |
| | |
| | | return new PointF(worldX, worldY); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 世界投影坐标转换为屏幕坐标 |
| | | /// </summary> |
| | | /// <param name="mapPos"></param> |
| | | /// <param name="z"></param> |
| | | /// <returns></returns> |
| | | private PointF MapToScreen(PointF mapPos, float z = 0) |
| | | { |
| | | |
| | |
| | | return new PointF(x, y); |
| | | } |
| | | /// <summary> |
| | | /// 获取地图投影坐标 |
| | | /// 获取世界投影坐标 |
| | | /// </summary> |
| | | /// <param name="point"></param> |
| | | /// <param name="z"></param> |