From fab5d6e30b9a42a1f94524fca74ef227d2c963e4 Mon Sep 17 00:00:00 2001
From: cloudflight <cloudflight@126.com>
Date: 星期六, 20 七月 2024 11:12:32 +0800
Subject: [PATCH] 1

---
 Hydraulic/Hydro.MapUI/Map/MapViewer.cs |  941 +++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 690 insertions(+), 251 deletions(-)

diff --git a/Hydraulic/Hydro.MapUI/Map/MapViewer.cs b/Hydraulic/Hydro.MapUI/Map/MapViewer.cs
index 1ef0769..8aa6812 100644
--- a/Hydraulic/Hydro.MapUI/Map/MapViewer.cs
+++ b/Hydraulic/Hydro.MapUI/Map/MapViewer.cs
@@ -1,12 +1,16 @@
 锘�//using CloudWaterNetwork.Magnifier;
+//using DevExpress.XtraEditors;
+using DevExpress.XtraEditors.Filtering;
 using Hydro.CommonBase;
-using Hydro.Inp;
+using Hydro.Core.Model;
+using Hydro.Core;
 //using ConfigApp;
 //using DevExpress.Diagram.Core.Layout;
 //using DevExpress.DirectX.NativeInterop.Direct2D;
 //using DevExpress.Utils.Extensions;
 //using dict_py_Inner;
 using Hydro.MapView;
+using Hydro.MapView.Base;
 using Hydro.MapView.Common;
 using Newtonsoft.Json;
 //using ReflectionManager_NameSpace;
@@ -16,20 +20,21 @@
 using System.ComponentModel;
 using System.Data;
 using System.Data.Common;
-using System.Diagnostics;
+//using System.Diagnostics;
 using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Numerics;
 using System.Reflection;
 using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Runtime.Remoting.Metadata;
+//using System.Runtime.InteropServices.WindowsRuntime;
+//using System.Runtime.Remoting.Metadata;
 using System.Security.Cryptography;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
-using System.Windows.Forms.DataVisualization.Charting;
+//using System.Windows.Forms.DataVisualization.Charting;
 //using static Hydro.Core.ObjectEnum;
 using static Hydro.MapView.MapViewEnum;
 using static System.Net.Mime.MediaTypeNames;
@@ -110,7 +115,9 @@
 
             this.showToolBar = showToolBar;
             InitializeComponent();
-
+            //var propertyForm = new PropertyForm();
+            //propertyForm.Dock = DockStyle.Right;
+            //this.Controls.Add(propertyForm);
             MapCenter = PointF.Empty;
             zoom = 1.0f;
             DoubleBuffered = true;
@@ -119,7 +126,7 @@
 
             //if (!showToolBar) this.panel1.Visible = false;
         }
-        public MapViewer() 
+        public MapViewer()
         {
 
             this.showToolBar = false;
@@ -127,13 +134,18 @@
 
             MapCenter = PointF.Empty;
             zoom = 1.0f;
-            
+
             SetStyle(ControlStyles.SupportsTransparentBackColor, true);
             BackColor = Color.Transparent;
 
         }
+        public void SetEditMode(bool isEditMode)
+        {
+            _IsEditMode = isEditMode;
+        }
         private void MapViewer_Load(object sender, EventArgs e)
         {
+            GlobalObject.PropertyForm = this.propertyForm;
             this.panel1.Visible = _showToolBar;
             this.statusStrip1.Visible = _showStatusBar;
 
@@ -161,10 +173,64 @@
 
             cb_Link_Colour.SelectedIndex = 0;
 
-            map.Init(TC,new DrawDelegate[] { Draw, Draw, DrawH },new MouseDelegate[] { mapMouseDown, mapMouseMove, mapMouseUp, mapMouseWheel });
+            map.Init(TC, new DrawDelegate[] { Draw, Draw, DrawBackGroud, DrawH }, new MouseDelegate[] { mapMouseDown, mapMouseMove, mapMouseUp, mapMouseWheel });
 
-            
 
+            TContainer TCCube = new TContainer();
+            TCCube.template = new Template();
+            TCCube.template.network = new MapViewNetWork();
+            TCCube.template.network.Areas = new List<AreaViewModel>();
+            Cube cb = new Cube();
+            foreach (var item in cb.FacesVertices)
+            {
+                AreaViewModel area = new AreaViewModel();
+                area.ID = item.Key.ToString();
+                area.InnerNodes = new List<NodeViewModel>();
+                //area.Name= item.Key.ToString();
+
+                //6涓潰璁剧疆涓嶄竴鏍风殑棰滆壊
+                switch (item.Key)
+                {
+                    case 1:
+                        area.color = Color.Red;
+                        area.Name = "鍙�";
+                        break;
+                    case 2:
+                        area.color = Color.SkyBlue;
+                        area.Name = "宸�";
+                        break;
+                    case 3:
+                        area.color = Color.Green;
+                        area.Name = "鍚�";
+                        break;
+                    case 4:
+                        area.color = Color.DarkBlue;
+                        area.Name = "鍓�";
+                        break;
+                    case 5:
+                        area.color = Color.Purple;
+                        area.Name = "涓�";
+                        break;
+                    case 6:
+                        area.color = Color.Orange;
+                        area.Name = "涓�";
+                        break;
+                    default:
+                        area.color = Color.White;
+                        break;
+                }
+
+                foreach (var p in item.Value)
+                {
+                    NodeViewModel node = new NodeViewModel();
+                    node.X = p.X;
+                    node.Y = p.Y;
+                    node.Elev = p.Z;
+                    area.InnerNodes.Add(node);
+                }
+                TCCube.template.network.Areas.Add(area);
+            }
+            CubeView.Init(TCCube, new DrawDelegate[] { Draw, Draw, DrawBackGroud, DrawH }, new MouseDelegate[] { CubeViewMouseDown, CubeViewMouseMove, CubeViewMouseUp, mapMouseWheel });
 
         }
 
@@ -175,7 +241,7 @@
 
         public bool LoadData(bool isDelCache = false)
         {
-            
+
             if (_Template == null) return false;
             if (isDelCache || _Template.network == null)
             {
@@ -252,7 +318,7 @@
             bool reLoad = _Template == template;
             this._Template = template;
             this._ViewModel = viewMode;
-            
+
 
             //if ( _Template?.Floors!=null)
             //{
@@ -295,7 +361,7 @@
                     SetMapInvalidate();
                 }
             }
-           
+
             鍒锋柊妤煎眰ToolStripMenuItem_Click(1, new EventArgs());
             label_center.Text = $"center锛�({MapCenter.X.ToString("0.00")} 锛寋MapCenter.Y.ToString("0.00")}锛�";
             label_zoom.Text = $"Zoom锛歿zoom.ToString("0.000")}";
@@ -377,8 +443,8 @@
 
         #region 閲嶇粯鍑芥暟
 
