using 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 actionsInfo = new Dictionary(); List> taskListInfo = new List>(); 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, }; 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> 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>; 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.ColorDimmableLight: { #region ----初始化设备功能数据---- //Dictionary switchdictionary = new Dictionary(); //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 brightnessdictionary = new Dictionary(); 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 + 1; Btnvelue.Text = lightbrightnessvalue.ToString() + "%"; horizontalSeekBarVol.Progress = lightbrightnessvalue; } } } } break; case DeviceType.WindowCoveringDevice: { #region ----初始化设备功能数据---- //Dictionary switchdictionary = new Dictionary(); //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 brightnessdictionary = new Dictionary(); 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; } } } }