黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
 
 
 
using System;
using System.Collections.Generic;
using Shared;
using Shared.Phone;
using Shared.R;
using Shared.Common;
namespace Shared.Phone.Device.Logic
{
 
    public class EverymonthPage : FrameLayout
    {
        public EverymonthPage()
        {
            Tag = "Logic";
        }
        public void Show(string titlename)
        {
          
 
            #region  上面的布局代码
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.Text = titlename;
            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
            #endregion
 
            var middle = new FrameLayout
            {
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
 
 
            var frameLayout = new FrameLayout
            {
                Y = Application.GetRealHeight(80),
                X = Application.GetRealWidth(50),
                Width = Application.GetRealWidth(1080 - 100),
                Height = Application.GetRealHeight(180 * 5 + 50),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
            };
            middle.AddChidren(frameLayout);
            
       
            var saveBtn = new Button
            {
                Y = middle.Height - Application.GetRealHeight(260),
                X = Application.GetRealWidth(85),
                Height = Application.GetRealHeight(130),//194
                Width = Application.GetRealWidth(910),
                Radius = (uint)Application.GetRealHeight(60),
                BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
                TextID = MyInternationalizationString.Save,
                TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                TextSize = 16,
            };
            middle.AddChidren(saveBtn);
 
            var monselectedlist = new List<string>();
            monselectedlist.Clear();
            if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 3)
            {
                if (Common.Logic.CurrentLogic.TimeAttribute.MonthDate != 0)
                {
                    string len = "";
                    var maxvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.MonthDate, 2);
                    var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length));
                    for (int j = 31; j >= 0; j--)
                    {
                        len += str.Substring(j, 1);
                    }
 
                    for (int j = 0; j < len.Length; j++)
                    {
                        var strvalue = len.Substring(j, 1);
                        if (strvalue == "1")
                        {
                            monselectedlist.Add((j + 1).ToString());
                        }
                    }
 
                }
            }
 
 
            int k = 1;
            for (int i = 0; i < 5; i++)
            {
                var timeRow = new RowLayout
                {
                    Height = Application.GetRealHeight(180),
                    Y = Application.GetRealHeight(180 * i),
                    LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                };
                frameLayout.AddChidren(timeRow);
                for (int j = 1; j < 8; j++)
                {
                    if (k > 31)
                    {
                        continue;
                    }
 
                    var monBtn = new Button
                    {
 
                        Text = k.ToString().Length == 1 ? "0" + k.ToString() : k.ToString(),
                        Y = Application.GetRealHeight(40),
                        Height = Application.GetMinRealAverage(100),
                        Width = Application.GetMinRealAverage(100),
                        X = Application.GetRealWidth(35 * j) + Application.GetRealWidth(100 * (j - 1)),
                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                        Radius = (uint)Application.GetMinRealAverage(50),
                        BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                        SelectedBackgroundColor = ZigbeeColor.Current.LogicAddColor,
                        Tag = k,
                    };
                    timeRow.AddChidren(monBtn);
 
 
 
                    if (monselectedlist.Contains(k.ToString()))
                    {
                        monBtn.IsSelected = true;
                    }
                    k++;
 
                    monBtn.MouseDownEventHandler += (sender, e) =>
                    {
                        monBtn.IsSelected = !monBtn.IsSelected;
                        var selectedmon = monselectedlist.Find((c) => { return c == monBtn.Tag.ToString(); });
                        if (monBtn.IsSelected)
                        {
                            if (selectedmon == null)
                            {
                                monselectedlist.Add(monBtn.Tag.ToString());
 
                            }
 
                        }
                        else
                        {
                            if (selectedmon != null)
                            {
                                monselectedlist.Remove(monBtn.Tag.ToString());
                            }
                        }
                    };
                }
            }
 
 
 
            saveBtn.MouseUpEventHandler += (sedder, e) =>
            {
 
                if (monselectedlist.Count == 0)
                {
 
                    var alert = new ShowMsgControl(ShowMsgType.Normal,
                          Language.StringByID(MyInternationalizationString.selectweek),
                         Language.StringByID(MyInternationalizationString.confrim));
                    alert.Show();
                    return;
                }
                string s = "";
                for (int i = 32; i > 0; i--)
                {
                    var selectedmon = monselectedlist.Find((a) => { return a == i.ToString(); });
                    if (selectedmon != null)
                    {
                        s += "1";
                    }
                    else
                    {
                        s += "0";
                    }
 
                }
                var intvalue = Convert.ToInt32(s, 2);
                Common.Logic.CurrentLogic.TimeAttribute.Repeat = 3;
                Common.Logic.CurrentLogic.TimeAttribute.MonthDate = intvalue;
 
                var logicCommunalPage = new LogicCommunalPage();
                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
 
            };
 
 
 
        }
    }
}