From ed2f4a97aa48cdb4a013d2a389877f52eb3eccdf Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 29 十月 2019 13:15:59 +0800 Subject: [PATCH] Merge branch 'DEV_GXC' of http://172.16.1.23:6688/r/~xm/HomeApp into DEV_GXC --- ZigbeeApp/Shared/Phone/Device/Logic/SetDeviceState.cs | 681 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 681 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/SetDeviceState.cs b/ZigbeeApp/Shared/Phone/Device/Logic/SetDeviceState.cs new file mode 100755 index 0000000..bd9932d --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/SetDeviceState.cs @@ -0,0 +1,681 @@ +锘縰sing System; +using System.Collections.Generic; +using Shared; +using Shared.R; +using Shared.Phone; +using ZigBee.Device; +using Shared.Common; + +namespace Shared.Phone.Device.Logic +{ + public class SetDeviceState:FrameLayout + { + public SetDeviceState() + { + Tag = "Logic"; + } + Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); + List<Dictionary<string, string>> taskListInfo = new List<Dictionary<string, string>>(); + public void Show (CommonDevice common,string topText,bool edit) + { + this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor; + UserView.HomePage.Instance.ScrollEnabled = false; + var topFrameLayout = new FrameLayout + { + Height = Application.GetRealHeight(140), + Y = Application.GetRealHeight(80), + }; + AddChidren(topFrameLayout); + + var titleName = new Button { + Text =topText, + //TextID = MyInternationalizationString.adddevice, + TextSize = 17, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealWidth(150), + }; + topFrameLayout.AddChidren (titleName); + + var back = new Button { + Width = Application.GetRealWidth (110), + Height = Application.GetRealHeight (110), + X = Application.GetRealWidth (20), + Gravity = Gravity.CenterVertical, + UnSelectedImagePath = "ZigeeLogic/Back.png", + }; + topFrameLayout.AddChidren (back); + back.MouseDownEventHandler += (sender, e) => { + RemoveFromParent (); + UserView.HomePage.Instance.ScrollEnabled = true; + }; + + + var middle = new FrameLayout (); + middle.Y = topFrameLayout.Bottom; + middle.Height = Application.GetRealHeight (1920 - 220); + middle.BackgroundColor =ZigbeeColor.Current.LogicBackgroundColor; + this.AddChidren (middle); + + var bjframelayout = new FrameLayout + { + X = Application.GetRealWidth(50), + Width = Application.GetRealWidth(1080 - 100), + Height = Application.GetRealHeight(1300), + Y=Application.GetRealHeight(50), + BackgroundColor= ZigbeeColor.Current.LogicTopViewBackgroundColor, + }; + middle.AddChidren(bjframelayout); + + List<Dictionary<string,string>> TaskList = null; + foreach (var deviceinfo in Common.Logic.CurrentLogic.Actions) + { + if (deviceinfo["LinkType"].ToString() == "0") + { + + if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr &&deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString()) + { + TaskList = deviceinfo["TaskList"] as List<Dictionary<string, string>>; + break; + } + } + } + string SelectedDeviceStatus = "no"; + + if (actionsInfo.ContainsKey("LinkType")) + { + actionsInfo.Remove("LinkType"); + } + if (actionsInfo.ContainsKey("DeviceAddr")) + { + actionsInfo.Remove("DeviceAddr"); + } + if (actionsInfo.ContainsKey("Epoint")) + { + actionsInfo.Remove("Epoint"); + } + if (actionsInfo.ContainsKey("Time")) + { + actionsInfo.Remove("Time"); + } + if (actionsInfo.ContainsKey("TaskList")) + { + actionsInfo.Remove("TaskList"); + } + actionsInfo.Add("LinkType", 0); + actionsInfo.Add("DeviceAddr", common.DeviceAddr); + actionsInfo.Add("Epoint", common.DeviceEpoint); + actionsInfo.Add("Time", 0); + actionsInfo.Add("TaskList", taskListInfo); + switch (common.Type) + { + case DeviceType.DimmableLight: + { + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + //Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + //if (switchdictionary.ContainsKey("TaskType")) + //{ + // switchdictionary.Remove("TaskType"); + //} + //if (switchdictionary.ContainsKey("Data1")) + //{ + // switchdictionary.Remove("Data1"); + //} + //if (switchdictionary.ContainsKey("Data2")) + //{ + // switchdictionary.Remove("Data2"); + //} + //switchdictionary.Add("TaskType", "1"); + //switchdictionary.Add("Data1", "0"); + //switchdictionary.Add("Data2", "0"); + //taskListInfo.Add(switchdictionary); + Dictionary<string, string> brightnessdictionary = new Dictionary<string, string>(); + if (brightnessdictionary.ContainsKey("TaskType")) + { + brightnessdictionary.Remove("TaskType"); + } + if (brightnessdictionary.ContainsKey("Data1")) + { + brightnessdictionary.Remove("Data1"); + } + if (brightnessdictionary.ContainsKey("Data2")) + { + brightnessdictionary.Remove("Data2"); + } + brightnessdictionary.Add("TaskType", "3"); + brightnessdictionary.Add("Data1", "0"); + brightnessdictionary.Add("Data2", "0"); + taskListInfo.Add(brightnessdictionary); + #endregion + + #region 鐏厜View + var Btndevicename = new Button + { + Text = common.DeviceEpointName, + Y = Application.GetRealHeight(150), + X = Application.GetRealWidth(190), + Width = Application.GetRealWidth(600), + Height = Application.GetRealHeight(150), + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextSize = 16, + TextAlignment = TextAlignment.Center, + }; + bjframelayout.AddChidren(Btndevicename); + + + var Btniocn = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Light.png", + X = Application.GetRealWidth(440), + Y = Btndevicename.Bottom + Application.GetRealHeight(100), + }; + bjframelayout.AddChidren(Btniocn); + + var Btnvelue = new Button + { + Width = Application.GetRealWidth(200), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(390), + Y = Btniocn.Bottom + Application.GetRealHeight(100), + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + Text = "0%", + }; + bjframelayout.AddChidren(Btnvelue); + + var horizontalSeekBarVolframelayout = new FrameLayout + { + Y = Btnvelue.Bottom, + Width = Application.GetRealWidth(880), + Height = Application.GetRealHeight(80), + X = Application.GetRealWidth(50), + }; + bjframelayout.AddChidren(horizontalSeekBarVolframelayout); + + + var horizontalSeekBarVol = new HorizontalSeekBar + { + Width = Application.GetRealWidth(880 - 50), + Height = Application.GetRealHeight(80), + Radius = (uint)Application.GetRealHeight(25), + X = Application.GetRealWidth(25), + Gravity = Gravity.CenterVertical, + ProgressColor = 0xffFE5E00, + Max = 100, + SleepTime = 1000, + ThumbRadius = 9, + //IsCanClick=false + }; + horizontalSeekBarVolframelayout.AddChidren(horizontalSeekBarVol); + + + var Btnswitch = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Light.png", + SelectedImagePath = "Room/LightSelected.png", + X = Application.GetRealWidth(440), + Y = horizontalSeekBarVolframelayout.Bottom + Application.GetRealHeight(80), + }; + //bjframelayout.AddChidren(Btnswitch); + + var textfl = new FrameLayout + { + Width = Application.GetRealWidth(980), + Height = Application.GetRealHeight(160), + BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor, + Y = Application.GetRealHeight(1300 - 160), + }; + bjframelayout.AddChidren(textfl); + + var Btnregioniocn = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Light.png", + X = Application.GetRealWidth(40), + Y = Application.GetRealHeight(25), + }; + textfl.AddChidren(Btnregioniocn); + + var Btnregionname = new Button + { + Width = Application.GetRealWidth(600), + Height = Application.GetRealHeight(110), + X = Application.GetRealWidth(150 + 30), + TextAlignment = TextAlignment.CenterLeft, + Text ="", + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + Y = Application.GetRealHeight(25), + }; + textfl.AddChidren(Btnregionname); + Send.RoomNmae(Btnregionname,common); + #endregion + horizontalSeekBarVol.ProgressChanged += (sender, e) => + { + SelectedDeviceStatus = "selected"; + Btnvelue.Text = horizontalSeekBarVol.Progress.ToString() + "%"; + + if (brightnessdictionary.ContainsKey("Data1")) + { + brightnessdictionary.Remove("Data1"); + } + var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;//鏈�澶т寒搴﹀�兼槸254闇�瑕佽浆鎹紱 + brightnessdictionary.Add("Data1", lightbrightnessvalue.ToString()); + //var dd = (lightbrightnessvalue * 100)/254+1; + }; + + Btnswitch.MouseUpEventHandler += (sender, e) => + { + SelectedDeviceStatus = "selected"; + Btnswitch.IsSelected = !Btnswitch.IsSelected; + + //if (switchdictionary.ContainsKey("Data1")) + //{ + // switchdictionary.Remove("Data1"); + //} + //if (Btnswitch.IsSelected) + //{ + // switchdictionary.Add("Data1", "1"); + //} + //else + //{ + // switchdictionary.Add("Data1", "0"); + //} + }; + + if (edit&&TaskList!=null) + { + foreach (var value in TaskList) + { + if (value["TaskType"] == "1") + { + //if (switchdictionary.ContainsKey("Data1")) + //{ + // switchdictionary.Remove("Data1"); + //} + //if (value["Data1"] == "1") + //{ + // switchdictionary.Add("Data1", "1"); + // Btnswitch.IsSelected = true; + //} + //else + //{ + // switchdictionary.Add("Data1", "0"); + // Btnswitch.IsSelected = false; + //} + } + else if (value["TaskType"] == "3") + { + if (brightnessdictionary.ContainsKey("Data1")) + { + brightnessdictionary.Remove("Data1"); + } + var intvalue = int.Parse(value["Data1"]); + brightnessdictionary.Add("Data1", intvalue.ToString()); + var lightbrightnessvalue = (intvalue * 100) / 254; + Btnvelue.Text = lightbrightnessvalue.ToString() + "%"; + horizontalSeekBarVol.Progress = lightbrightnessvalue; + + } + } + } + + } + break; + case DeviceType.WindowCoveringDevice: + { + #region ----鍒濆鍖栬澶囧姛鑳芥暟鎹�---- + //Dictionary<string, string> switchdictionary = new Dictionary<string, string>(); + //if (switchdictionary.ContainsKey("TaskType")) + //{ + // switchdictionary.Remove("TaskType"); + //} + //if (switchdictionary.ContainsKey("Data1")) + //{ + // switchdictionary.Remove("Data1"); + //} + //if (switchdictionary.ContainsKey("Data2")) + //{ + // switchdictionary.Remove("Data2"); + //} + //switchdictionary.Add("TaskType", "6"); + //switchdictionary.Add("Data1", "1"); + //switchdictionary.Add("Data2", "0"); + //taskListInfo.Add(switchdictionary); + + Dictionary<string, string> brightnessdictionary = new Dictionary<string, string>(); + if (brightnessdictionary.ContainsKey("TaskType")) + { + brightnessdictionary.Remove("TaskType"); + } + if (brightnessdictionary.ContainsKey("Data2")) + { + brightnessdictionary.Remove("Data2"); + } + if (brightnessdictionary.ContainsKey("Data1")) + { + brightnessdictionary.Remove("Data1"); + } + brightnessdictionary.Add("TaskType", "6"); + brightnessdictionary.Add("Data1", "5"); + brightnessdictionary.Add("Data2", "0"); + taskListInfo.Add(brightnessdictionary); + #endregion + + #region 绐楀笜View + + var Btndevicename = new Button + { + Text = common.DeviceEpointName, + Y = Application.GetRealHeight(150), + X = Application.GetRealWidth(190), + Width = Application.GetRealWidth(600), + Height = Application.GetRealHeight(150), + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextSize = 16, + TextAlignment = TextAlignment.Center, + }; + bjframelayout.AddChidren(Btndevicename); + + + var Btniocn = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Curtain.png", + X = Application.GetRealWidth(440), + Y = Btndevicename.Bottom + Application.GetRealHeight(100), + }; + bjframelayout.AddChidren(Btniocn); + + var Btnvelue = new Button + { + Width = Application.GetRealWidth(200), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(390), + Y = Btniocn.Bottom + Application.GetRealHeight(100), + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + Text = "0%", + }; + bjframelayout.AddChidren(Btnvelue); + + var horizontalSeekBarVolframelayout = new FrameLayout + { + Y = Btnvelue.Bottom, + Width = Application.GetRealWidth(880), + Height = Application.GetRealHeight(80), + X = Application.GetRealWidth(50), + }; + bjframelayout.AddChidren(horizontalSeekBarVolframelayout); + + + var horizontalSeekBarVol = new HorizontalSeekBar + { + Width = Application.GetRealWidth(880 - 50), + Height = Application.GetRealHeight(80), + Radius = (uint)Application.GetRealHeight(25), + X = Application.GetRealWidth(25), + Gravity = Gravity.CenterVertical, + ProgressColor = 0xffFE5E00, + Max = 100, + SleepTime = 1000, + ThumbRadius = 9, + //IsCanClick=false + }; + horizontalSeekBarVolframelayout.AddChidren(horizontalSeekBarVol); + + + var Btnswitch = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Curtain.png", + SelectedImagePath = "Room/CurtainSelected.png", + X = Application.GetRealWidth(440), + Y = horizontalSeekBarVolframelayout.Bottom + Application.GetRealHeight(80), + }; + //bjframelayout.AddChidren(Btnswitch); + + var textfl = new FrameLayout + { + Width = Application.GetRealWidth(980), + Height = Application.GetRealHeight(160), + BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor, + Y = Application.GetRealHeight(1300 - 160), + }; + bjframelayout.AddChidren(textfl); + + var Btnregioniocn = new Button + { + Width = Application.GetRealWidth(110), + Height = Application.GetRealHeight(110), + UnSelectedImagePath = "Room/Curtain.png", + X = Application.GetRealWidth(40), + Y = Application.GetRealHeight(25), + }; + textfl.AddChidren(Btnregioniocn); + + var Btnregionname = new Button + { + Width = Application.GetRealWidth(600), + Height = Application.GetRealHeight(110), + X = Application.GetRealWidth(150 + 30), + TextAlignment = TextAlignment.CenterLeft, + Text ="", + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + Y = Application.GetRealHeight(25), + }; + textfl.AddChidren(Btnregionname); + Send.RoomNmae(Btnregionname,common); + #endregion + + horizontalSeekBarVol.ProgressChanged += (sender, e) => + { + SelectedDeviceStatus = "selected"; + Btnvelue.Text = horizontalSeekBarVol.Progress.ToString() + "%"; + if (brightnessdictionary.ContainsKey("Data1")) + { + brightnessdictionary.Remove("Data1"); + } + brightnessdictionary.Add("Data1", "5"); + if (brightnessdictionary.ContainsKey("Data2")) + { + brightnessdictionary.Remove("Data2"); + } + brightnessdictionary.Add("Data2", horizontalSeekBarVol.Progress.ToString()); + + + }; + + Btnswitch.MouseUpEventHandler += (sender, e) => + { + SelectedDeviceStatus = "selected"; + Btnswitch.IsSelected = !Btnswitch.IsSelected; + //if (switchdictionary.ContainsKey("Data1")) + //{ + // switchdictionary.Remove("Data1"); + //} + //if (Btnswitch.IsSelected) + //{ + // switchdictionary.Add("Data1", "0"); + //} + //else + //{ + // switchdictionary.Add("Data1", "1"); + //} + }; + + + if (edit && TaskList != null) + { + foreach (var value in TaskList) + { + if (value["TaskType"] == "6") + { + if (value["Data1"] == "5") + { + if (brightnessdictionary.ContainsKey("Data2")) + { + brightnessdictionary.Remove("Data2"); + } + var lightbrightnessvalue = int.Parse(value["Data2"]); + brightnessdictionary.Add("Data2", lightbrightnessvalue.ToString()); + Btnvelue.Text = lightbrightnessvalue.ToString() + "%"; + horizontalSeekBarVol.Progress = lightbrightnessvalue; + } + } + + } + } + + /* + if (edit && TaskList != null) + { + foreach (var value in TaskList) + { + if (value["TaskType"] == "6") + { + + if (value["Data1"] == "0") + { + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "0"); + Btnswitch.IsSelected = true; + } + else if (value["Data1"] == "1") + { + if (switchdictionary.ContainsKey("Data1")) + { + switchdictionary.Remove("Data1"); + } + switchdictionary.Add("Data1", "1"); + Btnswitch.IsSelected = false; + } + else if (value["Data1"] == "5") + { + if (brightnessdictionary.ContainsKey("Data2")) + { + brightnessdictionary.Remove("Data2"); + } + var lightbrightnessvalue = int.Parse(value["Data2"]); + brightnessdictionary.Add("Data2", lightbrightnessvalue.ToString()); + Btnvelue.Text = lightbrightnessvalue.ToString() + "%"; + horizontalSeekBarVol.Progress = lightbrightnessvalue; + } + } + + } + } + */ + + } + break; + + } + var btnsave = new Button + { + Height = Application.GetRealHeight(150),//194 + Y = bjframelayout.Bottom+Application.GetRealHeight(100), + //Text = "淇濆瓨", + Width = Application.GetRealWidth(500), + Radius = (uint)Application.GetRealHeight(50), + BackgroundColor = ZigbeeColor.Current.LogicButtonBlueColor, + X = Application.GetRealWidth(290), + TextID=MyInternationalizationString.Save, + }; + middle.AddChidren(btnsave); + btnsave.MouseUpEventHandler += (sedder, e) => { + if (SelectedDeviceStatus == "selected") + { + LogicIfon.AddDeviceactions(common,actionsInfo); + } + else + { + if (!edit) + { + var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt), + Language.StringByID(MyInternationalizationString.selectdevicestatuscondition), + Language.StringByID(MyInternationalizationString.complete)); + + alert.Show(); + return; + } + edit = false; + } + this.RemoveFromParent (); + var logicCommunalPage = new LogicCommunalPage (); + UserView.HomePage.Instance.AddChidren (logicCommunalPage); + UserView.HomePage.Instance.PageIndex += 1; + logicCommunalPage.Show (()=>{}); + }; + + } + + void FreshAirReadupdateModeImage (int mode, Button btn,Button btn1) + { + ///鏂伴:mode:(0:鏅鸿兘锛�1:鏂伴锛�2:鍐呭惊鐜紝3:鎭掓俯) + switch (mode) { + case 0: + btn.UnSelectedImagePath = "FreshAir/FASmart.png"; + btn1.UnSelectedImagePath = "FreshAir/FASmart.png"; + break; + case 1: + btn.UnSelectedImagePath = "FreshAir/FAManual.png"; + btn1.UnSelectedImagePath = "FreshAir/FAManual.png"; + break; + case 2: + btn.UnSelectedImagePath = "FreshAir/FAInternalCirculation.png"; + btn1.UnSelectedImagePath = "FreshAir/FAInternalCirculation.png"; + break; + case 3: + btn.UnSelectedImagePath = "FreshAir/FAConstantTemp.png"; + btn1.UnSelectedImagePath = "FreshAir/FAConstantTemp.png"; + break; + default: + btn.UnSelectedImagePath = "FreshAir/FASmart.png"; + btn1.UnSelectedImagePath = "FreshAir/FASmart.png"; + break; + } + } + + void ACupdateModeImage (int mode, Button btn,Button btn1) + { + ///绌鸿皟:mode:(0锛氬埗鍐凤紝1锛氬埗鐑紝2锛氶�氶锛�3锛氳嚜鍔紝4锛氭娊婀�) + switch (mode) { + case 0: + btn.UnSelectedImagePath = "AC/ACRefrigeration.png"; + btn1.UnSelectedImagePath = "AC/ACRefrigeration.png"; + break; + case 1: + btn.UnSelectedImagePath = "AC/ACHeating.png"; + btn1.UnSelectedImagePath = "AC/ACHeating.png"; + break; + case 2: + btn.UnSelectedImagePath = "AC/ACModeAuto.png"; + btn1.UnSelectedImagePath = "AC/ACModeAuto.png"; + break; + case 3: + btn.UnSelectedImagePath = "AC/ACAuto.png"; + btn1.UnSelectedImagePath = "AC/ACAuto.png"; + break; + case 4: + btn.UnSelectedImagePath = "AC/ACDehumidification.png"; + btn1.UnSelectedImagePath = "AC/ACDehumidification.png"; + break; + default: + btn.UnSelectedImagePath = "AC/ACRefrigeration.png"; + btn1.UnSelectedImagePath = "AC/ACRefrigeration.png"; + break; + } + } + + } +} -- Gitblit v1.8.0