黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using System;
using System.Collections.Generic;
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.Phone.Device.Logic.LogicView;
using Shared.R;
using ZigBee.Device;
 
namespace Shared.Phone.Device.Logic
{
    public class OneTimePoint : FrameLayout
    {
        public OneTimePoint()
        {
            Tag = "Logic";
        }
        
        public void Show(Action<string> action)
        {
            #region  上面的布局代码
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.TextID = MyInternationalizationString.addtime;
            view.clickBtn.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent();
                action("");
            };
            #endregion
 
            var middle = new FrameLayout
            {
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184 - 260),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            #region   -----类型 时刻 自定义时间
            TypeView typeView = new TypeView();
            middle.AddChidren(typeView.Show());
            typeView.textBtn.TextID = MyInternationalizationString.type;
            typeView.titleBtn.Width = Application.GetRealWidth(630 + 70);
            typeView.titleBtn.TextID = MyInternationalizationString.immediateexecution;
            typeView.backBtn.Visible = false;
 
            TypeView skView = new TypeView();
            skView.frameLayout.Y = typeView.frameLayout.Bottom;
            middle.AddChidren(skView.Show());
            skView.textBtn.TextID = MyInternationalizationString.moment;
            skView.backBtn.UnSelectedImagePath = "ZigeeLogic/dropdown.png";
 
            #endregion
 
            var rowTimeView = new FrameLayout
            {
                Y = skView.frameLayout.Bottom,
                Height = Application.GetRealHeight(600),
            };
            middle.AddChidren(rowTimeView);
 
            TimeView timeview = new TimeView
            {
 
                Height = Application.GetRealHeight(550),
                BackgroundColor = 0x40ffffff,
                Width = Application.GetRealWidth(1080),
            };
            rowTimeView.AddChidren(timeview);
 
            //保存
            SaveView saveView = new SaveView();
            saveView.frameLayout.Y = middle.Bottom;
            this.AddChidren(saveView.Show());
            saveView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                string h = timeview.Hour.ToString();
                string m = timeview.Minute.ToString();
                Dictionary<string, string> timeIfon = new Dictionary<string, string>();
                timeIfon.Add("Type", "0");
                timeIfon.Add("IsValid", "1");
                timeIfon.Add("DateType", "0");
                timeIfon.Add("RemindTime", "0");
                timeIfon.Add("EnDelay", "0");
                timeIfon.Add("DelayTime", "0");
                timeIfon.Add("DoorLockOpenDelayTime", "0");
                timeIfon.Add("StartHour", h);
                timeIfon.Add("StartMin", m);
                for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
                {
                    if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "0")
                    {
                        Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
                        Common.Logic.CurrentLogic.Conditions.Insert(i, timeIfon);
                        break;
                    }
                }
                string s = h + ":" + (m.Length < 2 ? "0" + m : m);
                this.RemoveFromParent();
                action(s);
            };
 
        }
 
    }
}