private void button1_Click(object sender, EventArgs e) { result = new CurrentSectionDepartment(); result.department = comboBox1.SelectedItem.ToString(); result.section = comboBox2.SelectedItem.ToString(); DialogResult = DialogResult.OK; }
public void AddSection() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Application app = new Application(); CurrentSectionDepartment curSectDept = app.GetSectionDepartment(doc); app.WriteSectionToDWG(doc, curSectDept); }
public SectionSelectForm(Dictionary <string, List <string> > dict, CurrentSectionDepartment preSelected = null) { m_dict = dict; InitializeComponent(); MouseDown += Form1_MouseDown; MouseUp += Form1_MouseUp; MouseMove += Form1_MouseMove; comboBox1.Items.AddRange(dict.Keys.ToArray()); if (preSelected != null) { if (comboBox1.Items.Contains(preSelected.department)) { int comb1index = comboBox1.Items.IndexOf(preSelected.department); comboBox1.SelectedIndex = comb1index; List <string> sectsList = m_dict[m_dict.Keys.ToArray()[comb1index]]; SectionsFill(sectsList); if (comboBox2.Items.Contains(preSelected.section)) { int comb2index = comboBox2.Items.IndexOf(preSelected.section); comboBox2.SelectedIndex = comb2index; } else { int comb2index = comboBox2.Items.Add(preSelected.section); comboBox2.SelectedIndex = comb2index; } } else { comboBox1.SelectedIndex = 0; SectionsFill(m_dict[m_dict.Keys.ToArray()[0]]); } } else { comboBox1.SelectedIndex = 0; SectionsFill(m_dict[m_dict.Keys.ToArray()[0]]); } comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged; }
public CurrentSectionDepartment ShowForm(CurrentSectionDepartment sectDept = null) { SectionSelectForm form = new SectionSelectForm(Departments, sectDept); System.Windows.Forms.DialogResult res = form.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { return(form.result); } return(null); }
public void WriteSectionToDWG(Document doc, CurrentSectionDepartment sectDept = null) { CurrentSectionDepartment selResult = ShowForm(sectDept); if (selResult == null) { return; } CustomDataManager CDManager = new CustomDataManager(); CDManager.DWG.SetStringValue(doc, dept, selResult.department); CDManager.DWG.SetStringValue(doc, sect, selResult.section); }
private void DocumentManager_DocumentCreated(object sender, DocumentCollectionEventArgs e) { Document doc = e.Document; var f = doc.IsNamedDrawing; Application app = new Application(); CurrentSectionDepartment curSectDept = app.GetSectionDepartment(doc); if (curSectDept == null || curSectDept.department == "" || curSectDept.section == "") { //If data contains in DWG not full or not specified, then call method app.WriteSectionToDWG(doc); } }
/// <summary> /// Returns the object contains current section and department from DWG if these data contains in DWG, else returns NULL. /// </summary> /// <param name="doc"></param> /// <returns></returns> public CurrentSectionDepartment GetSectionDepartment(Document doc) { CustomDataManager CDManager = new CustomDataManager(); string curDept = CDManager.DWG.GetStringValue(doc, dept); string curSect = CDManager.DWG.GetStringValue(doc, sect); if (curDept == null) { return(null); } if (curSect == null) { return(null); } CurrentSectionDepartment curSectDept = new CurrentSectionDepartment(curDept, curSect); return(curSectDept); }