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);
|
}
|
}
|
}
|
}
|