HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
using System;
using System.Linq;
 
namespace ZigBee.Droid.Common
{
    public class OwnCodes
    {
 
        #region set/get
        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 开光状态:0=关,1=开,
        /// <para>0:</para>
        /// </summary>
        public int OnOffStatus
        {
            get
            {
                //if (DeviceStatusReport != null && DeviceStatusReport.CluterID == 6)
                //{
                //    var attriButeList = DeviceStatusReport.AttriBute;
                //    foreach (var attriBute1 in attriButeList)
                //    {
                //        return attriBute1.AttriButeData;
                //    }
                //}
                return 0;
            }
            set
            {
                //if (DeviceStatusReport != null && DeviceStatusReport.CluterID == 6)
                //{
                //    var attriButeList = DeviceStatusReport.AttriBute;
                //    foreach (var attriBute1 in attriButeList)
                //    {
                //        attriBute1.AttriButeData = value;
                //    }
                //}
            }
        }
        #endregion
 
        #region json格式,发数据中列表有数组的情况
        //public static void hdlButtonSetBind(ZigBee.Device.ZbGateway gateway, ZigBee.Device.HDLbutton.BindListDeviceInfo bindListObj, string buttonMacAddr, int epoint, int buttonMode, int buttonType)
        //{
        //    var jobject = new JObject { { "DeviceAddr", buttonMacAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 6 } };
 
        //    var bindList = new JArray{
        //        new JObject {{ "BindType", bindListObj.BindType},{ "BindMacAddr", bindListObj.BindMacAddr},{ "BindEpoint", bindListObj.BindEpoint }}
        //    };
        //    var data = new JObject { { "ButtonEpoint", epoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "BindList", bindList }
        //     };
 
        //    jobject.Add("Data", data);
        //    gateway.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        #endregion
 
        #region Int 与byte的运算
        // (1)
        //int count = 5;
        //int homeId = 112;
        // byte[] byteHomeId = new byte[4];
        //for (int i = 0; i < byteHomeId.Length; i++)
        //{
        //    byteHomeId[i] = (byte)((homeId >> (i * 8)) & 0xFF);
        //}
        //byteHomeId[0] = (byte)((homeId >> 24) & 0xff);//H
        //byteHomeId[1] = (byte)((homeId >> 16) & 0xff);
        //byteHomeId[2] = (byte)((homeId >> 8) & 0xff);
        //byteHomeId[3] = (byte)(homeId & 0xff);//L
 
        //(2)、
        // int homeID = (bytes[7] & 0xff) << 24 | (bytes[8] & 0xff) << 16 | (bytes[9] & 0xff) << 8 | (bytes[10] & 0xff);
        #endregion
 
        #region 进度显示
        //Application.RunOnMainThread(() =>
        //{
        //    int pro = (int)(index * 1.0 / backuplist.Count * 100);
        //    MainPage.Loading.Text = pro.ToString() + "%";
        //};
        #endregion
 
        /// <summary>
        /// 方式一:使用lambda表达式筛选过滤掉数组中空字符串
        /// </summary>
        /// <param name="args"></param>
        static void FilterOutEmptyStrings1()
        {
            string[] strArray = { "", "111", "", "222", "", "333" };
            Console.WriteLine("输出带有空字符串的数组:");
            foreach (string str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.WriteLine("-------------------------------------------");
            //使用lambda表达式过滤掉空字符串
            strArray = strArray.Where(s => !string.IsNullOrEmpty(s)).ToArray();
            Console.WriteLine("输出过滤掉空字符串的数组:");
            foreach (string str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.Read();
        }
 
        /// <summary>
        /// 方式二:使用泛型集合List<string>的ForEach循环,过滤获取正确的字符串,重新添加到新字符串数组中
        /// </summary>
        /// <param name="args"></param>
        public void FilterOutEmptyStrings2()
        {
            string[] strArray = { "", "111", "", "222", "", "333" };
 
            /*
             *使用List泛型集合的ForEach方法循环获取非空空字符串
             *这里使用了匿名方法
             */
            var list = new System.Collections.Generic.List<string>();
 
            strArray.ToList().ForEach(
                (s) =>
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        list.Add(s);
                    }
                });
 
            foreach (string str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.Read();
        }
 
        /// <summary>
        /// 使用传统循环方式来排除和删除字符串数组中的空字符串
        /// </summary>
        public void FilterOutEmptyStrings3()
        {
            string[] strArray = { "", "111", "", "222", "", "333" };
            Console.WriteLine("输出带有空字符串的数组:");
            foreach (string str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.WriteLine("-------------------------------------------");
 
            //使用循环排除和过滤掉空字符串    
            var list = new System.Collections.Generic.List<string>();
            foreach (string s in strArray)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    list.Add(s);
                }
            }
            strArray = list.ToArray();
 
            Console.WriteLine("输出过滤掉空字符串的数组:");
            foreach (string str in strArray)
            {
                Console.WriteLine(str);
            }
            Console.Read();
        }
 
        #region &GPS位置变化事件
        /// <summary>
        /// GPS位置变化事件
        /// </summary>
        //public static Action<double, double> LocationAction;
        //LocationAction = (arg1, arg2) => {
        //    LocationAction = null;
        //    System.Threading.Tasks.Task.Run(() => {
        //        while (true) {
        //            try {
        //                Shared.SimpleControl.CommonPage.AirQuality = new service.hdlcontrol.com_WebServiceAirQuality.WebServiceAirQuality().GetAirQuality(arg2.ToString (), arg1.ToString ());
        //                if (Shared.SimpleControl.CommonPage.AirQuality != null)
        //                    break;
        //            } catch { }
        //        }
        //        Shared.Application.RunOnMainThread(() => {
        //            if (CommonPage.RefreshAir != null)
        //                CommonPage.RefreshAir();
        //        } );
        //    } );
        //} ;
        #endregion
 
        #region 电话号码写法
        // EditText etPhoneNumber = new EditText()
        // {
        //     X = btnPhoneZone.Right + Application.GetRealWidth(10),
        //     Width = Application.GetRealWidth(410),
        //     TextAlignment = TextAlignment.Center,
        // };
        // phoneNumView.AddChidren(etPhoneNumber);
 
        //etPhoneNumber.TextChangeEventHandler += (sender, e) => {
        //    if (e.Length > 11)
        //    {
        //        etPhoneNumber.Text = e.Remove(11);
        //    }
        //    else if (e.Length == 11)
        //    {
        //        var reg = new Regex("^[1]+[3,5,7,8]+\\d{9}");
        //        var mFalg = reg.Match(etPhoneNumber.Text.Trim());
        //        if (mFalg.Success)
        //        {
        //            btnNext.IsSelected = btnNext.Enable = true;
        //        }
        //        else
        //        {
        //           new Tip() { CloseTime = 3, Text = "号码错误", Direction = AMPopTipDirection.Down } .Show(etPhoneNumber);
 
        //        }
        //    }
        //    else if (e.Length< 11)
        //    {
        //        btnNext.IsSelected = btnNext.Enable = false;
        //    }
        //} ;
        #endregion
 
        #region 进度显示
        #endregion
    }
}