qin
2024-06-04 9ce8c084837093466adc0efcb48e8de4f618bc04
Hydraulic/Hydro.MapUI/Map/MapViewer.cs
@@ -165,12 +165,8 @@
            cb_Link_Colour.SelectedIndex = 0;
<<<<<<< HEAD
            map.Init(TC,new DrawDelegate[] { Draw, Draw, DrawBackGroud, DrawH },new MouseDelegate[] { mapMouseDown, mapMouseMove, mapMouseUp, mapMouseWheel });
=======
            map.Init(TC, new DrawDelegate[] { Draw, Draw, DrawH }, new MouseDelegate[] { mapMouseDown, mapMouseMove, mapMouseUp, mapMouseWheel });
>>>>>>> 0f2ff322746347b91941d936ee27067295e57c76
@@ -396,145 +392,6 @@
                __needpaintall = value;
            }
        }
<<<<<<< HEAD
=======
        //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);
        //}
>>>>>>> 0f2ff322746347b91941d936ee27067295e57c76
        PointF[] getCurclePoints(int num)
        {
@@ -949,6 +806,7 @@
            {
                var net = _newTemplate.network;//clone
                var net0 = _newTemplate.network.DeepCopyByBin<MapViewNetWork>();
                //var net0 = _newTemplate.network.DeepCopyByBin<MapViewNetWork>();
                List<NodeViewModel> nodes = _Nodes.Select(node => (NodeViewModel)node).ToList();
                float minDist = 100f;
                NodeViewModel minNode = null;
@@ -1023,18 +881,11 @@
               
                _isInsertingObject = false;
<<<<<<< HEAD
                _newTemplate.network = net0;
                _isInsertingObject = true;
                _undoOldValue = new PointF3D(0, 0, 0);
                _OperaNode = _newTemplate.network.Nodes.Find(node => node.ID == _newTemplate.Node1) as NodeViewModel;
=======
                //_OperaNode = null;
                //_Network.Nodes.AddRange(net.Nodes);
                //_Network.Links.AddRange(net.Links);
>>>>>>> 0f2ff322746347b91941d936ee27067295e57c76
            _OperaNode = _newTemplate.network.Nodes.Find(node => node.ID == _newTemplate.Node1) as NodeViewModel;
                _isInsertingObject = true;
                SetMapInvalidate();
                return;