| | |
| | | using System; |
| | | using Shared.Common; |
| | | namespace Shared.Phone.Device.CommonForm |
| | | { |
| | | public class SceneCategoryView : FrameLayout |
| | | { |
| | | /// <summary> |
| | | /// scene |
| | | /// </summary> |
| | | public SceneUI scene; |
| | | /// <summary> |
| | | /// room |
| | | /// </summary> |
| | | public Shared.Common.Room room; |
| | | /// <summary> |
| | | /// delayTimeBtn |
| | | /// </summary> |
| | | private Button delayTimeBtn; |
| | | /// <summary> |
| | | /// delayImgBtn |
| | | /// </summary> |
| | | private Button delayImgBtn; |
| | | /// <summary> |
| | | /// sceneImg |
| | | /// </summary> |
| | | private ImageView sceneImg; |
| | | |
| | | /// <summary> |
| | | /// SceneCategoryView |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <param name="y"></param> |
| | | public SceneCategoryView(int x, int y) |
| | | { |
| | | X = Application.GetRealWidth(x); |
| | | Y = Application.GetRealHeight(y); |
| | | Width = Application.GetRealWidth(1080); |
| | | Height = Application.GetRealHeight(446); |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// init |
| | | /// </summary> |
| | | public void Init(SceneUI sceneUI,Common.Room curRoom) |
| | | { |
| | | this.scene = sceneUI; |
| | | this.room = curRoom; |
| | | |
| | | InitFrame(); |
| | | InitStatu(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// InitFrame |
| | | /// </summary> |
| | | private void InitFrame() |
| | | { |
| | | var sceneRowLayout = new RowLayout |
| | | { |
| | | Y = Application.GetRealHeight(46), |
| | | Height = Application.GetRealHeight(446 - 46), |
| | | LineColor = ZigbeeColor.Current.GXCGrayBackgroundColor, |
| | | Tag= scene |
| | | }; |
| | | AddChidren(sceneRowLayout); |
| | | |
| | | sceneImg = new ImageView() |
| | | { |
| | | X = Application.GetRealWidth(179), |
| | | Width = Application.GetRealWidth(844), |
| | | Height = Application.GetRealHeight(400), |
| | | ImagePath = scene.IconPathType == 0 ? scene.IconPath : System.IO.Path.Combine(Config.Instance.FullPath, scene.IconPath), |
| | | Radius = (uint)Application.GetRealHeight(17) |
| | | }; |
| | | sceneRowLayout.AddChidren(sceneImg); |
| | | //sceneImg.SetViewShadow(true); |
| | | |
| | | var leftFL = new FrameLayout |
| | | { |
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Y = Application.GetRealHeight(58), |
| | | Width = Application.GetRealWidth(251), |
| | | Height = Application.GetRealHeight(282), |
| | | BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2, |
| | | Radius = (uint)Application.GetRealHeight(17) |
| | | }; |
| | | sceneRowLayout.AddChidren(leftFL); |
| | | |
| | | var collectionBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(23), |
| | | Y = Application.GetRealHeight(23), |
| | | Width = Application.GetMinRealAverage(65), |
| | | Height = Application.GetMinRealAverage(65), |
| | | UnSelectedImagePath = "Item/Collection.png", |
| | | SelectedImagePath = "Item/CollectionSelected.png", |
| | | IsSelected = Common.Room.CurrentRoom.GetLoveRoom().SceneUIFilePathList.Contains(scene.FileName), |
| | | Tag = scene |
| | | }; |
| | | leftFL.AddChidren(collectionBtn); |
| | | |
| | | var sceneNameBtn = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(176), |
| | | Height = Application.GetRealHeight(150), |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | Text = scene.Name, |
| | | Gravity = Gravity.Center, |
| | | IsMoreLines = true |
| | | }; |
| | | leftFL.AddChidren(sceneNameBtn); |
| | | |
| | | var collection = new Button |
| | | { |
| | | Tag = scene |
| | | }; |
| | | leftFL.AddChidren(collection); |
| | | collection.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (room.IsLove) |
| | | { |
| | | Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); |
| | | RemoveViewByTag(collectionBtn.Tag); |
| | | } |
| | | else |
| | | { |
| | | collectionBtn.IsSelected = !collectionBtn.IsSelected; |
| | | if (collectionBtn.IsSelected) |
| | | { |
| | | Common.Room.CurrentRoom.GetLoveRoom().AddScene(scene); |
| | | } |
| | | else |
| | | { |
| | | Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | delayTimeBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(780), |
| | | Y = Application.GetRealHeight(317), |
| | | Width = Application.GetRealWidth(200), |
| | | Height = Application.GetRealHeight(58), |
| | | Text = CommonFormResouce.GetTimeString(scene.SceneDelayTime), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor3 |
| | | }; |
| | | sceneRowLayout.AddChidren(delayTimeBtn); |
| | | |
| | | delayImgBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(900), |
| | | Y = Application.GetRealHeight(30), |
| | | Width = Application.GetMinRealAverage(52), |
| | | Height = Application.GetMinRealAverage(52), |
| | | UnSelectedImagePath = "Scene/Delaying.png", |
| | | Visible=false |
| | | }; |
| | | sceneRowLayout.AddChidren(delayImgBtn); |
| | | |
| | | //定时 |
| | | var delayBtn = new RowLayoutDeleteButton |
| | | { |
| | | TextID = R.MyInternationalizationString.Delay, |
| | | Tag = scene.SceneDelayTime |
| | | }; |
| | | sceneRowLayout.AddLeftView(delayBtn); |
| | | //编辑 |
| | | var settingBtn = new Device.CommonForm.RowLayoutEditButton() |
| | | { |
| | | TextID = R.MyInternationalizationString.Editor, |
| | | Tag = scene.SceneDelayTime |
| | | }; |
| | | //删除 |
| | | var deleteBtn = new Device.CommonForm.RowLayoutDeleteButton |
| | | { |
| | | Tag = scene |
| | | }; |
| | | |
| | | if (room.IsSharedRoom) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (room.IsLove) |
| | | { |
| | | sceneRowLayout.AddRightView(deleteBtn); |
| | | } |
| | | else |
| | | { |
| | | sceneRowLayout.AddRightView(settingBtn); |
| | | sceneRowLayout.AddRightView(deleteBtn); |
| | | } |
| | | } |
| | | |
| | | //删除场景 |
| | | EventHandler<MouseEventArgs> delEvent = (sender, e) => |
| | | { |
| | | if (room.IsLove) |
| | | { |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteScene(scene); |
| | | RemoveFromParent(); |
| | | } |
| | | else |
| | | { |
| | | var tip = new CustomAlert { }; |
| | | Common.CommonPage.Instance.AddChidren(tip); |
| | | tip.Show(Language.StringByID(R.MyInternationalizationString.ConfirmDelete)); |
| | | |
| | | tip.ResultEventHandler += async (e1) => |
| | | { |
| | | if (e1) |
| | | { |
| | | //0 移除失败 1 移除成功 2 没有该场景 |
| | | var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id); |
| | | if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null) |
| | | { |
| | | CommonPage.Instance.FailureToServer(); |
| | | return; |
| | | } |
| | | //1成功 |
| | | if (removeSceneAllData.removeSceneData.Result == 1) |
| | | { |
| | | room.RemoveScene(scene); |
| | | //RefreshBodyView(); |
| | | RemoveFromParent(); |
| | | } |
| | | //0 移除失败 |
| | | else if (removeSceneAllData.removeSceneData.Result == 0) |
| | | { |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); |
| | | return; |
| | | } |
| | | //2 没有该场景 |
| | | else if (removeSceneAllData.removeSceneData.Result == 2) |
| | | { |
| | | room.RemoveScene(scene); |
| | | //RefreshBodyView(); |
| | | RemoveFromParent(); |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneIsNull); |
| | | return; |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | }; |
| | | deleteBtn.MouseUpEventHandler += delEvent; |
| | | //编辑场景 |
| | | settingBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | SceneUI.EditScene(scene, room); |
| | | }; |
| | | //编辑延时 |
| | | delayBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (scene.RemainTime > 0) |
| | | { |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying)); |
| | | return; |
| | | } |
| | | var timeSelect = new SelectTime(); |
| | | CommonPage.Instance.AddChidren(timeSelect); |
| | | timeSelect.TempTime = scene.SceneDelayTime; |
| | | timeSelect.Init(); |
| | | timeSelect.TimeAction = (t) => |
| | | { |
| | | scene.SceneDelayTime = t; |
| | | delayTimeBtn.Text = CommonFormResouce.GetTimeString(t); |
| | | }; |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// InitStatu |
| | | /// </summary> |
| | | private void InitStatu() |
| | | { |
| | | sceneImg.MouseUpEventHandler += SceneUpHandler; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SceneUpHandler |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="args"></param> |
| | | private async void SceneUpHandler(object sender, MouseEventArgs args) |
| | | { |
| | | if (scene.RemainTime > 0 && scene.SceneDelayTime == 0) |
| | | { |
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying)); |
| | | return; |
| | | } |
| | | //1成功 0失败 |
| | | //后面补上相关提示 |
| | | // Error参数含义 |
| | | //<para>1:网关无法解析命令数据。</para> |
| | | //<para>2:协调器正在升级或备份/恢复数据 |
| | | //<para>3:操作设备/组/场景不存在</para> |
| | | //<para>4:其他错误</para> |
| | | //<para>5:数据传输错误(在某次客户端向网关发送数据的过程中,网关在合理时间范围内接收客户端数据不完整导致该错误发生。如客户端向网关一次发送100个字节的数据,但网关等待接收了一秒只接收了80个字节。发生该错误,网关将主动关闭客户端连接)</para> |
| | | var sceneOpenAllData = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime); |
| | | |
| | | if (sceneOpenAllData == null || sceneOpenAllData.sceneOpenData == null) |
| | | { |
| | | return; |
| | | } |
| | | if (sceneOpenAllData.sceneOpenData.Result == 0) |
| | | { |
| | | if (sceneOpenAllData.errorResponData == null) |
| | | { |
| | | return; |
| | | } |
| | | CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ControlSceneFail); |
| | | } |
| | | |
| | | scene.RemainTime = scene.SceneDelayTime; |
| | | scene.SceneDelayTime = 0; |
| | | new System.Threading.Thread(() => |
| | | { |
| | | while (scene.RemainTime > 0) |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | SetTimeText(CommonFormResouce.GetTimeString(scene.RemainTime)); |
| | | }); |
| | | scene.RemainTime -= 1; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | SetTimeImage(); |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SetTimeText |
| | | /// </summary> |
| | | /// <param name="name"></param> |
| | | public void SetTimeText(string name) |
| | | { |
| | | delayImgBtn.Visible = true; |
| | | delayTimeBtn.Text = name; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SetTimeImage |
| | | /// </summary> |
| | | public void SetTimeImage() |
| | | { |
| | | delayImgBtn.Visible = false; |
| | | delayTimeBtn.Text = string.Empty; |
| | | } |
| | | } |
| | | } |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using Shared.Common;
|
| | | using Shared.Phone.UserCenter;
|
| | |
|
| | | namespace Shared.Phone.Device.CommonForm
|
| | | {
|
| | | public class SceneCategoryView : RowLayoutBase
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// scene
|
| | | /// </summary>
|
| | | public SceneUI scene;
|
| | | /// <summary>
|
| | | /// room
|
| | | /// </summary>
|
| | | private Common.Room room;
|
| | | /// <summary>
|
| | | /// 延时时间
|
| | | /// </summary>
|
| | | private NormalViewControl btnDelayTime;
|
| | | /// <summary>
|
| | | /// 延时图标
|
| | | /// </summary>
|
| | | private IconViewControl btnDelayIcon;
|
| | | /// <summary>
|
| | | /// 场景图片控件
|
| | | /// </summary>
|
| | | private ScenePictrueControl sceneContr = null;
|
| | | /// <summary>
|
| | | /// 是否已经完成控件初始化结束
|
| | | /// </summary>
|
| | | private bool isInitControlFinish = false;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// SceneCategoryView
|
| | | /// </summary>
|
| | | public SceneCategoryView()
|
| | | {
|
| | | this.Width = Application.GetRealWidth(1080);
|
| | | this.Height = Application.GetRealHeight(397 + 46);
|
| | | this.BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor;
|
| | | this.IsUseSameSubViewWidth = false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化
|
| | | /// </summary>
|
| | | /// <param name="i_scene"></param>
|
| | | public void InitControl(SceneUI i_scene, Common.Room i_room)
|
| | | {
|
| | | this.RemoveAll();
|
| | |
|
| | | this.LineColor = UserCenterColor.Current.Transparent;
|
| | |
|
| | | this.scene = i_scene;
|
| | | this.room = i_room;
|
| | |
|
| | | //自定义的场景图片控件
|
| | | this.sceneContr = new ScenePictrueControl();
|
| | | this.AddChidren(sceneContr);
|
| | | sceneContr.InitControl(this.scene);
|
| | |
|
| | | //场景点击
|
| | | sceneContr.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //不能反复点击
|
| | | sceneContr.CanClick = false;
|
| | | this.SceneUpHandler(sceneContr);
|
| | | };
|
| | |
|
| | | //收藏
|
| | | sceneContr.AddCollectionControl();
|
| | | sceneContr.CollectEvent += (collect) =>
|
| | | {
|
| | | if (room.IsLove)
|
| | | {
|
| | | this.RemoveFromParent();
|
| | | }
|
| | | };
|
| | | |
| | | //延时时间
|
| | | this.btnDelayTime = new NormalViewControl(400, 58, true);
|
| | | btnDelayTime.X = Application.GetRealWidth(580);
|
| | | btnDelayTime.Y = Application.GetRealHeight(317);
|
| | | btnDelayTime.Text = this.GetTimeString(scene.SceneDelayTime);
|
| | | btnDelayTime.TextAlignment = TextAlignment.CenterRight;
|
| | | btnDelayTime.TextColor = ZigbeeColor.Current.GXCTextSelectedColor3;
|
| | | btnDelayTime.IsBold = true;
|
| | | this.AddChidren(btnDelayTime);
|
| | |
|
| | | //延时图标
|
| | | this.btnDelayIcon = new IconViewControl(52);
|
| | | btnDelayIcon.X = Application.GetRealWidth(900);
|
| | | btnDelayIcon.Y = Application.GetRealHeight(30);
|
| | | btnDelayIcon.Width = this.GetPictrueRealSize(52);
|
| | | btnDelayIcon.Height = this.GetPictrueRealSize(52);
|
| | | btnDelayIcon.UnSelectedImagePath = "Scene/Delaying.png";
|
| | | this.AddChidren(btnDelayIcon);
|
| | | btnDelayIcon.Visible = false;
|
| | |
|
| | | if (isInitControlFinish == true)
|
| | | {
|
| | | //编辑场景的回调函数会重新刷新控件
|
| | | //所以这里不再初始化
|
| | | return;
|
| | | }
|
| | | this.isInitControlFinish = true;
|
| | |
|
| | | //添加左边的空白区域
|
| | | var btnTemp1 = new NormalViewControl(Application.GetRealWidth(58), sceneContr.btnScenePic.Height, false);
|
| | | this.AddLeftView(btnTemp1);
|
| | | //定时
|
| | | var btnDelay = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
|
| | | btnDelay.BackgroundColor = ZigbeeColor.Current.GXCTextSelectedColor;
|
| | | btnDelay.TextID = R.MyInternationalizationString.Delay;
|
| | | btnDelay.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
|
| | | btnDelay.TextAlignment = TextAlignment.Center;
|
| | | btnDelay.Tag = scene.SceneDelayTime;
|
| | | btnDelay.Radius = (uint)Application.GetRealHeight(17);
|
| | | btnDelay.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight |
|
| | | HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
|
| | | this.AddLeftView(btnDelay);
|
| | | //变更按钮的高度
|
| | | btnDelay.Height = sceneContr.btnScenePic.Height;
|
| | | btnDelay.Y = 0;
|
| | |
|
| | | //编辑
|
| | | var btnEditor = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
|
| | | btnEditor.BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor;
|
| | | btnEditor.TextID = R.MyInternationalizationString.Edit;
|
| | | btnEditor.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
|
| | | btnEditor.TextAlignment = TextAlignment.Center;
|
| | | btnEditor.Tag = scene.SceneDelayTime;
|
| | | btnEditor.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerTopLeft);
|
| | |
|
| | | //删除
|
| | | var btnDelete = new NormalViewControl(Application.GetRealWidth(199), sceneContr.btnScenePic.Height, false);
|
| | | btnDelete.Tag = scene;
|
| | | btnDelete.BackgroundColor = ZigbeeColor.Current.GXCRedColor;
|
| | | btnDelete.TextID = R.MyInternationalizationString.Delete;
|
| | | btnDelete.TextColor = ZigbeeColor.Current.GXCTextWhiteColor;
|
| | | btnDelete.TextAlignment = TextAlignment.Center;
|
| | | btnDelete.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
|
| | |
|
| | | if (room.IsSharedRoom == false && room.IsLove == false)
|
| | | {
|
| | | //不是分享,并且不是收藏
|
| | | this.AddRightView(btnEditor);
|
| | | this.AddRightView(btnDelete);
|
| | | //变更按钮的高度
|
| | | btnEditor.Height = sceneContr.btnScenePic.Height;
|
| | | btnEditor.Y = 0;
|
| | | btnDelete.Height = sceneContr.btnScenePic.Height;
|
| | | btnDelete.Y = 0;
|
| | | //添加右边空白区域
|
| | | var btnTemp2 = new NormalViewControl(Application.GetRealWidth(58), sceneContr.btnScenePic.Height, false);
|
| | | this.AddRightView(btnTemp2);
|
| | | }
|
| | |
|
| | | //删除场景
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var alert = new ShowMsgControl(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.ConfirmDelete));
|
| | | alert.Show();
|
| | | alert.ConfirmClickEvent += async () =>
|
| | | {
|
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //移除缓存
|
| | | HdlSceneLogic.Current.DeleteLocalScene(scene);
|
| | | RemoveFromParent();
|
| | | return;
|
| | | }
|
| | | //0 移除失败 1 移除成功 2 没有该场景
|
| | | var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id);
|
| | | if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null)
|
| | | {
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.RequestServerFailed));
|
| | | return;
|
| | | }
|
| | | //1成功
|
| | | if (removeSceneAllData.removeSceneData.Result == 1)
|
| | | {
|
| | | HdlSceneLogic.Current.DeleteLocalScene(scene);
|
| | | RemoveFromParent();
|
| | | }
|
| | | //0 移除失败
|
| | | else if (removeSceneAllData.removeSceneData.Result == 0)
|
| | | {
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain));
|
| | | return;
|
| | | }
|
| | | //2 没有该场景
|
| | | else if (removeSceneAllData.removeSceneData.Result == 2)
|
| | | {
|
| | | HdlSceneLogic.Current.DeleteLocalScene(scene);
|
| | | RemoveFromParent();
|
| | | return;
|
| | | }
|
| | | };
|
| | | };
|
| | |
|
| | | //编辑场景
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //关闭左滑菜单
|
| | | this.HideMenu();
|
| | | //编辑场景
|
| | | var form = new Phone.Category.AddOrEditorSceneForm();
|
| | | form.AddForm(i_scene);
|
| | | form.SceneChangedEvent = (myScene, roomId) =>
|
| | | {
|
| | | if (roomId != room.Id)
|
| | | {
|
| | | //它变更了房间
|
| | | this.RemoveFromParent();
|
| | | }
|
| | | else
|
| | | {
|
| | | this.InitControl(myScene, room);
|
| | | }
|
| | | };
|
| | | };
|
| | | //编辑延时
|
| | | btnDelay.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (scene.RemainTime > 0)
|
| | | {
|
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.TheSceneIsDelaying));
|
| | | return;
|
| | | }
|
| | | var timeSelect = new SelectTime();
|
| | | CommonPage.Instance.AddChidren(timeSelect);
|
| | | timeSelect.TempTime = scene.SceneDelayTime;
|
| | | timeSelect.Init();
|
| | | timeSelect.TimeAction = (t) =>
|
| | | {
|
| | | //隐藏右划菜单
|
| | | this.HideMenu();
|
| | | if (t != 0)
|
| | | {
|
| | | scene.SceneDelayTime = t;
|
| | | btnDelayTime.Text = this.GetTimeString(t);
|
| | | //编辑延时时,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | }
|
| | | };
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | /// <summary>
|
| | | /// |
| | | /// </summary>
|
| | | /// <param name="sceneContr"></param>
|
| | | private async void SceneUpHandler(ScenePictrueControl sceneContr)
|
| | | {
|
| | | if (scene.SceneDelayTime <= 0 && scene.RemainTime <= 0)
|
| | | {
|
| | | //如果没有延迟的话,直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | }
|
| | | //调用场景
|
| | | var result = await HdlSceneLogic.Current.ControlScene(scene);
|
| | | if (result == false)
|
| | | {
|
| | | sceneContr.CanClick = true;
|
| | | return;
|
| | | }
|
| | | |
| | | scene.RemainTime = scene.SceneDelayTime;
|
| | | scene.SceneDelayTime = 0;
|
| | | if (scene.RemainTime <= 0)
|
| | | {
|
| | | sceneContr.CanClick = true;
|
| | | return;
|
| | | }
|
| | | //调用有延时的场景,需要刷新主页
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | int myRemainTime = scene.RemainTime;
|
| | | //开启内部延时时间线程(旨在全部地方的同一场景时间同步)
|
| | | HdlSceneLogic.Current.StartDelayTimeThread(scene);
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | while (myRemainTime > 0 && this.Parent != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | SetTimeText(this.GetTimeString(scene.RemainTime));
|
| | | }, ShowErrorMode.NO);
|
| | | myRemainTime--;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (this.Parent != null)
|
| | | {
|
| | | SetTimeImage();
|
| | | //直接开启Loading特效
|
| | | this.StartLoadingApreal();
|
| | | sceneContr.CanClick = true;
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// SetTimeText
|
| | | /// </summary>
|
| | | /// <param name="name"></param>
|
| | | public void SetTimeText(string name)
|
| | | {
|
| | | btnDelayIcon.Visible = true;
|
| | | btnDelayTime.Text = name;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// SetTimeImage
|
| | | /// </summary>
|
| | | public void SetTimeImage()
|
| | | {
|
| | | btnDelayIcon.Visible = false;
|
| | | btnDelayTime.Text = string.Empty;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 开启Loading特效
|
| | | /// </summary>
|
| | | public void StartLoadingApreal()
|
| | | {
|
| | | //弄个遮罩遮住
|
| | | var frameBack1 = new FrameLayout();
|
| | | frameBack1.Y = sceneContr.btnScenePic.Y;
|
| | | frameBack1.X = sceneContr.btnScenePic.X;
|
| | | frameBack1.Width = sceneContr.btnScenePic.Width;
|
| | | frameBack1.Height = sceneContr.btnScenePic.Height;
|
| | | frameBack1.Radius = (uint)Application.GetRealHeight(17);
|
| | | frameBack1.BackgroundColor = 0xb3000000;
|
| | | this.AddChidren(frameBack1);
|
| | |
|
| | | var frameBack2 = new FrameLayout();
|
| | | frameBack2.Y = sceneContr.btnSceneName.Y;
|
| | | frameBack2.X = sceneContr.btnSceneName.X;
|
| | | frameBack2.Width = sceneContr.btnSceneName.Width;
|
| | | frameBack2.Height = sceneContr.btnSceneName.Height;
|
| | | frameBack2.Radius = (uint)Application.GetRealHeight(17);
|
| | | frameBack2.BackgroundColor = 0xb3000000;
|
| | | this.AddChidren(frameBack2);
|
| | |
|
| | | //再加个转圈的
|
| | | var loadContr = new MyProgressLoading();
|
| | | loadContr.LoadingBackgroundColor = UserCenterColor.Current.Transparent;
|
| | | frameBack1.AddChidren(loadContr);
|
| | | loadContr.StartLoading(1000);
|
| | | loadContr.DisponeEvent += () =>
|
| | | {
|
| | | frameBack1.RemoveFromParent();
|
| | | frameBack2.RemoveFromParent();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <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
|
| | | {
|
| | | /// <summary>
|
| | | /// 控件销毁的事件
|
| | | /// </summary>
|
| | | public Action DisponeEvent = null;
|
| | | /// <summary>
|
| | | /// 控件销毁
|
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | base.RemoveFromParent();
|
| | |
|
| | | this.DisponeEvent?.Invoke();
|
| | | this.DisponeEvent = null;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|