예제 #1
0
        private void comboBoxLevelA_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (object obj in comboBoxFloor.Items)
            {
                cLevel cl = obj as cLevel;
                if (cl.dElevation == ((cLevel)comboBoxLevelA.SelectedItem).dElevation)
                {
                    comboBoxFloor.Text = cl.sLevelName;
                    break;
                }
            }

            //上一个
            if (comboBoxLevelA.SelectedIndex == comboBoxLevelA.Items.Count - 1) //到顶层
            {
                comboBoxCeil.Text = comboBoxLevelA.Text;
                return;
            }
            string sss = ((cLevel)comboBoxLevelA.Items[comboBoxLevelA.SelectedIndex + 1]).sLevelName;

            comboBoxCeil.Text = ((cLevel)comboBoxLevelA.Items[comboBoxLevelA.SelectedIndex + 1]).sLevelName;


            //foreach (object obj in comboBoxCeil.Items)
            //{
            //    cLevel cl = obj as cLevel;
            //    if (cl.dElevation == ((cLevel)comboBoxLevelA.SelectedItem).dElevation)
            //    {
            //        comboBoxFloor.Text = cl.sLevelName;
            //        break;
            //    }
            //}
        }
예제 #2
0
        private void RefreshForm()
        {
            if (m_UIApplication == null)
            {
                return;
            }

            comboBoxLevelA.Items.Clear();
            ArrayList alLevel = new ArrayList();
            ArrayList alFloor = new ArrayList();
            ArrayList alCeil  = new ArrayList();

            FilteredElementCollector collector;

            collector = new FilteredElementCollector(m_UIApplication.ActiveUIDocument.Document).OfCategory(BuiltInCategory.OST_Levels).OfClass(typeof(Level));

            var Elems = from eleFilter in collector
                        orderby((Level)eleFilter).Elevation
                        select eleFilter;

            foreach (Element ele in Elems) //得到楼层
            {
                Level l = ele as Level;
                //cLevel cl = new cLevel(l.Name, CommRevit.changeINCHtoMM(l.Elevation)/1000);
                cLevel cl = new cLevel(l.Name, UnitUtils.ConvertFromInternalUnits(l.Elevation, DisplayUnitType.DUT_METERS));
                alLevel.Add(cl);
                alCeil.Add(cl);
                alFloor.Add(cl);
            }

            comboBoxLevelA.DisplayMember = "sLevelName";
            comboBoxLevelA.ValueMember   = "dElevation";
            comboBoxLevelA.DataSource    = alLevel;

            comboBoxCeil.DisplayMember = "sLevelName";
            comboBoxCeil.ValueMember   = "dElevation";
            comboBoxCeil.DataSource    = alFloor;
            if (comboBoxCeil.Items.Count > 1)
            {
                comboBoxCeil.SelectedIndex = 1;
            }

            comboBoxFloor.DisplayMember = "sLevelName";
            comboBoxFloor.ValueMember   = "dElevation";
            comboBoxFloor.DataSource    = alCeil;
            if (comboBoxFloor.Items.Count > 0)
            {
                comboBoxFloor.SelectedIndex = 0;
            }
        }