陈嘉乐
2021-03-16 6b5f23413ceac72ad97d354e658798c8a422f556
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
using System;
using Shared;
using System.Collections.Generic;
namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice.View
{
    public class HeigthChangeView
    {
 
 
        /// <summary>
        /// 背景
        /// </summary>
        FrameLayout fLayout = new FrameLayout
        {
            BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
        };
        /// <summary>
        /// 
        /// </summary>
        FrameLayout iconFLyout = new FrameLayout
        {
            X = Application.GetRealWidth(205),
            Y = Application.GetRealHeight(314),
            Width = Application.GetRealWidth(160),
            Height = Application.GetRealHeight(21 + 44),
            //BackgroundImagePath = "LogicIcon/bjicon.png",
        };
        /// <summary>
        /// 
        /// </summary>
        FrameLayout textFLyout = new FrameLayout
        {
            X = Application.GetRealWidth(8),
            Y = Application.GetRealHeight(14),
            Width = Application.GetRealWidth(144),
            Height = Application.GetRealHeight(44),
        };
        /// <summary>
        /// 
        /// </summary>
        VerticalScrolViewLayout vv = new VerticalScrolViewLayout
        {
            X = Application.GetRealWidth(8),
            Y = Application.GetRealHeight(14),
            Width = Application.GetRealWidth(144),
            Height = Application.GetRealHeight(44 * 4),
        };
        /// <summary>
        /// View方法
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="list"></param>
        /// <param name="action"></param>
        public void Show(FrameLayout frame, List<Pir> list, Action<Pir> action)
        {
 
            frame.AddChidren(fLayout);
            fLayout.AddChidren(iconFLyout);
 
            fLayout.MouseUpEventHandler += (sender1, e1) =>
            {
                fLayout.RemoveFromParent();
            };
            if (list.Count > 4)
            {
                iconFLyout.Height = Application.GetRealHeight(21 + 44 * 4);
                iconFLyout.AddChidren(vv);
                iconFLyout.BackgroundImagePath = "PirIcon/4.png";
            }
            else
            {
 
                iconFLyout.AddChidren(textFLyout);
                iconFLyout.Height = Application.GetRealHeight(21 + 44 * list.Count);
                textFLyout.Height = Application.GetRealHeight(44 * list.Count);
                iconFLyout.BackgroundImagePath = $"PirIcon/{list.Count}.png";
            }
 
 
            for (int i = 0; i < list.Count; i++)
            {
                var pirJson = list[i];
                View.PirNameView pirNameView = new View.PirNameView();
                if (list.Count > 4)
                {
                    vv.AddChidren(pirNameView.FLayoutView());
                }
                else
                {
                    pirNameView.frameLayout.Y = Application.GetRealHeight(i * 44);
                    textFLyout.AddChidren(pirNameView.FLayoutView());
                }
                pirNameView.btnName.Text = pirJson.name;
                pirNameView.btnClick.Tag = pirJson;
                pirNameView.btnClick.MouseUpEventHandler += (sender2, e2) =>
                {
                    var pir = pirNameView.btnClick.Tag as Pir;
                    action(pir);
                    fLayout.RemoveFromParent();
 
                    //deviceNameBtn.Text = pirJson.name;
                    //Pir.currPir = pirJson;
 
                };
                if (list.Count - 1 == i)
                {
                    ///改变最后那条一个线的颜色,界面显示效果作用;
                    pirNameView.btnLine.BackgroundColor = CSS.CSS_Color.view;
                }
            }
        }
    }
}