| | |
| | | //场景点击
|
| | | sceneContr.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.SceneUpHandler();
|
| | | //不能反复点击
|
| | | sceneContr.CanClick = false;
|
| | | this.SceneUpHandler(sceneContr);
|
| | | };
|
| | |
|
| | | //收藏
|
| | |
| | | this.btnDelayTime = new NormalViewControl(400, 58, true);
|
| | | btnDelayTime.X = Application.GetRealWidth(580);
|
| | | btnDelayTime.Y = Application.GetRealHeight(317);
|
| | | btnDelayTime.Text = CommonFormResouce.GetTimeString(scene.SceneDelayTime);
|
| | | btnDelayTime.Text = this.GetTimeString(scene.SceneDelayTime);
|
| | | btnDelayTime.TextAlignment = TextAlignment.CenterRight;
|
| | | btnDelayTime.TextColor = ZigbeeColor.Current.GXCTextSelectedColor3;
|
| | | btnDelayTime.IsBold = true;
|
| | |
| | | var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id);
|
| | | if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null)
|
| | | {
|
| | | CommonPage.Instance.FailureToServer();
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.RequestServerFailed));
|
| | | return;
|
| | | }
|
| | | //1成功
|
| | |
| | | //0 移除失败
|
| | | else if (removeSceneAllData.removeSceneData.Result == 0)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain));
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain));
|
| | | return;
|
| | | }
|
| | | //2 没有该场景
|
| | |
| | | {
|
| | | if (scene.RemainTime > 0)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
|
| | | return;
|
| | | }
|
| | | var timeSelect = new SelectTime();
|
| | |
| | | {
|
| | | //隐藏右划菜单
|
| | | this.HideMenu();
|
| | | scene.SceneDelayTime = t;
|
| | | btnDelayTime.Text = CommonFormResouce.GetTimeString(t);
|
| | | if (t != 0)
|
| | | {
|
| | | scene.SceneDelayTime = t;
|
| | | btnDelayTime.Text = this.GetTimeString(t);
|
| | | //编辑延时时,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | }
|
| | | };
|
| | | };
|
| | | }
|
| | |
| | | /// <summary>
|
| | | ///
|
| | | /// </summary>
|
| | | /// <param name="btnScenePic"></param>
|
| | | /// <param name="btnSceneName"></param>
|
| | | private async void SceneUpHandler()
|
| | | /// <param name="sceneContr"></param>
|
| | | private async void SceneUpHandler(ScenePictrueControl sceneContr)
|
| | | {
|
| | | if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0)
|
| | | {
|
| | |
| | | var result = await HdlSceneLogic.Current.ControlScene(scene);
|
| | | if (result == false)
|
| | | {
|
| | | sceneContr.CanClick = true;
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | scene.SceneDelayTime = 0;
|
| | | if (scene.RemainTime <= 0)
|
| | | {
|
| | | sceneContr.CanClick = true;
|
| | | return;
|
| | | }
|
| | | //调用有延时的场景,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | int myRemainTime = scene.RemainTime;
|
| | | //开启内部延时时间线程(旨在全部地方的同一场景时间同步)
|
| | | HdlSceneLogic.Current.StartDelayTimeThread(scene);
|
| | |
| | | while (myRemainTime > 0 && this.Parent != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime));
|
| | | });
|
| | | SetTimeText(this.GetTimeString(scene.RemainTime));
|
| | | }, ShowErrorMode.NO);
|
| | | myRemainTime--;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (this.Parent != null)
|
| | | {
|
| | | SetTimeImage();
|
| | | //直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | sceneContr.CanClick = true;
|
| | | }
|
| | | });
|
| | | }, ShowErrorMode.NO);
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取场景延时字符串
|
| | | /// </summary>
|
| | | /// <param name="second"></param>
|
| | | /// <returns></returns>
|
| | | private string GetTimeString(int second)
|
| | | {
|
| | | if (second == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | string timeStr = string.Empty;
|
| | | int hour = second / 3600;
|
| | | int minu = second % 3600 / 60;
|
| | | int sec = second % 60;
|
| | | if (hour > 0)
|
| | | {
|
| | | timeStr += $"{hour}{Language.StringByID(R.MyInternationalizationString.Hour)}";
|
| | | if (minu > 0)
|
| | | {
|
| | | timeStr += $"{minu}{Language.StringByID(R.MyInternationalizationString.Minute)}";
|
| | | }
|
| | | if (sec > 0)
|
| | | {
|
| | | timeStr += $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
|
| | | }
|
| | | return timeStr;
|
| | | }
|
| | | else if (minu > 0)
|
| | | {
|
| | | timeStr += $"{minu}{Language.StringByID(R.MyInternationalizationString.Minute)}";
|
| | | if (sec > 0)
|
| | | {
|
| | | timeStr += $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
|
| | | }
|
| | | return timeStr;
|
| | | }
|
| | | else
|
| | | {
|
| | | return $"{sec}{Language.StringByID(R.MyInternationalizationString.Second)}";
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 自定义控件(需要的它移除事件)
|
| | | /// </summary>
|
| | | private class MyProgressLoading : ProgressLoading
|