黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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>
        /// <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();
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                System.Threading.Thread.Sleep(ControlCommonResourse.StatuChangedWaitTime);
                Application.RunOnMainThread(() =>
                {
                    //设置处于非选择状态时,显示的图标
                    this.SetUnSelectPictrue();
                });
            });
        }
 
        /// <summary>
        /// 设置处于选择状态时,显示的图标
        /// </summary>
        public void SetSelectPictrue()
        {
            this.IsSelected = true;
        }
 
        /// <summary>
        /// 设置处于非选择状态时,显示的图标
        /// </summary>
        public void SetUnSelectPictrue()
        {
            //设置不选择状态
            this.IsSelected = false;
        }
        #endregion
    }
}