public void FillInList(ITypeDescriptorContext context, ListBox editControl)
        {
            BrokerServiceConfiguration service = (BrokerServiceConfiguration)context.Instance;

            editControl.Items.Clear();

            foreach (ServiceQueue item in service.ServiceBroker.Queues)
            {
                editControl.Items.Add(String.Format(CultureInfo.InvariantCulture, item.Name));
            }
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                try
                {
                    BrokerServiceConfiguration service = (BrokerServiceConfiguration)context.Instance;
                    // get the editor service
                    this.m_FormEditorService = (IWindowsFormsEditorService)
                                               provider.GetService(typeof(IWindowsFormsEditorService));

                    // create the control for the UI
                    ListBox editControl = new ListBox();
                    editControl.Click += new EventHandler(ListClick);

                    editControl.ScrollAlwaysVisible = false;
                    editControl.Height = 70;
                    editControl.Width  = 250;

                    editControl.BorderStyle = BorderStyle.None;

                    // modify the control properties
                    FillInList(context, editControl);

                    // editor service renders control and manages control events
                    this.m_FormEditorService.DropDownControl(editControl);

                    if (editControl.SelectedItem == null)
                    {
                        return(service.QueueName);
                    }
                    else
                    {
                        // return the updated newValue
                        return(editControl.SelectedItem);
                    }
                }
                finally
                {
                    this.m_FormEditorService = null;
                }
            }
            else
            {
                return(value);
            }
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                try
                {
                    BrokerServiceConfiguration service = (BrokerServiceConfiguration)context.Instance;
                    // get the editor service
                    this.m_FormEditorService = (IWindowsFormsEditorService)
                                               provider.GetService(typeof(IWindowsFormsEditorService));

                    // create the control for the UI
                    CheckedListBox editControl = new CheckedListBox();
                    editControl.ScrollAlwaysVisible = false;
                    editControl.Height = 70;
                    editControl.Width  = 250;

                    editControl.BorderStyle = BorderStyle.None;

                    // modify the control properties
                    FillInText(context, provider, editControl);

                    // editor service renders control and manages control events
                    this.m_FormEditorService.DropDownControl(editControl);

                    service.ContractNames.Clear();
                    foreach (object item in editControl.CheckedItems)
                    {
                        service.ContractNames.Add(item.ToString());
                    }

                    // return the updated newValue
                    return(service.ContractNames);
                }
                finally
                {
                    this.m_FormEditorService = null;
                }
            }
            else
            {
                return(value);
            }
        }
        public void FillInText(ITypeDescriptorContext context, IServiceProvider provider, CheckedListBox editControl)
        {
            BrokerServiceConfiguration service = (BrokerServiceConfiguration)context.Instance;
            string baseUrn = service.ServiceBroker.Parent.ExtendedProperties["BaseUrn"].Value.ToString();

            foreach (ServiceContract item in service.ServiceBroker.ServiceContracts)
            {
                if (item.Name.StartsWith(baseUrn + "contract", StringComparison.OrdinalIgnoreCase))
                {
                    bool check = false;
                    if (service.ContractNames != null &&
                        service.ContractNames.Contains(item.Name))
                    {
                        check = true;
                    }
                    editControl.Items.Add(item.Name, check);
                }
            }
        }