ZigbeeApp/GateWay.Droid/Application.cs
@@ -73,6 +73,7 @@ } }; BaseActivity.OnCreateActoin += (activity, application) => { Shared.Application.FontSize = 12; AppCenter.Start("4802834a-e7e9-4dd8-93f1-c2f88f0bd464", typeof(Analytics), typeof(Crashes)); #if Release //保存获取的极光服务器上的注册ID到本地文件 var registrationId = JPushInterface.GetRegistrationID(activity); System.Console.WriteLine("registrationId-极光id=" + registrationId); if (!string.IsNullOrEmpty(registrationId)) { Shared.Common.Config.Instance.RegistrationID = registrationId; Shared.Common.Config.Instance.Save(); } #endif }; BaseActivity.RefreshUIAction += (activity) => { Shared.Language.CurrentLanguage = "Chinese"; Shared.Common.CommonPage.Instance.Show(); }; BaseActivity.OnResumeAction += (activity) => { }; BaseActivity.NetworkStateChanged += (v) => { //网络状态变化处理事件 ZigbeeApp/GateWay.Droid/Assets/Language.ini
@@ -556,7 +556,7 @@ 11001=场景 11002=自动化 11010=没有功能 \n 请在个人中心中--设备管理处添加 11010=没有功能 {\r\n} 请在个人中心中--设备管理处添加 11011=编辑 11012=设置功能 11013=信息编辑 @@ -570,7 +570,7 @@ 11021=保存 11022=提示 11023=取消 11024=没有场景 \n 请点击右上角添加 11024=没有场景 {\r\n} 请点击右上角添加 11025=设置 11026=定时 11027=确定删除吗? @@ -587,9 +587,18 @@ 13102=选择住宅 13103=新用户登录,请先绑定网关 13104=添加智能网关 13105=编辑房间 13106=房间名称 13107=所属楼层 13108=温度 13109=湿度 13110=当前 13111=开 13112=关 13113=不开启 13114=秒 13115=分钟 13116=小时 ZigbeeApp/Shared/Common/Room.cs
@@ -36,14 +36,24 @@ /// 楼层Id /// 新增时使用Guid /// </summary> public string FloorId = string.Empty; public string FloorId = "Floor1"; /// <summary> /// 楼层名称 /// </summary> public string FloorName { get { return GetFloorNameById(FloorId); } } /// <summary> /// 房间名 /// </summary> public string Name = string.Empty; /// <summary> /// 房间的时候背景图 /// 房间背景图 /// </summary> public string BackgroundImage = string.Empty; @@ -73,6 +83,11 @@ public readonly List<string> DeviceUIFilePathList = new List<string>(); /// <summary> /// 喜爱房间id /// </summary> public const string LoveRoomId= "Favorite"; /// <summary> /// 是否是默认喜爱房间 /// </summary> /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value> @@ -81,7 +96,7 @@ { get { return Id == "Favorite"; return Id == LoveRoomId; } } @@ -110,8 +125,7 @@ { return new List<string> { }; } var loveRoom = Lists[0]; return loveRoom.DeviceUIFilePathList; return GetLoveRoom().DeviceUIFilePathList; } } @@ -204,7 +218,7 @@ if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false) { //默认添加喜爱的房间--禁止修改房间名 var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = "Favorite" }; var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = LoveRoomId }; love.Save(true); //添加到house 房间路径列表 var currentHome = Config.Instance.Home; @@ -321,6 +335,15 @@ #endregion #region ◆ 获取房间________________________ /// <summary> /// 获取喜爱房间 /// </summary> /// <returns></returns> public static Room GetLoveRoom() { return CurrentRoom.GetRoomById(LoveRoomId); } /// <summary> /// 通过路径获取房间 @@ -897,6 +920,28 @@ #endregion #region ◆ 设备是否收藏______________________ /// <summary> /// 是否是收藏设备 /// </summary> /// <param name="room"></param> /// <param name="filePath"></param> /// <returns></returns> public bool IsCollectInRoom(Room room,string filePath) { if(room.IsLove) { return true; } if (GetLoveRoom().DeviceUIFilePathList.Find((obj) => obj == filePath) == null) { return false; } return true; } #endregion #region ◆ 修改场景________________________ /// <summary> @@ -1121,7 +1166,7 @@ var dicRoom = new Dictionary<string, Common.Room>(); foreach (var room in Common.Room.Lists) { if (room.FloorId != i_floorKeys) if (room.FloorId != i_floorKeys || room.IsLove == true) { //不是同一个楼层 continue; @@ -1245,5 +1290,33 @@ } #endregion #region ◆ 楼层___________________________ /// <summary> /// 获取楼层名称 /// </summary> /// <param name="floorId"></param> /// <returns></returns> public string GetFloorNameById(string floorId) { if (Config.Instance.Home.FloorDics.Count == 0) { return null; } foreach (var floor in Config.Instance.Home.FloorDics) { if (floorId == floor.Key) { return floor.Value; } } return null; } #endregion } } ZigbeeApp/Shared/Common/SceneUI.cs
@@ -61,6 +61,10 @@ /// 标识当前场景是否是分享的场景 /// </summary> public bool IsSharedScene = false; /// <summary> /// 是否收藏 /// </summary> public bool IsCollected = false; /// <summary> /// 延时执行时间--整个场景延时(不是延时场景里面的执行目标) @@ -77,7 +81,11 @@ #endregion #region ◆ 通过场景id获取场景路径_____________ /// <summary> /// GetSceneFilePathBySceneId /// </summary> /// <param name="sceneId"></param> /// <returns></returns> public static string GetSceneFilePathBySceneId(int sceneId) { return $"Scene_{sceneId}.json"; @@ -85,6 +93,21 @@ #endregion #region ◆ 收藏____________________________ /// <summary> /// collect /// </summary> /// <param name="collected"></param> /// <param name="autoBackup"></param> public void Collect(bool collected, bool autoBackup = true) { IsCollected = collected; Save(autoBackup); } #endregion #region ◆ 保存____________________________ /// <summary> ZigbeeApp/Shared/Common/ZigbeeColor.cs
@@ -135,10 +135,22 @@ /// 字体浅色 0xFFCBCACA /// </summary> public uint GXCTextGrayColor3 = 0xFFCBCACA; /// <summary> /// 字体浅色 0xFF666666 /// </summary> public uint GXCTextGrayColor4 = 0xFF666666; /// <summary> /// 字体选中颜色 0xFFFC744B /// </summary> public uint GXCTextSelectedColor = 0xFFFC744B; /// <summary> /// 字体选中颜色 0xFFFC744B /// 字体选中颜色 0xFFFB744A /// </summary> public uint GXCTextSelectedColor = 0xFFFC744B; public uint GXCTextSelectedColor2 = 0xFFFB744A; /// <summary> /// 字体选中颜色 0xFFFFB400 /// </summary> public uint GXCTextSelectedColor3 = 0xFFFFB400; /// <summary> /// 底部未选中颜色 0xFF8E8E93 /// </summary> @@ -159,6 +171,14 @@ /// 黑色背景 0xFF333333 /// </summary> public uint GXCBlackBackgroundColor2 = 0xFF333333; /// <summary> /// functionView 0x1AFC744B /// </summary> public uint GXCForFunctionUnSelectedBackgroundColor = 0x1AFC744B; /// <summary> /// functionView 0xFFFC744B /// </summary> public uint GXCForFunctionBackgroundColor = 0xFFFC744B; /// <summary> /// 0xFFFEF1ED /// </summary> @@ -234,7 +254,7 @@ /// <summary> /// topview color 0xD1F8F8F8 /// </summary> public uint GXCTopViewBackgroundColor = 0xD1F8F8F8; public uint GXCTopViewBackgroundColor = 0xFFF9F9F9; /// <summary> /// title color 0xFF030303 /// </summary> @@ -251,7 +271,14 @@ /// 底部线条颜色 0xFFBABABA /// </summary> public uint GXCBottomLineColor = 0xFFBABABA; /// <summary> /// GXCWaveSeekBarUnSelectedColor 0xFFEBEBED /// </summary> public uint GXCWaveSeekBarUnSelectedColor = 0xFFEBEBED; /// <summary> /// GXCWaveSeekBarColor 0xFFFE4F35 /// </summary> public uint GXCWaveSeekBarColor = 0xFFFE4F35; ZigbeeApp/Shared/Phone/Device/AC/ACControlBase.cs
@@ -409,8 +409,8 @@ Application.RunOnMainThread(() => { string msg = Language.StringByID(R.MyInternationalizationString.TheACIsClose); //var tip = new Phone.UserCenter.TipViewControl(msg, 1000, 1); //tip.ShowView(); var tip = new Phone.UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Tip, msg); tip.Show(); }); } ZigbeeApp/Shared/Phone/Device/Account/PhoneEmailForm.cs
@@ -34,17 +34,28 @@ PhoneEmailFL = new FrameLayout() { Y = Application.GetRealHeight(y), Height = Application.GetRealHeight(height), Width = Application.GetRealWidth(width), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Radius = (uint)Application.GetRealHeight(height / 2), Width = Application.GetMinRealAverage(905), Height = Application.GetMinRealAverage(170), //BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor, //Radius = (uint)Application.GetRealHeight(height / 2), Gravity = Gravity.CenterHorizontal }; frameLayout.AddChidren(PhoneEmailFL); var bg = new Button { Width = Application.GetMinRealAverage(905), Height = Application.GetMinRealAverage(170), UnSelectedImagePath = "Account/PhoneEmail_White.png", Gravity = Gravity.CenterHorizontal }; PhoneEmailFL.AddChidren(bg); SelectedPhone = new Button() { Width = Application.GetRealWidth(width / 2 + 20), X=Application.GetRealWidth(10), Width = Application.GetMinRealAverage(905 / 2 + 20), Height=Application.GetMinRealAverage(height), SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor, TextID = R.MyInternationalizationString.PhoneNum, TextColor = ZigbeeColor.Current.GXCTextColor, @@ -57,8 +68,9 @@ SelectedEmail = new Button() { X = Application.GetRealWidth(width / 2 - 20), Width = Application.GetRealWidth(width / 2 + 20), X = Application.GetMinRealAverage(905 / 2 - 20), Width = Application.GetMinRealAverage(905 / 2 + 20), Height = Application.GetMinRealAverage(height), SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor, TextID = R.MyInternationalizationString.Email, TextColor = ZigbeeColor.Current.GXCTextColor, ZigbeeApp/Shared/Phone/Device/CommonForm/CommonEnum.cs
New file @@ -0,0 +1,9 @@ using System; namespace Shared.Phone.Device.CommonForm { public enum Direction { Left = 1, Right = 2 } } ZigbeeApp/Shared/Phone/Device/CommonForm/CommonFormResouce.cs
@@ -6,6 +6,11 @@ public class CommonFormResouce { /// <summary> /// AppRealWidth /// </summary> public const int AppRealWidth = 1080; /// <summary> /// 字体12 /// </summary> public const int loginTextSize = 12; @@ -164,11 +169,48 @@ return null; } } /// <summary> /// GetSwitchStatu /// </summary> /// <param name="statu"></param> /// <returns></returns> public static string GetSwitchStatu(bool statu) { if (statu) { return $"{Language.StringByID(R.MyInternationalizationString.Current)} : {Language.StringByID(R.MyInternationalizationString.Open)}"; } else { return $"{Language.StringByID(R.MyInternationalizationString.Current)} : {Language.StringByID(R.MyInternationalizationString.Close)}"; } } /// <summary> /// 获取场景延时字符串 /// </summary> /// <param name="second"></param> /// <returns></returns> public static string GetTimeString(int second) { string tStr; if (second / 3600 > 0) { tStr = $"{second / 3600}{Language.StringByID(R.MyInternationalizationString.Hour)}"; } else if (second / 60 > 0) { tStr = $"{second / 60}{Language.StringByID(R.MyInternationalizationString.Minute)}"; } else { tStr = $"{second}{Language.StringByID(R.MyInternationalizationString.Second)}"; } return tStr; } } public enum Direction { Left=1, Right=2 } } ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs
@@ -161,7 +161,7 @@ var nameRow = new DeviceInfoEditRow(170); nameRow.Init(); nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : "); nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName); nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceEpointName); infoFL.AddChidren(nameRow); var zoneRow = new DeviceInfoRow(308); ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceInfoWithZoneRow.cs
New file @@ -0,0 +1,123 @@ using System; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class DeviceInfoWithZoneRow : FrameLayout { /// <summary> /// 图片 /// </summary> public Button IconButton; /// <summary> /// NameBtn /// </summary> public Button NameButton; /// <summary> /// ZoneButton /// </summary> public Button ZoneButton; /// <summary> /// NextBtn /// </summary> public Button NextBtn; /// <summary> /// DeviceInfoWithZoneRow /// </summary> /// <param name="y"></param> public DeviceInfoWithZoneRow(int y) { X = Application.GetRealWidth(0); Y = Application.GetRealHeight(y); Width = Application.GetRealWidth(1080); Height = Application.GetRealHeight(127); } /// <summary> /// Init /// </summary> public void Init() { IconButton = new Button() { X = Application.GetRealWidth(CommonFormResouce.X_Left), Height = Application.GetMinRealAverage(80), Width = Application.GetMinRealAverage(80), Gravity = Gravity.CenterVertical, }; AddChidren(IconButton); NameButton = new Button { X = Application.GetRealWidth(176), Y=Application.GetRealHeight(12), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextAlignment = TextAlignment.CenterLeft }; AddChidren(NameButton); ZoneButton = new Button { X = Application.GetRealWidth(176), Y = Application.GetRealHeight(72), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(50), TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor2, TextAlignment = TextAlignment.CenterLeft }; AddChidren(ZoneButton); NextBtn = new Button { X = Application.GetRealWidth(910), Width = Application.GetMinRealAverage(100), Height = Application.GetMinRealAverage(100), Gravity = Gravity.CenterVertical, SelectedImagePath = "Item/Next.png", UnSelectedImagePath = "Item/NextSelected.png" }; AddChidren(NextBtn); var line = new Button() { X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = Height - 2, Width = Application.GetRealWidth(965), Height = 2, BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2, }; AddChidren(line); } /// <summary> /// SetName /// </summary> /// <param name="title"></param> public void SetName(string title) { ZoneButton.Text = title; } /// <summary> /// SetZone /// </summary> /// <param name="title"></param> public void SetZone(string title) { NameButton.Text = title; } /// <summary> /// SetIcon /// </summary> /// <param name="imagePath"></param> public void SetIcon(string imagePath) { IconButton.UnSelectedImagePath = imagePath; } } } ZigbeeApp/Shared/Phone/Device/CommonForm/FunctionMainView.cs
New file @@ -0,0 +1,223 @@ using System; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class FunctionMainView : FrameLayout { /// <summary> /// name /// </summary> public Button NameButton; /// <summary> /// collect /// </summary> public Button CollectButton; /// <summary> /// Image /// </summary> public Button IconButton; /// <summary> /// ImageBG /// </summary> public Button ImageBG; /// <summary> /// statu /// </summary> public Button StatuButton; /// <summary> /// switch /// </summary> public Button SwitchButton; /// <summary> /// CardBG /// </summary> public Button CardBG; /// <summary> /// v_Selected /// </summary> private bool v_Selected; /// <summary> /// IsSelected /// </summary> public bool IsSelected { set { try { v_Selected = value; SetStatu(v_Selected); } catch { }; } get { return v_Selected; } } public FunctionMainView(int x,int y) { X = Application.GetRealWidth(x); Y = Application.GetRealHeight(y); Width = Application.GetMinRealAverage(487); Height = Application.GetMinRealAverage(348); } /// <summary> /// init /// </summary> public void Init() { //var bg = new Button //{ // Width = Application.GetMinReal(487), // Height = Application.GetMinReal(348), //UnSelectedImagePath = "Item/FunctionViewBG.png" //}; //AddChidren(bg); CardBG = new Button { Width = Application.GetMinRealAverage(487), Height = Application.GetMinRealAverage(348), UnSelectedImagePath = "Item/FunctionCardView.png", SelectedImagePath = "Item/FunctionCardViewSelected.png", Gravity=Gravity.CenterHorizontal }; AddChidren(CardBG); NameButton = new Button() { X=Application.GetMinRealAverage(40), Y = Application.GetMinRealAverage(17), Width = Application.GetMinRealAverage(320), Height = Application.GetMinRealAverage(63), TextColor = ZigbeeColor.Current.GXCTextGrayColor, SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextAlignment=TextAlignment.CenterLeft }; AddChidren(NameButton); CollectButton = new Button { X = Application.GetMinRealAverage(366), Y = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(107), Height = Application.GetMinRealAverage(107), UnSelectedImagePath="Item/Collection1.png", SelectedImagePath="Item/CollectionSelected1.png" }; AddChidren(CollectButton); var imgFL = new FrameLayout { X = Application.GetMinRealAverage(40), Y = Application.GetMinRealAverage(101), Width = Application.GetMinRealAverage(124), Height = Application.GetMinRealAverage(124) }; AddChidren(imgFL); ImageBG = new Button() { //X=Application.GetMinRealAverage(40), //Y = Application.GetMinRealAverage(101), Width = Application.GetMinRealAverage(124), Height = Application.GetMinRealAverage(124), Gravity=Gravity.Center, BackgroundColor = ZigbeeColor.Current.GXCForFunctionUnSelectedBackgroundColor, SelectedBackgroundColor = ZigbeeColor.Current.GXCForFunctionBackgroundColor, Radius=(uint)Application.GetMinRealAverage(124/2) }; imgFL.AddChidren(ImageBG); IconButton = new Button() { //X=Application.GetMinRealAverage(63), //Y = Application.GetMinRealAverage(121), Width = Application.GetMinRealAverage(84), Height = Application.GetMinRealAverage(84), Gravity=Gravity.Center }; imgFL.AddChidren(IconButton); StatuButton = new Button() { X=Application.GetMinRealAverage(46), Y = Application.GetMinRealAverage(239), Width = Application.GetMinRealAverage(279), Height = Application.GetMinRealAverage(60), TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextSelectedColor, TextAlignment=TextAlignment.CenterLeft }; AddChidren(StatuButton); SwitchButton = new Button { X = Application.GetMinRealAverage(325), Y = Application.GetMinRealAverage(202), Width = Application.GetMinRealAverage(109), Height = Application.GetMinRealAverage(104), UnSelectedImagePath = "Item/Switch1.png", SelectedImagePath = "Item/SwitchSelected1.png" }; AddChidren(SwitchButton); } /// <summary> /// SetStatu /// </summary> /// <param name="statu"></param> public void SetStatu(bool statu) { NameButton.IsSelected = IconButton.IsSelected = SwitchButton.IsSelected = StatuButton.IsSelected = CardBG.IsSelected = statu; } /// <summary> /// SetDeviceImage /// </summary> /// <param name="img"></param> /// <param name="seletedImg"></param> public void SetDeviceImage(string img,string seletedImg) { IconButton.UnSelectedImagePath = img; IconButton.SelectedImagePath = seletedImg; } /// <summary> /// SetDeviceName /// </summary> /// <param name="name"></param> public void SetDeviceName(string name) { NameButton.Text = name; } /// <summary> /// SetStatu /// </summary> /// <param name="statu"></param> public void SetStatuText(string statu) { StatuButton.Text = statu; } /// <summary> /// SetCollect /// </summary> /// <param name="collect"></param> public void SetCollect(bool collect) { CollectButton.IsSelected = collect; } } } ZigbeeApp/Shared/Phone/Device/CommonForm/RoomMainView.cs
New file @@ -0,0 +1,97 @@ using System; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class RoomMainView : FrameLayout { /// <summary> /// SceneIcon /// </summary> public Button Icon; /// <summary> /// RoomNameButton /// </summary> public Button RoomNameButton; /// <summary> /// CardBG /// </summary> private Button CardBG; /// <summary> /// RoomMainView /// </summary> /// <param name="x"></param> /// <param name="y"></param> public RoomMainView(int x, int y) { X = Application.GetRealWidth(x); Y = Application.GetRealHeight(y); Width = Application.GetMinRealAverage(487); Height = Application.GetMinRealAverage(348); } /// <summary> /// init /// </summary> public void Init() { CardBG = new Button { Width = Application.GetMinRealAverage(495), Height = Application.GetMinRealAverage(354), UnSelectedImagePath = "Room/RoomCardView.png", Gravity = Gravity.CenterHorizontal }; AddChidren(CardBG); Icon = new Button { X = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(467), Height = Application.GetMinRealAverage(311), Gravity = Gravity.CenterHorizontal, Radius=(uint)Application.GetMinRealAverage(29) }; AddChidren(Icon); var nameBG = new Button { X=Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(141), Height = Application.GetMinRealAverage(84), UnSelectedImagePath = "Room/RoomCardView_Name.png", }; AddChidren(nameBG); RoomNameButton = new Button() { X = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(141), Height = Application.GetMinRealAverage(84), TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; AddChidren(RoomNameButton); } /// <summary> /// SetRoomName /// </summary> /// <param name="name"></param> public void SetRoomName(string name) { RoomNameButton.Text = name; } /// <summary> /// SetRoomIcon /// </summary> /// <param name="imagePath"></param> public void SetRoomIcon(string imagePath) { Icon.UnSelectedImagePath = imagePath; } } } ZigbeeApp/Shared/Phone/Device/CommonForm/SceneMainView.cs
New file @@ -0,0 +1,183 @@ using System; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class SceneMainView : FrameLayout { /// <summary> /// name /// </summary> public Button TimeButton; /// <summary> /// collect /// </summary> public Button CollectButton; /// <summary> /// SceneIcon /// </summary> public Button SceneIcon; /// <summary> /// statu /// </summary> public Button SceneNameButton; /// <summary> /// CardBG /// </summary> private Button CardBG; /// <summary> /// v_Selected /// </summary> private bool v_Selected; /// <summary> /// IsSelected /// </summary> public bool IsSelected { set { try { v_Selected = value; //SetStatu(v_Selected); } catch { }; } get { return v_Selected; } } public SceneMainView(int x, int y) { X = Application.GetRealWidth(x); Y = Application.GetRealHeight(y); Width = Application.GetMinRealAverage(487); Height = Application.GetMinRealAverage(348); } /// <summary> /// init /// </summary> public void Init() { CardBG = new Button { Width = Application.GetMinRealAverage(487), Height = Application.GetMinRealAverage(348), UnSelectedImagePath = "Item/FunctionCardView.png", Gravity = Gravity.CenterHorizontal }; AddChidren(CardBG); SceneIcon = new Button { X = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(458), Height = Application.GetRealHeight(305), Gravity = Gravity.CenterHorizontal }; AddChidren(SceneIcon); var sceneBG = new Button { Width = Application.GetMinRealAverage(487), Height = Application.GetMinRealAverage(348), UnSelectedImagePath = "Item/SceneCard.png", Gravity = Gravity.CenterHorizontal }; AddChidren(sceneBG); TimeButton = new Button() { X = Application.GetMinRealAverage(40), Y = Application.GetMinRealAverage(17), Width = Application.GetMinRealAverage(320), Height = Application.GetMinRealAverage(63), TextColor = ZigbeeColor.Current.GXCTextSelectedColor3, TextAlignment = TextAlignment.CenterLeft, Text="58s" }; AddChidren(TimeButton); CollectButton = new Button { X = Application.GetMinRealAverage(366), Y = Application.GetMinRealAverage(14), Width = Application.GetMinRealAverage(107), Height = Application.GetMinRealAverage(107), UnSelectedImagePath = "Item/Collection1.png", SelectedImagePath = "Item/CollectionSelected1.png" }; AddChidren(CollectButton); SceneNameButton = new Button() { X = Application.GetMinRealAverage(46), Y = Application.GetMinRealAverage(239), Width = Application.GetMinRealAverage(279), Height = Application.GetMinRealAverage(60), TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextSelectedColor, TextAlignment = TextAlignment.CenterLeft, Text="起床" }; AddChidren(SceneNameButton); } /// <summary> /// SetTimeText /// </summary> /// <param name="name"></param> public void SetTimeText(string name) { TimeButton.Width = Application.GetMinRealAverage(320); TimeButton.Height = Application.GetMinRealAverage(63); TimeButton.UnSelectedImagePath = string.Empty; TimeButton.Text = name; } /// <summary> /// SetTimeImage /// </summary> public void SetTimeImage() { TimeButton.Width = Application.GetMinRealAverage(63); TimeButton.Height = Application.GetMinRealAverage(63); TimeButton.UnSelectedImagePath = "Item/Time.png"; TimeButton.Text = string.Empty; } /// <summary> /// SetStatu /// </summary> /// <param name="statu"></param> public void SetSceneNameText(string statu) { SceneNameButton.Text = statu; } /// <summary> /// SetIcon /// </summary> /// <param name="iconPath"></param> public void SetIcon(string iconPath) { SceneIcon.UnSelectedImagePath = iconPath; } /// <summary> /// SetCollect /// </summary> /// <param name="collect"></param> public void SetCollect(bool collect) { CollectButton.IsSelected = collect; } } } ZigbeeApp/Shared/Phone/Device/CommonForm/SelectTime.cs
New file @@ -0,0 +1,248 @@ using System; using System.Collections.Generic; using Shared.Common; namespace Shared.Phone.Device.CommonForm { public class SelectTime:FrameLayout { public Action<int> TimeAction; Button TempSelectBtn; Button TempTimeBtn; public int TempTime; /// <summary> /// Init /// </summary> public void Init() { var dialog = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor }; AddChidren(dialog); dialog.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; var backgroundFL = new FrameLayout { Y = Application.GetRealHeight(596), Height = Application.GetRealHeight(1425), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Radius=(uint)Application.GetRealHeight(20) }; dialog.AddChidren(backgroundFL); var topView = new FrameLayout { Height = Application.GetRealHeight(138) }; backgroundFL.AddChidren(topView); var cancle = new Button { X=Application.GetRealWidth(80), Width=Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextGrayColor, TextID=R.MyInternationalizationString.Cancel, TextSize=16 }; topView.AddChidren(cancle); var title = new Button { Width = Application.GetRealWidth(300), Gravity=Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextBlackColor2, TextID=R.MyInternationalizationString.Delay, TextSize = 16 }; topView.AddChidren(title); var confrim=new Button { X = Application.GetRealWidth(CommonFormResouce.AppRealWidth-80-300), Width = Application.GetRealWidth(300), TextAlignment = TextAlignment.CenterRight, TextColor = ZigbeeColor.Current.GXCTextSelectedColor2, TextID = R.MyInternationalizationString.Confrim, TextSize = 16 }; topView.AddChidren(confrim); var timeLayout = new VerticalScrolViewLayout { Y = Application.GetRealHeight(207), Height = Application.GetRealHeight(703+127*2+12*2) }; backgroundFL.AddChidren(timeLayout); TempSelectBtn = new Button(); TempTimeBtn = new Button(); var unKe = new FrameLayout { Y = timeLayout.Bottom, Height = Application.GetRealHeight(161), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; backgroundFL.AddChidren(unKe); var notOpen = new Button { X = Application.GetRealWidth(80), TextColor = ZigbeeColor.Current.GXCTextGrayColor4, TextID = R.MyInternationalizationString.NotOpen, TextAlignment = TextAlignment.CenterLeft, Gravity = Gravity.CenterVertical, TextSize=16 }; unKe.AddChidren(notOpen); cancle.MouseUpEventHandler += Close; confrim.MouseUpEventHandler += Confrim_MouseEvent; notOpen.MouseUpEventHandler += NotOpen_MouseEvent; var tList = new List<int>(); tList.Add(15); tList.Add(30); tList.Add(60); tList.Add(60 * 5); tList.Add(60 * 15); tList.Add(60 * 30); tList.Add(60 * 60); foreach(var t in tList) { AddTime(timeLayout, t); } } /// <summary> /// AddTime /// </summary> /// <param name="verticalScrolView"></param> private void AddTime(VerticalScrolViewLayout verticalScrolView, int timess) { var row = new FrameLayout { Height = Application.GetRealHeight(127+12), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; verticalScrolView.AddChidren(row); var trow = new FrameLayout { Y=Application.GetRealHeight(12), Height = Application.GetRealHeight(127), BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor }; row.AddChidren(trow); var timeBtn = new Button { X = Application.GetRealWidth(80), Width=Application.GetRealWidth(500), TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextGrayColor4, SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor, IsSelected=false }; trow.AddChidren(timeBtn); var selectBtn = new Button { X = Application.GetRealWidth(942), Width = Application.GetMinRealAverage(60), Height=Application.GetMinRealAverage(60), Gravity=Gravity.CenterVertical, UnSelectedImagePath="Item/ItemSelected.png", Visible=false }; trow.AddChidren(selectBtn); var Line = new FrameLayout() { Y = trow.Height - 1, Width = Application.GetRealWidth(919), Height = 1, Gravity=Gravity.CenterHorizontal, BackgroundColor = Common.ZigbeeColor.Current.GXCGrayLineColor2 }; trow.AddChidren(Line); EventHandler<MouseEventArgs> eventHandler = (sender, e) => { TempTimeBtn.IsSelected = false; TempSelectBtn.Visible = false; timeBtn.IsSelected = true; selectBtn.Visible = true; TempTimeBtn = timeBtn; TempSelectBtn = selectBtn; TempTime = timess; }; timeBtn.MouseUpEventHandler += eventHandler; trow.MouseUpEventHandler += eventHandler; timeBtn.Text =CommonFormResouce.GetTimeString(timess); if (timess == TempTime) { timeBtn.IsSelected = true; selectBtn.Visible = true; TempTimeBtn = timeBtn; TempSelectBtn = selectBtn; } } /// <summary> /// Close /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void Close(object sender,MouseEventArgs mouseEventArgs) { RemoveFromParent(); } /// <summary> /// Confrim_MouseEvent /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void Confrim_MouseEvent(object sender,MouseEventArgs mouseEventArgs) { TimeAction.Invoke(TempTime); RemoveFromParent(); } /// <summary> /// NotOpen_MouseEvent /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void NotOpen_MouseEvent(object sender,MouseEventArgs mouseEventArgs) { TimeAction.Invoke(0); RemoveFromParent(); } } } ZigbeeApp/Shared/Phone/Device/CommonForm/TopFrameLayout.cs
@@ -33,7 +33,7 @@ public TopFrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor; Width = Application.GetRealWidth(CommonPage.AppRealWidth); Width = Application.GetRealWidth(CommonFormResouce.AppRealWidth); Height = Application.GetRealHeight(CommonFormResouce.TopFrameLayout_Height); } ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs
@@ -1,5 +1,6 @@ using System; using Shared.Common; using Shared.Phone.Device.CommonForm; using ZigBee.Device; namespace Shared.Phone.Device.Light @@ -17,10 +18,6 @@ ///// </summary> private CommonForm.TopFrameLayout top; /// <summary> /// 更多设置 /// </summary> private Button moreBtn; /// <summary> /// 传过来的设备 /// </summary> private DeviceUI device; @@ -33,25 +30,14 @@ /// </summary> private Shared.Common.Room room; /// <summary> /// The middle fl. /// bodyFrameLayout /// </summary> private FrameLayout midFL; private FrameLayout bodyFrameLayout; /// <summary> /// 收藏按钮 /// </summary> private Button collectionBtn; /// <summary> /// 设备是否在线标识--Online /// </summary> private readonly string DeviceStatus_Online = "Online"; /// <summary> /// 设备状态开关标识--Switch /// </summary> private readonly string DeviceStatus_OnOffStatus = "Switch"; /// <summary> /// The light image. /// </summary> private Button deviceIMG; /// <summary> /// 开关 /// </summary> @@ -59,12 +45,22 @@ /// <summary> /// 滑条 /// </summary> private HorizontalSeekBar levelSeekBar; /// <summary> /// 延时 300毫秒 /// </summary> private int sleepSpan = 300; private WaveSeekBar levelSeekBar; private Button StatuBtn; /// <summary> /// 房间 /// </summary> private Button roomBtn; /// <summary> /// 房间名 /// </summary> private Button roomName; /// <summary> /// MaxLevel /// </summary> private const int MaxLevel = 254; #endregion #region ◆ 接口__________________________ @@ -135,6 +131,18 @@ } dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; switchBtn.IsSelected = dimmableLight.OnOffStatus == 1; StatuBtn.Text = CommonFormResouce.GetSwitchStatu(switchBtn.IsSelected); if (switchBtn.IsSelected == true) { levelSeekBar.IsClickable = true; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; } else { levelSeekBar.IsClickable = false; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; } //change color dimmableLight.LastDateTime = DateTime.Now; } //亮度 @@ -153,18 +161,11 @@ //此属性表明当前亮度程度 dimmableLight.Level = attriButeList[0].AttriButeData; dimmableLight.LastDateTime = DateTime.Now; levelSeekBar.Progress = dimmableLight.Level; levelSeekBar.Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100); break; } } //***新改***设备状态上报中,当CluterID=3,证明设备在线,直接标记 else if ((common as DimmableLight).DeviceStatusReport.CluterID == 3) { dimmableLight = deviceUI.CommonDevice as DimmableLight; dimmableLight.IsOnline = 1; deviceIMG.IsSelected = dimmableLight.IsOnline == 1; dimmableLight.LastDateTime = DateTime.Now; } } } catch (Exception ex) @@ -175,34 +176,7 @@ } else if (typeTag == "OnlineStatusChange") { Application.RunOnMainThread(() => { try { var deviceUI = device; //设备为空 if (deviceUI.CommonDevice == null) { return; } //是否为当前设备 if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) { return; } if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) { dimmableLight = deviceUI.CommonDevice as DimmableLight; dimmableLight.IsOnline = (common as DimmableLight).IsOnline; deviceIMG.IsSelected = dimmableLight.IsOnline == 1; dimmableLight.LastDateTime = DateTime.Now; } } catch (Exception ex) { System.Console.WriteLine($"Error:{ex.Message}"); } }); } } @@ -231,6 +205,7 @@ public DimmableLightControl() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; ZbGateway.StatusList.Add(this); } #endregion @@ -243,7 +218,6 @@ /// <param name="room">Room.</param> public void Show(DeviceUI device, Shared.Common.Room room) { ZbGateway.StatusList.Add(this); this.device = device; this.room = room; this.dimmableLight = device.CommonDevice as ZigBee.Device.DimmableLight; @@ -251,7 +225,7 @@ //添加topview AddTopView(); //添加midview AddMidview(); AddBodyView(this.device); //绑定事件 BindEvent(); //收藏 @@ -296,27 +270,28 @@ RemoveFromParent(); }; AddMoreview(); } /// <summary> /// Adds the moreview. /// </summary> private void AddMoreview() { moreBtn = new CommonForm.SelectedStatuButton() var sharedBtn = new Button { X = Application.GetRealWidth(CommonPage.AppRealWidth - 150), Width = Application.GetMinReal(110), Height = Application.GetMinReal(110), X = Application.GetRealWidth(850), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/More.png", SelectedImagePath = "Item/MoreSelected.png", UnSelectedImagePath = "Item/Shared.png" }; top.topView.AddChidren(sharedBtn); var moreBtn = new Button { X = Application.GetRealWidth(953), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/More.png" }; top.topView.AddChidren(moreBtn); moreBtn.MouseUpEventHandler += MoreEvent; } /// <summary> /// 更多设置 /// </summary> @@ -339,17 +314,17 @@ #region ◆ midview_______________________ /// <summary> /// Adds the midview. /// AddBodyView /// </summary> private void AddMidview() public void AddBodyView(DeviceUI device) { midFL = new FrameLayout() bodyFrameLayout = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), Y = top.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(midFL); AddChidren(bodyFrameLayout); AddItemview(); } @@ -367,111 +342,123 @@ Y = Application.GetRealHeight(115), Width = Application.GetRealWidth(965), Height = Application.GetRealHeight(1316), Radius = CommonPage.BigFormRadius, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; midFL.AddChidren(itemView); var deviceView = new FrameLayout() { X = 2, Y = 2, Width = itemView.Width - 4, Height = itemView.Height - Application.GetRealHeight(138), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = device }; itemView.AddChidren(deviceView); bodyFrameLayout.AddChidren(itemView); collectionBtn = new Button() { X = deviceView.Width - Application.GetRealWidth(130), Y = Application.GetRealHeight(20), Width = Application.GetMinReal(110), Height = Application.GetMinReal(110), X = Application.GetRealWidth(850), Y = Application.GetRealHeight(46), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png" }; deviceView.AddChidren(collectionBtn); itemView.AddChidren(collectionBtn); deviceIMG = new Button() var deviceNameBtn = new Button() { Y = Application.GetRealHeight(100), Height = Application.GetMinRealAverage(240), Width = Application.GetMinRealAverage(240), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = device.IconPath, SelectedImagePath = device.OnlineIconPath, IsSelected = dimmableLight.IsOnline == 1, Tag = DeviceStatus_Online }; deviceView.AddChidren(deviceIMG); var lightName = new Button() { Y = deviceIMG.Bottom, Height = Application.GetRealHeight(85), Y = Application.GetRealHeight(46), Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, Text = device.CommonDevice.DeviceEpointName, TextColor = ZigbeeColor.Current.GXCTextBlackColor TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15 }; deviceView.AddChidren(lightName); itemView.AddChidren(deviceNameBtn); levelSeekBar = new HorizontalSeekBar() StatuBtn = new Button { Y = lightName.Bottom + Application.GetRealHeight(150), Width = Application.GetRealWidth(800), Height = Application.GetRealHeight(80), Y = Application.GetRealHeight(118), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCSliderUnSelectedColor, ThumbColor = ZigbeeColor.Current.GXCButtonBlueColor, BorderColor = ZigbeeColor.Current.GXCButtonBlueColor, ProgressColor = ZigbeeColor.Current.GXCButtonBlueColor, Max = 254, Tag = "LevelSeekBar", Progress = dimmableLight.Level, SleepTime=sleepSpan, TextColor = ZigbeeColor.Current.GXCTextGrayColor, Text = CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline == 1) }; deviceView.AddChidren(levelSeekBar); levelSeekBar.ProgressChanged += (send2, e2) => itemView.AddChidren(StatuBtn); levelSeekBar = new WaveSeekBar() { dimmableLight.SetLevel(levelSeekBar.Progress); Y = Application.GetRealHeight(377), Width = Application.GetRealWidth(271), Height = Application.GetRealHeight(533), Gravity = Gravity.CenterHorizontal, WavePadding = 2, MaxValue=100, Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100), WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor }; itemView.AddChidren(levelSeekBar); if (dimmableLight.OnOffStatus==1) { levelSeekBar.IsClickable = true; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; } else { levelSeekBar.IsClickable = false; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; } levelSeekBar.OnProgressChangedEvent += (send2, e2) => { dimmableLight.SetLevel((int)(levelSeekBar.Progress*MaxLevel/100.0)); }; switchBtn = new Button() { Y = levelSeekBar.Bottom + Application.GetRealHeight(150), Y = Application.GetRealHeight(1005), Width = Application.GetMinRealAverage(81), Height = Application.GetMinRealAverage(81), Gravity = Gravity.CenterHorizontal, Width = Application.GetMinRealAverage(180), Height = Application.GetMinRealAverage(120), UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", Tag = DeviceStatus_OnOffStatus, IsSelected = dimmableLight.OnOffStatus == 1 IsSelected = (device.CommonDevice as DimmableLight).OnOffStatus == 1 }; deviceView.AddChidren(switchBtn); itemView.AddChidren(switchBtn); var roomBtn = new Button() var roomBG = new Button { X = Application.GetRealWidth(50), Y = Application.GetRealHeight(25) + deviceView.Bottom, Y = Application.GetRealHeight(1178 - 50), Height = Application.GetRealHeight(138 + 50), BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius) }; itemView.AddChidren(roomBG); var roomBG2 = new Button { Y = Application.GetRealHeight(1178 - 50), Height = Application.GetRealHeight(50), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; itemView.AddChidren(roomBG2); roomBtn = new Button() { X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = Application.GetRealHeight(1207), Width = Application.GetMinReal(80), Height = Application.GetMinReal(80), UnSelectedImagePath = "Item/Room.png", SelectedImagePath = "Item/RoomSelected.png" UnSelectedImagePath = "Item/Room.png" }; itemView.AddChidren(roomBtn); var roomName = new Button() roomName = new Button() { X = roomBtn.Right + Application.GetRealWidth(20), Y = roomBtn.Y, X = Application.GetRealWidth(150), Y = Application.GetRealHeight(1224), Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(80), Height = Application.GetRealHeight(50), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemView.AddChidren(roomName); } @@ -486,7 +473,6 @@ { switchBtn.MouseUpEventHandler += Switch_MouseUpEvent; collectionBtn.MouseUpEventHandler += Collection; moreBtn.MouseUpEventHandler += MoreEvent; } #endregion @@ -501,13 +487,18 @@ private void Switch_MouseUpEvent(object sender, MouseEventArgs eventArgs) { switchBtn.IsSelected = !switchBtn.IsSelected; StatuBtn.Text = CommonFormResouce.GetSwitchStatu(switchBtn.IsSelected); if (switchBtn.IsSelected == true) { dimmableLight.SwitchControl(1); levelSeekBar.IsClickable = true; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; } else { dimmableLight.SwitchControl(0); levelSeekBar.IsClickable = false; levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; } } @@ -538,15 +529,15 @@ private void Collection(object sender, MouseEventArgs e) { //collection if (collectionBtn.IsSelected) if ((sender as Button).IsSelected) { Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); collectionBtn.IsSelected = false; Shared.Common.Room.GetLoveRoom().DeleteDevice(device.FileName); (sender as Button).IsSelected = false; } else { Shared.Common.Room.Lists[0].AddDevice(device.FileName); collectionBtn.IsSelected = true; Shared.Common.Room.GetLoveRoom().AddDevice(device.FileName); (sender as Button).IsSelected = true; } } ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs
@@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Shared.Common; using Shared.Phone.Device.CommonForm; using Shared.Phone.UserView; using ZigBee.Device; namespace Shared.Phone.Device.Light @@ -12,14 +13,6 @@ { #region ◆ 变量__________________________ /// <summary> /// 设备是否在线标识--Online /// </summary> private readonly string DeviceStatus_Online = "Online"; /// <summary> /// 设备状态开关标识--Switch /// </summary> private readonly string DeviceStatus_OnOffStatus = "Switch"; /// <summary> /// 开关 /// </summary> private Button switchBtn; @@ -27,10 +20,7 @@ /// The action. /// </summary> public Action action; /// <summary> /// The light view. /// </summary> private FrameLayout deviceView; /// <summary> /// The light image. /// </summary> @@ -47,10 +37,7 @@ /// 传过来的房间 /// </summary> private Shared.Common.Room room; /// <summary> /// 更多设置 /// </summary> private Button moreBtn; /// <summary> /// 房间 /// </summary> @@ -67,6 +54,13 @@ /// 是否发送控制命令成功了 /// </summary> private bool sendedControlCommand = false; /// <summary> /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; private Button StatuBtn; #endregion @@ -114,7 +108,7 @@ { try { var deviceUI = deviceView.Tag as DeviceUI; var deviceUI = device; //设备为空 if (deviceUI.CommonDevice == null) { @@ -132,20 +126,13 @@ var light = deviceUI.CommonDevice as ToggleLight; light.DeviceStatusReport = (common as ToggleLight).DeviceStatusReport; //记录、更新状态 if(light.DeviceStatusReport.AttriBute==null || light.DeviceStatusReport.AttriBute.Count==0) if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) { return; } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; switchBtn.IsSelected = light.OnOffStatus == 1; light.LastDateTime = DateTime.Now; } //***新改***设备状态上报中,当CluterID=3,证明设备在线,直接标记 else if ((common as ToggleLight).DeviceStatusReport.CluterID == 3) { var light = deviceUI.CommonDevice as ToggleLight; light.IsOnline = 1; deviceIMG.IsSelected = light.IsOnline == 1; deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; StatuBtn.Text = CommonFormResouce.GetSwitchStatu(deviceIMG.IsSelected); light.LastDateTime = DateTime.Now; } } @@ -158,75 +145,49 @@ } else if (typeTag == "OnlineStatusChange") { Application.RunOnMainThread(() => { try { var deviceUI = deviceView.Tag as DeviceUI; //设备为空 if (deviceUI.CommonDevice == null) { return; } //是否为当前设备 if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) { return; } if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) { var light = deviceUI.CommonDevice as ToggleLight; light.IsOnline = (common as ToggleLight).IsOnline; deviceIMG.IsSelected = light.IsOnline == 1; light.LastDateTime = DateTime.Now; } } catch (Exception ex) { System.Console.WriteLine($"Error:{ex.Message}"); } }); } } #endregion #region ◆ 初始化________________________ #region ◆ 初始化_____________________ /// <summary> /// 重写移除方法 /// </summary> public override void RemoveFromParent() { ZbGateway.StatusList.Remove(this); action(); action = null; RemoveUpdateControlDeviceStatuAction(); base.RemoveFromParent(); } /// <summary> /// 构造方法 /// </summary> public LightControl() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; ZbGateway.StatusList.Add(this); } /// <summary> /// 显示界面 /// </summary> /// <param name="device">Device.</param> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> public void Show(DeviceUI device,Shared.Common.Room room) public void Show(DeviceUI dev,Shared.Common.Room room) { #region topview var topBGView = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.Navigation_Height), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; AddChidren(topBGView); var topView = new FrameLayout() { Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y), Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, }; AddChidren(topView); moreBtn = new Device.CommonForm.SelectedStatuButton() { X=Application.GetRealWidth(CommonPage.AppRealWidth-150), Width=Application.GetMinReal(110), Height=Application.GetMinReal(110), Gravity=Gravity.CenterVertical, UnSelectedImagePath = "Item/More.png", SelectedImagePath = "Item/MoreSelected.png", }; topView.AddChidren(moreBtn); var back = new Device.CommonForm.BackButton() { }; topView.AddChidren(back); back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; if (device == null || device.CommonDevice == null || room == null) { return; } this.device = device; this.zbGateway = this.device.CommonDevice.Gateway; device = dev; zbGateway = this.device.CommonDevice.Gateway; this.room = room; var light = device.CommonDevice as ToggleLight; AddTop(); AddBodyView(device); var light = dev.CommonDevice as ToggleLight; //补上非远程 if (light.Gateway == null) { @@ -249,122 +210,9 @@ light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); } } #endregion #region midFL var midFL = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), Y = topView.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; this.AddChidren(midFL); var itemView = new FrameLayout() { X = Application.GetRealWidth(50), Y = Application.GetRealHeight(50), Width = Application.GetRealWidth(CommonPage.AppRealWidth - 100), Height = Application.GetRealHeight(850), Radius = CommonPage.BigFormRadius, Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; midFL.AddChidren(itemView); deviceView = new FrameLayout() { X = 2, Y = 2, Width = itemView.Width - 4, Height = itemView.Height - Application.GetRealHeight(130), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = device }; itemView.AddChidren(deviceView); collectionBtn = new Button() { X = deviceView.Width - Application.GetRealWidth(130), Y = Application.GetRealHeight(20), Width = Application.GetMinReal(110), Height = Application.GetMinReal(110), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png" }; deviceView.AddChidren(collectionBtn); deviceIMG = new Button() { Y = Application.GetRealHeight(100), Height = Application.GetMinRealAverage(240), Width = Application.GetMinRealAverage(240), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = device.IconPath, SelectedImagePath = device.OnlineIconPath, IsSelected = light.IsOnline == 1, Tag = DeviceStatus_Online }; deviceView.AddChidren(deviceIMG); var lightName = new Button() { Y = deviceIMG.Bottom, Height = Application.GetRealHeight(85), Gravity = Gravity.CenterHorizontal, Text = device.CommonDevice.DeviceEpointName, TextColor = ZigbeeColor.Current.GXCTextBlackColor }; deviceView.AddChidren(lightName); switchBtn = new Button() { Y = lightName.Bottom + Application.GetRealHeight(70), Gravity = Gravity.CenterHorizontal, Width = Application.GetMinRealAverage(180), Height = Application.GetMinRealAverage(120), UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", Tag = DeviceStatus_OnOffStatus, IsSelected = light.OnOffStatus == 1 }; deviceView.AddChidren(switchBtn); roomBtn = new Button() { X = Application.GetRealWidth(50), Y = Application.GetRealHeight(25) + deviceView.Bottom, Width = Application.GetMinReal(80), Height = Application.GetMinReal(80), UnSelectedImagePath = "Item/Room.png", SelectedImagePath = "Item/RoomSelected.png" }; itemView.AddChidren(roomBtn); roomName = new Button() { X = roomBtn.Right + Application.GetRealWidth(20), Y = roomBtn.Y, Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(80), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor }; itemView.AddChidren(roomName); //var moreBtn = new Button() //{ // X = itemView.Width - Application.GetRealWidth(130), // Y = roomBtn.Y, // Width = Application.GetMinReal(80), // Height = Application.GetMinReal(80), // UnSelectedImagePath = "Item/More.png", // SelectedImagePath = "Item/MoreSelected.png", //}; //itemView.AddChidren(moreBtn); var dev = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); if (dev == null) var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); if (de == null) { collectionBtn.IsSelected = false; } @@ -372,29 +220,172 @@ { collectionBtn.IsSelected = true; } this.BindEvent(); #endregion BindEvent(); } /// <summary> /// 重写移除方法 /// </summary> public override void RemoveFromParent() { ZbGateway.StatusList.Remove(this); action(); action = null; RemoveUpdateControlDeviceStatuAction(); base.RemoveFromParent(); } #endregion #region ◆ Add______________________________ /// <summary> /// 构造方法 /// AddTop /// </summary> public LightControl() public void AddTop() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; ZbGateway.StatusList.Add(this); var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; var sharedBtn = new Button { X = Application.GetRealWidth(850), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Shared.png" }; top.topView.AddChidren(sharedBtn); var moreBtn = new Button { X = Application.GetRealWidth(953), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), Gravity=Gravity.CenterVertical, UnSelectedImagePath = "Item/More.png" }; top.topView.AddChidren(moreBtn); moreBtn.MouseUpEventHandler += More; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView(DeviceUI device) { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); var itemView = new FrameLayout() { Y = Application.GetRealHeight(115), Width = Application.GetRealWidth(965), Height = Application.GetRealHeight(1316), Radius =(uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), Gravity = Gravity.CenterHorizontal, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; bodyFrameLayout.AddChidren(itemView); collectionBtn = new Button() { X = Application.GetRealWidth(850), Y = Application.GetRealHeight(46), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png" }; itemView.AddChidren(collectionBtn); var deviceNameBtn = new Button() { Y = Application.GetRealHeight(46), Width=Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, Text = device.CommonDevice.DeviceEpointName, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize=15 }; itemView.AddChidren(deviceNameBtn); StatuBtn = new Button { Y = Application.GetRealHeight(118), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, Text=CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline==1) }; itemView.AddChidren(StatuBtn); deviceIMG = new Button() { Y = Application.GetRealHeight(389), Width = Application.GetMinRealAverage(377), Height = Application.GetMinRealAverage(435), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/DeskLamp.png", SelectedImagePath = "Light/DeskLampSelected.png", IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); switchBtn = new Button() { Y = Application.GetRealHeight(996), Width = Application.GetMinRealAverage(81), Height = Application.GetMinRealAverage(81), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); var roomBG = new Button { Y = Application.GetRealHeight(1178-50), Height = Application.GetRealHeight(138+50), BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius) }; itemView.AddChidren(roomBG); var roomBG2 = new Button { Y = Application.GetRealHeight(1178 - 50), Height = Application.GetRealHeight(50), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; itemView.AddChidren(roomBG2); roomBtn = new Button() { X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = Application.GetRealHeight(1207), Width = Application.GetMinReal(80), Height = Application.GetMinReal(80), UnSelectedImagePath = "Item/Room.png" }; itemView.AddChidren(roomBtn); roomName = new Button() { X = Application.GetRealWidth(150), Y = Application.GetRealHeight(1224), Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(50), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemView.AddChidren(roomName); } #endregion @@ -406,10 +397,8 @@ private void BindEvent() { switchBtn.MouseUpEventHandler += Switch; deviceIMG.MouseUpEventHandler += Switch; collectionBtn.MouseUpEventHandler += Collection; moreBtn.MouseUpEventHandler += More; roomBtn.MouseUpEventHandler += BackToRoomHandler; roomName.MouseUpEventHandler += BackToRoomHandler; } #endregion @@ -426,6 +415,8 @@ sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; deviceIMG.IsSelected = !deviceIMG.IsSelected; StatuBtn.Text = CommonFormResouce.GetSwitchStatu(deviceIMG.IsSelected); if (switchBtn.IsSelected == true) { (device.CommonDevice as ToggleLight).SwitchControl(1); @@ -448,6 +439,8 @@ } }); } #endregion @@ -480,30 +473,16 @@ private void Collection(object sender, MouseEventArgs e) { //collection if (collectionBtn.IsSelected) if ((sender as Button).IsSelected) { Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); collectionBtn.IsSelected = false; Shared.Common.Room.GetLoveRoom().DeleteDevice(device.FileName); (sender as Button).IsSelected = false; } else { Shared.Common.Room.Lists[0].AddDevice(device.FileName); collectionBtn.IsSelected = true; Shared.Common.Room.GetLoveRoom().AddDevice(device.FileName); (sender as Button).IsSelected = true; } } #endregion #region ◆ 回到主页________________________ /// <summary> /// 回到主页 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void BackToRoomHandler(object sender, MouseEventArgs mouseEventArgs ) { //backToRoom } #endregion ZigbeeApp/Shared/Phone/Device/Room/AddRoom.cs
@@ -290,7 +290,7 @@ }; settingContentFL.AddChidren(settingLine); confirm = new Device.CommonForm.CompleteButton(1700, 700, 90); confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); confirm.SetTitle(R.MyInternationalizationString.Confrim); this.AddChidren(confirm); #endregion ZigbeeApp/Shared/Phone/Device/Room/AddRoomScene.cs
@@ -139,7 +139,7 @@ //1-60秒 //PickerView.Show(tList, (obj) => //{ // targetDevice.DelayTime = int.Parse(obj.Split(' ')[0]); //targetDevice.DelayTime = int.Parse(obj.Split(' ')[0]); //}, Language.StringByID(R.MyInternationalizationString.Confrim)); }; devRight.MouseUpEventHandler += (sender, e) => ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
New file @@ -0,0 +1,217 @@ using System; using System.Collections.Generic; using Shared.Common; using Shared.Phone.Device.CommonForm; using Shared.Phone.UserView; namespace Shared.Phone.Device.Room { public class EditRoom : FrameLayout { #region ◆ 变量____________________________ /// <summary> /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; /// <summary> /// The room. /// </summary> public Shared.Common.Room room; /// <summary> /// The action. /// </summary> public Action action; #endregion public EditRoom() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } /// <summary> /// Show this instance. /// </summary> public void Show(Shared.Common.Room r) { room = r; AddTop(); AddBodyView(); } #region Add____________________________________ /// <summary> /// AddTop /// </summary> public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.EditRoom); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView() { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); var imgFL = new FrameLayout { Y=Application.GetRealHeight(60), Width=Application.GetMinRealAverage(916), Height = Application.GetMinRealAverage(478), Gravity=Gravity.CenterHorizontal, BackgroundImagePath= "Room/Room_Rectangle.png" }; bodyFrameLayout.AddChidren(imgFL); var backGround = new Button() { Y = Application.GetRealHeight(60), Width = Application.GetMinRealAverage(887), Height = Application.GetMinRealAverage(444), Gravity = Gravity.CenterHorizontal, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), UnSelectedImagePath = room.BackgroundImage }; bodyFrameLayout.AddChidren(backGround); var infoFL = new FrameLayout { Y = Application.GetRealHeight(562), Height = Application.GetRealHeight(1175), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; bodyFrameLayout.AddChidren(infoFL); var infoEdit = new Button { X = Application.GetRealWidth(CommonFormResouce.X_Left), Y=Application.GetRealHeight(80), Height = Application.GetRealHeight(60), Width = Application.GetRealWidth(700), TextID = R.MyInternationalizationString.EditInfo, TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, TextAlignment = TextAlignment.CenterLeft, TextSize = 15 }; infoFL.AddChidren(infoEdit); var nameRow = new DeviceInfoEditRow(170); nameRow.Init(); nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.RoomName)} :"); nameRow.SetPlaceHoldText(room.Name); infoFL.AddChidren(nameRow); var floorRow = new DeviceInfoRow(308); floorRow.Init(); floorRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongFloor)} :"); floorRow.SetTitle(room.FloorName); infoFL.AddChidren(floorRow); floorRow.NextBtn.MouseUpEventHandler += (sender, e) => { if (Config.Instance.Home.FloorDics != null) { List<string> floorIds = new List<string> { }; List<string> floorNames = new List<string> { }; foreach (var floor in Config.Instance.Home.FloorDics) { floorIds.Add(floor.Key); floorNames.Add(floor.Value); } PickerView.Show(floorNames, (index) => { room.FloorId = floorIds[index]; floorRow.SetTitle(room.FloorName); }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); } }; var temperatureRow = new DeviceInfoRow(446); temperatureRow.Init(); temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature); temperatureRow.SetTitle("26.8℃"); temperatureRow.NameText.TextAlignment = TextAlignment.CenterRight; infoFL.AddChidren(temperatureRow); temperatureRow.NextBtn.MouseUpEventHandler += (sender, e) => { var tem = new RoomTemperatureSetting { }; HomePage.Instance.AddChidren(tem); HomePage.Instance.PageIndex += 1; tem.Show(room); tem.action = (selectTemp) => { }; }; var humidityRow = new DeviceInfoRow(585); humidityRow.Init(); humidityRow.SetTipTitle(R.MyInternationalizationString.Humidity); humidityRow.SetTitle("66.5%"); humidityRow.NameText.TextAlignment = TextAlignment.CenterRight; infoFL.AddChidren(humidityRow); humidityRow.NextBtn.MouseUpEventHandler += (sender, e) => { var tem = new RoomHumiditySetting { }; HomePage.Instance.AddChidren(tem); HomePage.Instance.PageIndex += 1; tem.Show(room); tem.action = (selectTemp) => { }; }; var shareRow = new DeviceInfoRow(723); shareRow.Init(); shareRow.SetTipTitle(R.MyInternationalizationString.Share); shareRow.SetTitle("2 人"); shareRow.NameText.TextAlignment = TextAlignment.CenterRight; infoFL.AddChidren(shareRow); shareRow.NextBtn.MouseUpEventHandler += (sender, e) => { var tem = new RoomShareSetting { }; HomePage.Instance.AddChidren(tem); HomePage.Instance.PageIndex += 1; tem.Show(room); tem.action = (selectTemp) => { }; }; var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); confirm.SetTitle(R.MyInternationalizationString.Confrim); AddChidren(confirm); } #endregion } } ZigbeeApp/Shared/Phone/Device/Room/RoomHumiditySetting.cs
New file @@ -0,0 +1,110 @@ using System; using Shared.Common; using Shared.Phone.Device.CommonForm; namespace Shared.Phone.Device.Room { public class RoomHumiditySetting:FrameLayout { #region ◆ 变量____________________________ /// <summary> /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; /// <summary> /// verticalScrolView /// </summary> private VerticalScrolViewLayout verticalScrolView; /// <summary> /// The room. /// </summary> public Shared.Common.Room room; /// <summary> /// The action. /// </summary> public Action<string> action; #endregion public RoomHumiditySetting() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } /// <summary> /// Show this instance. /// </summary> public void Show(Shared.Common.Room r) { room = r; AddTop(); AddBodyView(); } #region Add____________________________________ /// <summary> /// AddTop /// </summary> public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.Humidity); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView() { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); verticalScrolView = new VerticalScrolViewLayout { Height = Application.GetRealHeight(1737) }; bodyFrameLayout.AddChidren(verticalScrolView); var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); confirm.SetTitle(R.MyInternationalizationString.Save); AddChidren(confirm); for (int i = 0; i < 15; i++) { AddItem(verticalScrolView, 20 + i * (127 + 20)); } } /// <summary> /// AddItem /// </summary> /// <param name="vertical"></param> public void AddItem(VerticalScrolViewLayout vertical, int y) { var dev = new DeviceInfoWithZoneRow(y); vertical.AddChidren(dev); dev.Init(); dev.SetIcon("DeviceIcon/1.png"); dev.SetName("湿度传感器" + y); dev.SetZone(room.FloorName + ", " + room.Name); } #endregion } } ZigbeeApp/Shared/Phone/Device/Room/RoomManagement.cs
@@ -1,5 +1,6 @@ using System; using Shared.Common; using Shared.Phone.Device.Category; using Shared.Phone.Device.CommonForm; namespace Shared.Phone.Device.Room @@ -14,6 +15,10 @@ /// </summary> private FrameLayout bodyFrameLayout; private Button floorBtn; private FrameLayout itemView; #endregion @@ -23,7 +28,7 @@ public override void RemoveFromParent() { //更新界面 action?.Invoke(); //action?.Invoke(); base.RemoveFromParent(); } /// <summary> @@ -52,37 +57,52 @@ RemoveFromParent(); }; var addRoomItemBtn = new Device.CommonForm.SelectedStatuButton() floorBtn = new Button() { X = Application.GetRealWidth(1080 - 150), Width = Application.GetMinRealAverage(100), Height = Application.GetMinRealAverage(100), X = Application.GetRealWidth(750), Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Add.png", SelectedImagePath = "Item/AddSelected.png" TextAlignment = TextAlignment.CenterRight, TextColor = ZigbeeColor.Current.GXCTextBlackColor, }; top.AddChidren(addRoomItemBtn); addRoomItemBtn.MouseUpEventHandler += (sender, e) => var selectFloorBtn = new Button() { var addRoom = new AddRoom(); UserView.HomePage.Instance.AddChidren(addRoom); UserView.HomePage.Instance.PageIndex += 1; addRoom.action = () => { Show(); }; AddRoom.OldBackgroundImagePath = string.Empty; addRoom.Show(""); X = Application.GetRealWidth(950), Width = Application.GetMinRealAverage(69), Height = Application.GetMinRealAverage(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Drop_Down.png" }; floorBtn.Text = Config.Instance.Home.GetCurrentFloorName(); top.topView.AddChidren(floorBtn); top.topView.AddChidren(selectFloorBtn); selectFloorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; floorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; } /// <summary> /// 选择楼层 /// </summary> /// <param name="sender">Sender.</param> /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void SelectedFloor_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) { var floors = new SelectFloor(); AddChidren(floors); floors.Init(599, 161); floors.FloorAction += (floorName) => { floorBtn.Text = floorName; }; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView() { RemoveAll(); bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), @@ -90,6 +110,44 @@ BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); var roomScrolView = new VerticalScrolViewLayout { }; bodyFrameLayout.AddChidren(roomScrolView); for (int i = 0; i < Shared.Common.Room.Lists.Count; i++) { var room = Shared.Common.Room.Lists[i]; int xx = 43 + i % 2 * (20 + 487); int yy = 0; if (i == 0 || i == 1) { if (i % 2 == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(354 + 58), Tag = room }; roomScrolView.AddChidren(itemView); } yy = 58; } else if (i % 2 == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(354), Tag = room }; roomScrolView.AddChidren(itemView); } var roomView = new RoomMainView(xx, yy); itemView.AddChidren(roomView); roomView.Init(); roomView.SetRoomName(room.Name); roomView.SetRoomIcon(room.BackgroundImage); } } @@ -100,72 +158,18 @@ /// </summary> void RoomPage() { RemoveAll(); #region topview var topBGView = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.Navigation_Height), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; AddChidren(topBGView); var topView = new FrameLayout() { Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y), Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, }; AddChidren(topView); var title = new Button() { TextAlignment = TextAlignment.Center, TextID=R.MyInternationalizationString.RoomList, TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500), Gravity = Gravity.CenterHorizontal }; topView.AddChidren(title); BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; var back = new Device.CommonForm.BackButton() { }; topView.AddChidren(back); return; back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; var addRoomItemBtn = new Device.CommonForm.SelectedStatuButton() { Width = Application.GetMinRealAverage(100), Height = Application.GetMinRealAverage(100), UnSelectedImagePath = "Item/Add.png", SelectedImagePath="Item/AddSelected.png", X = Application.GetRealWidth(1080 - 150), Gravity = Gravity.CenterVertical }; topView.AddChidren(addRoomItemBtn); //Action action = RoomPage; addRoomItemBtn.MouseUpEventHandler += (sender, e) => { //AddOrUpdateRoom(action); var addRoom = new AddRoom(); Shared.Phone.UserView.HomePage.Instance.AddChidren(addRoom); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addRoom.action = () => { Show(); }; AddRoom.OldBackgroundImagePath = string.Empty; addRoom.Show(""); }; #endregion var middleHomePage = new FrameLayout() { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), Y = topView.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; this.AddChidren(middleHomePage); var RoomBodyView = new VerticalScrolViewLayout() { Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; middleHomePage.AddChidren(RoomBodyView); foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) ZigbeeApp/Shared/Phone/Device/Room/RoomShareSetting.cs
New file @@ -0,0 +1,105 @@ using System; using Shared.Common; using Shared.Phone.Device.CommonForm; namespace Shared.Phone.Device.Room { public class RoomShareSetting:FrameLayout { #region ◆ 变量____________________________ /// <summary> /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; /// <summary> /// verticalScrolView /// </summary> private VerticalScrolViewLayout verticalScrolView; /// <summary> /// The room. /// </summary> public Shared.Common.Room room; /// <summary> /// The action. /// </summary> public Action<string> action; #endregion public RoomShareSetting() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } /// <summary> /// Show this instance. /// </summary> public void Show(Shared.Common.Room r) { room = r; AddTop(); AddBodyView(); } #region Add____________________________________ /// <summary> /// AddTop /// </summary> public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.Share); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView() { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); verticalScrolView = new VerticalScrolViewLayout { Height = Application.GetRealHeight(1737) }; bodyFrameLayout.AddChidren(verticalScrolView); var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); confirm.SetTitle(R.MyInternationalizationString.Save); AddChidren(confirm); for (int i = 0; i < 15; i++) { AddItem(verticalScrolView, 20 + i * (127 + 20)); } } /// <summary> /// AddItem /// </summary> /// <param name="vertical"></param> public void AddItem(VerticalScrolViewLayout vertical, int y) { var dev = new DeviceInfoRow(y); vertical.AddChidren(dev); dev.Init(); dev.SetTipTitle("用户 " + y); } #endregion } } ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs
New file @@ -0,0 +1,110 @@ using System; using Shared.Common; using Shared.Phone.Device.CommonForm; namespace Shared.Phone.Device.Room { public class RoomTemperatureSetting : FrameLayout { #region ◆ 变量____________________________ /// <summary> /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; /// <summary> /// The action. /// </summary> public Action<string> action; /// <summary> /// verticalScrolView /// </summary> private VerticalScrolViewLayout verticalScrolView; /// <summary> /// The room. /// </summary> public Shared.Common.Room room; #endregion public RoomTemperatureSetting() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } /// <summary> /// Show this instance. /// </summary> public void Show(Shared.Common.Room r) { room = r; AddTop(); AddBodyView(); } #region Add____________________________________ /// <summary> /// AddTop /// </summary> public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.Temperature); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; } /// <summary> /// AddBodyView /// </summary> public void AddBodyView() { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); verticalScrolView = new VerticalScrolViewLayout { Height = Application.GetRealHeight(1737) }; bodyFrameLayout.AddChidren(verticalScrolView); var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); confirm.SetTitle(R.MyInternationalizationString.Save); AddChidren(confirm); for(int i=0;i<15;i++) { AddItem(verticalScrolView, 20 + i * (127 + 20)); } } /// <summary> /// AddItem /// </summary> /// <param name="vertical"></param> public void AddItem(VerticalScrolViewLayout vertical,int y) { var dev = new DeviceInfoWithZoneRow(y); vertical.AddChidren(dev); dev.Init(); dev.SetIcon("DeviceIcon/1.png"); dev.SetName("温度传感器"+y); dev.SetZone(room.FloorName + ", " + room.Name); } #endregion } } ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
@@ -30,14 +30,7 @@ /// 功能和场景bodyView /// </summary> private FrameLayout functionSceneBodyView; /// <summary> /// The height of the top frame layout -- 500 /// </summary> private static readonly int topFrameLayout_Height = 500; /// <summary> /// 1524 /// </summary> private static readonly int midView_Height = 1524; /// <summary> /// The height of the room page view. -- 550 /// </summary> @@ -78,6 +71,9 @@ /// </summary> private readonly int sleepSpan = 300; private FrameLayout itemView; #endregion #region ◆ 接口____________________________ @@ -115,9 +111,8 @@ for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) { var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; var rowLayout = rowFL.GetChildren(0) as RowLayout; var deviceUI = rowLayout.Tag as DeviceUI; if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0) var deviceUI = rowFL.Tag as DeviceUI; if (deviceUI.CommonDevice == null || rowFL.ChildrenCount == 0) { //设备为空或者控件为空 continue; @@ -128,7 +123,7 @@ //判断是否为当前设备 continue; } var frameLayout = rowLayout.GetChildren(0) as FrameLayout; var frameLayout = rowFL.GetChildren(0) as FrameLayout; switch (deviceUI.CommonDevice.Type) { case DeviceType.OnOffOutput: @@ -137,46 +132,17 @@ { var onOffOutputLight = deviceUI.CommonDevice as ZigBee.Device.ToggleLight; onOffOutputLight.DeviceStatusReport = (common as ZigBee.Device.ToggleLight).DeviceStatusReport; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_OnOffStatus) { //记录、更新状态 if (onOffOutputLight.DeviceStatusReport.AttriBute == null || onOffOutputLight.DeviceStatusReport.AttriBute.Count == 0) { continue; } onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData; (tempView as Button).IsSelected = onOffOutputLight.OnOffStatus == 1; //记录回复时间 onOffOutputLight.LastDateTime = DateTime.Now; } } } //当CluterID=3,就证明该设备在线,直接标记 if ((common as ZigBee.Device.ToggleLight).DeviceStatusReport.CluterID == 3) { var onOffOutputLight = deviceUI.CommonDevice as ToggleLight; onOffOutputLight.IsOnline = 1; for (int j = 0; j < frameLayout.ChildrenCount; j++) //记录、更新状态 if (onOffOutputLight.DeviceStatusReport.AttriBute == null || onOffOutputLight.DeviceStatusReport.AttriBute.Count == 0) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = onOffOutputLight.IsOnline == 1; //记录回复时间 onOffOutputLight.LastDateTime = DateTime.Now; } continue; } onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData; (rowFL.GetChildren(0) as FunctionMainView).IsSelected = onOffOutputLight.OnOffStatus == 1; (rowFL.GetChildren(0) as FunctionMainView).StatuButton.Text = CommonFormResouce.GetSwitchStatu(onOffOutputLight.OnOffStatus == 1); //记录回复时间 onOffOutputLight.LastDateTime = DateTime.Now; } break; @@ -356,31 +322,22 @@ case DeviceType.DimmableLight: //调光灯功能 //开关功能 if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 6) if ((common as DimmableLight).DeviceStatusReport.CluterID == 6) { var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; dimmableLight.DeviceStatusReport = (common as ZigBee.Device.DimmableLight).DeviceStatusReport; for (int j = 0; j < frameLayout.ChildrenCount; j++) var dimmableLight = deviceUI.CommonDevice as DimmableLight; dimmableLight.DeviceStatusReport = (common as DimmableLight).DeviceStatusReport; //记录、更新状态 if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_OnOffStatus) { //记录、更新状态 if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0) { return; } dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; (tempView as Button).IsSelected = dimmableLight.OnOffStatus == 1; //记录回复时间 dimmableLight.LastDateTime = DateTime.Now; } return; } dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; (rowFL.GetChildren(0) as FunctionMainView).IsSelected = dimmableLight.OnOffStatus == 1; (rowFL.GetChildren(0) as FunctionMainView).StatuButton.Text = CommonFormResouce.GetSwitchStatu(dimmableLight.OnOffStatus == 1); //记录回复时间 dimmableLight.LastDateTime = DateTime.Now; } //亮度 if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 8) { @@ -412,27 +369,6 @@ break; } } //当CluterID=3,就证明该设备在线,直接标记 if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 3) { var dimmableLight = deviceUI.CommonDevice as DimmableLight; dimmableLight.IsOnline = 1; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = dimmableLight.IsOnline == 1; //记录回复时间 dimmableLight.LastDateTime = DateTime.Now; } } } break; } @@ -444,130 +380,7 @@ } }); } //设备在线状态上报 else if (typeTag == "OnlineStatusChange") { Application.RunOnMainThread(() => { try { for (int i = 0; deviceVerticalScrolViewLayout != null && i < deviceVerticalScrolViewLayout.ChildrenCount; i++) { var rowFL = deviceVerticalScrolViewLayout.GetChildren(i) as FrameLayout; var rowLayout = rowFL.GetChildren(0) as RowLayout; var deviceUI = rowLayout.Tag as DeviceUI; if (deviceUI.CommonDevice == null || rowLayout.ChildrenCount == 0) { //设备为空或者控件为空 continue; } if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint) { //判断是否为当前设备 continue; } var frameLayout = rowLayout.GetChildren(0) as FrameLayout; switch (deviceUI.CommonDevice.Type) { case DeviceType.OnOffOutput: var onOffOutputLight = deviceUI.CommonDevice as ToggleLight; onOffOutputLight.IsOnline = (common as ToggleLight).IsOnline; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = onOffOutputLight.IsOnline == 1; } } //记录回复时间 onOffOutputLight.LastDateTime = DateTime.Now; break; case DeviceType.AirSwitch: var airSwitch = deviceUI.CommonDevice as AirSwitch; airSwitch.IsOnline = (common as AirSwitch).IsOnline; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = airSwitch.IsOnline == 1; } } //记录回复时间 airSwitch.LastDateTime = DateTime.Now; break; case DeviceType.WindowCoveringDevice: var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade; rollershade.IsOnline = (common as Rollershade).IsOnline; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = rollershade.IsOnline == 1; } } //记录回复时间 rollershade.LastDateTime = DateTime.Now; break; case DeviceType.Thermostat: var ac = deviceUI.CommonDevice as ZigBee.Device.AC; ac.IsOnline = (common as ZigBee.Device.AC).IsOnline; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = ac.IsOnline == 1; } } //记录回复时间 ac.LastDateTime = DateTime.Now; break; case DeviceType.DimmableLight: var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; dimmableLight.IsOnline = (common as ZigBee.Device.DimmableLight).IsOnline; for (int j = 0; j < frameLayout.ChildrenCount; j++) { var tempView = frameLayout.GetChildren(j); if (tempView.Tag == null) { continue; } if (tempView.Tag.ToString() == deviceStatus_Online) { (tempView as Button).IsSelected = dimmableLight.IsOnline == 1; } } //记录回复时间 dimmableLight.LastDateTime = DateTime.Now; break; } } } catch (Exception ex) { System.Console.WriteLine($"主页功能刷新-Error:{ex.Message}"); } }); } } /// <summary> /// Changeds the IL ogic status. @@ -845,7 +658,10 @@ //消息 messageBtn.MouseUpEventHandler += (send, e) => { var roomList = new Shared.Phone.Device.Room.RoomManagement(); HomePage.Instance.AddChidren(roomList); HomePage.Instance.PageIndex += 1; roomList.Show(); }; #endregion @@ -914,10 +730,10 @@ // Show(); //}; var editRoom = new Device.Room.AddRoom(); var editRoom = new Device.Room.EditRoom(); HomePage.Instance.AddChidren(editRoom); HomePage.Instance.PageIndex += 1; editRoom.Show(); editRoom.Show(room); editRoom.action += () => { Show(); @@ -1159,7 +975,7 @@ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void GoToAddGateWay(object sender, MouseEventArgs mouseEventArgs) { UserCenter.GatewayAdd.NewGateWaySelectForm selectNewGateWayForm = new UserCenter.GatewayAdd.NewGateWaySelectForm { }; var selectNewGateWayForm = new UserCenter.GatewayAdd.NewGateWaySelectForm { }; selectNewGateWayForm.AddForm(selectNewGateWayForm); } @@ -1172,13 +988,23 @@ /// </summary> private void ShowNoFunctionTip() { var noFunction = new Button { Y = Application.GetRealHeight(69), Width = Application.GetMinRealAverage(683), Height = Application.GetMinRealAverage(392), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/NoFunction.png" }; functionSceneBodyView.AddChidren(noFunction); var noFunctionTip = new Button() { Y=noFunction.Bottom, Height = Application.GetRealHeight(200), TextID = R.MyInternationalizationString.NoFunction, Text = Language.StringByID(R.MyInternationalizationString.NoFunction).Replace("{\\r\\n}","\r\n"), TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center, Gravity = Gravity.Center IsMoreLines=true }; functionSceneBodyView.AddChidren(noFunctionTip); } @@ -1202,13 +1028,31 @@ else { deviceVerticalScrolViewLayout = new VerticalScrolViewLayout { }; functionSceneBodyView.AddChidren(deviceVerticalScrolViewLayout); foreach (var device in deviceList) for(int i=0;i<deviceList.Count;i++) { int t = i % 2; int tt = i / 2; int xx = 43 + i % 2 * (20 + 487); int yy = 14; var device = deviceList[i]; if (device == null || device.CommonDevice == null) { continue; } if (i % 2 == 0) { itemView = new FrameLayout() { Height = Application.GetRealHeight(14 + 348), Tag = device }; deviceVerticalScrolViewLayout.AddChidren(itemView); } //删除设备 EventHandler<MouseEventArgs> delEvent = (sender, e) => { @@ -1225,36 +1069,38 @@ }; }; //收藏 //EventHandler<MouseEventArgs> collectionEvent = (sender, e) => //{ // if ((sender as Button).IsSelected) // { // Room.Lists[0].DeleteDevice(device.FilePath); // (sender as Button).IsSelected = false; // if (Room.CurrentRoom == Room.Lists[0]) // { // DeviceVerticalScrolViewLayout.RemoveViewByTag((sender as Button).Tag); // } // } // else // { // Room.Lists[0].AddDevice(device.FilePath); // (sender as Button).IsSelected = true; // } // //RefreshBodyView(); //}; EventHandler<MouseEventArgs> collectionEvent = (sender, e) => { if (Room.CurrentRoom == Room.Lists[0]) if ((sender as Button).IsSelected) { Room.Lists[0].DeleteDevice(device.FileName); deviceVerticalScrolViewLayout.RemoveViewByTag((sender as Button).Tag); Shared.Common.Room.GetLoveRoom().DeleteDevice(device.FileName); (sender as Button).IsSelected = false; } else { Shared.Common.Room.GetLoveRoom().AddDevice(device.FileName); (sender as Button).IsSelected = true; } if (Room.CurrentRoom.IsLove) { RefreshBodyView(); } }; //////判断设备是否支持的属性 如开关等控制 if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) { var lightView = new FunctionMainView(xx, yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText("开"); lightView.SetDeviceName("lightee"); //lightView.SetStatu(true); lightView.IsSelected = true; lightView.SetCollect(true); continue; //窗帘 卷帘 var rollerShade = (ZigBee.Device.Rollershade)device.CommonDevice; //不上非远程 @@ -1603,6 +1449,7 @@ { //开关灯 var light = device.CommonDevice as ToggleLight; //补上非远程 if (light.Gateway == null) { @@ -1626,96 +1473,29 @@ } } var lightView = new FunctionMainView(xx,yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText(CommonFormResouce.GetSwitchStatu(light.OnOffStatus==1)); lightView.SetDeviceName(device.CommonDevice.DeviceEpointName); lightView.IsSelected = light.OnOffStatus==1; lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom,device.FileName)); var deviceFL = new FrameLayout var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); if (dev == null) { Height = Application.GetRealHeight(deviceFL_Height), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = device }; deviceVerticalScrolViewLayout.AddChidren(deviceFL); var deviceRowLayout = new RowLayout lightView.CollectButton.IsSelected = false; } else { Y = Application.GetRealHeight(25), Height = Application.GetRealHeight(deviceFL_Height - 25) - 1, LineColor = ZigbeeColor.Current.GXCBackgroundColor, BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, Radius = CommonPage.BigFormRadius, Tag = device }; deviceFL.AddChidren(deviceRowLayout); lightView.CollectButton.IsSelected = true; } var deviceItemFL = new FrameLayout() lightView.SwitchButton.MouseUpEventHandler += (sender, e) => { BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, Radius = CommonPage.BigFormRadius }; deviceRowLayout.AddChidren(deviceItemFL); var deviceIMG = new Button() { X = Application.GetRealWidth(50), Y = Application.GetRealHeight(30), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = device.IconPath, SelectedImagePath = device.OnlineIconPath, IsSelected = light.IsOnline == 1, Tag = deviceStatus_Online }; deviceItemFL.AddChidren(deviceIMG); var deviceName = new Button() { X = Application.GetRealWidth(10), Y = deviceIMG.Bottom, Width = Application.GetRealWidth(180), Height = Application.GetRealHeight(80), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextAlignment = TextAlignment.Center, Text = device.CommonDevice.DeviceEpointName, TextSize = 10, IsMoreLines = true }; deviceItemFL.AddChidren(deviceName); var collectionBtn = new Button() { X = deviceItemFL.Right - Application.GetRealWidth(150), Y = Application.GetRealHeight(20), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png", Tag = device }; //***先隐藏****** //deviceItemFL.AddChidren(collectionBtn); var switchBtnBG = new Button { X = deviceItemFL.Right - Application.GetRealWidth(250), Width = Application.GetMinRealAverage(250), Height = Application.GetMinRealAverage(250), Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(switchBtnBG); var switchBtn = new Button { X = deviceItemFL.Right - Application.GetRealWidth(200), //Y = deviceItemFL.Bottom - Application.GetRealHeight(120), Width = Application.GetMinRealAverage(183), Height = Application.GetMinRealAverage(123), UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", IsSelected = light.OnOffStatus == 1, Tag = deviceStatus_OnOffStatus, //Visible=false Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(switchBtn); switchBtn.MouseUpEventHandler += (send2, e2) => { switchBtn.IsSelected = !switchBtn.IsSelected; if (switchBtn.IsSelected == true) (sender as Button).IsSelected = !(sender as Button).IsSelected; if ((sender as Button).IsSelected) { zbGateway = device.CommonDevice.Gateway; sendedControlCommand = false; @@ -1724,8 +1504,11 @@ light.SwitchControl(1); //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => ((sender as Button).Parent as FunctionMainView).SetStatuText(CommonFormResouce.GetSwitchStatu(true)); ((sender as Button).Parent as FunctionMainView).IsSelected = true; //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => { if (Parent == null) { @@ -1747,8 +1530,11 @@ light.SwitchControl(0); //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => ((sender as Button).Parent as FunctionMainView).SetStatuText(CommonFormResouce.GetSwitchStatu(false)); ((sender as Button).Parent as FunctionMainView).IsSelected = false; //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => { if (Parent == null) { @@ -1763,31 +1549,7 @@ } }; var deleteBtn = new Device.CommonForm.RowLayoutDeleteButton { Tag = device, IsMoreLines = true }; if (Room.CurrentRoom.IsLove) { deleteBtn.TextID = R.MyInternationalizationString.CancelCollect; deleteBtn.BackgroundColor = ZigbeeColor.Current.GXCCancelCollectionBGColor; deleteBtn.MouseUpEventHandler += collectionEvent; deviceRowLayout.AddRightView(deleteBtn); } else if (Room.CurrentRoom.IsSharedRoom) { //不处理 } else { deleteBtn.MouseUpEventHandler += delEvent; deviceRowLayout.AddRightView(deleteBtn); } EventHandler<MouseEventArgs> lightHandler = (sender, e) => lightView.CardBG.MouseUpEventHandler += (sender, e) => { var lightControl = new Phone.Device.Light.LightControl(); UserView.HomePage.Instance.AddChidren(lightControl); @@ -1795,44 +1557,25 @@ lightControl.action = RefreshBodyView; lightControl.Show(device, Room.CurrentRoom); }; //deviceItemFL.MouseLongEventHandler += lightHandler; deviceItemFL.MouseUpEventHandler += lightHandler; deviceName.MouseUpEventHandler += lightHandler; deviceIMG.MouseUpEventHandler += lightHandler; //collectionBtn.MouseUpEventHandler += (sender, e) => //{ // if (collectionBtn.IsSelected) // { // Room.Lists[0].DeleteDevice(device.FilePath); // collectionBtn.IsSelected = false; // if(Room.CurrentRoom==Room.Lists[0]) // { // RefreshBodyView(); // } // } // else // { // Room.Lists[0].AddDevice(device.FilePath); // collectionBtn.IsSelected = true; // } // //RefreshBodyView(); //}; collectionBtn.MouseUpEventHandler += collectionEvent; //var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FilePath); //if (dev == null) //{ // collectionBtn.IsSelected = false; //} //else //{ // collectionBtn.IsSelected = true; //} lightView.CollectButton.MouseUpEventHandler += collectionEvent; } else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) { var lightView = new FunctionMainView(xx, yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText("开"); lightView.SetDeviceName("airSwitch"); //lightView.SetStatu(true); lightView.IsSelected = true; lightView.SetCollect(true); continue; //空气开关 var airSwitch = device.CommonDevice as AirSwitch; @@ -2063,6 +1806,18 @@ } else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) { var lightView = new FunctionMainView(xx, yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText("开"); lightView.SetDeviceName("空调"); //lightView.SetStatu(true); lightView.IsSelected = true; lightView.SetCollect(true); continue; //恒温器-AC-空调 var ac = device.CommonDevice as AC; @@ -2417,7 +2172,6 @@ { //调光灯 var dimmableLight = device.CommonDevice as DimmableLight; //补上非远程 if (dimmableLight.Gateway == null) { @@ -2430,7 +2184,6 @@ { dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); dimmableLight.ReadOnOffStatus(); dimmableLight.ReadLevel(); }); } else @@ -2440,189 +2193,86 @@ { dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); dimmableLight.ReadOnOffStatus(); dimmableLight.ReadLevel(); } } var deviceFL = new FrameLayout { Height = Application.GetRealHeight(deviceFL_Height), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = device }; deviceVerticalScrolViewLayout.AddChidren(deviceFL); var deviceRowLayout = new RowLayout { Y = Application.GetRealHeight(25), Height = Application.GetRealHeight(deviceFL_Height - 25) - 1, LineColor = ZigbeeColor.Current.GXCBackgroundColor, BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, Radius = CommonPage.BigFormRadius, Tag = device }; deviceFL.AddChidren(deviceRowLayout); var lightView = new FunctionMainView(xx, yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText(CommonFormResouce.GetSwitchStatu(dimmableLight.OnOffStatus == 1)); lightView.SetDeviceName(device.CommonDevice.DeviceEpointName); lightView.IsSelected = dimmableLight.OnOffStatus == 1; lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom, device.FileName)); var deviceItemFL = new FrameLayout() var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); if (dev == null) { BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, Radius = CommonPage.BigFormRadius }; deviceRowLayout.AddChidren(deviceItemFL); var deviceIMG = new Button() { X = Application.GetRealWidth(50), Y = Application.GetRealHeight(30), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = device.IconPath, SelectedImagePath = device.OnlineIconPath, IsSelected = dimmableLight.IsOnline == 1, Tag = deviceStatus_Online }; deviceItemFL.AddChidren(deviceIMG); var deviceName = new Button() { X = Application.GetRealWidth(10), Y = deviceIMG.Bottom, Width = Application.GetRealWidth(180), Height = Application.GetRealHeight(80), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextAlignment = TextAlignment.Center, Text = device.CommonDevice.DeviceEpointName, TextSize = 10, IsMoreLines = true }; deviceItemFL.AddChidren(deviceName); var levelSeekBar = new HorizontalSeekBar() { X = deviceIMG.Right + Application.GetRealWidth(50), Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(80), Gravity = Gravity.CenterVertical, BackgroundColor = ZigbeeColor.Current.GXCSliderUnSelectedColor, ThumbColor = ZigbeeColor.Current.GXCButtonBlueColor, BorderColor = ZigbeeColor.Current.GXCButtonBlueColor, ProgressColor = ZigbeeColor.Current.GXCButtonBlueColor, Max = 254, Tag = "LevelSeekBar", Progress = dimmableLight.Level, SleepTime = sleepSpan }; deviceItemFL.AddChidren(levelSeekBar); levelSeekBar.ProgressChanged += (send2, e2) => { dimmableLight.SetLevel(levelSeekBar.Progress); }; var collectionBtn = new Button() { X = deviceItemFL.Right - Application.GetRealWidth(150), Y = Application.GetRealHeight(20), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png", Tag = device }; //***先隐藏****** //deviceItemFL.AddChidren(collectionBtn); var switchBtnBG = new Button { X = deviceItemFL.Right - Application.GetRealWidth(250), Width = Application.GetMinRealAverage(250), Height = Application.GetMinRealAverage(250), Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(switchBtnBG); var switchBtn = new Button { X = deviceItemFL.Right - Application.GetRealWidth(200), //Y = deviceItemFL.Bottom - Application.GetRealHeight(120), Width = Application.GetMinRealAverage(183), Height = Application.GetMinRealAverage(123), UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", IsSelected = dimmableLight.OnOffStatus == 1, Tag = deviceStatus_OnOffStatus, //Visible=false Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(switchBtn); switchBtn.MouseUpEventHandler += (send2, e2) => { switchBtn.IsSelected = !switchBtn.IsSelected; if (switchBtn.IsSelected == true) { //zbGateway = device.CommonDevice.Gateway; //sendedControlCommand = false; //zbGateway.ReportAction += UpdateDeviceControllStatu; //AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); dimmableLight.SwitchControl(1); //控制延时回调 //DeviceUI.SendCommandDelayAction(device.CommonDevice, () => //{ //if (Parent == null) //{ // return; //} //RemoveUpdateControlDeviceStatuAction(zbGateway); //if (sendedControlCommand == false) //{ // DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); //} //}); } else { //zbGateway = device.CommonDevice.Gateway; //sendedControlCommand = false; //zbGateway.ReportAction += UpdateDeviceControllStatu; //AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); dimmableLight.SwitchControl(0); //控制延时回调 //DeviceUI.SendCommandDelayAction(device.CommonDevice, () => //{ // if (Parent == null) // { // return; // } // RemoveUpdateControlDeviceStatuAction(zbGateway); // if (sendedControlCommand == false) // { // DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); // } //}); } }; var deleteBtn = new Device.CommonForm.RowLayoutDeleteButton { Tag = device, IsMoreLines = true }; if (Room.CurrentRoom.IsLove) { deleteBtn.TextID = R.MyInternationalizationString.CancelCollect; deleteBtn.BackgroundColor = ZigbeeColor.Current.GXCCancelCollectionBGColor; deleteBtn.MouseUpEventHandler += collectionEvent; deviceRowLayout.AddRightView(deleteBtn); } else if (Room.CurrentRoom.IsSharedRoom) { //不处理 lightView.CollectButton.IsSelected = false; } else { deleteBtn.MouseUpEventHandler += delEvent; deviceRowLayout.AddRightView(deleteBtn); lightView.CollectButton.IsSelected = true; } EventHandler<MouseEventArgs> dimmableLightHandler = (sender, e) => lightView.SwitchButton.MouseUpEventHandler += (sender, e) => { (sender as Button).IsSelected = !(sender as Button).IsSelected; if ((sender as Button).IsSelected) { zbGateway = device.CommonDevice.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); dimmableLight.SwitchControl(1); ((sender as Button).Parent as FunctionMainView).SetStatuText(CommonFormResouce.GetSwitchStatu(true)); ((sender as Button).Parent as FunctionMainView).IsSelected = true; //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => { if (Parent == null) { return; } RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } else { zbGateway = device.CommonDevice.Gateway; sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, device.CommonDevice); dimmableLight.SwitchControl(0); ((sender as Button).Parent as FunctionMainView).SetStatuText(CommonFormResouce.GetSwitchStatu(false)); ((sender as Button).Parent as FunctionMainView).IsSelected = false; //控制延时回调 DeviceUI.SendCommandDelayAction(device.CommonDevice, () => { if (Parent == null) { return; } RemoveUpdateControlDeviceStatuAction(zbGateway); if (sendedControlCommand == false) { DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } }; lightView.CardBG.MouseUpEventHandler += (sender, e) => { var dimmableLightControl = new Phone.Device.Light.DimmableLightControl(); UserView.HomePage.Instance.AddChidren(dimmableLightControl); @@ -2631,43 +2281,22 @@ dimmableLightControl.action = RefreshBodyView; dimmableLightControl.Show(device, Room.CurrentRoom); }; //deviceItemFL.MouseLongEventHandler += dimmableLightHandler; deviceItemFL.MouseUpEventHandler += dimmableLightHandler; deviceName.MouseUpEventHandler += dimmableLightHandler; deviceIMG.MouseUpEventHandler += dimmableLightHandler; //collectionBtn.MouseUpEventHandler += (sender, e) => //{ // if (collectionBtn.IsSelected) // { // Room.Lists[0].DeleteDevice(device.FilePath); // collectionBtn.IsSelected = false; // if(Room.CurrentRoom==Room.Lists[0]) // { // RefreshBodyView(); // } // } // else // { // Room.Lists[0].AddDevice(device.FilePath); // collectionBtn.IsSelected = true; // } // //RefreshBodyView(); //}; collectionBtn.MouseUpEventHandler += collectionEvent; //var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FilePath); //if (dev == null) //{ // collectionBtn.IsSelected = false; //} //else //{ // collectionBtn.IsSelected = true; //} lightView.CollectButton.MouseUpEventHandler += collectionEvent; } else if (device.CommonDevice.Type == DeviceType.OnOffSwitch) { var lightView = new FunctionMainView(xx, yy); itemView.AddChidren(lightView); lightView.Init(); lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath); lightView.SetStatuText("开"); lightView.SetDeviceName("按键"); //lightView.SetStatu(true); lightView.IsSelected = true; lightView.SetCollect(true); continue; //按键 var panel = (Panel)device.CommonDevice; @@ -2686,13 +2315,22 @@ /// </summary> private void ShowNoSceneTip() { var noScene = new Button { Y = Application.GetRealHeight(69), Width = Application.GetMinRealAverage(683), Height = Application.GetMinRealAverage(392), Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/NoFunction.png" }; functionSceneBodyView.AddChidren(noScene); var noScenceTip = new Button() { Y=noScene.Bottom, Height = Application.GetRealHeight(200), TextID = R.MyInternationalizationString.NoScene, Text =Language.StringByID(R.MyInternationalizationString.NoScene).Replace("{\\r\\n}","\r\n"), TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center, Gravity = Gravity.Center, IsMoreLines=true }; functionSceneBodyView.AddChidren(noScenceTip); } @@ -2716,81 +2354,66 @@ { var sceneScrolView = new VerticalScrolViewLayout { }; functionSceneBodyView.AddChidren(sceneScrolView); foreach (var scene in sceneList) for(int i=0;i<sceneList.Count;i++) { var scene = sceneList[i]; int xx = 43 + i % 2 * (20 + 487); int yy = 14; if (scene == null) { continue; } var sceneFL = new FrameLayout() if (i % 2 == 0) { Height = Application.GetRealHeight(400), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = scene }; sceneScrolView.AddChidren(sceneFL); var sceneRowLayout = new RowLayout() { Y = Application.GetRealHeight(30), Height = Application.GetRealHeight(400 - 10 - 30), LineColor = ZigbeeColor.Current.GXCBackgroundColor, Radius = CommonPage.BigFormRadius }; sceneFL.AddChidren(sceneRowLayout); var sceneItemFL = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, Radius = CommonPage.BigFormRadius }; sceneRowLayout.AddChidren(sceneItemFL); var sceneImg = new Button() { UnSelectedImagePath = scene.IconPath, Radius = CommonPage.BigFormRadius }; sceneItemFL.AddChidren(sceneImg); var hardBlackBG = new Button() { BackgroundColor = ZigbeeColor.Current.GXCBlack70Color, SelectedBackgroundColor = ZigbeeColor.Current.GXCBlack80Color, Radius = CommonPage.BigFormRadius }; sceneItemFL.AddChidren(hardBlackBG); var sceneNameBtn = new Button() { Text = scene.Name, TextColor = ZigbeeColor.Current.GXCTextWhiteColor, TextSize = 20 }; sceneItemFL.AddChidren(sceneNameBtn); //编辑 var editBtn = new Device.CommonForm.RowLayoutEditButton { TextID = R.MyInternationalizationString.Edit, Tag = scene }; //删除 var deleteBtn = new Device.CommonForm.RowLayoutDeleteButton { Tag = scene }; if (!Room.CurrentRoom.IsSharedRoom) { sceneRowLayout.AddRightView(editBtn); sceneRowLayout.AddRightView(deleteBtn); itemView = new FrameLayout() { Height = Application.GetRealHeight(14 + 348), Tag = scene }; sceneScrolView.AddChidren(itemView); } EventHandler<MouseEventArgs> sceneDownHandler = (sender, e) => var sceneView = new SceneMainView(xx, yy); itemView.AddChidren(sceneView); sceneView.Init(); sceneView.SetSceneNameText(scene.Name); sceneView.SetIcon($"SceneIcon/{i}.png"); sceneView.SetCollect(scene.IsCollected); if (scene.SceneDelayTime == 0) { hardBlackBG.IsSelected = true; sceneView.SetTimeImage(); } else { sceneView.SetTimeText(scene.SceneDelayTime.ToString()); } sceneView.TimeButton.MouseUpEventHandler += (sender, e) => { var timeSelect = new SelectTime(); CommonPage.Instance.AddChidren(timeSelect); timeSelect.TempTime = scene.DelayTime; timeSelect.Init(); timeSelect.TimeAction = (t) => { scene.SceneDelayTime = t; if(t>0) { sceneView.SetTimeText(CommonFormResouce.GetTimeString(scene.SceneDelayTime)); } else { sceneView.SetTimeImage(); } }; }; sceneNameBtn.MouseDownEventHandler += sceneDownHandler; hardBlackBG.MouseDownEventHandler += sceneDownHandler; //调用场景 EventHandler<MouseEventArgs> sceneUpHandler = async (sender, e) => { hardBlackBG.IsSelected = false; //1成功 0失败 //后面补上相关提示 // Error参数含义 @@ -2799,7 +2422,7 @@ //<para>3:操作设备/组/场景不存在</para> //<para>4:其他错误</para> //<para>5:数据传输错误(在某次客户端向网关发送数据的过程中,网关在合理时间范围内接收客户端数据不完整导致该错误发生。如客户端向网关一次发送100个字节的数据,但网关等待接收了一秒只接收了80个字节。发生该错误,网关将主动关闭客户端连接)</para> var sceneOpenAllData = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, 0); var sceneOpenAllData = await ZigBee.Device.Scene.ControlSceneAsync(scene.Id, scene.SceneDelayTime); if (sceneOpenAllData == null || sceneOpenAllData.sceneOpenData == null) { return; @@ -2813,54 +2436,32 @@ CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.ControlSceneFail); } }; sceneNameBtn.MouseUpEventHandler += sceneUpHandler; hardBlackBG.MouseUpEventHandler += sceneUpHandler; //编辑场景 EventHandler<MouseEventArgs> editEvent = (sender, e) => //收藏 EventHandler<MouseEventArgs> collectionEvent = (sender, e) => { SceneRoomUI.EditScene(scene, Room.CurrentRoom); }; editBtn.MouseUpEventHandler += editEvent; //删除场景 EventHandler<MouseEventArgs> delEvent = (sender, e) => { var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ConfirmDelete), Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); alert.Show(); alert.ResultEventHandler += async (send1, e1) => if ((sender as Button).IsSelected) { if (e1) { //0 移除失败 1 移除成功 2 没有该场景 var removeSceneAllData = await ZigBee.Device.Scene.DeleteSceneAsync(scene.Id); if (removeSceneAllData == null || removeSceneAllData.removeSceneData == null) { return; } if (removeSceneAllData.removeSceneData.Result == 1) { //1成功 Room.CurrentRoom.RemoveScene(scene); //RefreshBodyView(); sceneScrolView.RemoveViewByTag((sender as Button).Tag); } else if (removeSceneAllData.removeSceneData.Result == 0) { //0 移除失败 CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.DeleteSceneFail); } else if (removeSceneAllData.removeSceneData.Result == 2) { //2 没有该场景 Room.CurrentRoom.RemoveScene(scene); //RefreshBodyView(); sceneScrolView.RemoveViewByTag((sender as Button).Tag); } } }; scene.Collect(false); (sender as Button).IsSelected = false; } else { scene.Collect(true); (sender as Button).IsSelected = true; } scene.Save(); //if (Room.CurrentRoom.IsLove) //{ // RefreshBodyView(); //} }; deleteBtn.MouseUpEventHandler += delEvent; sceneView.CollectButton.MouseUpEventHandler += collectionEvent; sceneView.MouseUpEventHandler += sceneUpHandler; sceneView.SceneIcon.MouseUpEventHandler+= sceneUpHandler; sceneView.SceneNameButton.MouseUpEventHandler += sceneUpHandler; } } ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
@@ -167,10 +167,7 @@ /// 账户登录成功的主ID /// </summary> public int MasterID = 0; /// <summary> /// 用户ID /// </summary> public int UserID = 0; public static void ReFresh() { ZigbeeApp/Shared/R.cs
@@ -161,7 +161,6 @@ public readonly static int ProximithCardUnlock = 86; public readonly static int AllDate = 87; public readonly static int SmartDoorLock = 88; public readonly static int Current = 89; public readonly static int ClearTempPassword = 90; //面板绑定开始 @@ -684,7 +683,7 @@ /// </summary> public const int Cancel = 11023; /// <summary> /// 没有场景 \n 请点击右上角添加 /// 没有场景 {\r\n} 请点击右上角添加 /// </summary> public const int NoScene = 11024; /// <summary> @@ -727,8 +726,6 @@ #endregion #region 主页 /// <summary> @@ -752,9 +749,60 @@ /// 添加智能网关 /// </summary> public const int AddSmartGW = 13104; /// <summary> /// 编辑房间 /// </summary> public const int EditRoom = 13105; /// <summary> /// 房间名称 /// </summary> public const int RoomName = 13106; /// <summary> /// 所属楼层 /// </summary> public const int BelongFloor = 13107; /// <summary> /// 温度 /// </summary> public const int Temperature = 13108; /// <summary> /// 湿度 /// </summary> public const int Humidity = 13109; /// <summary> /// 当前 /// </summary> public const int Current = 13110; /// <summary> /// 开 /// </summary> public const int Open = 13111; /// <summary> /// 关 /// </summary> public const int Close = 13112; /// <summary> /// 不开启 /// </summary> public const int NotOpen = 13113; /// <summary> /// 秒 /// </summary> public static readonly int Second = 13114; /// <summary> /// 分钟 /// </summary> public static readonly int Minute = 13115; /// <summary> /// 小时 /// </summary> public static readonly int Hour = 13116; #endregion /// <summary> @@ -826,7 +874,7 @@ public static readonly int Logining = 11024; public static readonly int AddRoom = 11026; public static readonly int RoomName = 11027; public static readonly int SettingContent = 11031; @@ -838,7 +886,7 @@ public static readonly int HadSameRoom = 11037; //*****public static readonly int Function = 11038; public static readonly int EditRoom = 11040; public static readonly int Delete = 11041; public static readonly int AddFunction = 11042; @@ -856,7 +904,7 @@ public static readonly int DeviceSetting = 11055; public static readonly int AddDeviceSuccess = 11058; public static readonly int Close = 11059; public static readonly int Device = 11060; public static readonly int ConfirmDeleteThisRoom = 11062; @@ -871,7 +919,7 @@ public static readonly int NextStep = 11071; public static readonly int SelectRoom = 11072; public static readonly int SelectDevice = 11073; public static readonly int Open = 11074; /// <summary> /// 调光 /// </summary> @@ -923,14 +971,7 @@ public static readonly int TimeSpan = 11093; public static readonly int TheSceneHadExist = 11094; public static readonly int AddSceneFail = 11095; /// <summary> /// 秒 /// </summary> public static readonly int Second = 11096; /// <summary> /// 分钟 /// </summary> public static readonly int Minute = 11097; /// <summary> /// 自定义 /// </summary> ZigbeeApp/Shared/Shared.projitems
@@ -42,6 +42,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\ACLeftIconButtonRowLayout.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\BackButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\ButtonLineForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\CommonEnum.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\CommonFormResouce.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\CompleteButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\CustomAlert.cs" /> @@ -49,14 +50,19 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\DeviceIconSelectedIMGByLocal.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\DeviceInfoEditRow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\DeviceInfoRow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\DeviceInfoWithZoneRow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\FunctionButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\FunctionIconButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\FunctionMainView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\FunctionRow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\LeftIconButtonRow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\Line.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\RoomMainView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\RowLayoutDeleteButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\RowLayoutEditButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SceneMainView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SelectedStatuButton.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\SelectTime.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\CommonForm\TopFrameLayout.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Light\DimmableLightControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\AddLogicPage.cs" /> @@ -84,7 +90,11 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\TimePage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\TimePoint.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Logic\WeekPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Room\EditRoom.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Room\RoomCommon.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Room\RoomHumiditySetting.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Room\RoomShareSetting.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\Device\Room\RoomTemperatureSetting.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Abount\AbountForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\BelongAreaControl.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\InformationEditorControl.cs" />