public void GetPoints(ComponentLib lib) { this.points.Clear(); bool isFind = false; PointD pRotated; ComponentEx cmp = new ComponentEx(0); if (lib == null || lib.FindAll().Count == 0) { return; } foreach (ComponentEx item in lib.FindAll()) { if (item.component.Name.Contains(this.Comp) || this.Comp.Contains(item.component.Name)) { isFind = true; cmp = item; break; } } if (isFind) { if (tech == Technology.Adh) { if (cmp.component.AdhPoints.Count > 0) { foreach (GlueDot p in cmp.component.GetPoints(Technology.Adh)) { GlueDot dot = new GlueDot(); dot.IsWeight = p.IsWeight; dot.Weight = p.Weight; dot.Radius = p.Radius; dot.NunShots = p.NunShots; dot.index = p.index; dot.point = new PointD(p.point); this.RotateComp(dot.point, this.rotation, out pRotated); dot.point = pRotated + this.mid; this.points.Add(dot); } } else { GlueDot dot = new GlueDot(); dot.point = new PointD(this.mid); this.points.Add(dot); } } } else { GlueDot dot = new GlueDot(); dot.point = new PointD(this.mid); this.points.Add(dot); } }
private ComponentEx findComponentInLib(ComponentLib lib, string name) { foreach (ComponentEx item in lib.FindAll()) { if (item.component.Name == name) { return(item); } } return(null); }
private int findMaxIndex(ComponentLib lib) { int max = 0; foreach (ComponentEx item in lib.FindAll()) { if (item.Key > max) { max = item.Key; } } return(max); }
/// <summary> /// 将用户Lib融入到已有Lib /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMerge_Click(object sender, EventArgs e) { bool isFinded = false; if (string.IsNullOrEmpty(this.curLib.PathLib)) { return; } ComponentLib lib = new ComponentLib(); lib.Clear(); lib.AddRange(this.curLib.FindAll()); this.curLib.Save(); int index = findMaxIndex(lib); foreach (var userComp in this.curUserLib.FindAll()) { isFinded = false; foreach (var libComp in lib.FindAll()) { if (libComp.component.Name == userComp.component.Name) { isFinded = true; continue; } } if (isFinded == false) { index++; ComponentEx cmp = new ComponentEx(index); cmp.component = userComp.component.DepCopy(); lib.Add(cmp); } } string path = string.Format("{0}\\{1}.lib", Path.GetDirectoryName(this.curLib.GetPath()), Path.GetFileNameWithoutExtension(this.curLib.GetPath())); lib.SetPath(path); lib.PathLib = path; lib.Save(); }