xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
using System;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 一个简单的条形进度条
    /// </summary>
    public class ProgressLine : FrameLayout
    {
        /// <summary>
        /// 一个简单的条形进度条
        /// </summary>
        /// <param name="height">进度条高度</param>
        /// <param name="width">进度条宽度</param>
        public ProgressLine(int height = 3, int width = 1080)
        {
            this.Width = Application.GetRealWidth(width);
            this.Height = height;
            this.BackgroundColor = UserCenterColor.Current.DeepGray1;
        }
 
        /// <summary>
        /// 设定进度值
        /// </summary>
        /// <param name="value">进度值(与100的比率)</param>
        /// <param name="isLeft">从左边开始进度</param>
        public void SetValue(decimal value, bool isLeft = true)
        {
            this.RemoveAll();
            Button button = new Button();
            button.Height = this.Height;
            int width = (int)((value / 100) * this.Width);
            if (isLeft == false)
            {
                button.X = this.Width - width;
            }
            button.Width = width;
            button.BackgroundColor = UserCenterColor.Current.SelectTextColor;
            this.AddChidren(button);
        }
    }
}