黄学彪
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
using System;
namespace Shared.Phone.UserCenter.GatewayAdd
{
    /// <summary>
    /// 添加网关的选择画面
    /// </summary>
    public class NewGateWayMenuSelectForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 是否显示提示设置住宅地理位置
        /// </summary>
        private bool showSettion = true;
        /// <summary>
        /// 提示的FrameLayout
        /// </summary>
        private FrameLayout frameTip = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddGateway));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            var listView = new VerticalListControl(29);
            listView.Height = bodyFrameLayout.Height;
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
 
            //有线网关
            var row1 = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(row1);
            var btnIcon1 = row1.AddLeftIcon(81);
            btnIcon1.UnSelectedImagePath = "Gateway/WiredGateway.png";
            var btntext1 = row1.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uWiredGateway), 500);
            btntext1.TextSize = 15;
            row1.AddRightArrow();
            row1.AddBottomLine();
            row1.ButtonClickEvent += (sender, e) =>
            {
                //菜单按钮的点击事件
                this.MenuButtonClickEvent(1);
            };
 
            //无线网关
            var row2 = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(row2);
            var btnIcon2 = row2.AddLeftIcon(81);
            btnIcon2.UnSelectedImagePath = "Gateway/WirelessGateway.png";
            var btntext2 = row2.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uWirelessGateway), 500);
            btntext2.TextSize = 15;
            row2.AddRightArrow();
            row2.AddBottomLine();
            row2.ButtonClickEvent += (sender, e) =>
            {
                //菜单按钮的点击事件
                this.MenuButtonClickEvent(2);
            };
 
            //Mini网关
            var row3 = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(row3);
            var btnIcon3 = row3.AddLeftIcon(81);
            btnIcon3.UnSelectedImagePath = "Gateway/MiniGateway.png";
            var btntext3 = row3.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uMiniGateway), 500);
            btntext3.TextSize = 15;
            row3.AddRightArrow();
            row3.ButtonClickEvent += (sender, e) =>
            {
                //菜单按钮的点击事件
                this.MenuButtonClickEvent(3);
            };
            listView.AdjustRealHeight(Application.GetRealHeight(23));
 
            //如果还没有设置地理位置
            if (Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
            {
                this.frameTip = new FrameLayout();
                frameTip.X = Application.GetRealWidth(179);
                frameTip.Y = Application.GetRealHeight(1426);
                frameTip.Height = Application.GetRealHeight(100);
                frameTip.Width = Application.GetRealWidth(714);
                bodyFrameLayout.AddChidren(frameTip);
 
                var btnIcon = new IconViewControl(58);
                btnIcon.UnSelectedImagePath = "Item/Tips.png";
                frameTip.AddChidren(btnIcon);
 
                //如果不设置住宅的地理位置,则会影响自动化地理围栏功能的设置
                var btnTip = new NormalViewControl(Application.GetRealWidth(636), Application.GetRealHeight(100), false);
                btnTip.X = btnIcon.Right + Application.GetRealWidth(20);
                btnTip.TextAlignment = TextAlignment.Center;
                btnTip.TextColor = UserCenterColor.Current.TextGrayColor1;
                btnTip.TextSize = 12;
                btnTip.IsMoreLines = true;
                btnTip.Text = Language.StringByID(R.MyInternationalizationString.uNotSetLocationWillAffectTheAutomaticGeofencingFunction);
                frameTip.AddChidren(btnTip);
            }
        }
 
        #endregion
 
        #region ■ 按键点击___________________________
 
        /// <summary>
        /// 菜单按钮的点击事件
        /// </summary>
        /// <param name="menuDiv">1:有线网关 2:无线网关 3:mini网关</param>
        private void MenuButtonClickEvent(int menuDiv)
        {
            //只弹一次
            if (this.showSettion == true && Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
            {
                this.showSettion = false;
                //请前往住宅管理{0}设置住宅的地理位置
                string msg = Language.StringByID(R.MyInternationalizationString.uGotoResidenceAndSetLocation).Replace("{0}", "\r\n");
                var alert = new ShowMsgControl(ShowMsgType.Confirm, msg,
                    Language.StringByID(R.MyInternationalizationString.uGotoSettion),
                    Language.StringByID(R.MyInternationalizationString.uNeglect));
                alert.Show();
 
                //忽略
                alert.CancelClickEvent += () =>
                {
                    //显示指定的界面
                    this.ShowFormByMenuDiv(menuDiv);
                };
                //去设置
                alert.ConfirmClickEvent += () =>
                {
                    var form = new Residence.ResidenceManagementForm();
                    form.AddForm(false);
                };
                return;
            }
            //显示指定的界面
            this.ShowFormByMenuDiv(menuDiv);
        }
 
        /// <summary>
        /// 显示指定的界面
        /// </summary>
        /// <param name="menuDiv">1:有线网关 2:无线网关 3:mini网关</param>
        private void ShowFormByMenuDiv(int menuDiv)
        {
            if (menuDiv == 1)
            {
                var form = new WiredGatewayDirectionForm();
                form.AddForm();
            }
            else if (menuDiv == 2)
            {
                var menuContr = new BottomMenuSelectForm();
                menuContr.AddForm(2);
                //UDP模式(推荐)
                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uUdpModeRecommend), () =>
                {
                    var form = new WirelessUdpDirectionForm();
                    form.AddForm();
                });
                //AP模式
                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uApMode), () =>
                {
                    var form = new WirelessApDirection1Form();
                    form.AddForm();
                });
            }
            else if (menuDiv == 3)
            {
                var form = new MiniGatewayDirection1Form();
                form.AddForm();
            }
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 检测住宅经纬度
        /// </summary>
        /// <returns></returns>
        private bool CheckResidencePoint()
        {
            //只弹一次
            if (this.showSettion == false)
            {
                return true;
            }
            this.showSettion = false;
 
            if (Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
            {
                //请前往住宅管理{0}设置住宅的地理位置
                string msg = Language.StringByID(R.MyInternationalizationString.uGotoResidenceAndSetLocation).Replace("{0}", "\r\n");
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                {
                    var form = new Residence.ResidenceManagementForm();
                    form.AddForm(false);
 
                }, Language.StringByID(R.MyInternationalizationString.uGotoSettion));
                return false;
            }
            return true;
        }
 
        #endregion
 
        #region ■ 界面重新激活事件___________________
 
        /// <summary>
        /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
        /// </summary>
        public override int FormActionAgainEvent()
        {
            if (frameTip == null)
            {
                return 0;
            }
            if (Common.Config.Instance.Home.Latitude != 0 || Common.Config.Instance.Home.Longitude != 0)
            {
                //移除掉提示
                frameTip.RemoveFromParent();
                return 1;
            }
            return 1;
        }
 
        #endregion
    }
}