Exemplo n.º 1
0
        private void RefreshCategoryList(ComboBox categoriesBox, DB.CategoryType categoryType)
        {
            var categories = Revit.ActiveUIDocument.Document.Settings.Categories.Cast <DB.Category>().Where(x => x.AllowsBoundParameters);

            if (categoryType != DB.CategoryType.Invalid)
            {
                if (categoryType == (DB.CategoryType) 3)
                {
                    categories = categories.Where(x => x.IsTagCategory);
                }
                else
                {
                    categories = categories.Where(x => x.CategoryType == categoryType && !x.IsTagCategory);
                }
            }

            categoriesBox.SelectedIndex = -1;
            categoriesBox.Items.Clear();
            categoriesBox.DisplayMember = "DisplayName";
            foreach (var category in categories.OrderBy(x => x.Name))
            {
                if (!HasElementTypes(category.Id))
                {
                    continue;
                }

                categoriesBox.Items.Add(Types.Category.FromCategory(category));
            }
        }
Exemplo n.º 2
0
        private void RefreshCategoryList(ListBox listBox, DB.CategoryType categoryType)
        {
            var current = InstantiateT();

            if (SourceCount == 0 && PersistentDataCount == 1)
            {
                if (PersistentData.get_FirstItem(true) is Types.Category firstValue)
                {
                    current = firstValue.Duplicate() as Types.Category;
                }
            }

            var categories = Revit.ActiveUIDocument.Document.Settings.Categories.Cast <DB.Category>().Where(x => x.CategoryType == categoryType && !x.IsTagCategory);

            if (categoryType == (DB.CategoryType) 3)
            {
                categories = Revit.ActiveUIDocument.Document.Settings.Categories.Cast <DB.Category>().Where(x => x.IsTagCategory);
            }

            listBox.Items.Clear();
            foreach (var category in categories.OrderBy(x => x.Name))
            {
                var tag   = Types.Category.FromCategory(category);
                int index = listBox.Items.Add(tag);
                if (tag.UniqueID == current.UniqueID)
                {
                    listBox.SelectedIndex = index;
                }
            }
        }
Exemplo n.º 3
0
        private void RefreshCategoryList(ListBox listBox, DB.CategoryType categoryType)
        {
            var doc = Revit.ActiveUIDocument?.Document;

            if (doc is null)
            {
                return;
            }

            listBox.SelectedIndexChanged -= ListBox_SelectedIndexChanged;
            listBox.Items.Clear();

            using (var collector = doc.Settings.Categories)
            {
                var categories = collector.
                                 Cast <DB.Category>().
                                 Where(x => 3 == (int)categoryType ? x.IsTagCategory : x.CategoryType == categoryType && !x.IsTagCategory);

                listBox.DisplayMember = "DisplayName";
                foreach (var category in categories)
                {
                    listBox.Items.Add(Types.Category.FromCategory(category));
                }
            }

            listBox.SelectedIndex         = listBox.Items.OfType <Types.Category>().IndexOf(Current, 0).FirstOr(-1);
            listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
        }
Exemplo n.º 4
0
        private void RefreshCategoryList(ListBox listBox, DB.CategoryType categoryType)
        {
            var doc = Revit.ActiveUIDocument?.Document;

            if (doc is null)
            {
                return;
            }

            var selectedIndex = -1;

            try
            {
                listBox.SelectedIndexChanged -= ListBox_SelectedIndexChanged;
                listBox.Items.Clear();

                var current = default(Types.Category);
                if (SourceCount == 0 && PersistentDataCount == 1)
                {
                    if (PersistentData.get_FirstItem(true) is Types.Category firstValue)
                    {
                        current = firstValue as Types.Category;
                    }
                }

                using (var collector = doc.Settings.Categories)
                {
                    var categories = collector.
                                     Cast <DB.Category>().
                                     Where(x => 3 == (int)categoryType ? x.IsTagCategory : x.CategoryType == categoryType && !x.IsTagCategory);

                    foreach (var category in categories)
                    {
                        var tag   = Types.Category.FromCategory(category);
                        int index = listBox.Items.Add(tag.EmitProxy());
                        if (tag.UniqueID == current?.UniqueID)
                        {
                            selectedIndex = index;
                        }
                    }
                }
            }
            finally
            {
                listBox.SelectedIndex         = selectedIndex;
                listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
            }
        }
Exemplo n.º 5
0
        private void RefreshCategoryList(ComboBox categoriesBox, DB.CategoryType categoryType)
        {
            var categories = Revit.ActiveUIDocument.Document.Settings.Categories.Cast <DB.Category>().Where(x => x.AllowsBoundParameters);

            if (categoryType != DB.CategoryType.Invalid)
            {
                if (categoryType == (DB.CategoryType) 3)
                {
                    categories = categories.Where(x => x.IsTagCategory);
                }
                else
                {
                    categories = categories.Where(x => x.CategoryType == categoryType && !x.IsTagCategory);
                }
            }

            categoriesBox.SelectedIndex = -1;
            categoriesBox.Items.Clear();
            foreach (var category in categories.OrderBy(x => x.Name))
            {
                var tag   = Types.Category.FromCategory(category);
                int index = categoriesBox.Items.Add(tag.EmitProxy());
            }
        }