using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace ryControls
{
///
///
///
public partial class MsgUI : UserControl
{
///
///
///
public MsgUI()
{
InitializeComponent();
lblText.UpdateInfo();
timer1.Enabled = true;
}
int _MaxItemHeight = 0;
///
///最大高度
///
[Category("Appearance"), Description("最大高度")]
public int MaxItemHeight
{
get { return _MaxItemHeight; }
set { _MaxItemHeight = value; panel1.MaximumSize = new Size(10000, _MaxItemHeight); }
}
private string _title = "";
///
/// 标题
///
[Category("内容"), Description("标题")]
public string Title
{
get { return _title; }
set { if (ShowDateTime) { lblTitle.Text = value+"(" + ryControls.Pram.Pram.DateDiff(AddTime, DateTime.Now) + ")"; } else { lblTitle.Text = value; } _title = value; }
}
///
/// 是否显示时间
///
public bool ShowDateTime { get; set; } = false;
///
/// 添加时间
///
public DateTime AddTime { get; set; } = DateTime.Now;
///
/// 内容
///
[Browsable(true), Category("内容"), Description("内容")]
public override string Text
{
get { return lblText.Text; }
set { lblText.Text = value; lblText.UpdateInfo(); }
}
string _url = "";
///
/// 网址
///
[Category("内容"), Description("网址")]
public string Url
{
get { return _url; }
set
{
_url = value;
if (_url != "")
{
lblTitle.Font = new Font(lblTitle.Font, FontStyle.Underline);
lblTitle.Cursor = Cursors.Hand;
}
else
{
lblTitle.Font = new Font(lblTitle.Font, FontStyle.Regular);
lblTitle.Cursor = Cursors.Default;
}
}
}
private void MsgUI_Resize(object sender, EventArgs e)
{
lblText.UpdateInfo();
}
private void LblTitle_Click(object sender, EventArgs e)
{
if (_url != "")
{
ryCommon.RyFiles.RunFile(_url, "");
}
}
private void MsgUI_Load(object sender, EventArgs e)
{
}
private void Timer1_Tick(object sender, EventArgs e)
{
if (ShowDateTime) { lblTitle.Text = _title + "(" + ryControls.Pram.Pram.DateDiff(AddTime, DateTime.Now) + ")"; }
else
{ lblTitle.Text = _title; }
}
}
}