黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone
{
    /// <summary>
    /// Icon控件的共通
    /// </summary>
    public class IconControlCommon : ButtonBase
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 是否启用点亮功能(默认不启用)
        /// </summary>
        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.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(HdlControlResourse.StatuChangedWaitTime);
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        //设置不选择状态
                        this.IsSelected = false;
                    });
                });
            }
        }
        #endregion
    }
}