wxr
2022-03-18 8aa777aedd7492b7f2e28a172c2874f4ee7366a1
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
using Shared;
using HDL_ON.Stan;
using System;
using System.Collections.Generic;
using System.Text;
using HDL_ON.Entity;
using HDL_ON.DriverLayer;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 涂鸦扫地机器人耗材管理界面
    /// </summary>
    public class TuyaWeepRobotConsumablesMagPage: EditorCommonForm
    {
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_device">设备对象</param>
        /// <param name="robotData">扫地机器人数据</param>
        public void ShowForm(Function i_device, TuyaWeepRobotPage.WeepRobotData robotData)
        {
            base.SetTitleText(Language.StringByID(StringId.ConsumablesManagement));
 
            //边刷
            this.InitBrushControl(i_device, robotData.EdgeBrush, robotData.ResetEdgeBrush,
                Language.StringByID(StringId.RemainingLifeOfSideBrush),
                Language.StringByID(StringId.ResetSideBrush),
                Language.StringByID(StringId.ResetSideBrushMsg), "reset_edge_brush");
 
            //滚刷
            this.InitBrushControl(i_device, robotData.RollBrush, robotData.ResetRollBrush,
                Language.StringByID(StringId.RemainingLifeOfRollerBrush),
                Language.StringByID(StringId.ResetRollerBrush),
                Language.StringByID(StringId.ResetRollerBrushMsg), "reset_roll_brush");
 
            //滤网
            this.InitBrushControl(i_device, robotData.Filter, robotData.ResetFilter,
                Language.StringByID(StringId.RemainingLifeOfFilterScreen),
                Language.StringByID(StringId.ResetFilterScreen),
                Language.StringByID(StringId.ResetFilterScreenMsg), "reset_filter");
        }
 
        /// <summary>
        /// 初始化边刷控件
        /// </summary>
        /// <param name="i_device">设备对象</param>
        /// <param name="i_brushValue">边刷寿命</param>
        /// <param name="i_brushStatu">边刷状态</param>
        private void InitBrushControl(Function i_device, int i_brushValue, bool i_brushStatu, string i_brushText,
            string i_resetText, string i_resetMsg, string i_comand)
        {
            var myView = bodyFrameLayout.GetChildren(bodyFrameLayout.ChildrenCount - 1);
            var frameBack = new NormalFrameLayout();
            frameBack.Y = myView == null ? Application.GetRealHeight(12) : myView.Bottom + Application.GetRealHeight(12);
            frameBack.Width = Application.GetRealWidth(343);
            frameBack.Height = Application.GetRealHeight(100);
            frameBack.Radius = (uint)Application.GetRealWidth(12);
            frameBack.BackgroundColor = CSS.CSS_Color.MainBackgroundColor;
            frameBack.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(frameBack);
 
            var row1 = new FrameRowControl();
            row1.Height = Application.GetRealHeight(50);
            row1.Width = Application.GetRealWidth(343);
            frameBack.AddChidren(row1);
            //边刷剩余寿命
            var btnbrushText = row1.AddLeftCaption(i_brushText, 200);
            btnbrushText.TextColor = CSS.CSS_Color.FirstLevelTitleColor;
            //寿命值
            row1.AddMostRightView(i_brushValue + "%", 80);
            row1.AddBottomLine();
 
            var row2 = new FrameRowControl();
            row2.Y = row1.Bottom;
            row2.Height = Application.GetRealHeight(50);
            row2.Width = Application.GetRealWidth(343);
            frameBack.AddChidren(row2);
            //重置边刷
            var btnResetText = row2.AddLeftCaption(i_resetText, 200);
            btnResetText.TextColor = CSS.CSS_Color.FirstLevelTitleColor;
            //开关
            var btnSwitch = row2.AddMostRightSwitchIcon();
            btnSwitch.IsSelected = i_brushStatu;
            btnSwitch.ButtonClickEvent += (sender, e) =>
            {
                if (!i_device.online2d)
                {
                    new Tip()
                    {
                        CloseTime = 1,
                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                        Direction = AMPopTipDirection.None,
                    }.Show(MainPage.BaseView);
                    return;
                }
                if (btnSwitch.IsSelected == true)
                {
                    //取消的话直接取消
                    btnSwitch.CanClick = false;
                    btnSwitch.IsSelected = !btnSwitch.IsSelected;
 
                    HdlThreadLogic.Current.RunThread(() =>
                    {
                        var dic = new Dictionary<string, string>();
                        dic.Add(i_comand, "false");
                        Control.Ins.SendWriteCommand(i_device, dic, true);
                        btnSwitch.CanClick = true;
 
                    }, ShowErrorMode.NO);
                }
                else
                {
                    //开启需要确认
                    HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, i_resetMsg, () =>
                    {
                        btnSwitch.IsSelected = !btnSwitch.IsSelected;
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            var dic = new Dictionary<string, string>();
                            dic.Add(i_comand, "true");
                            Control.Ins.SendWriteCommand(i_device, dic, true);
                        }, ShowErrorMode.NO);
                    });
                }
            };
        }
 
        #endregion
    }
}