HDL Home App 第二版本 旧平台金堂用 正在使用
陈嘉乐
2020-12-30 81307af66465a6b5ba189b0fb9b347787f004a4e
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
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.R;
 
namespace Shared.Phone.Device.Logic
{
    public class PublicInterface
    {
 
        /// <summary>
        /// 单选择
        /// </summary>
        /// <param name="frame">显示在哪个界面的父控件</param>
        /// <param name="list">显示数据源</param>
        /// <param name="titleText">标题文本</param>
        /// <param name="stateText">之前状态文本</param>
        /// <param name="action">返回值</param>
        public void SingleSelectionShow(FrameLayout frame, List<string> list, int titleText, string stateText, Action<string> action)
        {
            FrameLayout frameLayout = new FrameLayout
            {
                BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor,
            };
            frame.AddChidren(frameLayout);
            CompleteView view = new CompleteView();
            view.Btntitle.TextID = titleText;
            frameLayout.AddChidren(view.Show(list.Count));
            UserView.HomePage.Instance.ScrollEnabled = false;
            view.Btncancel.MouseUpEventHandler += (sender, e) =>
            {
                UserView.HomePage.Instance.ScrollEnabled = true;
                //移除fLayout界面
                frameLayout.RemoveFromParent();
            };
            ///定义一个Btn记录选中状态
            Button checkIconBtn = new Button
            {
                Tag = "unknown",
            };
            Button checkTextBtn = new Button
            {
                Tag = "unknown",
            };
            for (int i = 0; i < list.Count; i++)
            {
                string str = list[i];
                mFunView mFun= new mFunView(); 
                mFun.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                mFun.titleBtn.SelectedTextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                mFun.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160 * i);
                view.fraView.AddChidren(mFun.Show());
                mFun.titleBtn.Text = str;
                mFun.clickviewBtn.Tag = str;//标记
                if (list.Count-1==i) {
                    //改变最后一条的颜色
                    mFun.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
                }
                if (stateText == str)
                {
                    //图标改变
                    checkIconBtn.Visible = false;
                    mFun.selectedIconBtn.Visible = true;
                    checkIconBtn = mFun.selectedIconBtn;
                    checkIconBtn.Tag = mFun.clickviewBtn.Tag.ToString();
                    //字体改变
                    checkTextBtn.IsSelected = false;
                    mFun.titleBtn.IsSelected = true;
                    checkTextBtn = mFun.titleBtn;
 
                }
                //点击事件
                mFun.clickviewBtn.MouseUpEventHandler += (sender1, e1) =>
                {
                    //图标改变
                    checkIconBtn.Visible = false;
                    mFun.selectedIconBtn.Visible = true;
                    checkIconBtn = mFun.selectedIconBtn;
                    checkIconBtn.Tag = mFun.clickviewBtn.Tag.ToString();
                    //字体改变
                    checkTextBtn.IsSelected = false;
                    mFun.titleBtn.IsSelected = true;
                    checkTextBtn = mFun.titleBtn;
                };
 
            }
            view.Btncomplete.MouseUpEventHandler += (sender1, e1) =>
            {
                if (checkIconBtn.Tag.ToString() == "unknown")
                {
                    return;
                }
                action(checkIconBtn.Tag.ToString());
                UserView.HomePage.Instance.ScrollEnabled = true;
                //移除fLayout界面
                frameLayout.RemoveFromParent();
            };
 
        }
 
 
        /// <summary>
        /// 获取界面列表
        /// </summary>
        /// <param name="isStr">自己定义自己用</param>
        /// <returns></returns>
        public List<string> GetViewList(string isStr)
        {
            List<string> list = null;
            switch (isStr)
            {
                case "安防":
                    {
                        list = new List<string> {
                 Language.StringByID(MyInternationalizationString.logicathomegarrison),
                Language.StringByID(MyInternationalizationString.logicremovehomegarrison),
                Language.StringByID(MyInternationalizationString.withdrawal),
                 Language.StringByID(MyInternationalizationString.urgentwithdrawal),
                            };
                    }
                    break;
                case "时间": {
                        list = new List<string> {
                 Language.StringByID(MyInternationalizationString.immediateexecution),
                Language.StringByID(MyInternationalizationString.timeframe),
                            };
                    }
                    break;
                case "地理围栏":
                    {
                        list = new List<string> {
                 Language.StringByID(MyInternationalizationString.athome),
                Language.StringByID(MyInternationalizationString.leavehome),
                            };
                    }
                    break;
 
 
            }
            return list;
        }
    }
}