-        bool _needPaintAll 
-        { 
+        bool _needPaintAll
+        {
             get
             {
                 return __needpaintall;
@@ -388,141 +454,7 @@
                 __needpaintall = value;
             }
         }
-        //protected override void OnPaint(PaintEventArgs e)
-        //{
-        //    base.OnPaint(e);
 
-        //    if (float.IsInfinity(zoom)) return;
-
-        //    //label_center.Text = $"center锛�({MapCenter.X.ToString("0.00")} 锛寋MapCenter.Y.ToString("0.00")}锛�";
-        //    //label_zoom.Text = $"Zoom锛歿zoom.ToString("0.000")}";
-        //    //toolStripStatusLabel_rotation.Text = $"Rotation锛�({Rotation.ToString("0")}锛寋RotationF.ToString("0")})";
-
-        //    //if (!_needPaintAll)
-        //    //    return;
-        //    int heightOfBar = showToolBar ? 24 : 0;
-        //    if (!showToolBar) heightOfBar = 0;
-
-
-
-        //    if (e.ClipRectangle != new Rectangle(this.Left, heightOfBar, this.map.Width, this.map.Height - heightOfBar - statusStrip1.Height)) return;
-
-
-        //    _needPaintAll = false;
-        //    if (buffer == null || buffer.Width != Width || buffer.Height != Height)
-        //    {
-        //        buffer?.Dispose();
-        //        buffer = new Bitmap(Width, Height);
-        //    }
-        //    // 浣跨敤缂撳瓨缁樺埗锛岄伩鍏嶅湪姣忔閲嶇粯鏃堕噸鏂拌绠楁墍鏈夎缁樺埗鐨勫厓绱�
-
-        //    //if (bufferG == null) bufferG = Graphics.FromImage(buffer);
-        //    using (var bufferG = Graphics.FromImage(buffer))
-        //    //using (var bufferG = e.Graphics)
-        //    {
-        //        // 鍏堝皢鎺т欢鐨勮儗鏅~鍏呬负鐧借壊
-        //        bufferG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
-        //        bufferG.Clear(Color.Transparent);
-        //        bufferG.TranslateTransform(Width / 2, Height / 2);
-        //        bufferG.ScaleTransform(Zoom.X, Zoom.Y);
-        //        bufferG.TranslateTransform(-MapCenter.X, -MapCenter.Y);
-
-        //        //if (_NodeColour==null)
-        //        //{
-        //        //    cb_Node_Colour_SelectedIndexChanged(1, new EventArgs());
-        //        //}
-        //        //if (_LinkColour==null)
-        //        //{
-        //        //    cb_Link_Colour_SelectedIndexChanged(1, new EventArgs());
-        //        //}
-        //        //BookMark    锛氱粯鍒跺湴鍥句簨浠�
-        //        Draw(bufferG, _Template);
-
-
-
-        //        if (_newTemplate?.network != null) Draw(bufferG, _newTemplate);
-
-        //        var r = 2f / zoom;
-        //        if (_isDragging && DragStartPos!=new PointF(0,0) && mousePosition!=new PointF(0,0))
-        //        {
-        //            label_center.Text = $"S:{DragStartPos.X}:{DragStartPos.Y} E:{mousePosition.X}:{mousePosition.Y}"; 
-        //            var _lastMousePosition = DragStartPos;
-        //            // 缁樺埗鐭╁舰
-        //            var start = new PointF((float)Math.Min(mousePosition.X, _lastMousePosition.X), (float)Math.Min(mousePosition.Y, _lastMousePosition.Y));
-        //            var size = new SizeF((float)Math.Abs(_lastMousePosition.X - mousePosition.X), (float)Math.Abs(_lastMousePosition.Y - mousePosition.Y));
-        //            if (size.Width == 0) size.Width = 0.01f;
-        //            if (size.Height == 0) size.Height = 0.01f;
-        //            var rectangle0 = new RectangleF(start, size);
-        //            using (var pen = new Pen(Color.Black, 0.5f * r))
-        //            {
-        //                bufferG.DrawRectangles(pen, new RectangleF[] { rectangle0 });
-        //            }
-        //        }
-        //        if (_isPainting)
-        //        {
-        //            if (_mouseState == MouseState.鏂板绔嬬)
-        //            {
-        //                var wPos=GetZZWorldPoint(_select_junction1.Position3D, _MousePosition,new Vector3(0,0,1));
-        //                using (var pen = new Pen(Color.Black, 1 * r))
-        //                {
-        //                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
-        //                    bufferG.DrawLine(pen, WorldPointToMapPoint(_select_junction1), WorldPointToMapPoint(wPos));
-        //                }
-        //            }
-        //            else
-        //            {
-        //                using (var pen = new Pen(Color.Black, 1 * r))
-        //                {
-        //                    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
-        //                    bufferG.DrawLine(pen, WorldPointToMapPoint(_select_junction1), _MousePosition);
-        //                }
-        //            }
-        //        }
-        //        if (_isDrawingPolygon && polygonPoints.Count > 0)
-        //        {
-        //            List<PointF> pf = polygonPoints.ToList();
-        //            pf.Add(new PointF(mousePosition.X, mousePosition.Y));
-        //            using (var pen = new Pen(Color.Black, 1 * r))
-        //            {
-        //                // 缁樺埗澶氳竟褰㈣櫄绾胯竟妗�
-        //                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
-        //                bufferG.DrawLines(pen, pf.ToArray());
-        //            }
-        //        }
-        //        if (_isSettingBackGroundPictur)
-        //        {
-                   
-        //            var _lastMousePosition = DragStartPos;
-        //            // 缁樺埗鐭╁舰
-        //            var start = new PointF((float)Math.Min(mousePosition.X, _lastMousePosition.X), (float)Math.Min(mousePosition.Y, _lastMousePosition.Y));
-        //            var size = new SizeF((float)Math.Abs(_lastMousePosition.X - mousePosition.X), (float)Math.Abs(_lastMousePosition.Y - mousePosition.Y));
-        //            var rectangle0 = new RectangleF(start, size);
-        //            using (var pen = new Pen(Color.Black, 1 * r))
-        //            {
-        //                bufferG.DrawRectangles(pen, new RectangleF[] { rectangle0 });
-        //            }
-        //        }
-
-        //        if (_isMovingObject)
-        //        {
-        //            var newP = _MousePosition;
-        //            //var p = MapPointToWorldPoint(, _OperaNode.Elev);
-        //            var oldP3D = (PointF3D)_undoOldValue;
-        //            var oldP = WorldPointToMapPoint(new PointF(oldP3D.X, oldP3D.Y), oldP3D.Z);
-        //            List<PointF> pf = new List<PointF> { oldP, newP };
-        //            using (var pen = new Pen(Color.Black, 1 * r))
-        //            {
-        //                // 缁樺埗澶氳竟褰㈣櫄绾胯竟妗�
-        //                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
-        //                bufferG.DrawLines(pen, pf.ToArray());
-        //            }
-        //        }
-
-        //    }
-        //    // 灏嗙敓鎴愮殑鐢诲竷缁樺埗鍒版帶浠朵笂
-        //    e.Graphics.DrawImage(buffer, 0, 0);
-
-        //}
 
         PointF[] getCurclePoints(int num)
         {
@@ -539,17 +471,21 @@
             return points;
         }
 
-        
-           
 
-       
-        
+
+
+
+
         private void timer_draw_Tick(object sender, EventArgs e)
         {
             _mouseHoverCheckFlag = true;
-            if (_timerDraw)
+            if (_timerDraw && map.Status == DrawingStatus.Ready)
+            {
                 this.map.Invalidate();
-            _timerDraw = false;
+                this.CubeView.Invalidate();
+                _timerDraw = false;
+            }
+
         }
 
         protected override void OnResize(EventArgs e)
@@ -565,13 +501,13 @@
 
 
         #region 榧犳爣浜嬩欢
-        
+
         void mapMouseDown(MouseEventArgs e)
         {
             base.OnMouseDown(e);
 
             _ClickStartPos = new PointF(e.X, e.Y);
-            DragStartPos= ScreenToMap(new PointF(e.X, e.Y));
+            DragStartPos = ScreenToMap(new PointF(e.X, e.Y));
             mousePosition = _MousePosition = ScreenToMap(new PointF(e.X, e.Y));
             if (e.Button == MouseButtons.Left && _isInsertingObject)
             {
@@ -623,7 +559,7 @@
                 }
 
                 //绉诲姩
-                if (selectedObjs.Count >= 1) //&& selectedObjs[0].isNode())
+                if (_IsEditMode && selectedObjs.Count >= 1) //&& selectedObjs[0].isNode())
                 {
                     List<NodeViewModel> nodes = selectedNodes;
                     foreach (NodeViewModel node in nodes)
@@ -752,7 +688,7 @@
                 //    Math.Abs((int)DragStartPos.Y - (int)MP.Y));
                 //DrawSelectionRect(selectionRect);
                 needInvalidate = true;
-                 
+
             }
             else if (_isRotating)
             {
@@ -786,7 +722,7 @@
                 // 閬嶅巻鎵�鏈夊璞�,鎵惧嚭鑼冨洿鍐呯殑瀵硅薄
                 PointF clickedPoint = new PointF(e.X, e.Y);  //ScreenToMap(new PointF(e.X, e.Y));
                 var obj = GetObj_by_ScreenPoint(clickedPoint);
-                if (hoveredObjs.Count > 0 && hoveredObjs[0] == obj || hoveredObjs.Count==0 && obj==null)
+                if (hoveredObjs.Count > 0 && hoveredObjs[0] == obj || hoveredObjs.Count == 0 && obj == null)
                 {
                     //needInvalidate = false;
                 }
@@ -795,18 +731,18 @@
                     needInvalidate = true;
                     hoveredObjs.ForEach(o => o.Hovered = false);
                     hoveredObjs.Clear();
-                    if (obj!=null)
+                    if (obj != null)
                     {
                         obj.Hovered = true;
                         hoveredObjs.Add(obj);
                     }
-                    
-                   
+
+
                 }
-                
+
 
             }
-            
+
 
 
             if (needInvalidate) this.SetMapInvalidate();
@@ -932,7 +868,8 @@
             }
             if  /*鎻掑叆缁撴瀯*/(e.Button == MouseButtons.Left && _isInsertingObject)
             {
-                var net = _newTemplate.network;
+                var net = _newTemplate.network;//clone
+                var net0 = _newTemplate.network.DeepCopyByBin<MapViewNetWork>();
                 List<NodeViewModel> nodes = _Nodes.Select(node => (NodeViewModel)node).ToList();
                 float minDist = 100f;
                 NodeViewModel minNode = null;
@@ -957,7 +894,7 @@
 
                     var p1 = (PointF3D)_undoOldValue;
                     var p2 = minNode.Position3D;
-                    var dd = _newTemplate.OffSet;
+                    //var dd = _newTemplate.OffSet;
                     dx = p2.X - p1.X;
                     dy = p2.Y - p1.Y;
                     dz = p2.Z - p1.Z;
@@ -988,7 +925,7 @@
                 var list = _Network.Add(net);
 
                 var j = _Network.AddPipe(minNode, _OperaNode);
-                j.Length = 0.0001f;
+                //j.Length = 0.0001f;
                 list.Add(j);
                 _OperaNode = null;
                 _NewNet.Clear();
@@ -1002,12 +939,18 @@
                 selectedObjs.AddRange(list);
 
                 MapObjectExtensions.AddCommand(_Network, "Add", null, list);
+
+
+
                 _isInsertingObject = false;
 
-                //_OperaNode = null;
-                //_Network.Nodes.AddRange(net.Nodes);
-                //_Network.Links.AddRange(net.Links);
-            
+
+
+                _newTemplate.network = net0;
+                _isInsertingObject = true;
+                _undoOldValue = new PointF3D(0, 0, 0);
+                _OperaNode = _newTemplate.network.Nodes.Find(node => node.ID == _newTemplate.Node1) as NodeViewModel;
+
                 SetMapInvalidate();
                 return;
             }
