Example #1
0
        void Refilter()
        {
            var cats = categories.Values.ToList();

            cats.Sort((a, b) => a.Priority != b.Priority ? b.Priority.CompareTo(a.Priority) : b.Text.CompareTo(a.Text));

            toolboxWidget.CategoryVisibilities.Clear();
            foreach (var category in cats)
            {
                bool hasVisibleChild = false;

                foreach (var child in category.Items)
                {
                    if (toolboxWidget.ShowCategories)
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue) && category.IsExpanded;
                    }
                    else
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue);
                    }
                    hasVisibleChild |= child.IsVisible;
                }

                category.IsVisible = hasVisibleChild;
                toolboxWidget.AddCategory(category);
            }

            toolboxWidget.RedrawItems(true, true);
        }
Example #2
0
        void Refilter(bool isNewData)
        {
            ToolboxWidgetItem selectedItem = null;

            //if there is a search our index of the selected item will change and we want get the new one
            if (!isNewData)
            {
                selectedItem = toolboxWidget.SelectedItem;
            }

            var cats = categories.Values.ToList();

            cats.Sort((a, b) => a.Priority != b.Priority ? b.Priority.CompareTo(a.Priority) : b.Text.CompareTo(a.Text));

            toolboxWidget.CategoryVisibilities.Clear();
            foreach (var category in cats)
            {
                bool hasVisibleChild = false;

                foreach (var child in category.Items)
                {
                    if (toolboxWidget.ShowCategories)
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue) && category.IsExpanded;
                    }
                    else
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue);
                    }
                    hasVisibleChild |= child.IsVisible;
                }

                category.IsVisible = hasVisibleChild;
                toolboxWidget.AddCategory(category);
            }

            toolboxWidget.RedrawItems(true, true, isNewData, selectedItem);
        }