public void AddLine(EntityInfo src, EntityInfo target) { try { Model model = ClassDiagCtrl.Ins.currentModel; ConnInfo con = new ConnInfo(); con.SrcElementID = src.ElementID; con.TargetElementID = target.ElementID; con.linetype = LineType.Line; AppConf.Ins.Application.Conns.Add(con); Line line = new Line((Shape)model.Shapes[con.SrcElementID], (Shape)model.Shapes[con.TargetElementID]); formConf.conLineKeys.Add(con, line); formConf.lineConKeys.Add(line, con); model.Lines.Add(model.Lines.CreateKey(), line); } catch (Exception ex) { } }
void model1_ElementInserted(object sender, ElementsEventArgs e) { //插入时候调用的方法,要判断是否已经在模型内存在,如果不存在,则加一个新的 if (e.Value is Table) { Table table = e.Value as Table; EntityInfo ent = table.Tag as EntityInfo; if (!formConf.ContainEntity(ent)) // 包含就不用管,不包含要加入关联. { MessageBox.Show("暂时不支持复制,请删除新添加的对象."); //EntityInfo newen = ent.Clone(); //table.LocationChanged += table_LocationChanged; //table.SelectedChanged += properGridCtrl.Ins.table_SelectedChanged; //AppConf.Ins.views_enkey.Add(ent, table); //AppConf.Ins.views_tbkey.Add(table, ent); //ProTreeCtrl.Ins.CheckedModule.Entitys.Add(ent); //ProTreeCtrl.Ins.ReLoadTree(); } } else if (e.Value is Line) { try { if (formConf.MouseDownTable != null) { if (formConf.MouseUpTable != null) { Console.WriteLine("MouseDown:" + formConf.MouseDownTable.ToString()); formConf.MouseUpTable = (sender as Model).CurrentMouseElements.MouseMoveElement as Table; Console.WriteLine("MouseUp:" + formConf.MouseUpTable.ToString()); ConnInfo con = new ConnInfo(); con.SrcElementID = formConf.MouseDownTable.ToString(); con.TargetElementID = formConf.MouseUpTable.ToString(); con.linetype = formConf.linetype; if (!formConf.lineConKeys.Keys.Contains((Line)e.Value)) { formConf.conLineKeys.Add(con, (Line)e.Value); formConf.lineConKeys.Add((Line)e.Value, con); AppConf.Ins.Application.Conns.Add(con); } } } } catch (Exception ex) { //MessageBox.Show(ex.Message); } } }