@@ -1077,7 +1020,7 @@
                     var l = new List<IBaseViewModel>();
                     l.Add(_Network.AddPipe(_OperaNode, minNode));
                     if (l.Count > 0) MapObjectExtensions.AddCommand(_Network, "Add", null, l);
-                   
+
                     _OperaNode = null;
                     _NewNet.Clear();
                 }
@@ -1152,7 +1095,7 @@
                     case MouseState.鏂板缓閲嶅鍣�:
                         if (_select_junction1 == null)
                         {
-                            if (_mouseState==MouseState.鏂板绔嬬)
+                            if (_mouseState == MouseState.鏂板绔嬬)
                             {
                                 var m = ScreenToVMap(new PointF(e.X, e.Y));
                                 z = m.Y;
@@ -1164,19 +1107,19 @@
                                 getPointAndHeight(e, out p, out z);
                                 Set_junction1(e);
                             }
-                            
+
                         }
                         else
                         {
                             if (_mouseState == MouseState.鏂板绔嬬)
                             {
                                 //闇�瑕佹妸榧犳爣浣嶇疆杞崲涓虹珛绠$殑浣嶇疆锛岃幏鍙栭紶鏍囦綅缃殑楂樼▼
-                                
+
                                 var wPos = GetZZWorldPoint(_select_junction1.Position3D, _MousePosition, new Vector3(0, 0, 1));
                                 //var m = ScreenToVMap(new PointF(e.X, e.Y));
                                 //z = m.Y;
                                 p = new PointF(wPos.X, wPos.Y);
-                                var l = AddLink(new PointF( e.X,e.Y), true, p, wPos.Z);
+                                var l = AddLink(new PointF(e.X, e.Y), isdoubleClick, p, wPos.Z);
                                 if (l.Count > 0) MapObjectExtensions.AddCommand(_Network, "Add", null, l);
                             }
                             else
@@ -1191,14 +1134,14 @@
                                 }
                                 else
                                 {
-                                    getPointAndHeight(e, _select_junction1, out p, out z);                                  
-                                    var l = AddLink(new PointF(e.X, e.Y), isdoubleClick, p,z);
+                                    getPointAndHeight(e, _select_junction1, out p, out z);
+                                    var l = AddLink(new PointF(e.X, e.Y), isdoubleClick, p, z);
                                     if (l.Count > 0) MapObjectExtensions.AddCommand(_Network, "Add", null, l);
                                 }
-                                
+
 
                             }
-                            
+
                         }
                         break;
                 }
@@ -1466,8 +1409,11 @@
                     if (!isMouseMoved)
                     {
                         鍙抽敭_Menu.Show(this, e.Location);
+
                         杞崲涓篢oolStripMenuItem.Enabled = selectedNodes.Count > 0; //(selectedObjs.Count == 1);
                         鍒犻櫎ToolStripMenuItem.Enabled = selectedObjs.Count > 0;
+                        鍒犻櫎ToolStripMenuItem1.Enabled = selectedObjs.Count > 0;
+
                     }
 
                     if (recordView) MapObjectExtensions.AddCommand(mapOption, "Map", mapOption0, mapOption);
