From 74a9ba8e9a2df9c39f9c2eb212a5ac889a055cd4 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 03 十二月 2019 10:47:51 +0800
Subject: [PATCH] 优化UI细节(请合并最新代码)
---
ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 319 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 252 insertions(+), 67 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
index 8d287f2..9763cd1 100755
--- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
@@ -15,22 +15,22 @@
/// 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>
@@ -55,6 +55,11 @@
/// The confirm button.
/// </summary>
private CommonForm.CompleteButton confirmBtn;
+
+ /// <summary>
+ /// backGround
+ /// </summary>
+ private Button backGround;
/// <summary>
/// 鏄惁淇敼
@@ -127,14 +132,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,7 +151,6 @@
targetRow.SetNameText(devNameText);
targetRow.SetZoneText(targetDevice.SceneUI.GetZone());
}
-
var editBtn = new Button()
{
@@ -273,16 +270,16 @@
/// </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));
- }
- }
+ //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 +324,17 @@
};
bodyFrameLayout.AddChidren(imgFL);
- var backGround = new Button()
+ backGround = new Button()
{
- 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),
+ Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius),
//UnSelectedImagePath = ImagePath
- UnSelectedImagePath = "SceneIcon/3.png"
+ UnSelectedImagePath = "SceneIcon/3.jpg"
};
imgFL.AddChidren(backGround);
+ backGround.SetViewShadow(true);
var infoFL = new FrameLayout
{
@@ -370,7 +368,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()
{
@@ -452,43 +450,209 @@
//閫夋嫨鑳屾櫙鍥�
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.UnSelectedImagePath = imgPath;
+ };
+ };
+ selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
+ {
+ selectFL.RemoveFromParent();
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"Scene_{tradeTime}";
+ //閫氳繃鐩告満鎷嶇収瑁佸壀
+ CropImage.TakePicture((imagePath) =>
+ {
+ if (isModify)
+ {
+ if (IconPathType != 0)
+ {
+ Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
+ }
+ }
+
+ IconPathType = 1;
+ backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+ backGround.UnSelectedImagePath = 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 = $"Scene_{tradeTime}";
+ //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
+ CropImage.SelectPicture((imagePath) =>
+ {
+ if (isModify)
+ {
+ if (IconPathType != 0)
+ {
+ Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
+ }
+ }
+
+ IconPathType = 2;
+ backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+ backGround.UnSelectedImagePath = 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.BelongFloor),
+ 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.BelongFloor),
+ 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) =>
@@ -523,6 +687,7 @@
BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
};
selectFL.AddChidren(itemFL);
+ itemFL.Animate = Animate.DownToUp;
var selectedFunctionBtn = new Button()
{
@@ -666,6 +831,8 @@
{
try
{
+ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ var fileName = $"Scene_{tradeTime}";
//鏀瑰悕
if (modifySceneUI.Name != nameRow.NameText.Text.Trim())
{
@@ -697,9 +864,15 @@
//鍥剧墖
if(IconPathType==1 || IconPathType ==2)
{
-
+ Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
+ modifySceneUI.IconPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
}
-
+ else
+ {
+ modifySceneUI.IconPath = backGround.UnSelectedImagePath;
+ }
+ modifySceneUI.IconPathType = IconPathType;
+
CommonPage.Loading.Start();
var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>();
for (int i = 0; i < sceneTargetDevicesList.Count; i++)
@@ -797,6 +970,7 @@
{
if (modifyRoom != curRoom)
{
+
modifyRoom.SceneUIList.Remove(modifySceneUI);
modifyRoom.SceneUIFilePathList.Remove(modifySceneUI.FileName);
curRoom.SceneUIList.Add(modifySceneUI);
@@ -843,6 +1017,19 @@
{
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 = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
+ }
+ else
+ {
+ imgPath = backGround.UnSelectedImagePath;
+ }
if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null)
{
Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
@@ -897,7 +1084,7 @@
}
}
- 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();
@@ -931,7 +1118,5 @@
}
#endregion
-
-
}
}
--
Gitblit v1.8.0