Beispiel #1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            SequenceChoice[]          choices = value as SequenceChoice[];
            SequenceChoiceMemberEntry entry   = (SequenceChoiceMemberEntry)ParserUtils.GetCompatibleType(typeof(SequenceChoiceMemberEntry), context.Instance);

            if ((choices != null) && (provider != null) && (entry != null))
            {
                IWindowsFormsEditorService service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

                if (service != null)
                {
                    Dictionary <string, Func <object> > dict = new Dictionary <string, Func <object> >();

                    dict.Add("New Choice", () => new SequenceChoice(entry));

                    using (ObjectCollectionForm frm = new ObjectCollectionForm(choices, dict))
                    {
                        if (service.ShowDialog(frm) == DialogResult.OK)
                        {
                            value = frm.Objects.Cast <SequenceChoice>().ToArray();
                        }
                    }
                }
            }

            return(value);
        }