@@ -1508,7 +1454,7 @@
         IBaseViewModel GetObj_by_ScreenPoint(PointF clickedPoint, float DistLimit = 15f)
         {
             float minDist = float.MaxValue;
-           
+
             int minIndex = -1;
             bool isJunction = true;
             IBaseViewModel obj = null;
@@ -1557,9 +1503,9 @@
             float minDist = float.MaxValue;
 
             int minIndex = -1;
-       
+
             IBaseViewModel obj = null;
-            List < IBaseViewModel > objs = new List<IBaseViewModel>();
+            List<IBaseViewModel> objs = new List<IBaseViewModel>();
             for (int i = 0; i < _Nodes.Count; i++)
             {
                 var node = _Nodes[i] as NodeViewModel;
@@ -1588,7 +1534,7 @@
                 //float dist = Get_dist(clickedPoint, currentPoint);
                 if (dist < minDist && dist <= DistLimit)
                 {
-                    
+
 
                     objs.Add(link);
                 }
@@ -1615,6 +1561,196 @@
         private int _lastMouseX;
         private int _lastMouseY;
         #endregion
+
+
+        #region CubeView榧犳爣浜嬩欢
+        void CubeViewMouseDown(MouseEventArgs e)
+        {
+            base.OnMouseDown(e);
+
+            _ClickStartPos = new PointF(e.X, e.Y);
+            DragStartPos = ScreenToMap(new PointF(e.X, e.Y));
+            mousePosition = _MousePosition = ScreenToMap(new PointF(e.X, e.Y));
+            if (e.Button == MouseButtons.Left && _isInsertingObject)
+            {
+
+            }
+            else if (e.Button == MouseButtons.Left && _mouseState == MouseState.鏃�)
+            {
+
+            }
+
+            else if (e.Button == MouseButtons.Left && _mouseState == MouseState.璁剧疆搴曞浘鑼冨洿)
+            {
+
+            }
+            else if (e.Button == MouseButtons.Right)
+            {
+                RotaStartPos = new PointF(e.X, e.Y);
+                Rotation0 = Rotation;
+                淇瑙掑害_start = RotationF;
+                _lastCursor = this.Cursor;
+
+                Cursor = Cursors.Hand;
+                mapOption0 = mapOption.Copy();
+                _isRotating = true;
+            }
+
+        }
+        void CubeViewMouseMove(MouseEventArgs e)
+        {
+            //base.OnMouseMove(e);
+            bool needInvalidate = false;
+            _MousePosition = ScreenToMap(new PointF(e.X, e.Y));
+
+
+            if (_isRotating)
+            {
+                mousePosition = _MousePosition;
+                bool is涓嬪崐灞忓箷 = RotaStartPos.Y >= this.map.Height / 2;
+                if (ModifierKeys != Keys.Alt) Rotation = Rotation0 + ((float)e.X - (float)RotaStartPos.X) * 180 * 2.5 / (float)this.map.Width * (is涓嬪崐灞忓箷 ? 1 : 1);
+                if (ModifierKeys != Keys.Shift) RotationF = 淇瑙掑害_start + ((float)e.Y - (float)RotaStartPos.Y) * 180 * 2.5 / (float)this.map.Height;
+                if (RotationF > 90) RotationF = 90;
+                if (RotationF < 0) RotationF = 0;
+                needInvalidate = true;
+
+            }
+
+            //else
+            /*鍒ゆ柇鏄惁瑙︾鍒板璞�*/
+            if (_mouseHoverCheckFlag)
+            {
+                _mouseHoverCheckFlag = false;
+                // 閬嶅巻鎵�鏈夊璞�,鎵惧嚭鑼冨洿鍐呯殑瀵硅薄
+                PointF clickedPoint = new PointF(e.X, e.Y);  //ScreenToMap(new PointF(e.X, e.Y));
+                var obj = GetObj_by_ScreenPoint(clickedPoint);
+                if (hoveredObjs.Count > 0 && hoveredObjs[0] == obj || hoveredObjs.Count == 0 && obj == null)
+                {
+                    //needInvalidate = false;
+                }
+                else
+                {
+                    needInvalidate = true;
+                    hoveredObjs.ForEach(o => o.Hovered = false);
+                    hoveredObjs.Clear();
+                    if (obj != null)
+                    {
+                        obj.Hovered = true;
+                        hoveredObjs.Add(obj);
+                    }
+
+
+                }
+
+
+            }
+
+
+
+            if (needInvalidate) this.SetMapInvalidate();
+            label_mouse.Text = $"X锛歿e.X.ToString("0")} Y锛歿e.Y.ToString("0")} [Map]X锛歿_MousePosition.X.ToString("0.00")} Y锛歿_MousePosition.Y.ToString("0.00")}";
+            _lastMouseX = e.X;
+            _lastMouseY = e.Y;
+        }
+        void CubeViewMouseUp(MouseEventArgs e)
+        {
+            //BookMark    锛氶紶鏍囨姮璧蜂簨浠�
+            base.OnMouseUp(e);
+            bool isMouseMoved = Get_dist(_ClickStartPos, new PointF(e.X, e.Y)) > 10;
+            bool isdoubleClick = (DateTime.Now - _lastMouseUp).TotalMilliseconds <= doubleClick_Delay;
+            _lastMouseUp = DateTime.Now;
+
+            if /*鐐归��*/(!isMouseMoved && _mouseState == MouseState.鏃� && e.Button == MouseButtons.Left && ModifierKeys == Keys.None)
+            {
+                _isDragging = false;
+
+                // 閬嶅巻鎵�鏈夌偣锛屾壘鍑烘渶杩戠殑鐐�
+                PointF clickedPoint = new PointF(e.X, e.Y);  //ScreenToMap(new PointF(e.X, e.Y));
+                var obj = GetObj_by_ScreenPoint(clickedPoint);
+                bool isJunction = obj is NodeViewModel;
+
+                if (obj != null)
+                {
+                    selectedObjs.ForEach(o => o.Selected = false);
+                    selectedObjs.Clear();
+                    obj.Selected = true;
+                    selectedObjs.Add(obj);
+                    if (GlobalObject.PropertyForm != null)
+                        GlobalObject.PropertyForm.SetObjs(selectedObjs);
+                    _OperaNode = null;
+
+
+                    SetMapInvalidate();
+                    mousePosition = new PointF(0, 0);
+
+
+                }
+                else
+                {
+                    //GlobalObject.LockSelect
+
+                    selectedObjs.ForEach(o => o.Selected = false);
+                    selectedObjs.Clear();
+                    if (GlobalObject.PropertyForm != null)
+                        GlobalObject.PropertyForm.SetObjs(selectedObjs);
+
+                    _OperaNode = null;
+
+                    SetMapInvalidate();
+                }
+                return;
+
+
+            }
+
+            if (/*鍙犲姞鐐归��*/!isMouseMoved && _mouseState == MouseState.鏃� && e.Button == MouseButtons.Left && ModifierKeys == Keys.Control)
+            {
+                _isDragging = false;
+
+                // 閬嶅巻鎵�鏈夌偣锛屾壘鍑烘渶杩戠殑鐐�
+                PointF clickedPoint = new PointF(e.X, e.Y);  //ScreenToMap(new PointF(e.X, e.Y));
+                var obj = GetObj_by_ScreenPoint(clickedPoint);
+                bool isJunction = obj is NodeViewModel;
+                if (obj != null)
+                {
+                    if (selectedObjs.Contains(obj))
+                    {
+                        obj.Selected = false;
+                        selectedObjs.Remove(obj);
+                        if (GlobalObject.PropertyForm != null)
+                            GlobalObject.PropertyForm.SetObjs(selectedObjs);
+
+                        SetMapInvalidate();
+                        mousePosition = new PointF(0, 0);
+                    }
+                    else
+                    {
+                        obj.Selected = true;
+                        selectedObjs.Add(obj);
+                        if (GlobalObject.PropertyForm != null)
+                            GlobalObject.PropertyForm.SetObjs(selectedObjs);
+                        SetMapInvalidate();
+                        mousePosition = new PointF(0, 0);
+                    }
+                }
+                return;
+            }
+
+            if (e.Button == MouseButtons.Right)
+            {
+                if (_isRotating)
+                {
+                    _isRotating = false;
+                    this.Cursor = _lastCursor;
+
+
+                    if (recordView) MapObjectExtensions.AddCommand(mapOption, "Map", mapOption0, mapOption);
+                    mousePosition = new PointF(0, 0);
+                }
+            }
+        }
+        #endregion
+
 
         #endregion 涓�銆佸叏灞�
 
@@ -1694,10 +1830,10 @@
         }
         private void 榛樿瑙嗚ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-       
+
 
             mapOption0 = mapOption.Copy();
-            
+
             InitCenter();
             RotationF = 45;
             Rotation = -45;
@@ -1820,8 +1956,8 @@
             {
                 _Template = new Template();
                 _Template.network = new MapViewNetWork();
-               
-                
+
+
                 //_Template.network.use_old = false;
                 // 鑾峰彇閫変腑鏂囦欢鐨勬枃浠惰矾寰�
                 string filePath = openFileDialog.FileName;
@@ -1861,7 +1997,7 @@
         {
             if (_filePath == null) return;
             FileInfo fi = new FileInfo(_filePath);
-            Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
+            System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
             //System.Diagnostics.Process.Start("explorer.exe", fi.Directory.FullName);
         }
         private void EPA涓墦寮�ToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1869,7 +2005,7 @@
             if (_filePath == null) return;
 
 
-            Process.Start(@"epanetH\Epanet2wH.exe", _filePath);
+            System.Diagnostics.Process.Start(@"epanetH\Epanet2wH.exe", _filePath);
         }
         private void 淇濆瓨ToolStripMenuItem_Click(object sender, EventArgs e)
         {
@@ -1911,7 +2047,7 @@
         #region 缁樺浘宸ュ叿
 
 
-        
+
         public void toolStripButton_鏂板缓鑺傜偣_Click(object sender, EventArgs e)
         {
             _mouseState = MouseState.鏂板鑺傜偣;
@@ -1922,6 +2058,55 @@
         {
             _mouseState = MouseState.鏃�;
             Cursor = Cursors.Default;
+            if (_isPainting)
+            {
+                _select_junction1 = null;
+                _isPainting = false;
+                SetMapInvalidate();
+            }
+            else if (_isDragging)
+            {
+                _isDragging = false;
+                SetMapInvalidate();
+            }
+            else if (_isPanning)
+            {
+                _isPanning = false;
+                SetMapInvalidate();
+            }
+            else if (_isRotating)
+            {
+                Rotation = Rotation0;
+                _isRotating = false;
+                SetMapInvalidate();
+            }
+            else if (_isMovingObject)
+            {
+                _NewNet.Clear();
+                _isMovingObject = false;
+                SetMapInvalidate();
+            }
+            else if (_mouseState != MouseState.鏃�)
+            {
+                _mouseState = MouseState.鏃�;
+                Cursor = Cursors.Default;
+            }
+            else if (_isInsertingObject)
+            {
+                _NewNet.Clear();
+                _isInsertingObject = false;
+                _OperaNode = null;
+                SetMapInvalidate();
+            }
+            else
+            {
+                _Nodes.ForEach(o => ((NodeViewModel)o).Selected = false);
+                _Links.ForEach(o => ((LinkViewModel)o).Selected = false);
+                selectedObjs.Clear();
+                SetMapInvalidate();
+
+
+            }
         }
 
         public void toolStripButton_鏂板缓绠$嚎_Click(object sender, EventArgs e)
@@ -1929,7 +2114,7 @@
             _mouseState = MouseState.鏂板绠$嚎;
             Cursor = Cursors.Cross;
         }
-        public void toolStripButton_鏂板缓绔嬬_Click(object sender,EventArgs e)
+        public void toolStripButton_鏂板缓绔嬬_Click(object sender, EventArgs e)
         {
             _mouseState = MouseState.鏂板绔嬬;
             Cursor = Cursors.Cross;
@@ -1952,7 +2137,7 @@
                     l.Add(_select_junction2);
                 }
 
-                if (_mouseState == MouseState.鏂板绠$嚎 || _mouseState==MouseState.鏂板绔嬬)
+                if (_mouseState == MouseState.鏂板绠$嚎 || _mouseState == MouseState.鏂板绔嬬)
                     l.Add(_Network.AddPipe(_select_junction1, _select_junction2));
                 else if (_mouseState == MouseState.鏂板缓闃�闂�)
                     l.Add(_Network.AddValve(_select_junction1, _select_junction2));
@@ -2015,7 +2200,7 @@
         }
 
         bool Buzylock = false;
-        private void MapViewer_KeyDown(object sender, KeyEventArgs e)
+        public void MapViewer_KeyDown(object sender, KeyEventArgs e)
         {
 
             if (e.KeyCode == Keys.Escape)
@@ -2073,7 +2258,7 @@
 
 
             }
-            if (e.KeyCode == Keys.Delete)
+            if (_IsEditMode && e.KeyCode == Keys.Delete)
             {
                 DeleteChoosedObj();
             }
@@ -2085,29 +2270,29 @@
                 SetMapInvalidate();
             }
 
