黄学彪
2019-12-12 7e863a33397f317ffc3ffd9288496d0e4f16aa66
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 左右滑动的进度条控件
    /// </summary>
    public class SeekBarControl : DiyImageSeekBar
    {
        #region ■ 变量声明___________________________
 
        private uint nowProgressBarColor = 0;
        /// <summary>
        /// 控件能否使用
        /// </summary>
        public new bool Enable
        {
            set
            {
                this.IsClickable = value;
                if (value == true)
                {
                    //原来的颜色
                    base.ProgressBarColor = nowProgressBarColor;
                }
                else
                {
                    //灰色
                    base.ProgressBarColor = 0xffe8e8e8;
                }
            }
        }
 
        /// <summary>
        /// 进度条颜色
        /// </summary>
        public new uint ProgressBarColor
        {
            set
            {
                nowProgressBarColor = value;
                base.ProgressBarColor = value;
            }
        }
 
        /// <summary>
        /// 进度值改变,如果要设置初始进度值,此变量要在设置初始进度值之前进行设置(第一个参数0:滑动的时候,1:手指弹起的时候)
        /// </summary>
        public Action<int, int> ProgressChangedEvent = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 左右滑动的进度条控件
        /// </summary>
        /// <param name="i_width">宽度,非真实值</param>
        public SeekBarControl(int i_width = 962)
        {
            this.Width = Application.GetRealWidth(i_width);
            this.Height = Application.GetRealHeight(84);
            this.ThumbImageHeight = Application.GetRealHeight(84);
            this.ThumbImagePath = "Item/SeekBarIcon.png";
            this.SeekBarViewHeight = Application.GetRealHeight(10);
            this.SeekBarBackgroundColor = 0xfff5f5f5;
            this.IsProgressTextShow = false;
            this.MaxValue = 100;
            this.Gravity = Gravity.CenterHorizontal;
 
            //进度条值改变事件
            this.OnProgressChangedEvent += this.MyProgressChangedEvent;
            //手指弹起事件
            this.OnStopTrackingTouchEvent += this.MyStopTrackingTouchEvent;
        }
 
        #endregion
 
        #region ■ 事件_______________________________
 
        /// <summary>
        /// 进度条值改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void MyProgressChangedEvent(object sender, int value)
        {
            if (this.ProgressChangedEvent == null)
            {
                this.OnProgressChangedEvent -= this.MyProgressChangedEvent;
                return;
            }
            this.ProgressChangedEvent(0, value);
        }
 
        /// <summary>
        /// 手指弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void MyStopTrackingTouchEvent(object sender, int value)
        {
            if (this.ProgressChangedEvent == null)
            {
                this.OnStopTrackingTouchEvent -= this.MyStopTrackingTouchEvent;
                return;
            }
            this.ProgressChangedEvent(1, value);
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 控件摧毁
        /// </summary>
        public override void RemoveFromParent()
        {
            this.ProgressChangedEvent = null;
            base.RemoveFromParent();
        }
 
        #endregion
    }
}