| | |
| | |
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | //调用场景
|
| | | this.SetSceneAction();
|
| | | };
|
| | |
| | | public void InitControl(Common.SceneUI i_scene)
|
| | | {
|
| | | this.SceneId = i_scene.Id;
|
| | | string hourText = Language.StringByID(R.MyInternationalizationString.Hour);
|
| | | string minuText = Language.StringByID(R.MyInternationalizationString.Minute);
|
| | | string secondText = Language.StringByID(R.MyInternationalizationString.Second);
|
| | |
|
| | | //场景图片控件
|
| | | this.btnScenePic = new ImageView();
|
| | |
| | | btnTimeView.Y = Application.GetMinRealAverage(10);
|
| | | btnTimeView.TextColor = 0xffffb400;
|
| | | btnTimeView.IsBold = true;
|
| | | if (i_scene.SceneDelayTime > 0)
|
| | | {
|
| | | btnTimeView.Text= this.GetTimeString(i_scene.SceneDelayTime, hourText, minuText, secondText);
|
| | | }
|
| | | this.AddChidren(btnTimeView, ChidrenBindMode.BindEventOnly);
|
| | |
|
| | | //时间图标控件
|
| | |
| | | btnTimeIcon.X = Application.GetMinRealAverage(37);
|
| | | btnTimeIcon.Y = Application.GetMinRealAverage(20);
|
| | | btnTimeIcon.UnSelectedImagePath = "Item/Time.png";
|
| | | this.AddChidren(btnTimeIcon, ChidrenBindMode.BindEventOnly);
|
| | | this.AddChidren(btnTimeIcon, ChidrenBindMode.NotBind);
|
| | | if (i_scene.SceneDelayTime > 0)
|
| | | {
|
| | | btnTimeIcon.Visible = false;
|
| | | }
|
| | | btnTimeIcon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (i_scene.RemainTime > 0)
|
| | | {
|
| | | //该场景正在延时,请稍后
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
|
| | | msgContr.Show();
|
| | | return;
|
| | | }
|
| | | var timeSelect = new Device.CommonForm.SelectTime();
|
| | | Common.CommonPage.Instance.AddChidren(timeSelect);
|
| | | timeSelect.TempTime = i_scene.SceneDelayTime;
|
| | | timeSelect.Init();
|
| | | timeSelect.TimeAction = (time) =>
|
| | | {
|
| | | i_scene.SceneDelayTime = time;
|
| | |
|
| | | //时间图标不显示
|
| | | this.btnTimeIcon.Visible = false;
|
| | | //显示剩余的时间
|
| | | this.btnTimeView.Text = this.GetTimeString(time, hourText, minuText, secondText);
|
| | | };
|
| | | };
|
| | |
|
| | | //收藏控件
|
| | | var btnCollect = new IconViewControl(107);
|
| | |
| | | {
|
| | | //这个场景不见的情况应该不可能
|
| | | var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(this.SceneId);
|
| | | if (scene.RemainTime > 0 )
|
| | | if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0)
|
| | | {
|
| | | //该场景正在延时,请稍后
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
|
| | | msgContr.Show();
|
| | | return;
|
| | | //如果没有延迟的话,直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | }
|
| | | //执行调用场景
|
| | | var result = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime);
|
| | | if (result == null || result.sceneOpenData == null)
|
| | | var result = await HdlSceneLogic.Current.ControlScene(scene);
|
| | | if (result == false)
|
| | | {
|
| | | //控制场景失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.ControlSceneFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | msgContr.Show();
|
| | | return;
|
| | | }
|
| | | if (result.sceneOpenData.Result == 0)
|
| | | {
|
| | | //控制场景失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.ControlSceneFail);
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | msgContr.Show();
|
| | | return;
|
| | | }
|
| | | //修改时间
|
| | | scene.RemainTime = scene.SceneDelayTime;
|
| | | scene.SceneDelayTime = 0;
|
| | | //开启延时倒计时特效
|
| | | this.StartRemainTimeApreal(scene, true);
|
| | | this.StartRemainTimeApreal(scene);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | }
|
| | |
|
| | | //开启延时倒计时特效
|
| | | this.StartRemainTimeApreal(i_scene, false);
|
| | | this.StartRemainTimeApreal(i_scene);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 开启延时倒计时特效
|
| | | /// </summary>
|
| | | /// <param name="i_scene"></param>
|
| | | /// <param name="setTime">是否更改场景对象里面的那个时间,旨在对应同一个场景在多个地方显示的同步问题</param>
|
| | | private void StartRemainTimeApreal(Common.SceneUI i_scene, bool setTime)
|
| | | private void StartRemainTimeApreal(Common.SceneUI i_scene)
|
| | | {
|
| | | if (i_scene.RemainTime <= 0)
|
| | | {
|
| | |
| | | //显示剩余的时间
|
| | | this.btnTimeView.Text = this.GetTimeString(i_scene.RemainTime, hourText, minuText, secondText);
|
| | |
|
| | | //开启内部延时时间线程(旨在全部地方的同一场景时间同步)
|
| | | HdlSceneLogic.Current.StartDelayTimeThread(i_scene);
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | while (remainTine > 0)
|
| | | while (remainTine > 0 && this.Parent != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | this.btnTimeView.Text = this.GetTimeString(remainTine, hourText, minuText, secondText);
|
| | | });
|
| | | if (setTime == true)
|
| | | {
|
| | | //覆盖剩余时间
|
| | | i_scene.RemainTime = remainTine;
|
| | | }
|
| | | remainTine--;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //无条件覆盖剩余时间
|
| | | i_scene.RemainTime = 0;
|
| | |
|
| | | //倒计时结束时,时间图标显示
|
| | | this.btnTimeIcon.Visible = true;
|
| | | this.btnTimeView.Text = string.Empty;
|
| | | //直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | |
| | | var loadContr = new MyProgressLoading();
|
| | | loadContr.LoadingBackgroundColor = UserCenterColor.Current.Transparent;
|
| | | frameBack.AddChidren(loadContr);
|
| | | loadContr.StartLoading();
|
| | | loadContr.StartLoading(1000);
|
| | | loadContr.DisponeEvent += () =>
|
| | | {
|
| | | frameBack.RemoveFromParent();
|
| | |
| | | int hour = second / 3600;
|
| | | int minu = second % 3600 / 60;
|
| | | int sec = second % 60;
|
| | | if (hour >= 0)
|
| | | if (hour > 0)
|
| | | {
|
| | | timeStr += hour + hourText;
|
| | | }
|