-            if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
             {
                 澶嶅埗ToolStripMenuItem_Click(1, new EventArgs());
             }
-            if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
             {
                 _ClickStartPos = Cursor.Position;
                 绮樿创ToolStripMenuItem1_Click(1, new EventArgs());
             }
-            if (e.KeyCode == Keys.D1 && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.D1 && e.Modifiers == Keys.Control)
             {
                 鍗楀寳瀵归綈ToolStripMenuItem_Click(1, new EventArgs());
 
             }
-            if (e.KeyCode == Keys.Oemtilde && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.Oemtilde && e.Modifiers == Keys.Control)
             {
                 涓滆タ瀵归綈ToolStripMenuItem_Click(1, new EventArgs());
             }
-            if (e.KeyCode == Keys.D2 && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.D2 && e.Modifiers == Keys.Control)
             {
                 绔栫洿瀵归綈ToolStripMenuItem_Click(1, new EventArgs());
             }
-            if (e.KeyCode == Keys.D3 && e.Modifiers == Keys.Control)
+            if (_IsEditMode && e.KeyCode == Keys.D3 && e.Modifiers == Keys.Control)
             {
                 鑷姩瀵归綈ToolStripMenuItem_Click(1, new EventArgs());
             }
@@ -2117,7 +2302,7 @@
 
         private void MapViewer_KeyPress(object sender, KeyPressEventArgs e)
         {
-            if (ctrlPressed && e.KeyChar == 'Z' - 64)
+            if (_IsEditMode && ctrlPressed && e.KeyChar == 'Z' - 64)
             {
                 // 鎵ц鐩稿簲鐨勬搷浣�
                 buttonUndo_Click(sender, e);
@@ -2126,7 +2311,7 @@
                 // 闃叉榛樿鎿嶄綔
                 e.Handled = true;
             }
-            if (ctrlPressed && e.KeyChar == 'Y' - 64)
+            if (_IsEditMode && ctrlPressed && e.KeyChar == 'Y' - 64)
             {
                 // 鎵ц鐩稿簲鐨勬搷浣�
                 buttonRedo_Click(sender, e);
@@ -2147,14 +2332,14 @@
         }
         private void MapViewer_PreKeyPress(object sender, PreviewKeyDownEventArgs e)
         {
-            if (e.Control && e.KeyCode == Keys.Z)
+            if (_IsEditMode && e.Control && e.KeyCode == Keys.Z)
             {
                 ctrlPressed = true;
                 // 闃叉榛樿鎿嶄綔
                 e.IsInputKey = true;
 
             }
-            if (e.Control && e.KeyCode == Keys.Y)
+            if (_IsEditMode && e.Control && e.KeyCode == Keys.Y)
             {
                 ctrlPressed = true;
                 // 闃叉榛樿鎿嶄綔
@@ -2302,7 +2487,7 @@
         {
             _IsEditMode = !_IsEditMode;
             //toolStripComboBox_娴忚妯″紡.Text = isEditMode ? "缂栬緫妯″紡" : "娴忚妯″紡";
-            LoadData(true);
+            //LoadData(true);
         }
 
         private void 娴忚妯″紡ToolStripMenuItem_Click(object sender, EventArgs e)
@@ -2310,7 +2495,7 @@
             var obj = sender as ToolStripItem;
             _IsEditMode = obj.Text == "缂栬緫妯″紡";
             //toolStripComboBox_娴忚妯″紡.Text = isEditMode ? "缂栬緫妯″紡" : "娴忚妯″紡";
-            LoadData(true);
+            //LoadData(true);
         }
         #endregion
 
@@ -2464,7 +2649,7 @@
 
         private void 缂╂斁ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-          
+
             var objs = GlobalObject.PropertyForm.selectionSet.selectedObjects;
             var list = objs.FindAll(o => o is NodeViewModel); //GlobalObject.PropertyForm.listBox1.SelectedItems;
             if (list.Count <= 0) return;
@@ -2538,12 +2723,199 @@
         }
 
 
-        
+        private void btn_鍒濆垎閰峗Click(object sender, EventArgs e)
+        {
+            //string result = null;
+            //if ((result=_Template.network.CheckValidate())!=null)
+            //{
+            //    MessageBox.Show(result);
+            //    return;
+            //}
+            List<WaterEquivalentSettings> settings = new List<WaterEquivalentSettings>();
+            settings.Add(new WaterEquivalentSettings()
+            {
+                waterEquivalents = new WaterEquivalentTemplate()
+                {
+                    ID = "1",
+                    Name = "1",
+                    WaterEquivalentCollection = new WaterEquivalentCollection()
+                    {
+                        new WaterEquivalent()
+                        {
+                            ID=1008,
+                            MinRatedFlow=0.48f,
+                            RatedFlow=0.72f,
+                            Count=1,
+                        },
+                        new WaterEquivalent()
+                        {
+                            ID=1009,
+                            MinRatedFlow=0.88f,
+                            RatedFlow=0.96f,
+                            Count=2,
+                        },
+                        new WaterEquivalent()
+                        {
+                            ID=1010,
+                            MinRatedFlow=1.08f,
+                            RatedFlow=1.08f,
+                            Count=3,
+                        }
+                    }
+                },
+                Meters = new List<string>()
+                {
+                    //鎸変互涓嬭寰嬬敓鎴愭暟缁勫埌M10锛�"M1","M2"
+
+                        "M1","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12","M13","M14","M15","M16",
+                    "M17","M18","M19","M20","M21","M22","M23","M24","M25","M26","M27","M28","M29","M30"
+                },
+            });
+
+
+            settings.Add(new WaterEquivalentSettings()
+            {
+                waterEquivalents = new WaterEquivalentTemplate()
+                {
+                    ID = "1",
+                    Name = "1",
+                    WaterEquivalentCollection = new WaterEquivalentCollection()
+                    {
+                        new WaterEquivalent()
+                        {
+                            ID=2008,
+                            MinRatedFlow=0.48f,
+                            RatedFlow=0.48f,
+                            Count=1,
+                        },
+                        new WaterEquivalent()
+                        {
+                            ID=2009,
+                            MinRatedFlow=0.12f,
+                            RatedFlow=0.12f,
+                            Count=5,
+                        },
+                        new WaterEquivalent()
+                        {
+                            ID=2010,
+                            MinRatedFlow=0.16f,
+                            RatedFlow=0.18f,
+                            Count=6,
+                        }
+                    }
+                },
+                Meters = new List<string>()
+                {
+                    //鎸変互涓嬭寰嬬敓鎴愭暟缁勫埌M10锛�"M1","M2"
+
+                       "M31","M32","M33","M34","M35","M36","M37","M38","M39","M40","M41","M42","M43","M44","M45","M46","M47","M48","M49","M50","M51","M52","M53","M54","M55","M56","M57","M58","M59","M60","M61","M62","M63","M64","M65","M66","M67","M68","M69","M70","M71","M72","M73","M74","M75","M76","M77","M78","M79","M80"
+                },
+            });
+            var head = _Network.reservoirs.FirstOrDefault().Head;
+            _Network.WaterDistribution(_Template.FullPath, GlobalPath.configPath + "config_waterDistri.wdb", settings, 40, head);
+
+        }
+        private void btn_鎷撴墤妫�鏌Click(object sender, EventArgs e)
+        {
+            Dictionary<string, List<string>> result = _Template.network.CheckValidate();
+            if (result.Count > 0)
+            {
+                //ListBox listBox2 = new ListBox();
+                //listBox2.Dock = DockStyle.Fill;
+                ////listBox2鐨刬tem涓轰粈涔堟樉绀轰笉鍑烘潵锛�
+
+                //listBox2.SelectedIndexChanged += (s, e) =>
+                //{
+                //    if (listBox2.SelectedIndex >= 0)
+                //    {
+                //        List<IBaseViewModel> Objs = new List<IBaseViewModel>();
+                //        Objs.AddRange(_Nodes.Select(n=>(NodeViewModel)n));
+                //        Objs.AddRange(_Links.Select(l => (LinkViewModel)l));
+                //        var obj = Objs.Find(o => o.ID == listBox2.SelectedItem.ToString());
+                //        if (obj != null)
+                //        {
+                //            obj.Selected = true;
+                //            selectedObjs.Add((NodeViewModel)obj);
+
+                //            SetMapInvalidate();
+                //        }
+
+                //    }
+                //};
+                ListBox listBox1 = new ListBox();
+                listBox1.Dock = DockStyle.Fill;
+                listBox1.Width = 200;
+                listBox1.Height = 400;
+                listBox1.Items.AddRange(result.Keys.ToArray());
+                listBox1.SelectedIndexChanged += (s, e) =>
+                {
+                    //listBox2.Items.Clear();
+                    if (listBox1.SelectedIndex >= 0)
+                    {
+                        var arr = result[listBox1.SelectedItem.ToString()].ToHashSet();
+
+                        List<IBaseViewModel> Objs = new List<IBaseViewModel>();
+                        Objs.AddRange(_Nodes.Select(n => (NodeViewModel)n));
+                        Objs.AddRange(_Links.Select(l => (LinkViewModel)l));
+                        var nodes = _Nodes.FindAll(o => arr.Contains(o.ID));
+                        var links = _Links.FindAll(o => arr.Contains(o.ID));
+                        //listBox2.Items.AddRange(result[listBox1.SelectedItem.ToString()].ToArray());
+                        selectedObjs.ForEach(obj => obj.Selected = false);
+                        selectedObjs.Clear();
+                        nodes.ForEach(obj =>
+                        {
+                            obj.Selected = true;
+                            selectedObjs.Add((NodeViewModel)obj);
+                        });
+                        links.ForEach(obj =>
+                        {
+                            obj.Selected = true;
+                            selectedObjs.Add((LinkViewModel)obj);
+                        });
+                        if (GlobalObject.PropertyForm != null)
+                            GlobalObject.PropertyForm.SetObjs(selectedObjs);
+                        SetMapInvalidate();
+                    }
+                };
+
+
+                Form ResultForm = new Form();
+                ResultForm.Text = "鎷撴墤妫�鏌ョ粨鏋�";
+                ResultForm.Width = 300;
+                ResultForm.Height = 400;
+                ResultForm.StartPosition = FormStartPosition.CenterScreen;
+                ResultForm.Controls.Add(listBox1);
+                ResultForm.MinimizeBox = false;
+                ResultForm.MaximizeBox = false;
+                //ResultForm.Controls.Add(listBox2);
+                //listBox2.Invalidate();
+                ResultForm.Show();
+
+                //鏂板缓涓�涓獥鍙o紝鏄剧ず妫�鏌ョ粨鏋�
+                //CheckForm checkForm = new CheckForm();
+                //checkForm.Show();
+            }
+            else
+            {
+                MessageBox.Show("鎷撴墤妫�鏌ラ�氳繃");
+            }
+            //if (!string.IsNullOrEmpty(result))
+            //{
+            //    MessageBox.Show(result);
+            //    return;
+            //}
+
+
+        }
 
         public void toolStripButton_璁$畻_Click(object sender, EventArgs e)
         {
-            //LoadData();
-            _Network.Calc(_Template.FullPath, GlobalPath.configPath+ "config_calc.wdb");
+            if (_Template == null)
+            {
+                MessageBox.Show("璇峰厛鎵撳紑鏂囦欢");
+                return;
+            }
+            _Network.Calc(_Template.FullPath, GlobalPath.configPath + "config_calc.wdb");
         }
 
         public void 鍏抽榾鎼滅储ToolStripMenuItem_Click(object sender, EventArgs e)
@@ -2819,7 +3191,7 @@
 
         //    }
         //}
-        private void TraversePipeNetworkALL(LinkViewModel startLink, HashSet<NodeViewModel> visitedNodes = null,int direction=0)
+        private void TraversePipeNetworkALL(LinkViewModel startLink, HashSet<NodeViewModel> visitedNodes = null, int direction = 0)
         {
 
             Queue<LinkViewModel> queue = new Queue<LinkViewModel>();
@@ -3204,6 +3576,59 @@
             }
         }
 
