private LineFoot DecodeElementFootByDb(DataRow dr) { LineFoot info = new LineFoot(); info.Idx = Convert.ToInt32(dr["lineIdx"]); info.InnerIdx = Convert.ToInt32(dr["innerId"]); info.PinsType = (enumPinsType)Enum.Parse(typeof(enumPinsType), dr["pinsType"].ToString()); info.Name = dr["name"].ToString(); info.LocX = Convert.ToInt32(dr["locX"]); info.LocY = Convert.ToInt32(dr["locY"]); info.Color = Color.FromArgb(Convert.ToInt32(dr["color"])); return(info); }
private bool CheckLocation(List <LineFoot> lineList) { bool result = true; if (dgvFoot.Rows.Count <= 1) { MessageBox.Show("未添加管脚信息"); return(false); } int imgWidth = int.Parse(tbWidth.Text), imgHeight = int.Parse(tbHeight.Text); int minX = int.MaxValue, minY = int.MaxValue, maxX = 0, maxY = 0; for (int i = 1; i < dgvFoot.Rows.Count; i++) { DataGridViewRow row = dgvFoot.Rows[i - 1]; LineFoot foot = new LineFoot(); foot.InnerIdx = Convert.ToInt32(row.Cells[0].Value); foot.Name = row.Cells[1].Value.ToString(); foot.PinsType = (enumPinsType)Enum.Parse(typeof(enumPinsType), row.Cells[2].Value.ToString()); foot.LocX = Convert.ToInt32(row.Cells[3].Value); foot.LocY = Convert.ToInt32(row.Cells[4].Value); if (!(foot.LocX >= 0 && foot.LocX <= imgWidth && foot.LocY >= 0 && foot.LocY <= imgHeight && (foot.LocX == 0 || foot.LocX == imgWidth || foot.LocY == 0 || foot.LocY == imgHeight))) { MessageBox.Show("管脚仅可以在元器件边界上"); result = false; break; } foot.NameLocX = Convert.ToInt32(row.Cells[5].Value); foot.NameLocY = Convert.ToInt32(row.Cells[6].Value); lineList.Add(foot); minX = Math.Min(foot.LocX, minX); minY = Math.Min(foot.LocY, minY); maxX = Math.Max(foot.LocX, maxX); maxY = Math.Max(foot.LocY, maxY); } result = result && !(maxX - minX > 0 && (maxX - minX) % this.netInterval != 0 || maxY - minY > 0 && (maxY - minY) % this.netInterval != 0); if (!result) { MessageBox.Show("管脚不在节点上"); } for (int i = 0; result && i < lineList.Count; i++) { LineFoot foot = lineList[i]; if (foot.LocX == imgWidth && (foot.LocX) % this.netInterval != 0 || foot.LocY == imgHeight && (foot.LocY) % this.netInterval != 0) { MessageBox.Show("管脚坐标不能都在节点上"); result = false; break; } } return(result); }