Esempio n. 1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));



                if (edSvc != null)
                {
                    // Create a CheckedListBox and populate it with all the enum values
                    FontListbox              = new ListBox();
                    FontListbox.DrawMode     = DrawMode.OwnerDrawFixed;
                    FontListbox.BorderStyle  = BorderStyle.None;
                    FontListbox.Sorted       = true;
                    FontListbox.MouseDown   += new MouseEventHandler(this.OnMouseDown);
                    FontListbox.DoubleClick += new EventHandler(this.ValueChanged);
                    FontListbox.DrawItem    += new DrawItemEventHandler(this.LB_DrawItem);
                    FontListbox.ItemHeight   = 20;
                    FontListbox.MouseMove   += new MouseEventHandler(this.OnMouseMoved);
                    FontListbox.Height       = 200;
                    FontListbox.Width        = 180;

                    ICollection fonts = new FontEnum().EnumFonts();
                    foreach (string font in fonts)
                    {
                        FontListbox.Items.Add(font);
                    }
                    edSvc.DropDownControl(FontListbox);
                    if (FontListbox.SelectedItem != null)
                    {
                        return(FontListbox.SelectedItem.ToString());
                    }
                }
            }

            return(value);
        }
Esempio n. 2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));


                
                if (edSvc != null)
                {
                    // Create a CheckedListBox and populate it with all the enum values
                    FontListbox = new ListBox();
                    FontListbox.DrawMode = DrawMode.OwnerDrawFixed;
                    FontListbox.BorderStyle = BorderStyle.None;
                    FontListbox.Sorted = true;
                    FontListbox.MouseDown += new MouseEventHandler(this.OnMouseDown);
                    FontListbox.DoubleClick += new EventHandler(this.ValueChanged);
                    FontListbox.DrawItem += new DrawItemEventHandler(this.LB_DrawItem);
                    FontListbox.ItemHeight = 20;
                    FontListbox.MouseMove += new MouseEventHandler(this.OnMouseMoved);
                    FontListbox.Height = 200;
                    FontListbox.Width = 180;

                    ICollection fonts = new FontEnum().EnumFonts();
                    foreach (string font in fonts)
                    {
                        FontListbox.Items.Add(font);
                    }
                    edSvc.DropDownControl(FontListbox);
                    if (FontListbox.SelectedItem != null)
                        return FontListbox.SelectedItem.ToString();
                }
            }

            return value;
        }