You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

445 lines
12 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace JwKdsV.Component
{
[ToolboxItem(true)]
public partial class TilePanel : BaseSubItemPanel
{
public TilePanel()
{
InitializeComponent();
RefreshTitle();
RefreshContent();
RefreshBottom();
}
#region title设置
/// <summary>
/// title比例
/// </summary>
private int _titleRatio = 30;
[Category("标题设置"), Description("标题区域所占比例")]
public int TitleRatio
{
get
{
return _titleRatio;
}
set
{
_titleRatio = value;
RefreshTitle();
}
}
/// <summary>
/// 标题区域是否显示
/// </summary>
private bool _titleVisible = true;
[Category("标题设置"), Description("标题区域是否显示")]
public bool TitleVisible
{
get
{
return _titleVisible;
}
set
{
_titleVisible = value;
RefreshTitle();
}
}
private ContentAlignment _titleAlignment = ContentAlignment.MiddleCenter;
/// <summary>
/// 标题显示位置
/// </summary>
[Category("标题设置"), Description("标题文本显示位置")]
public ContentAlignment TitleAlignment
{
get
{
return _titleAlignment;
}
set
{
_titleAlignment = value;
RefreshTitle();
}
}
private string _titleText = "标题";
[Category("标题设置"), Description("标题文本内容")]
public string TitleText
{
get
{
return _titleText;
}
set
{
_titleText = value;
RefreshTitle();
}
}
private Font _titleFont = new Font("宋体", 9);
[Category("标题设置"), Description("标题文本字体")]
public Font TitleFont
{
get
{
return _titleFont;
}
set
{
_titleFont = value;
RefreshTitle();
}
}
private Color _titleForeColor = Color.Black;
[Category("标题设置"), Description("标题文本颜色")]
public Color TitleForeColor
{
get
{
return _titleForeColor;
}
set
{
_titleForeColor = value;
RefreshTitle();
}
}
private Color _titleBackColor = Color.White;
[Category("标题设置"), Description("标题背景颜色")]
public Color TitleBackColor
{
get
{
return _titleBackColor;
}
set
{
_titleBackColor = value;
RefreshTitle();
}
}
[Category("标题设置"), Description("标题Tag")]
public object TitleTag { get; set; }
private void RefreshTitle()
{
this.titleLabel.Visible = this.TitleVisible;
this.titleLabel.TextAlign = this.TitleAlignment;
this.titleLabel.Text = this.TitleText;
this.titleLabel.Height = this.Height * this.TitleRatio / 100;
this.titleLabel.Font = this.TitleFont;
this.titleLabel.BackColor = this.TitleBackColor;
this.titleLabel.ForeColor = this.TitleForeColor;
}
#endregion
#region content设置
/// <summary>
/// content比例
/// </summary>
private int _contentRatio = 70;
[Category("内容设置"), Description("内容显示位置")]
public int ContentRatio
{
get
{
return _contentRatio;
}
set
{
_titleRatio = value;
RefreshContent();
}
}
/// <summary>
/// 内容区域是否显示
/// </summary>
private bool _contentVisible = true;
[Category("内容设置"), Description("内容是否显示")]
public bool ContentVisible
{
get
{
return _contentVisible;
}
set
{
_contentVisible = value;
RefreshContent();
}
}
private ContentAlignment _contentAlignment = ContentAlignment.MiddleCenter;
[Category("内容设置"), Description("内容文本展示位置")]
public ContentAlignment ContentAlignment
{
get
{
return _contentAlignment;
}
set
{
_contentAlignment = value;
RefreshContent();
}
}
private string _contentText = "内容";
[Category("内容设置"), Description("内容文本内容")]
public string ContentText
{
get
{
return _contentText;
}
set
{
_contentText = value;
if (true)
{
}
RefreshContent();
}
}
private Font _contentFont = new Font("宋体", 9);
[Category("内容设置"), Description("内容文本字体")]
public Font ContentFont
{
get
{
return _contentFont;
}
set
{
_contentFont = value;
RefreshContent();
}
}
private Color _contentForeColor = Color.Black;
[Category("内容设置"), Description("内容文本颜色")]
public Color ContentForeColor
{
get
{
return _contentForeColor;
}
set
{
_contentForeColor = value;
RefreshContent();
}
}
private Color _contentBackColor = Color.White;
[Category("内容设置"), Description("内容背景颜色")]
public Color ContentBackColor
{
get
{
return _contentBackColor;
}
set
{
_contentBackColor = value;
RefreshContent();
}
}
[Category("内容设置"), Description("内容Tag")]
public object ContentTag { get; set; }
private void RefreshContent()
{
this.contentLabel.Visible = this.ContentVisible;
this.contentLabel.TextAlign = this.ContentAlignment;
this.contentLabel.Text = this.ContentText;
this.contentLabel.Height = this.Height * this.ContentRatio / 100;
this.contentLabel.Font = this.ContentFont;
this.contentLabel.BackColor = this.ContentBackColor;
this.contentLabel.ForeColor = this.ContentForeColor;
}
#endregion
#region bottom设置
/// <summary>
/// bottom比例
/// </summary>
private int _bottomRatio = 0;
[Category("底部内容设置"), Description("底部内容所占比例")]
public int BottomRatio
{
get
{
return _bottomRatio;
}
set
{
_bottomRatio = value;
RefreshBottom();
}
}
/// <summary>
/// 底部区域是否显示
/// </summary>
private bool _bottomVisible = false;
[Category("底部内容设置"), Description("底部区域是否显示")]
public bool BottomVisible
{
get
{
return _bottomVisible;
}
set
{
_bottomVisible = value;
RefreshBottom();
}
}
private StringAlignment _bottomAlignment = StringAlignment.Far;
[Category("底部内容设置"), Description("底部文本展示位置")]
public StringAlignment BottomAlignment
{
get
{
return _bottomAlignment;
}
set
{
_bottomAlignment = value;
RefreshBottom();
}
}
private string _bottomText = "底部内容";
[Category("底部内容设置"), Description("底部内容文本内容")]
public string BottomText
{
get
{
return _bottomText;
}
set
{
_bottomText = value;
RefreshBottom();
}
}
private Font _bottomFont = new Font("宋体", 9);
[Category("底部内容设置"), Description("底部内容文本字体")]
public Font BottomFont
{
get
{
return _bottomFont;
}
set
{
_bottomFont = value;
RefreshBottom();
}
}
private Color _bottomForeColor = Color.Black;
[Category("底部内容设置"), Description("底部内容文本颜色")]
public Color BottomForeColor
{
get
{
return _bottomForeColor;
}
set
{
_bottomForeColor = value;
RefreshBottom();
}
}
private Color _bottomBackColor = Color.White;
[Category("底部内容设置"), Description("底部内容背景颜色")]
public Color BottomBackColor
{
get
{
return _bottomBackColor;
}
set
{
_bottomBackColor = value;
RefreshBottom();
}
}
[Category("底部内容设置"), Description("底部内容tag")]
public object BottomTag { get; set; }
private void RefreshBottom()
{
this.bottomLabel.Visible = this.BottomVisible;
this.bottomLabel.TextAlignment = this.BottomAlignment;
this.bottomLabel.Text = this.BottomText;
this.bottomLabel.Height = this.Height * this.BottomRatio / 100;
this.bottomLabel.Font = this.BottomFont;
this.bottomLabel.BackColor = this.BottomBackColor;
this.bottomLabel.ForeColor = this.BottomForeColor;
}
#endregion
private void OnTilePanelMouseDown(object sender, MouseEventArgs e)
{
ItemClick?.Invoke(this, e);
//if(this.Width > 8 && this.Height > 8)
//{
// this.Size = new Size(this.Width - 8, this.Height - 8);
// this.Location = new Point(this.Location.X + 4, this.Location.Y + 4);
//}
}
private void OnTilePanelMouseUp(object sender, MouseEventArgs e)
{
//if (this.Width > 8 && this.Height > 8)
//{
// this.Location = new Point(this.Location.X - 4, this.Location.Y - 4);
// this.Size = new Size(this.Width + 8, this.Height + 8);
//}
}
public delegate void EventHandle(object sender, EventArgs e);
public event EventHandle ItemClick;
}
}