+        /// <summary>
+        /// 鎵归噺涓�閿敓鎴愭ゼ灞傛ā鍨�
+        /// </summary>
+        public void BatchInsertNet(Template temp)
+        {
+            var nodes = _Nodes.Where(c => c.Elev > 0).Select(node => (NodeViewModel)node).ToList();
+            _undoOldValue = new PointF3D(0, 0, 0);
+            _OperaNode = temp.network.Nodes.Find(node => node.ID == temp.Node1) as NodeViewModel;
+            //foreach (var item in nodes)
+            if (nodes.Any())
+            {
+                for (var i = 0; i < nodes.Count(); i++)
+                {
+                    var net = temp.network.DeepCopy();
+
+                    float dx, dy, dz;
+                    var p1 = (PointF3D)_undoOldValue;
+                    var p2 = nodes[i].Position3D;
+                    var dd = temp.OffSet;
+                    dx = p2.X - p1.X;
+                    dy = p2.Y - p1.Y;
+                    dz = p2.Z - p1.Z;
+
+                    net.Nodes.ForEach(n => { ((NodeViewModel)n).Position3D = new PointF3D(n.X + dx, n.Y + dy, n.Elev + dz); });
+
+                    var list = _Network.Add(net);
+
+                    //var j = _Network.AddPipe(nodes[i], _OperaNode);
+                    //j.Length = 0.0001f;
+                    //list.Add(j);
+                    _NewNet.Clear();
+
+                    _Network.BuildRelation();
+
+                    selectedObjs.ForEach(o => o.Selected = false);
+                    selectedObjs.Clear();
+
+                    //list.ForEach(m => m.Selected = true);
+                    //selectedObjs.AddRange(list);
+
+                    MapObjectExtensions.AddCommand(_Network, "Add", null, list);
+                }
+
+                _OperaNode = null;
+
+                //_OperaNode = null;
+                //_Network.Nodes.AddRange(net.Nodes);
+                //_Network.Links.AddRange(net.Links);
+
+                SetMapInvalidate();
+            }
+        }
+
         private void 浠ュ綋鍓嶈瑙掑彟瀛楾oolStripMenuItem_Click(object sender, EventArgs e)
         {
             if (_Template == null) return;
@@ -3263,7 +3688,7 @@
             {
 
                 var objs = selectedObjs.FindAll(o => o is LinkViewModel).Select(o => o as LinkViewModel).ToList();
-                if (objs.Count == 0) selectedObjs.FindAll(o => o is NodeViewModel).Select(o => o as NodeViewModel).ToList().ForEach(o=>objs.AddRange(o.Links.Select(l=>l as LinkViewModel).ToList()));
+                if (objs.Count == 0) selectedObjs.FindAll(o => o is NodeViewModel).Select(o => o as NodeViewModel).ToList().ForEach(o => objs.AddRange(o.Links.Select(l => l as LinkViewModel).ToList()));
                 //objs鍘绘帀閲嶅鐨勫厓绱�
                 objs = objs.Distinct().ToList();
                 var visitedNodes = new HashSet<NodeViewModel>();
@@ -3280,21 +3705,21 @@
             {
 
                 var objs = selectedObjs.FindAll(o => o is LinkViewModel).Select(o => o as LinkViewModel).ToList();
-                if (objs.Count == 0) selectedObjs.FindAll(o => o is NodeViewModel).Select(o => o as NodeViewModel).ToList().ForEach(o => 
+                if (objs.Count == 0) selectedObjs.FindAll(o => o is NodeViewModel).Select(o => o as NodeViewModel).ToList().ForEach(o =>
                 {
-                    objs.AddRange(o.Links.Select(oo => oo as LinkViewModel).ToList().FindAll(oo=>oo.StartNode==o?oo.EN_FLOW>0:oo.EN_FLOW<0));
+                    objs.AddRange(o.Links.Select(oo => oo as LinkViewModel).ToList().FindAll(oo => oo.StartNode == o ? oo.EN_FLOW > 0 : oo.EN_FLOW < 0));
                 });
                 //objs鍘绘帀閲嶅鐨勫厓绱�
                 objs = objs.Distinct().ToList();
                 var visitedNodes = new HashSet<NodeViewModel>();
-                objs.ForEach(o => TraversePipeNetworkALL(o, visitedNodes,1));
+                objs.ForEach(o => TraversePipeNetworkALL(o, visitedNodes, 1));
                 this.SetMapInvalidate();
 
             }
         }
         public void 澶嶅埗ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            if(hoveredObjs.Count<=0 || !(hoveredObjs[0] is NodeViewModel))
+            if (hoveredObjs.Count <= 0 || !(hoveredObjs[0] is NodeViewModel))
             {
                 MessageBox.Show("璇峰皢榧犳爣鎮仠鍦ㄤ竴涓妭鐐瑰璞′笂,浣滀负鍩哄噯鐐�");
                 return;
@@ -3304,7 +3729,7 @@
                 MessageBox.Show("璇烽�夋嫨瑕佸鍒剁殑瀵硅薄");
                 return;
             }
-           
+
             _OperaNode = hoveredObjs[0] as NodeViewModel;
 
             MapViewNetWork net = new MapViewNetWork();
@@ -3329,14 +3754,14 @@
         public void 绮樿创ToolStripMenuItem1_Click(object sender, EventArgs e)
         {
             {
-                
+
                 var net = new MapViewNetWork();
                 string json = Clipboard.GetText();
                 net.ReadFromJson(json);
                 if (net.StartPoint == null) return;
                 string SID = net.StartPoint.ID;
-                net.StartPoint=net.Nodes.Find(n => n.ID == SID);
-                PointF minPoint = new PointF(net.StartPoint.X, net.StartPoint.Y);
+                net.StartPoint = net.Nodes.Find(n => n.ID == SID);
+                PointF3D minPoint = net.StartPoint.Position3D;// new PointF(net.StartPoint.X, net.StartPoint.Y);
                 Point controlLocation = this.PointToScreen(new Point(0, 0));
                 int offsetX = Cursor.Position.X - controlLocation.X;
                 int offsetY = Cursor.Position.Y - controlLocation.Y;
@@ -3345,22 +3770,23 @@
                 net.BuildRelation();
                 //var basePoint = MapPointToWorldPoint(ScreenToMap(position, net.StartPoint.Elev), net.StartPoint.Elev);
                 var mPos = _MousePosition;
-                if (hoveredObjs.Count>0 && hoveredObjs[0] is NodeViewModel minNode) 
+                if (hoveredObjs.Count > 0 && hoveredObjs[0] is NodeViewModel minNode)
                 {
-                   
-                    var basePoint = minNode.Position;
+
+                    var basePoint = minNode.Position3D;
                     net.Nodes.ForEach(obj =>
                     {
                         obj.X = obj.X + basePoint.X - minPoint.X;
                         obj.Y = obj.Y + basePoint.Y - minPoint.Y;
+                        obj.Elev = obj.Elev + basePoint.Z - minPoint.Z;
                     });
-                    
+
                     selectedObjs.ForEach(o => o.Selected = false);
                     selectedObjs.Clear();
                     selectedObjs.AddRange(net.Nodes.Select(n => (NodeViewModel)n));
                     selectedObjs.AddRange(net.Links.ViewLinks);
-                    var list = _Network.Add(net,null,false,minNode);
-                    
+                    var list = _Network.Add(net, null, false, minNode);
+                    net.BuildRelation();
                     //list.Add(_Network.AddPipe(Snode, minNode));
                     MapObjectExtensions.AddCommand(_Network, "Add", null, list);
                     SetMapInvalidate();
@@ -3378,11 +3804,12 @@
                     selectedObjs.AddRange(net.Nodes.Select(n => (NodeViewModel)n));
                     selectedObjs.AddRange(net.Links.ViewLinks);
                     var list = _Network.Add(net);
+                    net.BuildRelation();
                     MapObjectExtensions.AddCommand(_Network, "Add", null, list);
                     SetMapInvalidate();
                 }
 
-               
+
             }
         }
         private void 澧為噺淇濆瓨ToolStripMenuItem_Click(object sender, EventArgs e)
@@ -3409,7 +3836,7 @@
         }
         private void 璁句负鍏抽棴ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            selectedObjs.ForEach(obj => { if (obj is LinkViewModel link) link.Status =Hydro.Core.ObjectEnum. StatusType.CLOSED; });
+            selectedObjs.ForEach(obj => { if (obj is LinkViewModel link) link.Status = Hydro.Core.ObjectEnum.StatusType.CLOSED; });
             SetMapInvalidate();
         }
         private void 鏄剧ず鍏ㄩ儴妤煎眰ToolStripMenuItem_Click(object sender, EventArgs e)
