示例#1
0
        Execute()
        {
            //Get every level by iterating through all elements
            systemLevelsData = new List <LevelsDataSource>();

            FilteredElementCollector fec = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
            ElementClassFilter       elementsAreWanted = new ElementClassFilter(typeof(Level));

            fec.WherePasses(elementsAreWanted);
            List <Element> elements = fec.ToElements() as List <Element>;

            foreach (Element element in elements)
            {
                Level systemLevel = element as Level;
                if (systemLevel != null)
                {
                    LevelsDataSource levelsDataSourceRow = new LevelsDataSource();

                    levelsDataSourceRow.LevelIDValue = systemLevel.Id.IntegerValue;
                    levelsDataSourceRow.Name         = systemLevel.Name;

                    levelsDataSourceRow.Elevation = systemLevel.Elevation;

                    systemLevelsData.Add(levelsDataSourceRow);
                }
            }

            LevelsForm displayForm = new LevelsForm(this);

            displayForm.ShowDialog();

            return(true);
        }
示例#2
0
        Execute ()
        {
            //Get every level by iterating through all elements
            systemLevelsData = new List<LevelsDataSource>();

            FilteredElementCollector fec = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(Level));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Level systemLevel = element as Level;
               if (systemLevel != null)
               {
                  LevelsDataSource levelsDataSourceRow = new LevelsDataSource();

                  levelsDataSourceRow.LevelIDValue = systemLevel.Id.IntegerValue;
                  levelsDataSourceRow.Name = systemLevel.Name;

                  levelsDataSourceRow.Elevation = systemLevel.Elevation;

                  systemLevelsData.Add(levelsDataSourceRow);
               }
            }

            LevelsForm displayForm = new LevelsForm(this);
            displayForm.ShowDialog();

            return true;
        }
示例#3
0
        /// <summary>
        /// Used to make setting apply to the model.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OKButton_Click(object sender, EventArgs e)
        {
            //Set all changed Level name's and elevation's
            if (1 == m_systemLevelChangedFlag)
            {
                for (int i = 0; i < m_changedItemsFlag.LongLength; i++)
                {
                    if (1 == m_changedItemsFlag[i])
                    {
                        bindingSource1.Position = i;
                        LevelsDataSource changeItem = bindingSource1.Current as LevelsDataSource;
                        m_objectReference.SetLevel(changeItem.LevelIDValue, changeItem.Name, changeItem.Elevation);
                    }
                }
            }

            //Delete existing Levels
            for (int i = 0; i < m_deleteExistLevelTotal; i++)
            {
                m_objectReference.DeleteLevel(m_deleteExistLevelIDValue[i]);
            }

            //Create new Levels
            for (int i = m_systemLevelsTotal; i < bindingSource1.Count; i++)
            {
                bindingSource1.Position = i;
                LevelsDataSource newItem = bindingSource1.Current as LevelsDataSource;
                m_objectReference.CreateLevel(newItem.Name, newItem.Elevation);
            }
        }
示例#4
0
        /// <summary>
        /// Used to add a new item in the dataGridView control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addButton_Click(object sender, EventArgs e)
        {
            System.String newLevelName;
            double        newLevelElevation;

            if (bindingSource1.Count > 0)
            {
                bindingSource1.MoveLast();
                LevelsDataSource lastItem = bindingSource1.Current as LevelsDataSource;

                String lastLevelName      = lastItem.Name;
                Double lastLevelElevation = lastItem.Elevation;
                newLevelName      = lastLevelName;
                newLevelElevation = lastLevelElevation;
            }
            else
            {
                newLevelName      = "Level" + " " + "1";
                newLevelElevation = 0;
            }


            LevelsDataSource newLevel = new LevelsDataSource();

            newLevel.Name      = newLevelName;
            newLevel.Elevation = newLevelElevation;

            bindingSource1.Add(newLevel);
        }
示例#5
0
        /// <summary>
        /// Used to delete an item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (bindingSource1.Position > m_systemLevelsTotal - 1)
            {
                bindingSource1.RemoveCurrent();
                return;
            }

            if (bindingSource1.Position <= m_systemLevelsTotal - 1 && bindingSource1.Position >= 0)
            {
                LevelsDataSource aRow = bindingSource1.Current as LevelsDataSource;
                m_deleteExistLevelIDValue[m_deleteExistLevelTotal] = aRow.LevelIDValue;
                m_deleteExistLevelTotal++;

                bindingSource1.RemoveCurrent();

                m_systemLevelsTotal = m_systemLevelsTotal - 1;

                int[] temChangedItemsFlag = new int[m_systemLevelsTotal];
                for (int i = 0, j = 0; i < m_systemLevelsTotal; i++, j++)
                {
                    if (bindingSource1.Position == i)
                    {
                        j++;
                    }
                    temChangedItemsFlag[i] = m_changedItemsFlag[j];
                }
                m_changedItemsFlag = temChangedItemsFlag;

                return;
            }

            if (bindingSource1.Position < 0)
            {
                System.Windows.Forms.MessageBox.Show("No levels present.");
            }
        }
示例#6
0
        /// <summary>
        /// Used to add a new item in the dataGridView control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addButton_Click(object sender, EventArgs e)
        {
            System.String newLevelName;
            double newLevelElevation;

            if (bindingSource1.Count > 0)
            {
                bindingSource1.MoveLast();
                LevelsDataSource lastItem = bindingSource1.Current as LevelsDataSource;

                String lastLevelName = lastItem.Name;
                Double lastLevelElevation = lastItem.Elevation;
                newLevelName = lastLevelName;
                newLevelElevation = lastLevelElevation;
            }
            else
            {
                newLevelName = "Level" + " " + "1";
                newLevelElevation = 0;
            }

            LevelsDataSource newLevel = new LevelsDataSource();
            newLevel.Name = newLevelName;
            newLevel.Elevation = newLevelElevation;

            bindingSource1.Add(newLevel);
        }