SetNewCategories() public method

Set new categories, this method will possibly update existing criteria
If someone parameter of criteria cannot be supported by new categories, the old criteria will be cleaned and set to empty
public SetNewCategories ( ICollection newCatIds ) : bool
newCatIds ICollection New categories for current filter.
return bool
Exemplo n.º 1
0
        /// <summary>
        /// Categories for filter were changed, clean all old filter rules.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void categoryCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            // if item is checked by programming, suppress this event
            if (m_catChangedEventSuppress)
            {
                return;
            }
            //
            // Get all selected categories, include one which is going to be checked
            List <BuiltInCategory> selCats   = new List <BuiltInCategory>();
            List <ElementId>       selCatIds = new List <ElementId>();
            int itemCount = categoryCheckedListBox.Items.Count;

            for (int ii = 0; ii < itemCount; ii++)
            {
                // Skip current check item if it's going to be unchecked;
                // add current check item it's going to be checked
                bool addItemToChecked = false;
                if (null != e && e.Index == ii)
                {
                    addItemToChecked = (e.NewValue == CheckState.Checked);
                    if (!addItemToChecked)
                    {
                        continue;
                    }
                }
                //
                // add item checked and item is going to be checked
                if (addItemToChecked || categoryCheckedListBox.GetItemChecked(ii))
                {
                    String          curCat = categoryCheckedListBox.GetItemText(categoryCheckedListBox.Items[ii]);
                    BuiltInCategory param  = EnumParseUtility <BuiltInCategory> .Parse(curCat);

                    selCats.Add(param);
                    selCatIds.Add(new ElementId(param));
                }
            }
            //
            // Reset accordingly controls
            bool changed = m_currentFilterData.SetNewCategories(selCatIds);

            if (!changed)
            {
                return;
            }
            //
            // Update rules controls
            ResetRule_CategoriesChanged();
        }