Exemple #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                ListBox lbValues = new ListBox();
                lbValues.BorderStyle = BorderStyle.None;
                var fonts = JwIconfontManager.GetFonts();
                var ctrl  = context.Instance as IIconfont;
                var old   = ctrl.IconFontName;
                for (var i = 0; i < fonts.Length; i++)
                {
                    lbValues.Items.Add(fonts[i]);
                    if (fonts[i].ToUpper().Trim().Equals(old.ToUpper().Trim(), StringComparison.Ordinal))
                    {
                        lbValues.SelectedIndex = i;
                    }
                }
                lbValues.Click += (sender, arg) =>
                {
                    service.CloseDropDown();
                };
                service.DropDownControl(lbValues);
                if (lbValues.SelectedItem != null)
                {
                    return(lbValues.SelectedItem.ToString());
                }
                else
                {
                    return(old);
                }
            }

            return(value);
        }
Exemple #2
0
        public static Font GetIconFont(string fontkey, int insize)
        {
            var item = JwIconfontManager.GetFontInfo(fontkey);
            var size = insize * item.PointZoom;
            var font = new Font(item.Family, size, FontStyle.Regular, GraphicsUnit.Point);

            return(font);
        }