cloudflight
2023-12-02 c0f9915265878e56e91ee97f7f8d925db1e12626
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using Hydro.MapView;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Hydro.MapView.MapViewEnum;
using Hydro.MapView.Common;
namespace Hydro.MapUI
{
    public partial class Form_importObjs : Form
    {
        MapViewNetWork _net,_net0;
        public List<CheckBox> checkBoxes = new List<CheckBox>();
        List<bool> bools = new List<bool>();
        public Form_importObjs(MapViewNetWork net,MapViewNetWork net0)
        {
            InitializeComponent();
            _net= net;
            _net0 = net0;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                _net0.Nodes.Clear();
                _net0.Links.Clear();    
            }
            for (int i=1;i< checkBoxes.Count;i++)
            {
                var cb = checkBoxes[i];
                if (cb.Checked && cb.Tag != null)
                {
                    if (bools[i])
                    {
                        dynamic list = cb.Tag;
                        foreach(var o in list)
                        {                            
                            _net0.Nodes.Add(o);
                        }
                        
                    }
                    else
                    {
                        dynamic list = cb.Tag;
                        foreach (var o in list)
                        {
                            _net0.Links.Add(o);
                        }
                    }
                        
                }
            }
            _net0.BuildRelation();
            this.DialogResult = DialogResult.OK;    
            this.Close();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
 
        private void Form_importObjs_Load(object sender, EventArgs e)
        {
            int top = 30;
            foreach (MapObjectType objectType in Enum.GetValues(typeof(MapObjectType)))
            {
                // 执行相应的操作,比如打印或处理枚举值
                CheckBox cb = new CheckBox();
 
                List<IBaseViewModel> list;
                if (objectType == MapObjectType.全部)
                    list = _net.MapObjects;
                else
                    list =_net.MapObjects.FindAll(o=>o.GetType() == objectType.GetObjType());
                cb.Tag = list;
                cb.Text =$"{objectType}({list.Count})" ;
                cb.Tag = list;
                cb.Left = 30;
                cb.Top = top;
                cb.Checked = true;
                top += 30;
                checkBoxes .Add( cb);
                bools.Add(objectType.isNodeType());
                this.Controls.Add(cb);
                //Console.WriteLine(objectType.ToString());
            }
            checkBoxes[0].CheckedChanged += Form_importObjs_CheckedChanged;
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
 
        }
 
        private void groupBox1_Enter(object sender, EventArgs e)
        {
 
        }
 
        private void Form_importObjs_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxes[0].Checked)
            {
                checkBoxes.ForEach(cb => cb.Checked = true);
            }
            else
            {
                checkBoxes.ForEach(cb => cb.Checked = false);
            }
        }
    }
}