ab56a9bcf7
SVN-Revision: r240
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.Control.ImageLibrary
|
|
{
|
|
/// <summary>
|
|
/// ImageWhirligigExt控件设计模式行为
|
|
/// </summary>
|
|
[Description("ImageWhirligigExt控件设计模式行为")]
|
|
public class ImageWhirligigExtDesigner : DottedLineBorderExtDesigner
|
|
{
|
|
protected override void OnPaintAdornments(PaintEventArgs pe)
|
|
{
|
|
this.DrawTipText(pe.Graphics);
|
|
base.OnPaintAdornments(pe);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绘制提示文本
|
|
/// </summary>
|
|
/// <param name="graphics"></param>
|
|
private void DrawTipText(Graphics graphics)
|
|
{
|
|
ImageWhirligigExt _control = (ImageWhirligigExt)this.Control;
|
|
System.Windows.Forms.Control control = this.Control;
|
|
if (_control.Images.Count < 1)
|
|
{
|
|
string text = "请添加图片";
|
|
SizeF text_size = graphics.MeasureString(text, _control.Font);
|
|
SolidBrush text_sb = new SolidBrush((double)control.BackColor.GetBrightness() >= 0.5 ? ControlPaint.Dark(control.BackColor) : ControlPaint.Light(control.BackColor));
|
|
graphics.DrawString(text, _control.Font, text_sb, new RectangleF(control.ClientRectangle.X + (control.ClientRectangle.Width - text_size.Width) / 2f, control.ClientRectangle.Y + (control.ClientRectangle.Height - text_size.Height) / 2f, text_size.Width, text_size.Height));
|
|
text_sb.Dispose();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|