Ejemplo n.º 1
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                var listBox = new DoubleListBox();

                Tag[] categories = FetchAllCategories();

                listBox.AssignFlattenedSecondaryList(CatalogTagRegistry.AllTags().ToObjectArray());

                Tag currentlySelectedTag = ExtractTag(value);
                Tag currentCategory      = GetCurrentCategory(currentlySelectedTag);

                listBox.AssignPrimaryList(categories.ToObjectArray());
                AssignSelectedIndex(categories.ToObjectArray(), currentCategory, index => listBox.PrimarySelectedIndex = index);

                object[] availableTags = UpdateTagListBox(currentCategory, listBox);
                AssignSelectedIndex(availableTags, currentlySelectedTag, index => listBox.SecondarySelectedIndex = index);

                listBox.PrimaryItemSelected += (sender, args) =>
                {
                    int selectedIndex    = listBox.PrimarySelectedIndex;
                    Tag selectedCategory = categories[selectedIndex];

                    UpdateTagListBox(selectedCategory, listBox);
                };

                listBox.SecondaryItemSelected += (sender, args) => editorService.CloseDropDown();

                editorService.DropDownControl(listBox);

                return(listBox.SecondarySelectedItem ?? value);
            }
Ejemplo n.º 2
0
 private static IEnumerable <Tag> FetchTagsForCategory(Tag category)
 {
     return(CatalogTagRegistry.FetchTagsForCategory(category.Value).Order().ToArray());
 }
Ejemplo n.º 3
0
 private static Tag GetCurrentCategory(Tag currentlySelectedTag)
 {
     return(CatalogTagRegistry.GetCategoryFor(currentlySelectedTag));
 }
Ejemplo n.º 4
0
 private static Tag[] FetchAllCategories()
 {
     return
         (CatalogTagRegistry.AllCategoriesWithDummiesForUnpairedTags().Order().ToArray());
 }