/// <summary> /// the method is used to create new family type /// </summary> /// <param name="para">WindowParameter</param> /// <returns>indicate whether the NewType is successful</returns> private bool newFamilyType(WindowParameter para)//string typeName, double height, double width, double sillHeight) { DoubleHungWinPara dbhungPara = para as DoubleHungWinPara; string typeName = dbhungPara.Type; double height = dbhungPara.Height; double width = dbhungPara.Width; double sillHeight = dbhungPara.SillHeight; double windowInset = dbhungPara.Inset; switch (m_document.DisplayUnitSystem) { case Autodesk.Revit.DB.DisplayUnit.METRIC: height = Utility.MetricToImperial(height); width = Utility.MetricToImperial(width); sillHeight = Utility.MetricToImperial(sillHeight); windowInset = Utility.MetricToImperial(windowInset); break; } try { FamilyType type = m_familyManager.NewType(typeName); m_familyManager.CurrentType = type; m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT), height); m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH), width); m_familyManager.Set(m_familyManager.get_Parameter("Default Sill Height"), sillHeight); m_familyManager.Set(m_familyManager.get_Parameter("Window Inset"), windowInset); return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); return(false); } }
/// <summary> /// The duplicatebutton click function /// </summary> /// <param name="sender">sender</param> /// <param name="e">EventArgs</param> private void button_duplicateType_Click(object sender, EventArgs e) { transforData(); DoubleHungWinPara copyPara = new DoubleHungWinPara((DoubleHungWinPara)m_para.CurrentPara); SetParaText(copyPara); this.m_comboType.Focus(); }
/// <summary> /// The newtype button click function /// </summary> /// <param name="sender">sender</param> /// <param name="e">EventArgs</param> private void button_newType_Click(object sender, EventArgs e) { transforData(); DoubleHungWinPara newPara = new DoubleHungWinPara(m_para.Validator.IsMetric); SetParaText(newPara); this.m_comboType.Focus(); }
/// <summary> /// set WindowParameter text /// </summary> /// <param name="para">the WindowParameter</param> private void SetParaText(WindowParameter para) { DoubleHungWinPara dbhungPara = para as DoubleHungWinPara; m_sillHeight.Text = Convert.ToString(dbhungPara.SillHeight); m_width.Text = Convert.ToString(dbhungPara.Width); m_height.Text = Convert.ToString(dbhungPara.Height); m_inset.Text = Convert.ToString(dbhungPara.Inset); m_comboType.Text = dbhungPara.Type; }
/// <summary> /// set grid data /// </summary> private void SetGridData() { paraList.Clear(); foreach (String key in m_para.WinParaTab.Keys) { DoubleHungWinPara para = m_para.WinParaTab[key] as DoubleHungWinPara; if (null == para) { continue; } paraList.Add(para); } this.dataGridView1.DataSource = paraList; }
/// <summary> /// Initialize data /// </summary> private void InitializePara() { DoubleHungWinPara dbhungPara = new DoubleHungWinPara(m_para.Validator.IsMetric); if (!m_para.WinParaTab.Contains(dbhungPara.Type)) { m_para.WinParaTab.Add(dbhungPara.Type, dbhungPara); m_types.Add(dbhungPara.Type); } else { m_para.WinParaTab[dbhungPara.Type] = dbhungPara; } bindSource.DataSource = m_types; this.m_comboType.Items.Add(m_para.CurrentPara.Type); this.m_comboType.SelectedIndex = 0; this.m_glassMat.DataSource = m_para.GlassMaterials; this.m_sashMat.DataSource = m_para.FrameMaterials; this.m_pathName.Text = m_para.PathName; SetParaText(dbhungPara); }
/// <summary> /// transfer data /// </summary> private void transforData() { if (m_para.m_template == "DoubleHung") { DoubleHungWinPara dbhungPara = new DoubleHungWinPara(m_para.Validator.IsMetric); dbhungPara.Height = Convert.ToDouble(m_height.Text, System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); dbhungPara.Width = Convert.ToDouble(m_width.Text); dbhungPara.Inset = Convert.ToDouble(m_inset.Text); dbhungPara.SillHeight = Convert.ToDouble(m_sillHeight.Text); dbhungPara.Type = m_comboType.Text; m_para.CurrentPara = dbhungPara; if (!m_para.WinParaTab.Contains(dbhungPara.Type)) { m_para.WinParaTab.Add(dbhungPara.Type, dbhungPara); m_comboType.Items.Add(dbhungPara.Type); } else { m_para.WinParaTab[dbhungPara.Type] = dbhungPara; } } Update(); }
/// <summary> /// constructor of DoubleHungWinPara /// </summary> /// <param name="dbhungPara">DoubleHungWinPara</param> public DoubleHungWinPara(DoubleHungWinPara dbhungPara) : base(dbhungPara) { m_inset = dbhungPara.Inset; m_sillHeight = dbhungPara.SillHeight; }