namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 提示窗体
|
/// </summary>
|
public partial class TipForm : DevExpress.XtraEditors.XtraForm
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public TipForm()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public void Set(eTipStatus status, string caption, int interval)
|
{
|
this.timer1.Enabled = false;
|
this.labText.ImageOptions.ImageIndex = (int)status;
|
this.labText.Text = caption;
|
this.timer1.Interval = interval;
|
this.timer1.Enabled = true;
|
AdaptSize();
|
}
|
|
//自适应尺寸
|
private void AdaptSize()
|
{
|
int width = 300;
|
int height = 80;
|
var bestSize = this.labText.CalcBestSize();
|
if (width < bestSize.Width + 20)
|
{
|
width = bestSize.Width + 20;
|
}
|
if (height < bestSize.Height + 20)
|
{
|
height = bestSize.Height + 20;
|
}
|
this.Size = new Size(width, height);
|
}
|
|
/// <summary>
|
/// 绘制边框
|
/// </summary>
|
/// <param name="e"></param>
|
protected override void OnPaint(PaintEventArgs e)
|
{
|
base.OnPaint(e);
|
this.DrawBorder(e, Color.Gray, 1);
|
}
|
|
//事件
|
private void timer_Tick(object sender, EventArgs e)
|
{
|
this.timer1.Enabled = false;
|
this.Close();
|
}
|
|
|
|
}
|
}
|