private Relation AddRelation(Guid postId,Guid tagId, Guid guidFlag,Relation removeRelation) { //加非空校验; removeRelation.RelationId = Guid.NewGuid(); removeRelation.PostId = postId; removeRelation.TagId = tagId; bool IsSucess = RelationsDAO.CreateRelationsDAO().Save(removeRelation); Model.Tags.Tag tag = TagsDAO.CreateTagsDAO().GetTagById(tagId); //removeRelation = relation; if (IsSucess) { RectangleLabel label = new RectangleLabel(); label.ControlText = tag.TagContent; label.BorderColor = Color.Purple; label.BorderWidth = 1; label.InnerColor = Color.Transparent; //label.Tag = guidFlag; label.Tag = tagId; //计算位置 AddLabelToLocation(rectlblContainer, 2, label); //rectlblContainer.Controls.Add(label);//添加一个事件,E区显示已添加标签 } if (!IsSucess) { MessageBoxEx.Show(Constant.KM_ER_REFERENCE_ID_WRONG, Constant.KM_TYPE_WARN, MessageBoxButtons.OK); } return removeRelation; }
public void AddLabelToLocation(TX.Framework.WindowUI.Controls.TXPanel panel,int column, RectangleLabel label) { int labelCount = panel.Controls.Count; int lines = labelCount / column; int left = labelCount % column; int X = (left * WIDTH) + (left + 1) * (MARGIN*3); int Y = lines * HEIGHT + (lines + 1) * (MARGIN*3); //LabelWithCheck label = new LabelWithCheck(); label.Location = new Point(X,Y); panel.Controls.Add(label); }