From ba1e9fbc5c16652b7c1309fdbe1bb2818f2b9a4a Mon Sep 17 00:00:00 2001
From: qin <a@163.com>
Date: 星期五, 24 五月 2024 09:47:37 +0800
Subject: [PATCH] 优化加载背景逻辑

---
 Hydraulic/Hydro.MapUI/Map/MapViewer.Draw.cs |   56 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/Hydraulic/Hydro.MapUI/Map/MapViewer.Draw.cs b/Hydraulic/Hydro.MapUI/Map/MapViewer.Draw.cs
index 241b691..ea6fde9 100644
--- a/Hydraulic/Hydro.MapUI/Map/MapViewer.Draw.cs
+++ b/Hydraulic/Hydro.MapUI/Map/MapViewer.Draw.cs
@@ -64,33 +64,50 @@
                 //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 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 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));
-                var Cps = new List<PointF>
+                    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),
-                    p1,
-                    p3,p4
+                    p4,
+                    p3,p1
                     //template.BackGroundPoint2,
                     
                  
@@ -98,8 +115,9 @@
 
 
 
-                List<PointF> p = new List<PointF>();
-                Cps.ForEach(cp => p.Add(WorldPointToMapPoint(cp, template.BackGroundElev, template.OffSet)));
+                    //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

--
Gitblit v1.9.3