private void btnLoad_Click_1(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.curUserLib.PathLib)) { MessageBox.Show("Please save this current Component Library firstly,then load a new Component Library", "", MessageBoxButtons.OKCancel); return; } else { btnSave_Click(null, null); } OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.InitialDirectory = Application.StartupPath; openFileDlg.Filter = "LIB|*.lib"; openFileDlg.FilterIndex = 0; openFileDlg.RestoreDirectory = true; if (openFileDlg.ShowDialog() == DialogResult.OK) { CADImport.Instance.PathLib = openFileDlg.FileName;//完整路径 } this.curUserLib = this.loadLib(CADImport.Instance.PathLib); this.toolStripStsLblName.Text = Path.GetFileName(this.curUserLib.PathLib); this.lswUnEditedLoad(); }
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); }
private ComponentLib loadLib(string path) { ComponentLib lib = new ComponentLib(); if (String.IsNullOrEmpty(path)) { return(lib); } lib.SetPath(path); lib.PathLib = path; lib.Load(); return(lib); }
private void btnNew_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.curUserLib.PathLib)) { MessageBox.Show("Please save this current Component Library firstly,then create a new Component Library", "", MessageBoxButtons.OKCancel); return; } else { btnSave_Click(null, null); } this.curUserLib = new ComponentLib(); this.toolStripStsLblName.Text = Path.GetFileName(this.curUserLib.PathLib); this.lswUnEditedLoad(); }
/// <summary> /// 标准库加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLibLoad_Click(object sender, EventArgs e) { string pathLib = String.Empty; OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.InitialDirectory = Application.StartupPath; openFileDlg.Filter = "LIB|*.lib"; openFileDlg.FilterIndex = 0; openFileDlg.RestoreDirectory = true; if (openFileDlg.ShowDialog() == DialogResult.OK) { pathLib = openFileDlg.FileName;//完整路径 } this.curLib = this.loadLib(pathLib); this.toolStripStsLblLibName.Text = Path.GetFileName(this.curLib.PathLib); this.lswLibLoad(); if (this.lswLib.Items.Count > 0) { this.lswLib.Items[0].Selected = true; } }
/// <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(); }
public DialogComponentLibEdit Setup(PatternInfo pInfo) { this.curPinfo = pInfo; this.curUserLib = this.curPinfo.LibUser; return(this); }