using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone
{
///
/// 点击按钮类的共通
///
public class ClickButtonCommon : ButtonBase
{
#region ■ 变量声明___________________________
///
/// 是否启用点亮功能(默认启用)
///
public bool UseClickStatu = true;
///
/// 原来的背景色(迫不得己,这个东西需要开放出去,设置一次之后将不会再设置)
///
public uint oldBackgroundColor = 0;
///
/// 点击状态的背景色(迫不得己,这个东西需要开放出去,默认使用底层设置的)
///
public uint clickStatuColor = UserCenterColor.Current.ButtonClickStatuColor;
///
/// 是否处于选择状态
///
private bool isSelcetStatu = false;
#endregion
#region ■ 初始化_____________________________
///
/// 单击按钮类的共通(初始值:拥有点亮功能,白色字体,黑色背景,文字居中)
///
public ClickButtonCommon()
{
this.TextColor = UserCenterColor.Current.White;
this.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
this.TextAlignment = TextAlignment.Center;
this.ButtonDownClickEvent += this.Button_MouseDownEvent;
}
#endregion
#region ■ 控件点亮特效_______________________
///
/// 单击按下事件
///
///
///
private void Button_MouseDownEvent(object sender, MouseEventArgs e)
{
if (this.UseClickStatu == false)
{
//永久移除
this.ButtonDownClickEvent -= Button_MouseDownEvent;
return;
}
if (base.CanClick == false || isSelcetStatu == true)
{
//控件不能点击,或者当前处于选择状态,则不能触发
return;
}
if (this.oldBackgroundColor == 0)
{
this.oldBackgroundColor = this.BackgroundColor;
}
//设置点击后的状态
this.SetClickStatu();
HdlThreadLogic.Current.RunThread(() =>
{
System.Threading.Thread.Sleep(HdlControlResourse.StatuChangedWaitTime);
HdlThreadLogic.Current.RunMain(() =>
{
if (base.CanClick == false || isSelcetStatu == false)
{
//控件不能点击,或者当前处于非选择状态,则不能触发
return;
}
//设置非点击后的状态
this.SetNotClickStatu();
});
});
}
///
/// 设置点击后的状态
///
public override void SetClickStatu()
{
this.isSelcetStatu = true;
this.BackgroundColor = clickStatuColor;
}
///
/// 设置非点击后的状态
///
public override void SetNotClickStatu()
{
this.isSelcetStatu = false;
//设置不选择状态
this.BackgroundColor = oldBackgroundColor;
}
#endregion
}
}