Exemple #1
0
        public MyFont(MyFont font)
        {
            var type = typeof(MyFont);

            foreach (var item in type.GetProperties())
            {
                item.SetValue(this, item.GetValue(font, null), null);
            }
        }
Exemple #2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            try
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    MyFont font = new MyFont((MyFont)value);

                    if (font.FontType == FontTypeConverter.FontTypeSystem)
                    {
                        FontDialog dialog = new FontDialog();

                        dialog.ShowEffects = false;
                        dialog.Font        = new Font(font.Name, font.Size, font.Style);

                        if (dialog.ShowDialog().Equals(DialogResult.OK))
                        {
                            font.Name  = dialog.Font.Name;
                            font.Size  = (int)dialog.Font.SizeInPoints;
                            font.Style = dialog.Font.Style;
                            return(font);
                        }
                    }
                    else
                    {
                        OpenFileDialog dialog = new OpenFileDialog();

                        dialog.Filter   = "TrueType Font(*.ttf)|*.ttf|所有文件(*.*)|*.*";
                        dialog.FileName = font.Name;
                        if (dialog.ShowDialog().Equals(DialogResult.OK))
                        {
                            font.Name = dialog.FileName;
                            return(font);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBoxEx.Show(e.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(value);
        }
Exemple #3
0
 public void ResetFont()
 {
     _font = def_font;
 }
Exemple #4
0
 public FontConfig()
 {
     _font         = def_font;
     _font.Padding = def_padding;
     _source       = def_source;
 }