wxr
2020-06-15 b8e94316e41eba72d927d5ca7d931b26139ee8ff
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System;
using Android.Runtime;
using Android.Views;
using Com.Hdl.Widget;
 
namespace Shared
{
 
    /// <summary>
    /// ArcScaleSeekBar 空调 刻度圆弧控件
    /// </summary>
    public class ArcScaleSeekBar : BaseSeekBar
    {
        /// <summary>
        ///  当前视图
        /// </summary>
        /// <value>The HDLArcScaleSeekBar.</value>
        HDLArcScaleSeekBar mHDLArcScaleSeekBar
        {
            get
            {
                return AndroidView as HDLArcScaleSeekBar;
            }
            set
            {
                AndroidView = value;
            }
        }
 
        /// <summary>
        /// 构造函数
        /// </summary>
        public ArcScaleSeekBar()
        {
            mHDLArcScaleSeekBar = new HDLArcScaleSeekBar(Application.Activity);
            mOnProgressChangeListener = new OnProgressChangeListener(this);
            mHDLArcScaleSeekBar.SetOnProgressChangeListener(mOnProgressChangeListener);
 
        }
 
 
 
        /// <summary>
        /// 进度值显示单位
        /// </summary>
        /// <value>单位字符</value>
        public String ProgressBarUnitSring
        {
            set
            {
                mHDLArcScaleSeekBar.SetProgressBarUnitSring(value);
            }
        }
 
        /// <summary>
        /// 进度值最大值
        /// </summary>
        /// <value>最大值</value>
        public int MaxValue
        {
            set
            {
                mHDLArcScaleSeekBar.SetMaxValue(value);
            }
        }
 
        /// <summary>
        /// 进度值最小值
        /// </summary>
        /// <value>最小值</value>
        public int MinValue
        {
            set
            {
                mHDLArcScaleSeekBar.SetMinValue(value);
            }
        }
 
        /// <summary>
        /// 当前进度值
        /// </summary>
        /// <value>进度值</value>
        public int Progress
        {
            set
            {
                mHDLArcScaleSeekBar.Progress = value;
            }
 
            get
            {
                return mHDLArcScaleSeekBar.Progress;
            }
        }
 
 
 
        /// <summary>
        /// 当前进度值显示的文字颜色
        /// </summary>
        /// <value>文字颜色</value>
        public uint ProgressTextColor
        {
            set
            {
 
                byte r, g, b, a;
                r = (byte)(value / 256 / 256 % 256);
                g = (byte)(value / 256 % 256);
                b = (byte)(value % 256);
                a = (byte)(value / 256 / 256 / 256 % 256);
 
                mHDLArcScaleSeekBar.SetProgressTextColor(Android.Graphics.Color.Argb(a, r, g, b));
            }
        }
 
        /// <summary>
        /// 当前进度值显示的文字大小
        /// </summary>
        /// <value>文字大小</value>
        public int ProgressTextSize
        {
            set => mHDLArcScaleSeekBar.SetProgressTextSize(value);
        }
 
        /// <summary>
        /// 是否可以滑动
        /// </summary>
        /// <value>是否可以滑动</value>
        public bool IsClickable
        {
            set
            {
                mHDLArcScaleSeekBar.SetIsClickable(value);
            }
        }
 
        /// <summary>
        /// 是否可以滑动
        /// </summary>
        /// <value>是否可以滑动</value>
        public bool IsProgressTextShow
        {
            set
            {
                mHDLArcScaleSeekBar.SetProgressTextShow(value);
            }
        }
 
 
 
        /// <summary>
        /// 设置进度条 渐变颜色的开始颜色和结束颜色
        /// </summary>
        /// <value>开始颜色、结束颜色</value>
        public void SetProgressBarColors(uint startColor, uint endColor)
        {
            byte r, g, b, a;
            r = (byte)(startColor / 256 / 256 % 256);
            g = (byte)(startColor / 256 % 256);
            b = (byte)(startColor % 256);
            a = (byte)(startColor / 256 / 256 / 256 % 256);
 
            var start = Android.Graphics.Color.Argb(a, r, g, b);
 
 
            byte r2, g2, b2, a2;
            r2 = (byte)(endColor / 256 / 256 % 256);
            g2 = (byte)(endColor / 256 % 256);
            b2 = (byte)(endColor % 256);
            a2 = (byte)(endColor / 256 / 256 / 256 % 256);
 
            var end = Android.Graphics.Color.Argb(a2, r2, g2, b2);
 
      
            mHDLArcScaleSeekBar.SetStartColor(start);
            mHDLArcScaleSeekBar.SetEndColor(end);
            mHDLArcScaleSeekBar.PostInvalidate();
 
        }
 
        /// <summary>
        /// 是否离线 离线的话禁止滑动并绘制背景遮挡层
        /// </summary>
        /// <value>是否离线</value>
        public bool IsOffline
        {
            set
            {
                mHDLArcScaleSeekBar.SetOffline(value);
            }
        }
 
 
 
 
        /// <summary>
        /// EventHandler
        /// </summary>
        public EventHandler<int> OnProgressChangedEvent;
        public EventHandler<bool> OnStartTrackingTouchEvent;
        public EventHandler<int> OnStopTrackingTouchEvent;
 
        /// <summary>
        /// OnProgressChangeListener 继承响应事件
        /// </summary>
        OnProgressChangeListener mOnProgressChangeListener;
 
        public class OnProgressChangeListener : Java.Lang.Object, HDLArcScaleSeekBar.IOnProgressChangeListener
        {
 
            ArcScaleSeekBar _ArcScaleSeekBar;
 
            public OnProgressChangeListener(ArcScaleSeekBar view)
            {
                _ArcScaleSeekBar = view;
            }
 
            public void OnProgressChanged(HDLArcScaleSeekBar p0, int p1, bool p2)
            {
                if (_ArcScaleSeekBar.IsProgressChangeDelay()) return;
                _ArcScaleSeekBar.OnProgressChangedEvent?.Invoke(this, p0.Progress);
            }
 
            public void OnStartTrackingTouch(HDLArcScaleSeekBar p0)
            {
                _ArcScaleSeekBar.OnStartTrackingTouchEvent?.Invoke(this, true);
            }
 
            public void OnStopTrackingTouch(HDLArcScaleSeekBar p0)
            {
                _ArcScaleSeekBar.OnProgressChangedEvent?.Invoke(this, p0.Progress);
                _ArcScaleSeekBar.OnStopTrackingTouchEvent?.Invoke(this, p0.Progress);
 
            }
        }
    }
}