@@ -3531,7 +3958,7 @@
             {
                 var backgroundImagePath = openFileDialog.FileName;
                 Global.ClearFileReadOnly(_Template.BackGroundImg_FullPath);
-                File.Copy(backgroundImagePath, _Template.BackGroundImg_FullPath, true);
+                FileCopy.Copy(backgroundImagePath, _Template.BackGroundImg_FullPath, true);
                 璁剧疆搴曞浘ToolStripMenuItem_Click(1, new EventArgs());
             }
         }
@@ -3589,13 +4016,13 @@
         {
             if (_filePath == null) return;
             FileInfo fi = new FileInfo(_filePath);
-            Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
+            System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
         }
         private void label_file_Click(object sender, EventArgs e)
         {
             if (_filePath == null) return;
             FileInfo fi = new FileInfo(_filePath);
-            Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
+            System.Diagnostics.Process.Start("explorer.exe", $"/select,\"{_filePath}\"");
         }
         private void 璁句负绔嬬鐐筎oolStripMenuItem_Click(object sender, EventArgs e)
         {
@@ -3723,11 +4150,11 @@
                 string tagstring = i.ToString() + "妤�";
                 if (tags.Contains(tagstring))
                 {
-                    var item=ToolStripMenuItem_Floor.DropDownItems.Add(i.ToString() + "妤�");
+                    var item = ToolStripMenuItem_Floor.DropDownItems.Add(i.ToString() + "妤�");
                     item.Click += (oo, ee) =>
                     {
-                        
-                        
+
+
                         mapobjects.ForEach(o =>
                         {
                             if (o.Tags.Contains(tagstring))
@@ -3766,32 +4193,44 @@
         {
             _isShowDirection = !_isShowDirection;
         }
-        bool _isShowDirection=false;
+        bool _isShowDirection = false;
         private void 棰滆壊鍒嗙骇绠$悊ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            Form_Colour form_Colour = new Form_Colour(_Template.Colours);
+            Form_Colour form_Colour = new Form_Colour(_Template.Colours, _Template);
             form_Colour.Show(this);
         }
-       
-		private bool __needpaintall=false;
-        
 
-   
+        private bool __needpaintall = false;
+
+
+
         private void cb_Link_Colour_SelectedIndexChanged(object sender, EventArgs e)
         {
             if (_Template == null) return;
-            
-            var type = cb_Link_Colour.SelectedItem==null?ColourType.绠$嚎娴侀噺:(ColourType)cb_Link_Colour.SelectedItem;
-            mapOption.ColourLink = type;
+            var type = cb_Link_Colour.SelectedItem == null ? ColourType.绠$嚎娴侀噺 : (ColourType)cb_Link_Colour.SelectedItem;
+            var doubles = _Template.network.getMinMax(type);
+            var colour = new Colour(type, null, type.ToString());
+            List<ColourItem> colours = Colour.GetColourItems((float)doubles[0], (float)doubles[1], 5, Color.Gray, Color.Red);
+            colour.Items = colours;
+            LinkColour = colour;
             this.SetMapInvalidate();
+
+
+
         }
         private void cb_Node_Colour_SelectedIndexChanged(object sender, EventArgs e)
         {
             if (_Template == null) return;
-   
-            var type = cb_Node_Colour.SelectedItem==null?ColourType.鑺傜偣鑷敱鍘嬪姏:(ColourType)cb_Node_Colour.SelectedItem;
-            mapOption.ColourNode = type;
+            var type = cb_Node_Colour.SelectedItem == null ? ColourType.鑺傜偣鑷敱鍘嬪姏 : (ColourType)cb_Node_Colour.SelectedItem;
+            var doubles = _Template.network.getMinMax(type);
+            var colour = new Colour(type, null, type.ToString());
+            List<ColourItem> colours = Colour.GetColourItems((float)doubles[0], (float)doubles[1], 5, Color.Gray, Color.Red);
+            colour.Items = colours;
+            NodeColour = colour;
             this.SetMapInvalidate();
+
+
+
         }
 
         private void label_ZZ_Click(object sender, EventArgs e)
@@ -3802,7 +4241,7 @@
 
         private void 妤煎眰绠$悊ToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            if (_Template.Regions==null)
+            if (_Template.Regions == null)
             {
                 _Template.Regions = new List<TRegion>();
             }
@@ -3810,9 +4249,9 @@
             form_EditFloors.Show(this);
         }
 
-       
 
-        
+
+
         #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3