HDL Home App 第二版本 旧平台金堂用 正在使用
chenqiyang
2022-06-22 dc0309e64f02227d8e1468b7326c07955f804612
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/BaseCommonControl/Common/IconControlCommon.cs
old mode 100755 new mode 100644
@@ -1,87 +1,98 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// Icon控件的共通
    /// </summary>
    public class IconControlCommon : ButtonBase
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 是否启用点亮功能(默认不启用)
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// Icon控件的共通
    /// </summary>
    public class IconControlCommon : ButtonBase
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 是否启用点亮功能(默认不启用)
        /// </summary>
        public bool UseClickStatu = false;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// Icon控件的共通
        /// </summary>
        public IconControlCommon()
        {
            //这个事件是搞点亮特效的
            this.MouseDownEventHandler += this.Button_MouseDownEvent;
        }
        #endregion
        #region ■ 控件点亮特效_______________________
        /// <summary>
        /// 单击按下事件
        /// </summary>
        /// <param name="sender"></param>
        public bool UseClickStatu = false;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// Icon控件的共通
        /// </summary>
        public IconControlCommon()
        {
            //这个事件是搞点亮特效的
            this.ButtonDownClickEvent += this.Button_MouseDownEvent;
        }
        #endregion
        #region ■ 控件点亮特效_______________________
        /// <summary>
        /// 单击按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_MouseDownEvent(object sender, MouseEventArgs e)
        {
            if (this.UseClickStatu == false || string.IsNullOrEmpty(this.SelectedImagePath) == true)
            {
                //永久移除
                this.MouseDownEventHandler -= this.Button_MouseDownEvent;
                return;
            }
            if (base.CanClick == false || this.IsSelected == true)
            {
                //控件不能点击,或者当前处于选择状态,则不能触发
                return;
            }
            //设置处于选择状态时,显示的图标
            this.SetSelectPictrue();
            new System.Threading.Thread(() =>
            {
                System.Threading.Thread.Sleep(ControlCommonResourse.StatuChangedWaitTime);
                Application.RunOnMainThread(() =>
                {
                    //设置处于非选择状态时,显示的图标
                    this.SetUnSelectPictrue();
                });
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 设置处于选择状态时,显示的图标
        /// </summary>
        public void SetSelectPictrue()
        {
            this.IsSelected = true;
        }
        /// <summary>
        /// 设置处于非选择状态时,显示的图标
        /// </summary>
        public void SetUnSelectPictrue()
        {
            //设置不选择状态
            this.IsSelected = false;
        }
        #endregion
    }
}
        private void Button_MouseDownEvent(object sender, MouseEventArgs e)
        {
            if (this.UseClickStatu == false || string.IsNullOrEmpty(this.SelectedImagePath) == true)
            {
                //永久移除
                this.ButtonDownClickEvent -= Button_MouseDownEvent;
                return;
            }
            if (base.CanClick == false || this.IsSelected == true)
            {
                //控件不能点击,或者当前处于选择状态,则不能触发
                return;
            }
            //设置处于选择状态时,显示的图标
            this.SetSelectPictrue();
            //设置处于非选择状态时,显示的图标
            this.SetUnSelectPictrue(true);
        }
        /// <summary>
        /// 设置处于选择状态时,显示的图标
        /// </summary>
        public void SetSelectPictrue()
        {
            this.IsSelected = true;
        }
        /// <summary>
        /// 设置处于非选择状态时,显示的图标
        /// </summary>
        /// <param name="waitTime">追加变量:是否等待</param>
        public void SetUnSelectPictrue(bool waitTime)
        {
            if (waitTime == false)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //设置不选择状态
                    this.IsSelected = false;
                });
            }
            else
            {
                HdlThreadLogic.Current.RunThread(() =>
                {
                    System.Threading.Thread.Sleep(ControlCommonResourse.StatuChangedWaitTime);
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //设置不选择状态
                        this.IsSelected = false;
                    });
                });
            }
        }
        #endregion
    }
}