From 381bcdc53192f8e8a14fc4ca12ddbb29736c3392 Mon Sep 17 00:00:00 2001
From: cloudflight <cloudflight@126.com>
Date: 星期三, 15 五月 2024 14:43:18 +0800
Subject: [PATCH] feat:增加了MapViewer中NodeColour,LinkColour属性,可以直接从外部setColour类型

---
 Hydraulic/Hydro.MapUI/Map/MapViewer.Model.cs |  253 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 215 insertions(+), 38 deletions(-)

diff --git a/Hydraulic/Hydro.MapUI/Map/MapViewer.Model.cs b/Hydraulic/Hydro.MapUI/Map/MapViewer.Model.cs
index 6b08526..f7bd79f 100644
--- a/Hydraulic/Hydro.MapUI/Map/MapViewer.Model.cs
+++ b/Hydraulic/Hydro.MapUI/Map/MapViewer.Model.cs
@@ -21,6 +21,7 @@
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Windows.Forms.DataVisualization.Charting;
+using static Hydro.MapView.MapViewEnum;
 using static System.Net.Mime.MediaTypeNames;
 using static System.Windows.Forms.AxHost;
 using static System.Windows.Forms.LinkLabel;
@@ -34,12 +35,104 @@
     {
 
     }
+    public class TContainer
+    {
+
+        public MapDimensions mapOption = new MapDimensions();
+
+        public Template newTemplate  = null;
+
+        public Template template = null;
+
+    }
     public partial class MapViewer
     {
 
-        #region 鏂板绠$綉
+        #region 鏍稿績灞炴��
+        TContainer TC = new TContainer();
+
+
+        /// <summary>
+        /// 鍦板浘閫夐」
+        /// </summary>
+        public MapDimensions mapOption 
+        {
+            get { return TC.mapOption; }
+            set { TC.mapOption = value; }
+        }
+        /// <summary>
+        /// 鍦板浘閫夐」_璧峰鎿嶄綔鏃�
+        /// </summary>
+        private MapDimensions mapOption0 = new MapDimensions();
+        /// <summary>
+        /// 涓存椂绠$綉灞�
+        /// </summary>
         [Browsable(false)]
-        public Template _newTemplate { get; set; } = null;// new Template();
+        public Template _newTemplate
+        {
+            get { return TC.newTemplate; }
+            set { TC.newTemplate = value; }
+        }
+
+
+        [Browsable(false)]
+        public Template _Template
+        {
+            get {return TC.template; }
+            set
+            {
+                TC.template = value;
+
+                label_file.Text = TC.template?.filePath;
+            }
+        }
+
+        #endregion
+        #region 浜や簰灞炴��
+        /// <summary>
+        /// 鎮仠瀵硅薄
+        /// </summary>
+        private List<IBaseViewModel> hoveredObjs = new List<IBaseViewModel>();
+        /// <summary>
+        /// 閫変腑瀵硅薄
+        /// </summary>
+        public List<IBaseViewModel> selectedObjs = new List<IBaseViewModel>();
+
+
+        private List<NodeViewModel> selectedNodes => selectedObjs.FindAll(o => o is NodeViewModel).Select(o => (NodeViewModel)o).ToList();
+        private List<LinkViewModel> selectedLinks => selectedObjs.FindAll(o => o is LinkViewModel).Select(o => (LinkViewModel)o).ToList();
+
+        MouseState _mouseState = MouseState.鏃�;
+        private NodeViewModel _OperaNode = null;
+        public PointF mouseXY = new PointF(0, 0);
+
+        PointF DragStartPos;
+        PointF _ClickStartPos;
+        PointF RotaStartPos;
+        PointF BackGroudPicLeftPos;
+        bool _isPanning;
+        /// <summary>
+        /// 鎷栨嫿閫夋嫨
+        /// </summary>
+        bool _isDragging;
+        bool _isRotating;
+        bool _isPainting;
+        
+
+        PointF mousePosition;
+        // control+榧犳爣涓棿鎸変笅缂╂斁
+        bool _isInsertingObject = false;
+        bool _isMovingObject = false;
+        bool _isPastingObject = false;
+        Cursor _lastCursor;
+        object _undoOldValue = null;
+        private List<PointF> polygonPoints = new List<PointF>();
+
+        private bool _isDrawingPolygon;
+
+        #endregion
+        #region 鏂板绠$綉锛堣緟鍔╋級
+
         MapViewNetWork _NewNet
         {
             get
@@ -50,36 +143,51 @@
             }
         }
         #endregion
