| | |
| | | /// <summary>
|
| | | /// 场景卡片控件
|
| | | /// </summary>
|
| | | public class SceneCardControl : FrameLayoutControl
|
| | | public class SceneCardControl : FrameLayoutStatuControl
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | |
| | | public SceneCardControl()
|
| | | {
|
| | | //图片真实宽度+图片自身左右空白
|
| | | this.Width = Application.GetMinRealAverage(458 + 14 * 2);
|
| | | this.Width = HdlControlLogic.Current.GetPictrueRealSize(458 + 14 * 2);
|
| | | //图片高度+阴影
|
| | | this.Height = Application.GetMinRealAverage(305 + 43);
|
| | | this.Height = HdlControlLogic.Current.GetPictrueRealSize(305 + 43);
|
| | | //取消点击特效
|
| | | this.UseClickStatu = false;
|
| | |
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | //调用场景
|
| | | this.CanClick = false;
|
| | | 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();
|
| | | btnScenePic.X = Application.GetMinRealAverage(14);
|
| | | btnScenePic.Width = Application.GetMinRealAverage(458);
|
| | | btnScenePic.Height = Application.GetMinRealAverage(305);
|
| | | btnScenePic.Radius = (uint)Application.GetMinRealAverage(17);
|
| | | btnScenePic.X = HdlControlLogic.Current.GetPictrueRealSize(14);
|
| | | btnScenePic.Width = HdlControlLogic.Current.GetPictrueRealSize(458);
|
| | | btnScenePic.Height = HdlControlLogic.Current.GetPictrueRealSize(305);
|
| | | btnScenePic.Radius = (uint)Application.GetRealHeight(17);
|
| | | this.AddChidren(btnScenePic, ChidrenBindMode.NotBind);
|
| | |
|
| | | //场景背景图控件
|
| | | this.btnSceneBackGroud = new PicViewControl(this.Width, this.Height, false);
|
| | | btnSceneBackGroud.UnSelectedImagePath = "Scene/Background.png";
|
| | | this.AddChidren(btnSceneBackGroud, ChidrenBindMode.BindEventOnly);
|
| | | this.AddChidren(btnSceneBackGroud, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //延时时间显示控件
|
| | | this.btnTimeView = new NormalViewControl(Application.GetMinRealAverage(280), Application.GetMinRealAverage(63), false);
|
| | | btnTimeView.X = Application.GetMinRealAverage(37);
|
| | | btnTimeView.Y = Application.GetMinRealAverage(10);
|
| | | this.btnTimeView = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(280), HdlControlLogic.Current.GetPictrueRealSize(63), false);
|
| | | btnTimeView.X = HdlControlLogic.Current.GetPictrueRealSize(37);
|
| | | btnTimeView.Y = HdlControlLogic.Current.GetPictrueRealSize(10);
|
| | | btnTimeView.TextColor = 0xffffb400;
|
| | | btnTimeView.IsBold = true;
|
| | | this.AddChidren(btnTimeView, ChidrenBindMode.BindEventOnly);
|
| | | if (i_scene.SceneDelayTime > 0)
|
| | | {
|
| | | btnTimeView.Text= this.GetTimeString(i_scene.SceneDelayTime, hourText, minuText, secondText);
|
| | | }
|
| | | this.AddChidren(btnTimeView, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //时间图标控件
|
| | | this.btnTimeIcon = new IconViewControl(63);
|
| | | btnTimeIcon.X = Application.GetMinRealAverage(37);
|
| | | btnTimeIcon.Y = Application.GetMinRealAverage(20);
|
| | | btnTimeIcon.X = HdlControlLogic.Current.GetPictrueRealSize(37);
|
| | | btnTimeIcon.Y = HdlControlLogic.Current.GetPictrueRealSize(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) =>
|
| | | {
|
| | | //选择的是不开启
|
| | | if (time == 0) { return; }
|
| | |
|
| | | i_scene.SceneDelayTime = time;
|
| | |
|
| | | //时间图标不显示
|
| | | this.btnTimeIcon.Visible = false;
|
| | | //显示剩余的时间
|
| | | this.btnTimeView.Text = this.GetTimeString(time, hourText, minuText, secondText);
|
| | | //选择延时时,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | };
|
| | | };
|
| | |
|
| | | //收藏控件
|
| | | var btnCollect = new IconViewControl(107);
|
| | | btnCollect.X = Application.GetMinRealAverage(350);
|
| | | btnCollect.Y = Application.GetMinRealAverage(12);
|
| | | btnCollect.X = HdlControlLogic.Current.GetPictrueRealSize(350);
|
| | | btnCollect.Y = HdlControlLogic.Current.GetPictrueRealSize(12);
|
| | | btnCollect.UnSelectedImagePath = "Item/Collection1.png";
|
| | | btnCollect.SelectedImagePath = "Item/CollectionSelected1.png";
|
| | | this.AddChidren(btnCollect, ChidrenBindMode.NotBind);
|
| | |
| | | {
|
| | | //取消收藏
|
| | | HdlSceneLogic.Current.DeleteLoveScene(i_scene);
|
| | | if (HdlRoomLogic.Current.CurrentRoom.IsLove == true)
|
| | | if (HdlRoomLogic.Current.NowMainPageRoom.IsLove == true)
|
| | | {
|
| | | //如果当前房间是我的喜爱的话,回调卡片被删除的事件
|
| | | this.CardNeedRemoveEvent?.Invoke();
|
| | |
| | | };
|
| | |
|
| | | //场景名称控件
|
| | | this.btnSceneName = new NormalViewControl(Application.GetMinRealAverage(280), Application.GetMinRealAverage(63), false);
|
| | | btnSceneName.X = Application.GetMinRealAverage(37);
|
| | | btnSceneName.Y = Application.GetMinRealAverage(236);
|
| | | this.btnSceneName = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(280), HdlControlLogic.Current.GetPictrueRealSize(63), false);
|
| | | btnSceneName.X = HdlControlLogic.Current.GetPictrueRealSize(37);
|
| | | btnSceneName.Y = HdlControlLogic.Current.GetPictrueRealSize(236);
|
| | | btnSceneName.IsBold = true;
|
| | | btnSceneName.TextColor = UserCenterColor.Current.White;
|
| | | this.AddChidren(btnSceneName, ChidrenBindMode.BindEventOnly);
|
| | | this.AddChidren(btnSceneName, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //刷新控件状态
|
| | | this.RefreshControlInfo(i_scene);
|
| | |
| | | {
|
| | | //这个场景不见的情况应该不可能
|
| | | 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();
|
| | | this.CanClick = true;
|
| | | return;
|
| | | }
|
| | | if (result.sceneOpenData.Result == 0)
|
| | | if (scene.SceneDelayTime > 0)
|
| | | {
|
| | | //控制场景失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.ControlSceneFail);
|
| | | var msgContr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | msgContr.Show();
|
| | | return;
|
| | | //调用有延时的场景,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | }
|
| | | //修改时间
|
| | | scene.RemainTime = scene.SceneDelayTime;
|
| | | scene.SceneDelayTime = 0;
|
| | | //开启延时倒计时特效
|
| | | this.StartRemainTimeApreal(scene, true);
|
| | | this.StartRemainTimeApreal(scene);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //刷新图片
|
| | | if (i_scene.IconPathType == 0)
|
| | | {
|
| | | if (this.btnScenePic.ImagePath != i_scene.IconPath)
|
| | | //主页的场景卡片用的是另外的图
|
| | | string newPath = i_scene.IconPath.Replace("SceneIcon", "SceneCardIcon");
|
| | | if (this.btnScenePic.ImagePath != newPath)
|
| | | {
|
| | | this.btnScenePic.ImagePath = i_scene.IconPath;
|
| | | this.btnScenePic.ImagePath = newPath;
|
| | | }
|
| | | }
|
| | | else
|
| | |
| | | }
|
| | |
|
| | | //开启延时倒计时特效
|
| | | this.StartRemainTimeApreal(i_scene, false);
|
| | | this.CanClick = 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.CanClick = true;
|
| | | return;
|
| | | }
|
| | | int remainTine = i_scene.RemainTime;
|
| | |
| | | //显示剩余的时间
|
| | | 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(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | this.btnTimeView.Text = this.GetTimeString(remainTine, hourText, minuText, secondText);
|
| | | });
|
| | | if (setTime == true)
|
| | | {
|
| | | //覆盖剩余时间
|
| | | i_scene.RemainTime = remainTine;
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | remainTine--;
|
| | | }
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //无条件覆盖剩余时间
|
| | | i_scene.RemainTime = 0;
|
| | |
|
| | | //倒计时结束时,时间图标显示
|
| | | this.btnTimeIcon.Visible = true;
|
| | | this.btnTimeView.Text = string.Empty;
|
| | | });
|
| | | //直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | this.CanClick = true;
|
| | | }, ShowErrorMode.NO);
|
| | | })
|
| | | { 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;
|
| | | }
|