From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码
---
ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs | 932 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 905 insertions(+), 27 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs b/ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs
index a21fac5..9655afe 100755
--- a/ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs
+++ b/ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using ZigBee.Device;
namespace Shared.Phone.Category
{
@@ -13,6 +14,10 @@
{
#region 鈻� 鍙橀噺澹版槑___________________________
+ /// <summary>
+ /// 鍦烘櫙鍙樻洿浜嬩欢(鍦烘櫙,鎴块棿ID)
+ /// </summary>
+ public Action<SceneUI, string> SceneChangedEvent = null;
/// <summary>
/// 淇敼鐨勫満鏅�
/// </summary>
@@ -26,9 +31,33 @@
/// </summary>
private string nowRoomId = string.Empty;
/// <summary>
+ /// 褰撳墠鐣岄潰涓婃樉绀虹殑鎵ц鐩爣
+ /// </summary>
+ private List<Scene.DeviceListData> listAdjustTarget = null;
+ /// <summary>
/// 鏁翠釜鐣岄潰鐨勪笂涓嬫粦鍔ㄦ帶浠�
/// </summary>
private VerticalFrameControl listBodyControl = null;
+ /// <summary>
+ /// 娣诲姞鐩爣鐨勭殑瀹瑰櫒鎺т欢
+ /// </summary>
+ private FrameListControl frameTargetTableControl = null;
+ /// <summary>
+ /// 杩欎釜鏄姞鍒般�愭暣涓晫闈㈢殑涓婁笅婊戝姩鎺т欢銆戜腑,淇冧娇鐣岄潰鑳藉婊戝姩鍒氬ソ瓒呰繃銆愬畬鎴愭寜閽��
+ /// </summary>
+ private FrameLayout frameBottomTemp = null;
+ /// <summary>
+ /// 鍦烘櫙鍥剧墖鏄剧ず鎺т欢(鐢熸垚鍥剧墖鏂囦欢浣跨敤)
+ /// </summary>
+ private ImageView btnScenePic = null;
+ /// <summary>
+ /// 鍦烘櫙鍥剧墖鏄惁鍙樻洿(閽堝缂栬緫妯″紡)
+ /// </summary>
+ private bool isScenePictrueChanged = false;
+ /// <summary>
+ /// 鎵ц鐩爣鏄惁鏀瑰彉(閽堝缂栬緫妯″紡)
+ /// </summary>
+ private bool isAdjustTargetChanged = false;
#endregion
@@ -47,6 +76,7 @@
this.cloneScene = new SceneUI();
if (i_editorScene != null)
{
+ cloneScene.Id = i_editorScene.Id;
cloneScene.Name = i_editorScene.Name;
cloneScene.IconPath = i_editorScene.IconPath;
cloneScene.IconPathType = i_editorScene.IconPathType;
@@ -61,6 +91,8 @@
}
else
{
+ cloneScene.IconPath = "SceneIcon/0.png";
+ listAdjustTarget = new List<Scene.DeviceListData>();
//璁剧疆澶撮儴淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddScence));
}
@@ -74,10 +106,44 @@
/// </summary>
private void InitMiddleFrame()
{
+ //鏁翠釜鐣岄潰鐨勪笂涓嬫粦鍔ㄦ帶浠�
this.listBodyControl = new VerticalFrameControl();
listBodyControl.Height = bodyFrameLayout.Height;
bodyFrameLayout.AddChidren(listBodyControl);
+ //鍒濆鍖栧満鏅浘鐗�
+ this.InitScenePictureControl();
+
+ //鍒濆鍖栦俊鎭紪杈戞帶浠�
+ this.InitInfoEditorControl();
+
+ //鍒濆鍖栨坊鍔犵洰鏍�
+ this.InitAddTargetControl();
+
+ //鍒嗕韩鐨勫満鏅笉鑳戒繚瀛�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ //瀹屾垚
+ var btnSave = new BottomClickButton();
+ btnSave.TextID = R.MyInternationalizationString.uFinish;
+ bodyFrameLayout.AddChidren(btnSave);
+ btnSave.ButtonClickEvent += (sender, e) =>
+ {
+ //淇濆瓨鍦烘櫙鏁版嵁
+ this.SaveSceneData();
+ };
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栧満鏅浘鐗嘷____________________
+
+ /// <summary>
+ /// 鍒濆鍖栧満鏅浘鐗�
+ /// </summary>
+ private void InitScenePictureControl()
+ {
//鍦烘櫙鍥剧墖杩欓儴鍒嗙殑鐧借壊鑳屾櫙
var framePicBack = new FrameLayout();
framePicBack.Height = Application.GetRealHeight(559);
@@ -91,41 +157,44 @@
btnShadow.UnSelectedImagePath = "Room/Room_Rectangle.png";
framePicBack.AddChidren(btnShadow);
//鍦烘櫙鍥剧墖
- var btnPic = new ImageView();
- btnPic.Y = Application.GetRealHeight(46);
- btnPic.Width = Application.GetMinRealAverage(887);
- btnPic.Height = Application.GetMinRealAverage(444);
- btnPic.Radius = (uint)Application.GetRealHeight(17);
- btnPic.Gravity = Gravity.CenterHorizontal;
+ this.btnScenePic = new ImageView();
+ btnScenePic.Y = Application.GetRealHeight(46);
+ btnScenePic.Width = this.GetPictrueRealSize(887);
+ btnScenePic.Height = this.GetPictrueRealSize(444);
+ btnScenePic.Radius = (uint)Application.GetRealHeight(17);
+ btnScenePic.Gravity = Gravity.CenterHorizontal;
if (this.editorScene == null)
{
- btnPic.ImagePath = "SceneIcon/0.png";
+ btnScenePic.ImagePath = "SceneIcon/0.png";
}
else if (this.editorScene.IconPathType == 0)
{
- btnPic.ImagePath = this.editorScene.IconPath;
+ btnScenePic.ImagePath = this.editorScene.IconPath;
}
else
{
- btnPic.ImageBytes = Global.ReadFileByHomeId(this.editorScene.IconPath);
+ btnScenePic.ImageBytes = Global.ReadFileByHomeId(this.editorScene.IconPath);
}
- framePicBack.AddChidren(btnPic);
+ framePicBack.AddChidren(btnScenePic);
//鍥剧墖閬僵
var btnZhezhao = new FrameLayout();
- btnZhezhao.Width = btnPic.Width;
- btnZhezhao.Height = btnPic.Height;
- btnZhezhao.Y = btnPic.Y;
+ btnZhezhao.Width = btnScenePic.Width;
+ btnZhezhao.Height = btnScenePic.Height;
+ btnZhezhao.Y = btnScenePic.Y;
btnZhezhao.Gravity = Gravity.CenterHorizontal;
- btnZhezhao.Radius = btnPic.Radius;
+ btnZhezhao.Radius = (uint)Application.GetRealHeight(17);
+ btnZhezhao.BackgroundColor = UserCenterColor.Current.PictrueZhezhaoColor;
framePicBack.AddChidren(btnZhezhao);
- btnZhezhao.MouseUpEventHandler += (sender, e) =>
- {
- //鎴块棿鍥剧墖閫夋嫨
- this.ScenePictrueSelect(btnPic);
- };
- //鍒濆鍖栦俊鎭紪杈戞帶浠�
- this.InitInfoEditorControl();
+ //鍒嗕韩鐨勫満鏅笉鑳界紪杈�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ btnZhezhao.MouseUpEventHandler += (sender, e) =>
+ {
+ //鎴块棿鍥剧墖閫夋嫨
+ this.ScenePictrueSelect(btnScenePic);
+ };
+ }
}
#endregion
@@ -158,12 +227,720 @@
rowScene.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName);
rowScene.Y = btnTitle.Bottom + Application.GetRealHeight(23);
frameBack.AddChidren(rowScene);
+ rowScene.InitControl();
//搴曠嚎
rowScene.AddBottomLine();
+ rowScene.txtInput.TextChangeEventHandler += (sender, value) =>
+ {
+ this.cloneScene.Name = value;
+ };
//鎵�灞炲尯鍩�
var rowBelong = new BelongAreaControl();
- //rowBelong.Y= rowScene.Bottom+
+ rowBelong.Y = rowScene.Bottom + Application.GetRealHeight(14);
+ frameBack.AddChidren(rowBelong);
+ rowBelong.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.nowRoomId);
+ //鍒嗕韩鐨勫満鏅笉鑳界紪杈�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ rowBelong.SelectRoomEvent += (selectId) =>
+ {
+ this.nowRoomId = selectId;
+ };
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栨坊鍔犵洰鏍嘷____________________
+
+ /// <summary>
+ /// 鍒濆鍖栨坊鍔犵洰鏍�
+ /// </summary>
+ private void InitAddTargetControl()
+ {
+ if (this.frameTargetTableControl == null || this.frameTargetTableControl.Parent == null)
+ {
+ //娣诲姞鐩爣鐨勭殑瀹瑰櫒鎺т欢
+ this.frameTargetTableControl = new FrameListControl();
+ frameTargetTableControl.Y = Application.GetRealHeight(1034);
+ frameTargetTableControl.BackgroundColor = UserCenterColor.Current.White;
+ frameTargetTableControl.Height = Application.GetRealHeight(346);
+ this.listBodyControl.frameTable.AddChidren(frameTargetTableControl);
+ }
+ else
+ {
+ this.frameTargetTableControl?.RemoveAll();
+ frameTargetTableControl.Height = Application.GetRealHeight(346);
+ }
+
+ //娣诲姞鐩爣
+ var rowAddTarget = new FrameRowControl(frameTargetTableControl.rowSpace / 2);
+ rowAddTarget.UseClickStatu = false;
+ rowAddTarget.Y = Application.GetRealHeight(46 - 12);
+ frameTargetTableControl.AddChidren(rowAddTarget);
+ rowAddTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.AddScentTargetAction), 600);
+ //+鍙�
+ var btnAddIcon = rowAddTarget.AddMostRightEmptyIcon(61, 58);
+ btnAddIcon.UnSelectedImagePath = "Item/Add.png";
+ //搴曠嚎
+ rowAddTarget.AddBottomLine();
+ rowAddTarget.ButtonClickEvent += (sender, e) =>
+ {
+ //鏄剧ず娣诲姞鐩爣鑿滃崟
+ this.ShowAddTargetMenu();
+ };
+
+ HdlThreadLogic.Current.RunThread(async () =>
+ {
+ //浠庣綉鍏宠幏鍙栧満鏅殑鎵ц鐩爣
+ var result = await this.GetSceneTargetList();
+ if (result == true)
+ {
+ //娣诲姞銆愭墽琛岀洰鏍囪銆�
+ this.AddTargetRow();
+ }
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 鑾峰彇鍙婃坊鍔犮�愮洰鏍囪銆慱______________
+
+ /// <summary>
+ /// 娣诲姞銆愭墽琛岀洰鏍囪銆�
+ /// </summary>
+ private void AddTargetRow()
+ {
+ //妫�娴嬬綉鍏充笂鐨勬暟鎹槸鍚﹀拰鏈湴涓�鑷�
+ for (int i = 0; i < this.listAdjustTarget.Count; i++)
+ {
+ if (listAdjustTarget[i].Type == 0)
+ {
+ //璁惧
+ var device = Common.LocalDevice.Current.GetDevice(listAdjustTarget[i].DeviceAddr, listAdjustTarget[i].Epoint);
+ if (device == null)
+ {
+ //涓嶆樉绀鸿繖涓笉瀛樺湪鏈湴鐨勮澶�
+ listAdjustTarget.RemoveAt(i);
+ i--;
+ }
+ continue;
+ }
+ else if (listAdjustTarget[i].Type == 1)
+ {
+ //鍦烘櫙
+ var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(listAdjustTarget[i].ElseScenesId);
+ if (scene == null)
+ {
+ //涓嶆樉绀鸿繖涓笉瀛樺湪鏈湴鐨勮澶�
+ listAdjustTarget.RemoveAt(i);
+ i--;
+ }
+ continue;
+ }
+ }
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ for (int i = 0; i < listAdjustTarget.Count; i++)
+ {
+ if (listAdjustTarget[i].Type == 0)
+ {
+ //璁惧
+ this.AddDeviceTargetRow(listAdjustTarget[i], i, i != listAdjustTarget.Count - 1);
+ }
+ else if (listAdjustTarget[i].Type == 1)
+ {
+ //鍦烘櫙
+ this.AddSceneTargetRow(listAdjustTarget[i], i, i != listAdjustTarget.Count - 1);
+ }
+ else if (listAdjustTarget[i].Type == 2)
+ {
+ //寤舵椂
+ this.AddDelayTimeTargetRow(listAdjustTarget[i], i, i != listAdjustTarget.Count - 1);
+ }
+ }
+ //鍒濆鍖栦績浣跨晫闈㈣兘澶熷垰濂芥粦鍔ㄨ秴杩囦繚瀛樻寜閽殑鎺т欢
+ this.InitFrameBottomTempControl();
+
+ //璋冩暣鎵ц鐩爣鐨勬甯冮珮搴�
+ this.AdjustTargetTableHeight();
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 娣诲姞璁惧鎵ц鐩爣琛宊________________
+
+ /// <summary>
+ /// 娣诲姞璁惧鎵ц鐩爣琛�
+ /// </summary>
+ private void AddDeviceTargetRow(Scene.DeviceListData data, int index, bool addLine)
+ {
+ //璁惧
+ var device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
+ var rowDevice = new DeviceRoomControl(device, frameTargetTableControl.rowSpace / 2);
+ rowDevice.MainKeys = index.ToString();
+ this.frameTargetTableControl.AddChidren(rowDevice);
+ //鎺т欢鍚戝彸鍋忕Щ
+ rowDevice.frameTable.LeftOffset = Application.GetRealWidth(104) - ControlCommonResourse.XXLeft;
+ rowDevice.InitControl();
+ rowDevice.frameTable.UseClickStatu = false;
+
+ //鐘舵�佹枃鏈�
+ string statuText2 = HdlSafeguardLogic.Current.GetAdjustTargetStatuText(data.TaskList);
+ var btnStatu = rowDevice.frameTable.AddMostRightView(statuText2, 400);
+ if (addLine == true)
+ {
+ //搴曠嚎
+ rowDevice.frameTable.AddBottomLine();
+ }
+ //鍒嗕韩鐨勫満鏅笉鑳界紪杈�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ //缂栬緫
+ var btnEditor = rowDevice.AddEditorControl();
+ btnEditor.ButtonClickEvent += (sender, e) =>
+ {
+ if (device.Type == DeviceType.DimmableLight//璋冨厜鍣�
+ || device.Type == DeviceType.ColorDimmableLight)//褰╃伅
+ {
+ var form = new UserCenter.Safety.AlarmTargetStatuSelectLightForm();
+ form.AddForm(device, data.TaskList);
+ form.FinishSelectEvent += (statuText, listInfo) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+
+ if (listInfo.Count == 0) { statuText = string.Empty; }
+ btnStatu.Text = statuText;
+ //灏嗘柊鐨勬墽琛岀洰鏍囨坊鍔犲叆缂撳瓨
+ data.TaskList.Clear();
+ data.TaskList.AddRange(listInfo);
+ };
+ }
+ else if (device.Type == DeviceType.Thermostat)//绌鸿皟
+ {
+ var form = new UserCenter.Safety.AlarmTargetStatuSelectAcForm();
+ form.AddForm(device, data.TaskList);
+ form.FinishSelectEvent += (statuText, listInfo) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+
+ if (listInfo.Count == 0) { statuText = string.Empty; }
+ btnStatu.Text = statuText;
+ //灏嗘柊鐨勬墽琛岀洰鏍囨坊鍔犲叆缂撳瓨
+ data.TaskList.Clear();
+ data.TaskList.AddRange(listInfo);
+ };
+ }
+ else if (device.Type == DeviceType.WindowCoveringDevice)//绐楀笜
+ {
+ var form = new UserCenter.Safety.AlarmTargetStatuSelectCurtainForm();
+ form.AddForm(device, data.TaskList);
+ form.FinishSelectEvent += (statuText, listInfo) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+
+ if (listInfo.Count == 0) { statuText = string.Empty; }
+ btnStatu.Text = statuText;
+ //灏嗘柊鐨勬墽琛岀洰鏍囨坊鍔犲叆缂撳瓨
+ data.TaskList.Clear();
+ data.TaskList.AddRange(listInfo);
+ };
+ }
+ else
+ {
+ //鍏朵粬鐩存帴褰掍负寮�鍏崇被
+ var form = new UserCenter.Safety.AlarmTargetStatuSelectSwitchForm();
+ form.AddForm(device, data.TaskList);
+ form.FinishSelectEvent += (statuText, listInfo) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+
+ if (listInfo.Count == 0) { statuText = string.Empty; }
+ btnStatu.Text = statuText;
+ //灏嗘柊鐨勬墽琛岀洰鏍囨坊鍔犲叆缂撳瓨
+ data.TaskList.Clear();
+ data.TaskList.AddRange(listInfo);
+ };
+ }
+ };
+
+ //鍒犻櫎
+ var btnDelete = rowDevice.AddDeleteControl();
+ btnDelete.ButtonClickEvent += (sender, e) =>
+ {
+ //闅愯棌鍙虫粦鑿滃崟
+ rowDevice.HideMenu();
+ //纭鏄惁瑕佸垹闄わ紵
+ string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
+ this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ //璋冩暣鎵ц鐩爣閲岄潰鐨勫叏閮ㄥ潗鏍�(鍒犻櫎鐨勬椂鍊欎娇鐢�)
+ this.AdjustTargetLocation(rowDevice.MainKeys);
+ //绉婚櫎
+ rowDevice.RemoveFromParent();
+ this.listAdjustTarget.Remove(data);
+ //璋冩暣鎵ц鐩爣鐨勬甯冮珮搴�
+ this.AdjustTargetTableHeight();
+ });
+ };
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 娣诲姞鍦烘櫙鎵ц鐩爣琛宊________________
+
+ /// <summary>
+ /// 娣诲姞鍦烘櫙鎵ц鐩爣琛�
+ /// </summary>
+ private void AddSceneTargetRow(Scene.DeviceListData data, int index, bool addLine)
+ {
+ //鍦烘櫙
+ var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(data.ElseScenesId);
+ var rowScene = new SceneRoomControl(scene.Id, scene.Name, frameTargetTableControl.rowSpace / 2);
+ rowScene.MainKeys = index.ToString();
+ frameTargetTableControl.AddChidren(rowScene);
+ //鎺т欢鍚戝彸鍋忕Щ
+ rowScene.frameTable.LeftOffset = Application.GetRealWidth(104) - ControlCommonResourse.XXLeft;
+ rowScene.InitControl();
+ if (addLine == true)
+ {
+ //搴曠嚎
+ rowScene.frameTable.AddBottomLine();
+ }
+ rowScene.frameTable.UseClickStatu = false;
+
+ //鍒嗕韩鐨勫満鏅笉鑳界紪杈�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ //鍒犻櫎
+ var btnDelete = rowScene.AddDeleteControl();
+ btnDelete.ButtonClickEvent += (sender, e) =>
+ {
+ //闅愯棌鍙虫粦鑿滃崟
+ rowScene.HideMenu();
+
+ //纭鏄惁瑕佸垹闄わ紵
+ string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
+ this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ //璋冩暣鎵ц鐩爣閲岄潰鐨勫叏閮ㄥ潗鏍�(鍒犻櫎鐨勬椂鍊欎娇鐢�)
+ this.AdjustTargetLocation(rowScene.MainKeys);
+ //绉婚櫎
+ rowScene.RemoveFromParent();
+ this.listAdjustTarget.Remove(data);
+ //璋冩暣鎵ц鐩爣鐨勬甯冮珮搴�
+ this.AdjustTargetTableHeight();
+ });
+ };
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 娣诲姞寤舵椂琛宊________________________
+
+ /// <summary>
+ /// 娣诲姞寤舵椂琛�
+ /// </summary>
+ private void AddDelayTimeTargetRow(Scene.DeviceListData data, int index, bool addLine)
+ {
+ string hourText = Language.StringByID(R.MyInternationalizationString.Hour);
+ string minuText = Language.StringByID(R.MyInternationalizationString.Minute);
+ string secondText = Language.StringByID(R.MyInternationalizationString.Second);
+
+ //琛屾帶浠�
+ var rowDelay = new RowLayoutControl(frameTargetTableControl.rowSpace / 2);
+ rowDelay.MainKeys = index.ToString();
+ frameTargetTableControl.AddChidren(rowDelay);
+ //鎺т欢鍚戝彸鍋忕Щ
+ rowDelay.frameTable.LeftOffset = Application.GetRealWidth(104) - ControlCommonResourse.XXLeft;
+ rowDelay.frameTable.UseClickStatu = false;
+ //鍥炬爣
+ var btnIcon = rowDelay.frameTable.AddLeftIcon();
+ btnIcon.UnSelectedImagePath = "Item/Timer.png";
+ //寤舵椂
+ var btnDelay = rowDelay.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.Delay), 400);
+ btnDelay.TextColor = UserCenterColor.Current.TextGrayColor3;
+
+ //x灏忔椂x鍒嗛挓x绉掑悗
+ string timeStr = this.GetTimeString(data.DelayTime, hourText, minuText, secondText);
+ timeStr += Language.StringByID(R.MyInternationalizationString.Later);
+ var btnStatu = rowDelay.frameTable.AddMostRightView(timeStr, 300);
+
+ if (addLine == true)
+ {
+ //搴曠嚎
+ rowDelay.frameTable.AddBottomLine();
+ }
+
+ //鍒嗕韩鐨勫満鏅笉鑳界紪杈�
+ if (this.editorScene == null || this.editorScene.IsSharedScene == false)
+ {
+ //缂栬緫
+ var btnEditor = rowDelay.AddEditorControl();
+ btnEditor.ButtonClickEvent += (sender, e) =>
+ {
+ //寤舵椂鏃堕棿閫夋嫨
+ var form = new AdjustTargetAddDelayTimeForm();
+ form.AddForm(data.DelayTime);
+ form.FinishSelectEvent += (delayTime) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ data.DelayTime = delayTime;
+ //x灏忔椂x鍒嗛挓x绉掑悗
+ timeStr = this.GetTimeString(data.DelayTime, hourText, minuText, secondText);
+ btnStatu.Text = timeStr;
+ };
+ };
+ //鍒犻櫎
+ var btnDelete = rowDelay.AddDeleteControl();
+ btnDelete.ButtonClickEvent += (sender, e) =>
+ {
+ //闅愯棌鍙虫粦鑿滃崟
+ rowDelay.HideMenu();
+ //纭鏄惁瑕佸垹闄わ紵
+ string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
+ this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ //璋冩暣鎵ц鐩爣閲岄潰鐨勫叏閮ㄥ潗鏍�(鍒犻櫎鐨勬椂鍊欎娇鐢�)
+ this.AdjustTargetLocation(rowDelay.MainKeys);
+ //绉婚櫎
+ rowDelay.RemoveFromParent();
+ this.listAdjustTarget.Remove(data);
+ //璋冩暣鎵ц鐩爣鐨勬甯冮珮搴�
+ this.AdjustTargetTableHeight();
+ });
+ };
+ }
+ }
+
+ /// <summary>
+ /// 浠庣綉鍏宠幏鍙栧満鏅殑鎵ц鐩爣
+ /// </summary>
+ /// <returns></returns>
+ private async System.Threading.Tasks.Task<bool> GetSceneTargetList()
+ {
+ if (this.editorScene == null || this.listAdjustTarget != null)
+ {
+ return true;
+ }
+
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
+ //鑾峰彇鎵ц鐩爣鍒楄〃
+ var listData = await HdlSceneLogic.Current.GetAdjustTargetList(this.editorScene);
+ if (listData == null)
+ {
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return false;
+ }
+ this.listAdjustTarget = new List<Scene.DeviceListData>();
+ listAdjustTarget.AddRange(listData);
+
+ this.CloseProgressBar();
+ return true;
+ }
+
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖栦績浣跨晫闈㈡粦鍔ㄦ帶浠禵____________
+
+ /// <summary>
+ /// 鍒濆鍖栦績浣跨晫闈㈣兘澶熷垰濂芥粦鍔ㄨ秴杩囦繚瀛樻寜閽殑鎺т欢
+ /// </summary>
+ private void InitFrameBottomTempControl()
+ {
+ if (this.frameBottomTemp != null)
+ {
+ return;
+ }
+ //鍊熺敤涓�涓嬫帶浠剁殑Y杞�
+ var btnTemp = new BottomClickButton();
+
+ //閭d釜鐗规畩鐨勬帶浠�
+ this.frameBottomTemp = new FrameLayout();
+ frameBottomTemp.Height = bodyFrameLayout.Height - btnTemp.Yaxis + Application.GetRealHeight(23);
+ this.listBodyControl.AddChidren(frameBottomTemp);
+ }
+
+ #endregion
+
+ #region 鈻� 鏄剧ず娣诲姞鐩爣鑿滃崟___________________
+
+ /// <summary>
+ /// 鏄剧ず娣诲姞鐩爣鑿滃崟
+ /// </summary>
+ private void ShowAddTargetMenu()
+ {
+ var menuContr = new BottomMenuSelectForm();
+ menuContr.AddForm(3);
+ //鍔熻兘
+ menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uFunction), () =>
+ {
+ var form = new AdjustTargetAddDeviceForm();
+ form.AddForm(listAdjustTarget);
+ form.FinishSelectEvent += (dicData) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ foreach (var mainKey in dicData.Keys)
+ {
+ var device = LocalDevice.Current.GetDevice(mainKey);
+ var data = new Scene.DeviceListData();
+ data.Type = 0;
+ data.DeviceAddr = device.DeviceAddr;
+ data.Epoint = device.DeviceEpoint;
+ data.TaskList = dicData[mainKey];
+ this.listAdjustTarget.Add(data);
+ }
+ //鍒锋柊鍒楄〃鎺т欢
+ this.InitAddTargetControl();
+ };
+ });
+ //鍦烘櫙
+ menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uScence), () =>
+ {
+ var form = new AdjustTargetAddSceneForm();
+ form.AddForm(listAdjustTarget);
+ form.FinishSelectEvent += (listSceneId) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ foreach (int sceneId in listSceneId)
+ {
+ var data = new Scene.DeviceListData();
+ data.Type = 1;
+ data.ElseScenesId = sceneId;
+ this.listAdjustTarget.Add(data);
+ }
+ //鍒锋柊鍒楄〃鎺т欢
+ this.InitAddTargetControl();
+ };
+ });
+ //寤舵椂
+ menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.Delay), () =>
+ {
+ //寤舵椂鏃堕棿閫夋嫨
+ var form = new AdjustTargetAddDelayTimeForm();
+ form.AddForm(0);
+ form.FinishSelectEvent += (delayTime) =>
+ {
+ //鎵ц鐩爣宸茬粡鏀瑰彉
+ this.isAdjustTargetChanged = true;
+ var data = new Scene.DeviceListData();
+ data.Type = 2;
+ data.DelayTime = delayTime;
+ this.listAdjustTarget.Add(data);
+ //鍒锋柊鍒楄〃鎺т欢
+ this.InitAddTargetControl();
+ };
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 淇濆瓨鍦烘櫙鏁版嵁_______________________
+
+ /// <summary>
+ /// 淇濆瓨鍦烘櫙鏁版嵁
+ /// </summary>
+ private void SaveSceneData()
+ {
+ //妫�娴嬭兘鍚︿繚瀛樺満鏅�
+ if (this.CheckCanSaveScene() == false)
+ {
+ return;
+ }
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
+ //鏂板缓鍦烘櫙
+ if (this.editorScene == null)
+ {
+ //淇濆瓨鏂板缓鐨勫満鏅�
+ this.SaveSceneDataByNewMode();
+ }
+ //缂栬緫鍦烘櫙
+ else
+ {
+ //淇濆瓨缂栬緫鐨勫満鏅�
+ this.SaveSceneDataByEditorMode();
+ }
+ });
+ }
+
+ /// <summary>
+ /// 淇濆瓨鏂板缓鐨勫満鏅�
+ /// </summary>
+ private async void SaveSceneDataByNewMode()
+ {
+ //娣诲姞鍦烘櫙
+ this.editorScene = await HdlSceneLogic.Current.AddNewSceneToGateway(this.cloneScene.Name, this.listAdjustTarget);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+
+ if (editorScene == null)
+ {
+ return;
+ }
+ if (this.nowRoomId != string.Empty)
+ {
+ //娣诲姞鎴块棿
+ var newRoom = HdlRoomLogic.Current.GetRoomById(this.nowRoomId);
+ HdlSceneLogic.Current.AddSceneToRoom(newRoom, this.editorScene);
+ }
+ if (this.cloneScene.IconPathType != 0)
+ {
+ //鑷畾涔夊浘鐗�
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss");
+ var fileName = $"SceneIcon_{tradeTime}.png";
+ //鐢熸垚鏂囦欢鍥剧墖
+ IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), this.btnScenePic.ImageBytes);
+ HdlAutoBackupLogic.AddOrEditorFile(fileName);
+ this.cloneScene.IconPath = fileName;
+ }
+ //杞Щ灞炴��
+ this.editorScene.Name = this.cloneScene.Name;
+ this.editorScene.IconPathType = this.cloneScene.IconPathType;
+ this.editorScene.IconPath = this.cloneScene.IconPath;
+ this.editorScene.Save();
+
+ //鏂板缓鍦烘櫙,涓婚〉闇�瑕侀噸鏂板埛鏂�
+ UserView.UserPage.Instance.RefreshAllForm = true;
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //璋冪敤鍥炶皟鍑芥暟
+ this.SceneChangedEvent?.Invoke(this.editorScene, this.nowRoomId);
+ this.CloseForm();
+ });
+ }
+
+ /// <summary>
+ /// 淇濆瓨缂栬緫鐨勫満鏅�
+ /// </summary>
+ private async void SaveSceneDataByEditorMode()
+ {
+ if (this.editorScene.Name != this.cloneScene.Name)
+ {
+ //淇敼鍚嶇О
+ var result = await HdlSceneLogic.Current.EditorSceneNameFromGateway(this.editorScene, this.cloneScene.Name);
+ if (result == false)
+ {
+ return;
+ }
+ }
+ if (isAdjustTargetChanged == true)
+ {
+ //淇敼鍦烘櫙
+ var result = await HdlSceneLogic.Current.EditorSceneFromGateway(this.editorScene, this.listAdjustTarget);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
+ if (result == false)
+ {
+ return;
+ }
+ }
+
+ if (this.nowRoomId != string.Empty)
+ {
+ //鍙樻洿鎴块棿
+ HdlSceneLogic.Current.ChangedSceneRoom(this.editorScene, this.nowRoomId);
+ }
+ else
+ {
+ //绉婚櫎鍑烘埧闂�
+ var room = HdlRoomLogic.Current.GetRoomBySceneId(this.editorScene.Id);
+ if (room != null)
+ {
+ HdlSceneLogic.Current.DeleteSceneFromRoom(room, this.editorScene);
+ }
+ }
+
+ //鍥剧墖鏀瑰彉浜�
+ if (isScenePictrueChanged == true)
+ {
+ if (this.editorScene.IconPathType != 0)
+ {
+ //鍒犻櫎鑷畾涔夊浘鐗�
+ Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, this.editorScene.IconPath));
+ HdlAutoBackupLogic.DeleteFile(this.editorScene.IconPath);
+ }
+ if (this.cloneScene.IconPathType != 0)
+ {
+ //鑷畾涔夊浘鐗�
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss");
+ var fileName = $"SceneIcon_{tradeTime}.png";
+ //鐢熸垚鏂囦欢鍥剧墖
+ IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), this.btnScenePic.ImageBytes);
+ HdlAutoBackupLogic.AddOrEditorFile(fileName);
+ this.cloneScene.IconPath = fileName;
+ }
+ }
+
+ //杞Щ灞炴��
+ this.editorScene.Name = this.cloneScene.Name;
+ this.editorScene.IconPathType = this.cloneScene.IconPathType;
+ this.editorScene.IconPath = this.cloneScene.IconPath;
+ this.editorScene.Save();
+
+ //缂栬緫鍦烘櫙,涓婚〉闇�瑕侀噸鏂板埛鏂�
+ UserView.UserPage.Instance.RefreshAllForm = true;
+
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ //璋冪敤鍥炶皟鍑芥暟
+ this.SceneChangedEvent?.Invoke(this.editorScene, this.nowRoomId);
+ this.CloseForm();
+ });
+ }
+
+ /// <summary>
+ /// 妫�娴嬭兘鍚︿繚瀛樺満鏅�
+ /// </summary>
+ /// <returns></returns>
+ private bool CheckCanSaveScene()
+ {
+ if (this.cloneScene.Name == string.Empty)
+ {
+ //鍦烘櫙鍚嶄笉鑳戒负绌�
+ this.ShowMassage(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull));
+ return false;
+ }
+ bool hadTarget = false;
+ foreach (var data in this.listAdjustTarget)
+ {
+ if (data.Type == 0 || data.Type == 1)
+ {
+ //鎷ユ湁鎵ц鐩爣
+ hadTarget = true;
+ break;
+ }
+ }
+ if (hadTarget == false)
+ {
+ //璇锋坊鍔犳墽琛岀洰鏍�
+ this.ShowMassage(ShowMsgType.Remind, Language.StringByID(R.MyInternationalizationString.uPleaseAddAdjustTarget));
+ return false;
+ }
+ return true;
}
#endregion
@@ -181,11 +958,9 @@
//榛樿鍥惧簱
menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.LocalPicture), () =>
{
- var localPic = new Device.Room.AddRoomSelectPicByLocal();
- UserView.HomePage.Instance.AddChidren(localPic);
- UserView.HomePage.Instance.PageIndex += 1;
- localPic.Show();
- localPic.action = (imgPath) =>
+ var form = new SelectLocalSceneImageForm();
+ form.AddForm();
+ form.FinishSelectEvent = (imgPath) =>
{
if (string.IsNullOrEmpty(imgPath) == true)
{
@@ -195,6 +970,8 @@
this.cloneScene.IconPath = imgPath;
imgPath = IO.FileUtils.GetImageFilePath(imgPath);
imageContr.ImageBytes = IO.FileUtils.ReadFile(imgPath);
+ //鍦烘櫙鍥剧墖宸茬粡鏀瑰彉
+ this.isScenePictrueChanged = true;
};
});
//鎷嶇収
@@ -210,6 +987,9 @@
this.cloneScene.IconPathType = 1;
imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
System.IO.File.Delete(imagePath);
+ //鍦烘櫙鍥剧墖宸茬粡鏀瑰彉
+ this.isScenePictrueChanged = true;
+
}, "HdlPic", 2, 1);
});
//鎴戠殑鐩稿唽
@@ -225,6 +1005,8 @@
this.cloneScene.IconPathType = 2;
imageContr.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
System.IO.File.Delete(imagePath);
+ //鍦烘櫙鍥剧墖宸茬粡鏀瑰彉
+ this.isScenePictrueChanged = true;
}, "HdlPic", 2, 1);
});
@@ -232,8 +1014,104 @@
#endregion
+ #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+ /// <summary>
+ /// 鐣岄潰鍏抽棴
+ /// </summary>
+ public override void CloseFormBefore()
+ {
+ this.SceneChangedEvent = null;
+
+ base.CloseFormBefore();
+ }
+
+ #endregion
+
#region 鈻� 涓�鑸柟娉昣__________________________
+ /// <summary>
+ /// 鑾峰彇鏃堕棿鐨勭炕璇戞枃鏈�
+ /// </summary>
+ /// <param name="second"></param>
+ /// <param name="hourText">灏忔椂鐨勬枃鏈�</param>
+ /// <param name="minuText">鍒嗙殑鏂囨湰</param>
+ /// <param name="secondText">绉掔殑鏂囨湰</param>
+ /// <returns></returns>
+ private string GetTimeString(int second, string hourText, string minuText, string secondText)
+ {
+ string timeStr = string.Empty;
+ int hour = second / 3600;
+ int minu = second % 3600 / 60;
+ int sec = second % 60;
+ if (hour > 0)
+ {
+ timeStr += hour + hourText;
+ }
+ if (minu > 0)
+ {
+ timeStr += minu + minuText;
+ }
+ if (sec > 0)
+ {
+ timeStr += sec + secondText;
+ }
+ return timeStr;
+ }
+
+ /// <summary>
+ /// 璋冩暣鎵ц鐩爣鐨勬甯冮珮搴�
+ /// </summary>
+ private void AdjustTargetTableHeight()
+ {
+ //璋冩暣妗屽竷楂樺害
+ int minHeight = Application.GetRealHeight(346);
+ int realHeight = frameTargetTableControl.GetChildren(frameTargetTableControl.ChildrenCount - 1).Bottom;
+ realHeight += Application.GetRealHeight(23);
+ if (realHeight > minHeight)
+ {
+ frameTargetTableControl.Height = realHeight;
+ }
+ else if (frameTargetTableControl.Height != minHeight)
+ {
+ frameTargetTableControl.Height = minHeight;
+ }
+ //杩欎釜鐗规畩鐨勪笢瑗垮繀椤绘斁鍦ㄦ墽琛岀洰鏍囧鍣ㄧ殑搴曢儴
+ this.frameBottomTemp.Y = frameTargetTableControl.Bottom;
+ //璋冩暣鍏ㄥ眬涓婁笅婊戝姩鎺т欢鐨勬甯冮珮搴�
+ this.listBodyControl.AdjustTableHeight();
+ }
+
+ /// <summary>
+ /// 璋冩暣鎵ц鐩爣閲岄潰鐨勫叏閮ㄥ潗鏍�(鍒犻櫎鐨勬椂鍊欎娇鐢�)
+ /// </summary>
+ /// <param name="mainKey">鍒犻櫎鐨勪富閿�</param>
+ private void AdjustTargetLocation(string mainKey)
+ {
+ bool canChanged = false;
+ int YY = 0;
+ for (int i = 0; i < frameTargetTableControl.ChildrenCount; i++)
+ {
+ var myRow = frameTargetTableControl.GetChildren(i);
+ if (canChanged == false && (myRow is RowLayoutControl))
+ {
+ if (((RowLayoutControl)myRow).MainKeys == mainKey)
+ {
+ //宸茬粡鍒拌揪瑕佸垹闄ょ殑绱㈠紩
+ canChanged = true;
+ YY = frameTargetTableControl.GetChildren(i).Y;
+ }
+ continue;
+ }
+ if (canChanged == true)
+ {
+ //瀹冧笅闈㈢殑琛屽叏閮ㄥ線涓婄Щ
+ myRow.Y = YY;
+ YY = myRow.Bottom;
+ }
+ }
+ }
+
#endregion
}
}
--
Gitblit v1.8.0