-
-        #region 灞炴��
+        #region 鏄剧ず閫夐」锛堣緟鍔╋級
 
 
         private string _StartPoint = null;
         private string _EndPoint = null;
-        private bool __isEditMode = true;
+        //private bool __isEditMode = true;
         [Browsable(false)]
         public bool _IsEditMode
         {
-            get { return __isEditMode; }
+            get { return this.mapOption?.isEditMode??true; }
             set
             {
-                __isEditMode = value;
-                toolStripComboBox_娴忚妯″紡.Text = __isEditMode ? "缂栬緫妯″紡" : "娴忚妯″紡";
+                toolStripComboBox_娴忚妯″紡.Text = value ? "缂栬緫妯″紡" : "娴忚妯″紡";
+                
+                if (this.mapOption!=null) this.mapOption.isEditMode = value;
+                杞崲涓篢oolStripMenuItem.Visible = _IsEditMode;
+                toolStripSeparator9.Visible = _IsEditMode;
+                鍒犻櫎ToolStripMenuItem.Visible = _IsEditMode;
+                鍒犻櫎ToolStripMenuItem1.Visible = _IsEditMode;
+
+                澶嶅埗ToolStripMenuItem.Visible = _IsEditMode;
+                澶嶅埗ToolStripMenuItem1.Visible = _IsEditMode;
+                绮樿创ToolStripMenuItem.Visible = _IsEditMode;
+                绮樿创ToolStripMenuItem1.Visible = _IsEditMode;
+                璁剧疆闀垮害ToolStripMenuItem.Visible = _IsEditMode;
+                璁句负鍏抽棴ToolStripMenuItem.Visible = _IsEditMode;
+                璁句负绔嬬鐐筎oolStripMenuItem.Visible = _IsEditMode;
+                瀵归綈ToolStripMenuItem.Visible = _IsEditMode;
+                瀵归綈ToolStripMenuItem1.Visible = _IsEditMode;
+
+                toolStripButton_鏂板缓鑺傜偣.Enabled = _IsEditMode;
+                toolStripButton_鏂板缓绠$嚎.Enabled = _IsEditMode;
+                toolStripButton_鏂板缓绔嬬.Enabled = _IsEditMode;
+                toolStripButton_娣诲姞姘村簱.Enabled = _IsEditMode;
+                toolStripButton_娣诲姞姘存睜.Enabled = _IsEditMode;
+                toolStripButton_娣诲姞姘磋〃.Enabled = _IsEditMode;
+                toolStripButton_娣诲姞闃�闂�.Enabled = _IsEditMode;
+                toolStripButton_閲嶅鍣�.Enabled = _IsEditMode;
+       
+
+
             }
         }
 
-        private Template __template = null;
-        [Browsable (false)]
-        public Template _Template
-        {
-            get { return __template; }
-            set
-            {
-                __template = value;
-            
-                label_file.Text = __template==null?"": __template.filePath;
-            }
-        }
+   
         [Browsable(false)]
         public float Link_multiply
         {
@@ -157,7 +265,8 @@
                 return _Template?.network;
             }
         }
-
+        #endregion
+        #region 绠$綉灞炴�э紙杈呭姪锛�
         [Browsable(false)]
         public List<NodeCalcModel> _Nodes
         {
@@ -179,12 +288,9 @@
 
         }
         #endregion
+        #region 瑙嗚璁剧疆锛堣緟鍔╋級
 
-
-        #region 鍩虹鍦板浘瑙嗗浘閫夐」
-
-        MapDimensions mapOption = new MapDimensions();
-        MapDimensions mapOption0 = new MapDimensions();
+        
 
         private const float MinZoom = 0.1f;
         private const float MaxZoom = 1000.0f;
