public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication UIapp = commandData.Application; UIDocument UIdoc = UIapp.ActiveUIDocument; Document doc = UIdoc.Document; if (doc == null) { message = "Active document is null"; return(Result.Failed); } try { Main main = new Main(); main.Execute(commandData, ref message, elements); MakeFormStorage creator = new MakeFormStorage(UIapp); MakeFormWindowsForm windowsForm = new MakeFormWindowsForm(creator); windowsForm.Show(); return(Result.Succeeded); } catch (Exception ex) { message = ex.Message; return(Result.Failed); } }
public MakeFormWindowsForm(MakeFormStorage creator) { m_creator = creator; UIdoc = m_creator.RevitDoc; doc = UIdoc.Document; ExternalCommandData commandData = null; InitializeComponent(); AllDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //接著把form_list一個一個加進來datagridview foreach (string[] row in RoomHeight.form_list1) { AllDataGridView.Rows.Add(row); } foreach (string[] row in ParapetHeight.form_list2) { AllDataGridView.Rows.Add(row); } foreach (string[] row in WuToo.form_list3) { AllDataGridView.Rows.Add(row); } foreach (string[] row in WuToo.form_list4) { AllDataGridView.Rows.Add(row); } foreach (string[] row in StairsCheck.form_list5) { AllDataGridView.Rows.Add(row); } foreach (string[] row in StairsCheck.form_list6) { AllDataGridView.Rows.Add(row); } foreach (string[] row in RampSlope.form_list7) { AllDataGridView.Rows.Add(row); } foreach (string[] row in FireProofDoor.form_list8) { AllDataGridView.Rows.Add(row); } foreach (DataGridViewRow row in AllDataGridView.Rows) { //避免選到標題或是規範那個row if (row.Cells[5].Value != null) { if (row.Cells[5].Value.ToString() == "False") { row.DefaultCellStyle.BackColor = System.Drawing.Color.Red; //也把他加進去第二個頁籤(error) string[] s = new string[] { row.Cells[0].Value.ToString(), row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString(), row.Cells[3].Value.ToString(), row.Cells[4].Value.ToString(), row.Cells[5].Value.ToString() }; ErrorDataGridView.Rows.Add(s); } } } }