|
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Drawing.Design;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using System.Windows.Forms.Design;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeoSigma.SigmaDrawerStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 字体编辑器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class PropertyEditorWellFontEx : UITypeEditor
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
return UITypeEditorEditStyle.Modal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void PaintValue(PaintValueEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Value is WellFontEx font)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var brush = new SolidBrush(font.FontColor))
|
|
|
|
|
|
{
|
|
|
|
|
|
var rect = new Rectangle(e.Bounds.X, e.Bounds.Y, 20, e.Bounds.Height - 1);
|
|
|
|
|
|
e.Graphics.FillRectangle(brush, rect);
|
|
|
|
|
|
e.Graphics.DrawRectangle(Pens.Black, rect);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!(value is WellFontEx fontEx))
|
|
|
|
|
|
{
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IWindowsFormsEditorService edSvc = provider?.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
|
|
|
|
|
if (edSvc == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (FontDialog dlg = new FontDialog())
|
|
|
|
|
|
{
|
|
|
|
|
|
// 设置初始字体
|
|
|
|
|
|
dlg.Font = WellFontEx.ToFont(fontEx);
|
|
|
|
|
|
|
|
|
|
|
|
dlg.Color = fontEx.FontColor;
|
|
|
|
|
|
dlg.ShowColor = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = WellFontEx.FromFont(dlg.Font);
|
|
|
|
|
|
result.FontColor = dlg.Color;
|
|
|
|
|
|
result.Text = fontEx.Text;
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|