Example #1
0
        public static PersistentFont FromFont(Font font, Color color)
        {
            PersistentFont result = new PersistentFont();

            result.FontName  = font.Name;
            result.FontSize  = font.Size;
            result.FontStyle = font.Style;
            result.FontColor = color;
            return(result);
        }
Example #2
0
 public override void PaintValue(PaintValueEventArgs e)
 {
     if (e.Value != null)
     {
         PersistentFont font = (PersistentFont)e.Value;
         using (Brush color = new SolidBrush(font.FontColor))
         {
             GraphicsState state = e.Graphics.Save();
             e.Graphics.FillRectangle(color, e.Bounds);
             e.Graphics.Restore(state);
         }
     }
     else
     {
         base.PaintValue(e);
     }
 }
Example #3
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context == null || provider == null || context.Instance == null)
            {
                return(base.EditValue(provider, value));
            }

            FontDialog     dlg = new FontDialog();
            PersistentFont src = (PersistentFont)value;

            dlg.ShowColor = true;
            dlg.Font      = (Font)src.GdiFont.Clone();
            dlg.Color     = src.FontColor;
            if (dlg.ShowDialogEx() == DialogResult.OK)
            {
                return(PersistentFont.FromFont(dlg.Font, dlg.Color));
            }
            else
            {
                return(value);
            }
        }