|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Controls.Default
|
|
|
|
|
{
|
|
|
|
|
[ToolboxBitmap(typeof(TopPanel), "Resources.TopPanel.png")]
|
|
|
|
|
public partial class TopPanel : Panel
|
|
|
|
|
{
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
protected Assembly _assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
protected Stream _imageStream;
|
|
|
|
|
private Label systemName;
|
|
|
|
|
private string _topText = string.Empty; //系统名称
|
|
|
|
|
private int _titleSize; //系统名称字号
|
|
|
|
|
private int _titleXValue; //系统名称X坐标
|
|
|
|
|
private int _titleYValue; //系统名称Y坐标
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 构造方法
|
|
|
|
|
|
|
|
|
|
public TopPanel()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//加载设置背景图
|
|
|
|
|
this.Size = new Size(1920, 78);
|
|
|
|
|
_imageStream = _assembly.GetManifestResourceStream("Mesnac.Controls.Default.Resources.TopPanel.png");
|
|
|
|
|
this.BackgroundImage = Image.FromStream(_imageStream);
|
|
|
|
|
this.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
|
this.SizeChanged += new System.EventHandler(this.TopPanelSizeChanged); //大小改变事件
|
|
|
|
|
|
|
|
|
|
//创建设置Label
|
|
|
|
|
systemName = new Label();
|
|
|
|
|
this.Controls.Add(systemName);
|
|
|
|
|
systemName.AutoSize = true;
|
|
|
|
|
systemName.FlatStyle = System.Windows.Forms.FlatStyle.Flat; //显示样式
|
|
|
|
|
systemName.Font = new System.Drawing.Font("黑体", 24, FontStyle.Bold); //设置字体
|
|
|
|
|
systemName.TextAlign = ContentAlignment.MiddleCenter; //文字对齐
|
|
|
|
|
systemName.ForeColor = Color.White; //文字颜色
|
|
|
|
|
systemName.Location = new Point((this.Width - systemName.Width) / 2,(this.Height - systemName.Height) / 2);
|
|
|
|
|
systemName.SizeChanged += new System.EventHandler(systemNameSizeChanged); //大小改变事件
|
|
|
|
|
//systemName.Text = "测试一下";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TopPanel(IContainer container)
|
|
|
|
|
{
|
|
|
|
|
container.Add(this);
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 属性定义
|
|
|
|
|
|
|
|
|
|
public string TopText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _topText;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_topText = value;
|
|
|
|
|
systemName.Text = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TitleSize
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _titleSize;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_titleSize = value;
|
|
|
|
|
//systemName.Font = new System.Drawing.Font("黑体", value, FontStyle.Bold); //设置字体
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int TitleXValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _titleXValue;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_titleXValue = value;
|
|
|
|
|
systemName.Location = new Point(value, systemName.Location.Y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int TitleYValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _titleYValue;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_titleYValue = value;
|
|
|
|
|
systemName.Location = new Point(systemName.Location.X, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件处理
|
|
|
|
|
|
|
|
|
|
private void TopPanelSizeChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
systemName.Location = new Point((this.Width - systemName.Width) / 2, (this.Height - systemName.Height) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void systemNameSizeChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
systemName.Location = new Point((this.Width - systemName.Width) / 2, (this.Height - systemName.Height) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|