tangxu
2024-05-06 f01d639477141399fd3e092f3f0acb3ced7e02bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using Hydro.MapView;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Hydro.MapUI
{
    public partial class Form_Magnifier : Form
    {
        Template _template = null;
        float xMin = 9999999999999, yMin = 9999999999999;
        public Form_Magnifier(List<IBaseViewModel> list)
        {
            InitializeComponent();
            _template = new Template();
            _template.network = new MapViewNetWork();
            _template.network.Nodes.AddRange(list.FindAll(o=>o is NodeViewModel).Select(o=>o as NodeViewModel).ToList());
            _template.network.Links.AddRange(list.FindAll(o => o is LinkViewModel).Select(o => o as LinkViewModel).ToList());
            _template.network.Links.ForEach(l=> 
            {
                if (!_template.network.Nodes.Contains( l.StartNode))
                {
                    _template.network.Nodes.Add(l.StartNode);
                }
                if (!_template.network.Nodes.Contains(l.EndNode))
                {
                    _template.network.Nodes.Add(l.EndNode);
                }
            });
            _template.network.Nodes.ForEach(n => 
            {
                if (xMin > n.X) xMin = n.X;
                if (yMin > n.Y) yMin = n.Y;
            });
            //_template.network.MapObjects.ForEach(o => o.Selected = false);
            转换器();
 
 
 
 
        }
        private void Form_Magnifier_Load(object sender, EventArgs e)
        {
            MapViewer map = new MapViewer();
            map.Dock = DockStyle.Fill;
            this.Controls.Add(map);
            old_map = GlobalObject.map;
            GlobalObject.map = map;
            old_fr = GlobalObject.PropertyForm.GetWindow();
            GlobalObject.PropertyForm.SetWindows(this);
 
 
            map.SetData(_template);
            map.SetMapInvalidate();
        }
        private void 转换器()
        {
            _template.network.Nodes.ForEach(n =>
            {
                n.X -= xMin;
                n.X *= 10;
                n.Y -= yMin;
                n.Y *= 10;
            });
        }
        private void 还原器()
        {
            _template.network.Nodes.ForEach(n =>
            {
                n.X /= 10;
                n.X += xMin;
                n.Y /= 10;
                n.Y += yMin;
                
            });
        }
 
        private void Form_Magnifier_FormClosing(object sender, FormClosingEventArgs e)
        {
            还原器();
            //_template.network.MapObjects.ForEach(o => o.Selected = true);
            GlobalObject.map = old_map;
            
            //GlobalObject.PropertyForm.SetWindows(old_fr);
        }
        MapViewer old_map;
        Form old_fr;
        
    }
}