Esempio n. 1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (provider != null))
            {
                // Access the Property Browser's UI display service
                _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (_editorService != null)
                {
                    _listBox             = new ListBox();
                    _listBox.Click      += new EventHandler(_listBox_Click);
                    _listBox.BorderStyle = BorderStyle.None;
                    nugenCCalc           = (NugenCCalcBase)context.Instance;

                    if (nugenCCalc.Site.DesignMode)
                    {
                        foreach (Component component in context.Container.Components)
                        {
                            try
                            {
                                if (nugenCCalc.ValidateControl(component))
                                {
                                    _listBox.Items.Add(component);
                                }
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        if (nugenCCalc.Owner != null)
                        {
                            IterateControls((nugenCCalc.Owner as Form).Controls);
                        }
                    }

                    _editorService.DropDownControl(_listBox);
                    if (_listBox.SelectedItem != null)
                    {
                        value = _listBox.SelectedItem;
                    }
                }
            }
            return(value);
        }
Esempio n. 2
0
 private void IterateControls(Control.ControlCollection controls)
 {
     foreach (Control child in controls)
     {
         try
         {
             if (nugenCCalc.ValidateControl(child))
             {
                 _listBox.Items.Add(child);
             }
         }
         catch { }
         if (child.HasChildren)
         {
             IterateControls(child.Controls);
         }
     }
 }