//选中巷道触发事件 private void proSelectTunnel(object sender, List <DBTunnel> dbtunnels) { comboBoxEdit1.Properties.Items.Clear(); tunnelName.Clear(); dbt.Clear(); comboBoxEdit1.Text = "无选择" + "(" + dbt.Count.ToString() + ")"; DPTunnel dptunnel = new DPTunnel(); if (dbtunnels.Count == 0) { Display("Tunnel", dptunnel); } else { if (dbtunnels.Count == 1) { dptunnel.SetFromDBObject(dbtunnels[0]); Display("Tunnel", dptunnel); } for (int i = 0; i < dbtunnels.Count; i++) { tunnelName.Add(dbtunnels[i].Name); comboBoxEdit1.Properties.Items.Add((i + 1).ToString() + "." + tunnelName[i]); dbt.Add(dbtunnels[i]); } comboBoxEdit1.Text = "选择巷道数" + "(" + dbt.Count.ToString() + ")"; } try { propertyGridControl1.Refresh(); } catch (System.NullReferenceException) { } }
//数据库dblite修改后事件 private void dataUpdated(object sender, DBEntity entity) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; DBEntityControl dbControl = Project.Instance.GetTmpEntCol(doc); if (dbControl.Senders.Contains(Project.Instance.GetActivePropCtl(doc))) { return; } var selEntity = this.propertyGridControl1.SelectedObject; if (selEntity == null) { return; } if (selEntity is DPNode && entity is DBNode) { if (entity.HandleValue != ((DPNode)selEntity).HandleValue) { return; } DPNode displayNode = new DPNode(); displayNode.SetFromDBEntity(entity as DBNode); this.propertyGridControl1.SelectedObject = displayNode; this.propertyGridControl1.Refresh(); } else if (selEntity is DPTunnel && entity is DBTunnel) { if (entity.HandleValue != ((DPTunnel)selEntity).HandleValue) { return; } DPTunnel displayTunnel = new DPTunnel(); //if (displayTunnel.HandleValue != entity.HandleValue) return; displayTunnel.SetFromDBObject(entity as DBTunnel); this.propertyGridControl1.SelectedObject = displayTunnel; this.propertyGridControl1.Refresh(); } }
//combox下拉选项变化触发事件 private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) { if (dbt.Count > 0) { for (int i = 0; i < tunnelName.Count; i++) { if (comboBoxEdit1.SelectedIndex == i) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; DBEntityControl dbcontrol = Project.Instance.GetTmpEntCol(doc); DBEntity entity = dbcontrol.FindOne(Query.EQ("HandleValue", dbt[i].HandleValue)); DBTunnel dbtunnel = entity as DBTunnel; DPTunnel dptunnel = new DPTunnel(); dptunnel.SetFromDBObject(dbtunnel); if (Utils.GetEntityFromDB(dbt[i].HandleValue) != null) { Display("Tunnel", dptunnel); propertyGridControl1.Refresh(); } } } } comboBoxEdit1.Refresh(); }