| | |
| | | namespace HDL_ON.Stan
|
| | | {
|
| | | /// <summary>
|
| | | /// 电池百分比控件
|
| | | /// 电池百分比控件(高为25)
|
| | | /// </summary>
|
| | | public class BatteryPersentControl : NormalFrameLayout
|
| | | {
|
| | |
| | | /// 进度条
|
| | | /// </summary>
|
| | | private NormalViewControl btnProgress = null;
|
| | | /// <summary>
|
| | | /// 图标控件
|
| | | /// </summary>
|
| | | private IconViewControl btnIcon = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 电池百分比控件
|
| | | /// 电池百分比控件(高为25)
|
| | | /// </summary>
|
| | | public BatteryPersentControl()
|
| | | {
|
| | |
| | | /// <summary>
|
| | | /// 初始化控件
|
| | | /// </summary>
|
| | | public void InitControl()
|
| | | /// <param name="showPersent">是否在右边显示百分比</param>
|
| | | public void InitControl(bool showPersent = true)
|
| | | {
|
| | | var btnIcon = new IconViewControl(24);
|
| | | btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Battery.png";
|
| | | this.btnIcon = new IconViewControl(24);
|
| | | btnIcon.UnSelectedImagePath = "Public/BatteryEnough.png";
|
| | | this.AddChidren(btnIcon);
|
| | |
|
| | | //电池百分比
|
| | | this.btnBatteryView = new NormalViewControl(30, 16, true);
|
| | | btnBatteryView.X = btnIcon.Right + Application.GetRealWidth(4);
|
| | | btnBatteryView.Y = btnIcon.Y + (btnIcon.Height - Application.GetRealHeight(16)) / 2;
|
| | | btnBatteryView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
|
| | | btnBatteryView.TextColor = CSS_Color.PromptingColor1;
|
| | | this.AddChidren(btnBatteryView);
|
| | | if (showPersent == true)
|
| | | {
|
| | | this.btnBatteryView = new NormalViewControl(30, 16, true);
|
| | | btnBatteryView.X = btnIcon.Right + Application.GetRealWidth(4);
|
| | | btnBatteryView.Y = btnIcon.Y + (btnIcon.Height - Application.GetRealHeight(16)) / 2;
|
| | | btnBatteryView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
|
| | | btnBatteryView.TextColor = CSS_Color.PromptingColor1;
|
| | | this.AddChidren(btnBatteryView);
|
| | | }
|
| | |
|
| | | //进度条控件
|
| | | this.btnProgress = new NormalViewControl(this.GetPictrueRealSize(15), this.GetPictrueRealSize(8), false);
|
| | |
| | | public void SetValue(decimal i_value)
|
| | | {
|
| | | int myWidth = (int)((i_value / 100) * this.GetPictrueRealSize(15));
|
| | | this.btnBatteryView.Text = i_value + "%";
|
| | | if (this.btnBatteryView != null)
|
| | | {
|
| | | this.btnBatteryView.Text = i_value + "%";
|
| | | }
|
| | |
|
| | | this.btnProgress.Width = myWidth;
|
| | | if (i_value <= 20)
|
| | | {
|
| | | if (this.btnProgress.BackgroundColor == CSS_Color.PromptingColor1)
|
| | | {
|
| | | //变红色
|
| | | this.btnProgress.BackgroundColor = 0xfff62f48;
|
| | | }
|
| | | //变红色
|
| | | this.btnProgress.BackgroundColor = 0xfff62f48;
|
| | | this.btnIcon.UnSelectedImagePath = "Public/BatteryNot.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | if (this.btnProgress.BackgroundColor == 0xfff62f48)
|
| | | {
|
| | | //变红色
|
| | | this.btnProgress.BackgroundColor = CSS_Color.PromptingColor1;
|
| | | }
|
| | | //变灰色
|
| | | this.btnProgress.BackgroundColor = CSS_Color.PromptingColor1;
|
| | | this.btnIcon.UnSelectedImagePath = "Public/BatteryEnough.png";
|
| | | }
|
| | | }
|
| | |
|