/// <summary> /// 设定热点点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (this.txt_name.Text == "" || this.txt_name.Text.Equals(null)) //this.txt_name.Text.Equals(null)这个没有看明白 //而且,换行是怎么做到的? { MessageBox.Show("请先填入当前关注点的名称,然后点击设置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { int groupId = Program.TE.FindItem("热点"); if (groupId == 0) { groupId = Program.TE.CreateGroup("热点", 0); } GetPositionInfo gp = new GetPositionInfo(); gp.GetPosition(); ITerrainLocation5 itl = Program.TE.IObjectManager51_CreateLocation(gp.Longitude, gp.Latitude, gp.Height, gp.Yaw, gp.CameraDeltaPitch, 90, HeightStyleCode.HSC_DEFAULT, groupId, this.txt_name.Text.ToString()); this.tree_hotDot.Nodes.Clear(); this.InitTree(); } catch (Exception) { } }
/// <summary> /// 初始化树状结构 /// </summary> public void InitTree() { int groupID = Program.TE.FindItem("热点"); if (groupID == 0) { // groupID = Program.TE.CreateGroup("热点", 0); return; } int childId = Program.TE.GetNextItem(groupID, ItemCode.CHILD); while (childId != 0) { try { ITerrainLocation5 itl = (ITerrainLocation5)Program.TE.GetObjectEx(childId, "ITerrainLocation5"); //这个是用接口来操作,返回的也是一个接口 //yon TreeNode tn = new TreeNode(itl.Description); tn.Tag = itl; tn.ImageIndex = 0; tn.SelectedImageIndex = 0; this.tree_hotDot.Nodes.Add(tn); childId = Program.TE.GetNextItem(childId, ItemCode.NEXT); } catch (Exception ex) { //MessageBox.Show(ex.Message); } } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { ITerrainLocation5 itdo = (ITerrainLocation5)tn.Tag; Program.TE.DeleteItem(itdo.InfoTreeItemID); tree_hotDot.Nodes.Remove(tn); }
private void tree_hotDot_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { ITerrainLocation5 itdo = (ITerrainLocation5)tn.Tag; //itdo.Text = e.Label; itdo.Description = e.Label; tree_hotDot.LabelEdit = false; }