@@ -197,7 +303,8 @@
                 return mapOption.zoom;
             }
             set
-            { 
+            {
+                label_zoom.Text = $"Zoom锛歿zoom.ToString("0.000")}";
                 mapOption.zoom = value; 
             } 
         }
@@ -209,7 +316,8 @@
                 return mapOption.rotation; 
             } 
             set 
-            { 
+            {
+                toolStripStatusLabel_rotation.Text = $"Rotation锛�({Rotation.ToString("0")}锛寋RotationF.ToString("0")})";
                 mapOption.rotation = value; 
             } 
         }
@@ -223,13 +331,29 @@
                 return mapOption.Center; 
             } 
             set 
-            { 
+            {
+                label_center.Text = $"center锛�({MapCenter.X.ToString("0.00")} 锛寋MapCenter.Y.ToString("0.00")}锛�";
                 mapOption.Center = value; 
             } 
         }
         private PointF MapCenter0;
         private bool is3Dview = false;
         double 淇瑙掑害_start = 90;
+
+
+
+        public bool Lock2DView
+        {
+            get
+            {
+                return mapOption.Lock2DView;
+            }
+            set
+            {
+                mapOption.Lock2DView = value;
+            }
+        }
+
 
         /// <summary>
         /// 淇绾夸笌搴曢潰鐨勫す瑙掞紝鎶曞奖鐢╯in
@@ -239,18 +363,11 @@
         { 
             get 
             {
-                if (Lock2DView) 
-                    mapOption.rotationF = 90;
-                
                 return mapOption.rotationF; 
             } 
             set 
             { 
-                
-                if (Lock2DView) 
-                    mapOption.rotationF = 90;
-                else
-                    mapOption.rotationF = value;
+                mapOption.rotationF = value;
             } 
         }
         [Browsable(false)]
@@ -277,7 +394,67 @@
             return new PointF(0, 0);
         }
         #endregion
+        #region 棰滆壊鍒嗙骇锛堣緟鍔╋級
+        public Colour NodeColour
+        {
+            set
+            {
+                var type = value.Type;
+                value.isChoosed = true;
+                _Template?.Colours?.RemoveAll(cl => cl.Type == type);
+                _Template.Colours.Add(value);
+                mapOption.ColourNode = type;
+            }
+            private get
+            {
+                return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourNode);
+            }
+        }
+        public Colour LinkColour
+        {
+            set
+            {
+                var type = value.Type;
+                value.isChoosed = true;
+                _Template?.Colours?.RemoveAll(cl => cl.Type == type);
+                _Template.Colours.Add(value);
+                mapOption.ColourLink = type;
+            }
+            private get
+            {
+                return _Template?.Colours?.FirstOrDefault(cl => cl.isChoosed && cl.Type == mapOption.ColourLink);
+            }
+        }
+        
+        //private bool __isOrtho = true;
 
-
+        #endregion
+        #region 姝d氦妯″紡
+        private bool _isOrtho
+        {
+            get
+            {
+                return mapOption.IsOrtho;
+            }
+            set
+            {
+                mapOption.IsOrtho = value;
+                if (mapOption.IsOrtho)
+                {
+                    label_ZZ.Text = "姝d氦妯″紡:寮�";
+                }
+                else
+                {
+                    label_ZZ.Text = "姝d氦妯″紡:鍏�";
+                }
+            }
+        }
+        #endregion
+        #region 浜嬩欢
+        //鎸夊抚鏁板垽鏂槸鍚﹂噸缁橈紝鍑忓皯璁$畻閲忥紙姣忓抚鏈�澶氶噸缁樹竴娆★級
+        bool _timerDraw = false;
+        //鎸夊抚鏁板垽鏂紶鏍囨偓鍋滃璞★紝鍑忓皯璁$畻閲忥紙姣忓抚鏈�澶氬垽鏂竴娆★級
+        bool _mouseHoverCheckFlag = false;
+        #endregion
     }
 }

--
Gitblit v1.9.3