public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     Debug.Assert(provider != null, "No service provider; we cannot edit the value");
     if (provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
         if (edSvc != null)
         {
             IWindowsFormsEditorService service         = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
             CategoryFilterEditorUI     dialog          = new CategoryFilterEditorUI();
             CategoryFilterNode         currentSettings = (CategoryFilterNode)context.Instance;
             InitializeDialog(dialog, currentSettings);
             if (DialogResult.OK == service.ShowDialog(dialog))
             {
                 CategoryFilterMode categoryFilterMode = dialog.FilterMode;
                 NamedElementCollection <CategoryFilterEntry> categoryFilters = new NamedElementCollection <CategoryFilterEntry>();
                 foreach (string category in dialog.SelectedCategoryNames)
                 {
                     CategoryFilterEntry categoryFilter = new CategoryFilterEntry();
                     categoryFilter.Name = category;
                     categoryFilters.Add(categoryFilter);
                 }
                 return(new CategoryFilterSettings(categoryFilterMode, categoryFilters));
             }
         }
     }
     return(value);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    IWindowsFormsEditorService service = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));

                    CategoryFilterEditorUI dialog = new CategoryFilterEditorUI();
                    CategoryFilterNode currentSettings = (CategoryFilterNode)context.Instance;
                    InitializeDialog(dialog, currentSettings);

                    service.ShowDialog(dialog);

                    CategoryFilterMode categoryFilterMode = dialog.FilterMode;

                    NamedElementCollection<CategoryFilterEntry> categoryFilters = new NamedElementCollection<CategoryFilterEntry>();
                    foreach (string category in dialog.SelectedCategoryNames)
                    {
                        CategoryFilterEntry categoryFilter = new CategoryFilterEntry();
                        categoryFilter.Name = category;
                        categoryFilters.Add(categoryFilter);
                    }

                    return new CategoryFilterSettings(categoryFilterMode, categoryFilters);
                }
            }
            return value;
        }