2b2d109132
SVN-Revision: r1230
225 lines
7.2 KiB
C#
225 lines
7.2 KiB
C#
using DevExpress.XtraEditors;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class LabApiButtonEdit : BaseUserControl
|
|
{
|
|
public LabApiButtonEdit()
|
|
{
|
|
InitializeComponent();
|
|
txtEdit.ReadOnly = true;
|
|
btnMore.Click += OnBtnMoreClick;
|
|
}
|
|
/// <summary>
|
|
/// 获取数据
|
|
/// </summary>
|
|
public event EventHandler OnRefreshDataCallBack;
|
|
/// <summary>
|
|
/// 文本控件
|
|
/// </summary>
|
|
public TextEdit TextEdit
|
|
{
|
|
get
|
|
{
|
|
return txtEdit;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件显示文本</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="text">显示Lebel文本</param>
|
|
public override string LabelText
|
|
{
|
|
get
|
|
{
|
|
return this.lblText.Text;
|
|
}
|
|
set
|
|
{
|
|
this.lblText.Text = value;
|
|
if (FontSize > 0)
|
|
{
|
|
this.plLeft.Dock = DockStyle.Left;
|
|
this.plLeft.AutoSize = false;
|
|
this.lblText.AutoSize = false;
|
|
this.lblText.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.lblText.Location = new System.Drawing.Point(0, 0);
|
|
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
this.txtEdit.Properties.AutoHeight = false;
|
|
this.plLeft.Width = value.Length * GetCharWidth();
|
|
GetCharWidthMultilingual(this.lblText, this.lblText.Text, this.plLeft);
|
|
}
|
|
else
|
|
{
|
|
|
|
this.plLeft.AutoSize = true;
|
|
this.plLeft.Width = this.lblText.Width + PaddingLeft;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 字体大小
|
|
/// </summary>
|
|
/// <value>The size of the control.</value>
|
|
public override float FontSize
|
|
{
|
|
get
|
|
{
|
|
return base.FontSize;
|
|
}
|
|
set
|
|
{
|
|
base.FontSize = value;
|
|
if (value > 0)
|
|
{
|
|
this.lblText.Font = new Font(this.lblText.Font.FontFamily, value);
|
|
this.TextEdit.Font = new Font(this.TextEdit.Font.FontFamily, value);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public override string EditText
|
|
{
|
|
get
|
|
{
|
|
return this.txtEdit.Text;
|
|
}
|
|
set
|
|
{
|
|
this.txtEdit.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件提示文本</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>返回控件值</returns>
|
|
public override string NullText
|
|
{
|
|
get
|
|
{
|
|
return this.txtEdit.Properties.NullValuePrompt;
|
|
}
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
this.TextEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this.TextEdit.Properties.NullValuePrompt = value;
|
|
}
|
|
base.NullText = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 只读文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the read only label.</value>
|
|
public override bool ReadOnly
|
|
{
|
|
get
|
|
{
|
|
return base.ReadOnly;
|
|
}
|
|
set
|
|
{
|
|
base.ReadOnly = value;
|
|
this.txtEdit.Properties.ReadOnly = value;
|
|
this.lblText.ForeColor = value ? base.ReadOnlyLabelForceColor : Required ? base.RequiredLabelForceColor : base.DefaultLabelForceColor;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 必填文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override bool Required
|
|
{
|
|
get
|
|
{
|
|
return base.Required;
|
|
}
|
|
set
|
|
{
|
|
base.Required = value;
|
|
if (value)
|
|
{
|
|
this.lblText.ForeColor = base.RequiredLabelForceColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:格式化文本控件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-10-17</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="formatString">The format string.</param>
|
|
public void TextFormat(string formatString)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(formatString))
|
|
{
|
|
this.txtEdit.Properties.Mask.EditMask = "##########" + (formatString == "#" ? "0" : formatString);//#代表位数
|
|
this.txtEdit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
|
|
this.txtEdit.Properties.Mask.UseMaskAsDisplayFormat = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 点击按钮重新获取数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBtnMoreClick(object sender, EventArgs e)
|
|
{
|
|
if (OnRefreshDataCallBack != null)
|
|
{
|
|
OnRefreshDataCallBack(this, e);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 背景颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override Color BackgroundColor
|
|
{
|
|
get
|
|
{
|
|
return TextEdit.Properties.Appearance.BackColor;
|
|
}
|
|
set
|
|
{
|
|
TextEdit.Properties.Appearance.BackColor = value;
|
|
}
|