From 40f46f32cb00f4304a691d4f027a76a13a9ebb6d Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期一, 16 十二月 2019 15:11:36 +0800
Subject: [PATCH] 2019.12.16
---
ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 394 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 293 insertions(+), 101 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
old mode 100755
new mode 100644
index 8d287f2..7f1a2e0
--- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
@@ -15,28 +15,28 @@
/// bodyFrameLayout
/// </summary>
private FrameLayout bodyFrameLayout;
- /// <summary>
- /// floorIds
- /// </summary>
- List<string> floorIds = new List<string> { };
- /// <summary>
- /// floorNames
- /// </summary>
- List<string> floorNames = new List<string> { };
- /// <summary>
- /// roomNames
- /// </summary>
- List<List<string>> roomNames = new List<List<string>> { };
- /// <summary>
- /// roomNames
- /// </summary>
- List<List<Common.Room>> rooms = new List<List<Common.Room>> { };
+ ///// <summary>
+ ///// floorIds
+ ///// </summary>
+ //List<string> floorIds = new List<string> { };
+ ///// <summary>
+ ///// floorNames
+ ///// </summary>
+ //List<string> floorNames = new List<string> { };
+ ///// <summary>
+ ///// roomNames
+ ///// </summary>
+ //List<List<string>> roomNames = new List<List<string>> { };
+ ///// <summary>
+ ///// roomNames
+ ///// </summary>
+ //List<List<Common.Room>> rooms = new List<List<Common.Room>> { };
/// <summary>
/// ImagePath
/// </summary>
private string ImagePath="SceneIcon/1.png";
/// <summary>
- /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱
+ /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱
/// </summary>
public int IconPathType = 0;
/// <summary>
@@ -57,6 +57,11 @@
private CommonForm.CompleteButton confirmBtn;
/// <summary>
+ /// backGround
+ /// </summary>
+ private ImageView backGround;
+
+ /// <summary>
/// 鏄惁淇敼
/// </summary>
public bool isModify;
@@ -73,6 +78,14 @@
/// </summary>
public Common.Room modifyRoom;
+ /// <summary>
+ /// OldBackgroundImagePath
+ /// </summary>
+ private string OldBackgroundImagePath;
+ /// <summary>
+ /// OldIconPathType
+ /// </summary>
+ public int OldIconPathType;
#endregion
@@ -127,14 +140,7 @@
}
else if (targetDevice.Type == 2)
{
- if(targetDevice.DelayTime<60)
- {
- devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}";
- }
- else
- {
- devNameText = $"{targetDevice.DelayTime / 60} {Language.StringByID(R.MyInternationalizationString.Minute)} {targetDevice.DelayTime % 60} {Language.StringByID(R.MyInternationalizationString.Second)}";
- }
+ devNameText = CommonFormResouce.GetTimeString(targetDevice.DelayTime);
devNameText += Language.StringByID(R.MyInternationalizationString.Later);
var targetRow = new SceneTargetTimeRow(23);
targetRowLayout.AddChidren(targetRow);
@@ -153,8 +159,7 @@
targetRow.SetNameText(devNameText);
targetRow.SetZoneText(targetDevice.SceneUI.GetZone());
}
-
-
+
var editBtn = new Button()
{
BackgroundColor = ZigbeeColor.Current.GXCEditBackGroundColor,
@@ -181,7 +186,6 @@
//璁惧璇︾粏璁剧疆鐣岄潰
void detailMouseUpEventHandler(object sender, MouseEventArgs e)
{
- //璁惧
if (targetDevice.Type == 0)
{
if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null)
@@ -207,7 +211,6 @@
};
}
- //鏃堕棿闂撮殧
else if (targetDevice.Type == 2)
{
var delayTimeView = new SelectDelayTime();
@@ -226,7 +229,6 @@
RefreshTargetListView();
};
}
- //鍦烘櫙
else if (targetDevice.Type == 1)
{
var sceneView = new SelectScene();
@@ -248,8 +250,17 @@
};
}
}
+ }
-
+ if (sceneTargetDevicesList.Count > 2)
+ {
+ var targetRowLayout = new RowLayout()
+ {
+ Height = Application.GetRealHeight(300),
+ LineColor = ZigbeeColor.Current.GXCBackgroundColor,
+ BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
+ };
+ TargetListScrolView.AddChidren(targetRowLayout);
}
}
}
@@ -273,16 +284,7 @@
/// </summary>
private void Init()
{
- foreach (var floor in Config.Instance.Home.FloorDics)
- {
- floorIds.Add(floor.Key);
- floorNames.Add(floor.Value);
- if(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count>0)
- {
- roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key));
- rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key));
- }
- }
+
}
/// <summary>
@@ -327,16 +329,16 @@
};
bodyFrameLayout.AddChidren(imgFL);
- var backGround = new Button()
+ backGround = new ImageView()
{
- Width = Application.GetRealWidth(930),
- Height = Application.GetRealHeight(464),
+ Width = Application.GetMinRealAverage(930),
+ Height = Application.GetMinRealAverage(464),
Gravity = Gravity.Center,
- Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius),
- //UnSelectedImagePath = ImagePath
- UnSelectedImagePath = "SceneIcon/3.png"
+ Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius),
+ ImagePath = "SceneIcon/3.jpg"
};
imgFL.AddChidren(backGround);
+ backGround.SetViewShadow(true);
var infoFL = new FrameLayout
{
@@ -370,7 +372,7 @@
zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:");
//zoneRow.SetTitle(curRoom.Name);
infoFL.AddChidren(zoneRow);
- zoneRow.HideLine(false);
+ zoneRow.HideLine(true);
var targetFL = new FrameLayout()
{
@@ -423,12 +425,10 @@
};
addTargetFL.AddChidren(targetLine);
- //娣诲姞鐩爣鍚庣殑灞曠ず鍒楄〃
TargetListScrolView = new VerticalScrolViewLayout()
{
Y = Application.GetRealHeight(49+127),
Height = Application.GetRealHeight(730-127-49),
- //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
targetFL.AddChidren(TargetListScrolView);
@@ -437,10 +437,22 @@
if(isModify)
{
- backGround.UnSelectedImagePath = modifySceneUI.IconPath;
+ IconPathType = modifySceneUI.IconPathType;
+ OldIconPathType = modifySceneUI.IconPathType;
+ if (IconPathType != 0)
+ {
+ OldBackgroundImagePath = modifySceneUI.IconPath;
+ }
+ if (modifySceneUI.IconPathType==0)
+ {
+ backGround.ImagePath = modifySceneUI.IconPath;
+ }
+ else
+ {
+ backGround.ImagePath = System.IO.Path.Combine(Config.Instance.FullPath, modifySceneUI.IconPath);
+ }
nameRow.SetTitle(modifySceneUI.Name);
zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}");
- IconPathType = modifySceneUI.IconPathType;
curRoom = modifyRoom;
sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList);
}
@@ -449,60 +461,228 @@
#region event
- //閫夋嫨鑳屾櫙鍥�
EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) =>
{
- if (curRoom == null)
- {
- RoomCommon.ShowTipNoRoom();
- return;
- }
- if (curRoom.IsSharedRoom)
+ if (curRoom != null && curRoom.IsSharedRoom)
{
RoomCommon.ShowTipRoomIsShared();
return;
}
- var localPic = new CategorySceneSelectImgByLocal();
- Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
- Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
- localPic.Show();
- localPic.action = (imgPath) =>
+ int selectRow_Height = 150;
+ int selectRow_Width = 1034;
+ var selectFL = new FrameLayout()
{
- IconPathType = 0;
- backGround.UnSelectedImagePath = imgPath;
+ BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
+ };
+ AddChidren(selectFL);
+
+ var itemFL = new FrameLayout()
+ {
+ Y = Application.GetRealHeight(1276),
+ Height = Application.GetRealHeight(450),
+ Width = Application.GetRealWidth(selectRow_Width),
+ Gravity = Gravity.CenterHorizontal,
+ Radius = (uint)Application.GetRealHeight(17),
+ BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
+ };
+ selectFL.AddChidren(itemFL);
+ itemFL.Animate = Animate.DownToUp;
+
+ var selectLocalPicture = new Button()
+ {
+ Height = Application.GetRealHeight(selectRow_Height) - 1,
+ TextID = R.MyInternationalizationString.LocalPicture,
+ TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+ };
+ itemFL.AddChidren(selectLocalPicture);
+ var selectLocalLine = new Button()
+ {
+ Y = selectLocalPicture.Bottom,
+ Height = 1,
+ BackgroundColor = ZigbeeColor.Current.GXCLineColor
+ };
+ itemFL.AddChidren(selectLocalLine);
+
+ var selectPhotographBtn = new Button()
+ {
+ Y = selectLocalLine.Bottom,
+ Height = Application.GetRealHeight(selectRow_Height) - 1,
+ TextID = R.MyInternationalizationString.Photograph,
+ TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+ };
+ itemFL.AddChidren(selectPhotographBtn);
+ var selectPhotographLine = new Button()
+ {
+ Y = selectPhotographBtn.Bottom,
+ Height = 1,
+ BackgroundColor = ZigbeeColor.Current.GXCLineColor,
+ };
+ itemFL.AddChidren(selectPhotographLine);
+
+ var selectAblumsBtn = new Button()
+ {
+ Y = selectPhotographLine.Bottom,
+ Height = Application.GetRealHeight(selectRow_Height) - 1,
+ TextID = R.MyInternationalizationString.MyAblums,
+ TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+ };
+ itemFL.AddChidren(selectAblumsBtn);
+
+ var cancelBtn = new Button()
+ {
+ Y = Application.GetRealHeight(1742),
+ Height = Application.GetRealHeight(selectRow_Height),
+ Width = Application.GetRealWidth(selectRow_Width),
+ Gravity = Gravity.CenterHorizontal,
+ TextID = R.MyInternationalizationString.Cancel,
+ TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
+ BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ Radius = (uint)Application.GetRealHeight(17)
+ };
+ selectFL.AddChidren(cancelBtn);
+
+ selectLocalPicture.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ var localPic = new CategorySceneSelectImgByLocal();
+ Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
+ Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+ localPic.Show();
+ localPic.action = (imgPath) =>
+ {
+ IconPathType = 0;
+ backGround.ImageBytes = null;
+ backGround.ImagePath = imgPath;
+ };
+ };
+ selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"SceneIcon_{tradeTime}";
+ //閫氳繃鐩告満鎷嶇収瑁佸壀
+ CropImage.TakePicture((imagePath) =>
+ {
+ if (isModify)
+ {
+ if (IconPathType != 0)
+ {
+ Global.DeleteFilebyHomeId(backGround.ImagePath);
+ }
+ }
+
+ IconPathType = 1;
+ backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+ backGround.ImagePath = imagePath;
+ System.IO.File.Delete(imagePath);
+
+ }, fileName, 2, 1);
};
+ selectAblumsBtn.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"SceneIcon_{tradeTime}";
+ //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
+ CropImage.SelectPicture((imagePath) =>
+ {
+ if (isModify)
+ {
+ if (IconPathType != 0)
+ {
+ Global.DeleteFilebyHomeId(backGround.ImagePath);
+ }
+ }
+
+ IconPathType = 2;
+ backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+ backGround.ImagePath = imagePath;
+ System.IO.File.Delete(imagePath);
+
+ }, fileName, 2,1);
+ };
+
+ cancelBtn.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ };
+ selectFL.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ };
};
backGround.MouseUpEventHandler += backGroundIMGHander;
//鍖哄煙
EventHandler<MouseEventArgs> zoneHander = (sender, e) =>
{
- PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) =>
+ List<string> floorIds = new List<string> { };
+ List<string> floorNames = new List<string> { };
+ List<List<string>> roomNames = new List<List<string>> { };
+ List<List<Common.Room>> rooms = new List<List<Common.Room>> { };
+ List<Common.Room> rs = new List<Common.Room> { };
+ List<string> rNames = new List<string> { };
+ if (Config.Instance.Home.FloorDics.Count > 0)
{
- curRoom = rooms[index1][index2];
- zoneRow.NameText.Text = $"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}";
- }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
+ foreach (var floor in Config.Instance.Home.FloorDics)
+ {
+ floorIds.Add(floor.Key);
+ floorNames.Add(floor.Value);
+ if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0)
+ {
+ roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key));
+ rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key));
+ }
+ }
+ PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) =>
+ {
+ curRoom = rooms[index1][index2];
+ zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}");
+ }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongZone),
+ Language.StringByID(R.MyInternationalizationString.Confrim),
+ Language.StringByID(R.MyInternationalizationString.Cancel));
+ }
+ else
+ {
+ for (int i = 0; i < Common.Room.Lists.Count; i++)
+ {
+ var r = Common.Room.Lists[i];
+ if (r.IsLove)
+ {
+ continue;
+ }
+ rs.Add(r);
+ rNames.Add(r.Name);
+ }
+ PickerView.Show(rNames, (index1) =>
+ {
+ curRoom = rs[index1];
+ zoneRow.SetTitle(rs[index1].Name);
+ }, 0, Language.StringByID(R.MyInternationalizationString.BelongZone),
+ Language.StringByID(R.MyInternationalizationString.Confrim),
+ Language.StringByID(R.MyInternationalizationString.Cancel));
+ }
};
- zoneRow.NextBtn.MouseUpEventHandler += zoneHander;
- zoneRow.TipBtn.MouseUpEventHandler += zoneHander;
- zoneRow.NameText.MouseUpEventHandler += zoneHander;
- zoneRow.MouseUpEventHandler += zoneHander;
+ zoneRow.ClickBtn.MouseUpEventHandler += zoneHander;
//鎵ц鐩爣-娣诲姞鎵ц璁惧
EventHandler<MouseEventArgs> targetAddHander = (sender, e) =>
{
- if (curRoom == null)
+ //if (curRoom == null)
+ //{
+ // RoomCommon.ShowTipNoRoom();
+ // return;
+ //}
+ if(curRoom != null)
{
- RoomCommon.ShowTipNoRoom();
- return;
- }
- if (curRoom.IsSharedRoom)
- {
- RoomCommon.ShowTipRoomIsShared();
- return;
+ if (curRoom.IsSharedRoom)
+ {
+ RoomCommon.ShowTipRoomIsShared();
+ return;
+ }
}
int selectRow_Height = 150;
@@ -523,6 +703,7 @@
BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
};
selectFL.AddChidren(itemFL);
+ itemFL.Animate = Animate.DownToUp;
var selectedFunctionBtn = new Button()
{
@@ -607,7 +788,7 @@
sceneTargetDevicesList.Add(selectedScene);
RefreshTargetListView();
};
-
+
};
//娣诲姞鏃堕棿闂撮殧
selectedTimerBtn.MouseUpEventHandler += (send, ee) =>
@@ -666,40 +847,46 @@
{
try
{
- //鏀瑰悕
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"SceneIcon_{tradeTime}";
if (modifySceneUI.Name != nameRow.NameText.Text.Trim())
{
if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null)
{
- Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
+ CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist));
return;
}
- //淇敼鍚嶅瓧
var r = await ZigBee.Device.Scene.RenameSceneAsync(modifySceneUI.Id, nameRow.NameText.Text.Trim());
var reName = r.sceneRenameResponseData.Result;
if (reName == 0)
{
- //澶辫触
return;
}
else if (reName == 1)
{
- //鎴愬姛
modifySceneUI.Name = nameRow.NameText.Text.Trim();
}
else if (reName == 2)
{
- //娌℃湁璇ュ満鏅�
return;
}
}
- //鍥剧墖
- if(IconPathType==1 || IconPathType ==2)
+ if (OldIconPathType != 0)
{
-
+ Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath));
}
-
+ if (IconPathType == 1 || IconPathType == 2)
+ {
+ Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
+ modifySceneUI.IconPath = fileName;
+ }
+ else
+ {
+ modifySceneUI.IconPath = backGround.ImagePath;
+ }
+ modifySceneUI.IconPathType = IconPathType;
+
CommonPage.Loading.Start();
var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>();
for (int i = 0; i < sceneTargetDevicesList.Count; i++)
@@ -808,12 +995,10 @@
}
else if (result == 0)
{
- //澶辫触
Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
}
else if (result == -1)
{
- //宸插瓨鍦�
Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
}
}
@@ -843,6 +1028,18 @@
{
try
{
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"SceneIcon_{tradeTime}.png";
+ string imgPath;
+ if (IconPathType == 1 || IconPathType == 2)
+ {
+ Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
+ imgPath = fileName;
+ }
+ else
+ {
+ imgPath = backGround.ImagePath;
+ }
if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null)
{
Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
@@ -897,19 +1094,17 @@
}
}
- var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList);
+ var result = await curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList);
if (result == 1)
{
RemoveFromParent();
}
else if (result == 0)
{
- //澶辫触
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail);
}
else if (result == -1)
{
- //宸插瓨鍦�
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
}
}
@@ -925,13 +1120,10 @@
}
}
-
};
#endregion
}
#endregion
-
-
}
}
--
Gitblit v1.8.0