using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Security.Permissions;
using System.Windows.Forms;
using Dongke.WinForm.Utilities;
namespace Dongke.WinForm.Controls
{
///
/// 标准复选框列表控件
///
[ToolboxBitmap(typeof(CheckedListBox))]
[DefaultBindingProperty("SelectedValue"), DefaultProperty("Items"), DefaultEvent("ItemChecked")]
[LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")]
public class CklCheckedListBox : CheckedListBox, IDKControl, IDataVerifiable, IAsyncControl
{
#region 事件声明
#region ItemChecked
///
/// 当某项的选中状态更改后发生
///
private static readonly object EventItemChecked = new object();
///
/// 当某项的选中状态更改后发生。
///
[Description("当某项的选中状态更改后发生。"), Category("CustomerEx")]
public event ItemCheckedEventHandler ItemChecked
{
add
{
base.Events.AddHandler(EventItemChecked, value);
}
remove
{
base.Events.RemoveHandler(EventItemChecked, value);
}
}
#endregion
#region HasErrorChanged
///
/// 当 HasError 属性的值更改时发生。
///
private static readonly object EventHasErrorChanged = new object();
///
/// 当 HasError 属性的值更改时发生。
///
[Description("当 HasError 属性的值更改时发生。"), Category("CustomerEx")]
public event EventHandler HasErrorChanged
{
add
{
base.Events.AddHandler(EventHasErrorChanged, value);
}
remove
{
base.Events.RemoveHandler(EventHasErrorChanged, value);
}
}
#endregion
#endregion
#region 成员变量
///
/// 焦点是否进入控件
///
private bool _entered = false;
///
/// 鼠标是否进入控件
///
private bool _mouseOver = false;
///
/// 边框颜色
///
private Color? _borderColor = null;
///
/// 是否单选
///
private bool _simpleChecked = false;
///
/// 正在处理必须选中
///
private bool _isMustChecking = false;
///
/// 正在处理单项选中
///
private bool _isSimpleChecking = false;
///
/// 上次选中项个数
///
private int _inputCount = -1;
#endregion
#region 构造函数
///
/// 标准复选框列表控件
///
public CklCheckedListBox()
{
base.CheckOnClick = true;
base.FormattingEnabled = false;
base.ThreeDCheckBoxes = false;
CommonSetting.InitControls(this);
}
#endregion
#region 属性
///
/// 获取选中的文本
///
[Description("获取选中的文本。"), Category("CustomerEx")]
[DefaultValue(null)]
public string[] CheckedTexts
{
get
{
List checkedTexts = this.GetCheckedItemTexts();
return checkedTexts.ToArray();
}
}
///
/// 获取选中的值
///
[Description("获取选中的值。"), Category("CustomerEx")]
[DefaultValue(null)]
public object[] CheckedValues
{
get
{
List