New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | using Shared.Common; |
| | | using Shared.Phone; |
| | | using Shared.R; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Logic |
| | | { |
| | | public class AddScenePage : FrameLayout |
| | | { |
| | | |
| | | public AddScenePage() |
| | | { |
| | | Tag = "Logic"; |
| | | } |
| | | |
| | | ///房间滑动控件 |
| | | public HorizontalScrolViewLayout roomhorizontalScrol = new HorizontalScrolViewLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080 - 58), |
| | | Height = Application.GetRealHeight(200), |
| | | Y = Application.GetRealHeight(184), |
| | | X = Application.GetRealWidth(58), |
| | | }; |
| | | public VerticalScrolViewLayout middle = new VerticalScrolViewLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(Method.H - 260 - 200 - 184), |
| | | BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | }; |
| | | |
| | | Button roombjButton = new Button(); |
| | | Button roomTextButton = new Button(); |
| | | Button clickbutton = new Button(); |
| | | public string clickTag = "no"; |
| | | public SceneUI tempScene = null; |
| | | Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); |
| | | public void Show(string sceneType) |
| | | { |
| | | #region 上面的布局代码 |
| | | UserView.HomePage.Instance.ScrollEnabled = false; |
| | | this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; |
| | | TopView view = new TopView(); |
| | | this.AddChidren(view.TopRowView(true)); |
| | | view.toptitleNameBtn.TextID =MyInternationalizationString.addscene; |
| | | view.clickBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | UserView.HomePage.Instance.ScrollEnabled = true; |
| | | RemoveFromParent(); |
| | | }; |
| | | view.foolrnameBtn.Text = Config.Instance.Home.GetCurrentFloorName; |
| | | if (Config.Instance.Home.FloorDics.Count < 2) |
| | | { |
| | | ///没有楼层或者只有一个楼层,默认不显示图标和文本; |
| | | view.foolrnameBtn.Visible = false; |
| | | view.dropdownBtn.Visible = false; |
| | | view.foolrclickBtn.Visible = false; |
| | | } |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | { |
| | | Config.Instance.Home.CurrentFloorId = ""; |
| | | } |
| | | #endregion |
| | | |
| | | ///没有房间直接返回去; |
| | | var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); |
| | | if (listAllRoom.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | this.AddChidren(roomhorizontalScrol); |
| | | middle.Y = roomhorizontalScrol.Bottom; |
| | | this.AddChidren(middle); |
| | | LogicView.SaveView saveView = new LogicView.SaveView(); |
| | | saveView.frameLayout.Y = middle.Bottom; |
| | | this.AddChidren(saveView.Show()); |
| | | saveView.clickviewBtn.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | if (clickTag == "no" || tempScene == null) |
| | | { |
| | | var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, |
| | | Language.StringByID(MyInternationalizationString.scenetip), |
| | | Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.Show(); |
| | | return; |
| | | } |
| | | if (actionsInfo.ContainsKey("LinkType")) |
| | | { |
| | | actionsInfo.Remove("LinkType"); |
| | | } |
| | | actionsInfo.Add("LinkType", 2); |
| | | LogicIfon.AddSceneactions(tempScene, actionsInfo); |
| | | if (sceneType ==LogicView.IfString.Action_LogicScene) |
| | | { |
| | | //自动化场景 |
| | | var logicCommunalPage = new LogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(logicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | logicCommunalPage.Show(() => { }); |
| | | } |
| | | else { |
| | | //门锁场景 |
| | | var lockLogicCommunalPage = new DoorLockLogic.LockLogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | lockLogicCommunalPage.Show(() => { }); |
| | | } |
| | | |
| | | }; |
| | | |
| | | ///楼层点击事件 |
| | | view.foolrclickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | flMain.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | }; |
| | | var foolrbjicon = new FrameLayout |
| | | { |
| | | |
| | | Width = Application.GetRealWidth(450), |
| | | Height = Application.GetRealHeight(780), |
| | | X = Application.GetRealWidth(1080 - 468 - 35), |
| | | Y = Application.GetRealHeight(184), |
| | | BackgroundImagePath = "Item/SelectFloor_Right.png", |
| | | }; |
| | | flMain.AddChidren(foolrbjicon); |
| | | |
| | | var btnfoolrtext = new Button |
| | | { |
| | | Width = Application.GetRealWidth(450), |
| | | Height = Application.GetRealHeight(150), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | X = Application.GetRealWidth(80), |
| | | TextID = MyInternationalizationString.selecfoolr, |
| | | TextSize = 14, |
| | | }; |
| | | foolrbjicon.AddChidren(btnfoolrtext); |
| | | |
| | | var foolrbj = new VerticalScrolViewLayout |
| | | { |
| | | |
| | | Width = Application.GetRealWidth(450), |
| | | Height = foolrbjicon.Height - btnfoolrtext.Height, |
| | | X = Application.GetRealWidth(80), |
| | | Y = btnfoolrtext.Bottom, |
| | | }; |
| | | foolrbjicon.AddChidren(foolrbj); |
| | | |
| | | foreach (var foolr in Config.Instance.Home.FloorDics) |
| | | { |
| | | var foolrRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | }; |
| | | foolrbj.AddChidren(foolrRowLayout); |
| | | |
| | | var btnfoolricon = new Button |
| | | { |
| | | Width = Application.GetMinRealAverage(81), |
| | | Height = Application.GetMinRealAverage(81), |
| | | UnSelectedImagePath = "Floor/Floor.png", |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | foolrRowLayout.AddChidren(btnfoolricon); |
| | | |
| | | |
| | | var btnfoolrname = new Button |
| | | { |
| | | Width = Application.GetRealWidth(250), |
| | | Height = Application.GetRealHeight(150), |
| | | Text = foolr.Value, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | Tag = foolr.Key, |
| | | X = btnfoolricon.Right + Application.GetRealWidth(12), |
| | | TextSize = 14, |
| | | }; |
| | | foolrRowLayout.AddChidren(btnfoolrname); |
| | | if (view.foolrnameBtn.Text == foolr.Value) |
| | | { |
| | | btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png"; |
| | | btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor; |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) => |
| | | { |
| | | roomhorizontalScrol.RemoveAll(); |
| | | view.foolrnameBtn.Text = btnfoolrname.Text; |
| | | middle.RemoveAll(); |
| | | flMain.RemoveFromParent(); |
| | | var list = Method.GetRoomList(sceneType, btnfoolrname.Tag.ToString()); |
| | | AllRoomView(list); |
| | | |
| | | }; |
| | | foolrRowLayout.MouseUpEventHandler += foolrnameclick; |
| | | btnfoolrname.MouseUpEventHandler += foolrnameclick; |
| | | |
| | | |
| | | } |
| | | |
| | | }; |
| | | ///房间列表 |
| | | var roomlists = Method.GetRoomList(sceneType, Config.Instance.Home.CurrentFloorId); |
| | | if (roomlists.Count == 0) |
| | | { |
| | | ///没有房间直接返回去; |
| | | return; |
| | | } |
| | | ///第一次进来 |
| | | AllRoomView(roomlists); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 显示所有房间的方法 |
| | | /// </summary> |
| | | /// <param name="RoomList"></param> |
| | | void AllRoomView(List<Common.Room> RoomList ) { |
| | | for (int i = 0; i < RoomList.Count; i++) |
| | | { |
| | | var room = RoomList[i]; |
| | | var fra = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(200), |
| | | Width = Application.GetRealWidth(255), |
| | | }; |
| | | roomhorizontalScrol.AddChidren(fra); |
| | | |
| | | var roombjBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(158), |
| | | Width = Application.GetRealWidth(255), |
| | | UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png", |
| | | SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png", |
| | | Y = Application.GetRealHeight(21), |
| | | }; |
| | | fra.AddChidren(roombjBtn); |
| | | |
| | | var roomnameBtn = new Button |
| | | { |
| | | |
| | | Height = Application.GetRealHeight(152 - 26 - 20), |
| | | Width = Application.GetRealWidth(255 - 20 - 50), |
| | | Text = room.Name, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, |
| | | Y = Application.GetRealHeight(21 + 13 + 10), |
| | | X = Application.GetRealWidth(10 + 25), |
| | | |
| | | }; |
| | | fra.AddChidren(roomnameBtn); |
| | | |
| | | if (i == 0) |
| | | { |
| | | roombjButton.IsSelected = false; |
| | | roombjButton = roombjBtn; |
| | | roombjBtn.IsSelected = true; |
| | | |
| | | roomTextButton.IsSelected = false; |
| | | roomTextButton = roomnameBtn; |
| | | roomnameBtn.IsSelected = true; |
| | | SceneView(room.ListSceneId); |
| | | |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> roomclick = (sender, e) => |
| | | { |
| | | clickTag = "no"; |
| | | tempScene = null; |
| | | clickbutton = null; |
| | | clickbutton = new Button(); |
| | | |
| | | roombjButton.IsSelected = false; |
| | | roombjButton = roombjBtn; |
| | | roombjBtn.IsSelected = true; |
| | | |
| | | roomTextButton.IsSelected = false; |
| | | roomTextButton = roomnameBtn; |
| | | roomnameBtn.IsSelected = true; |
| | | SceneView(room.ListSceneId); |
| | | }; |
| | | roomnameBtn.MouseUpEventHandler += roomclick; |
| | | roombjBtn.MouseUpEventHandler += roomclick; |
| | | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 显示所有的场景的方法 |
| | | /// </summary> |
| | | /// <param name="scenelist"></param> |
| | | void SceneView(List<int>scenelist) |
| | | { |
| | | middle.RemoveAll(); |
| | | foreach (var sceneId in scenelist) |
| | | { |
| | | var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); |
| | | if (scene == null) |
| | | { |
| | | continue; |
| | | } |
| | | var sceneFramelayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | middle.AddChidren(sceneFramelayout); |
| | | |
| | | var sceneIconBtn = new Button |
| | | { |
| | | Width = Application.GetMinRealAverage(81), |
| | | Height = Application.GetMinRealAverage(81), |
| | | X = Application.GetRealWidth(58), |
| | | Y = Application.GetRealHeight(55), |
| | | UnSelectedImagePath = "ZigeeLogic/scene.png", |
| | | |
| | | }; |
| | | sceneFramelayout.AddChidren(sceneIconBtn); |
| | | |
| | | var sceneRow = new RowLayout |
| | | { |
| | | Y = Application.GetRealHeight(30), |
| | | Width = Application.GetRealWidth(850), |
| | | Height = Application.GetRealHeight(130), |
| | | X = Application.GetRealWidth(176 + 10), |
| | | LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor, |
| | | }; |
| | | sceneFramelayout.AddChidren(sceneRow); |
| | | |
| | | var scenename = new Button |
| | | { |
| | | Text = scene.Name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | SelectedTextColor = ZigbeeColor.Current.LogicAddColor, |
| | | TextSize = 14, |
| | | }; |
| | | sceneRow.AddChidren(scenename); |
| | | |
| | | var selectedBtn = new Button |
| | | { |
| | | Width = Application.GetMinRealAverage(60), |
| | | Height = Application.GetMinRealAverage(60), |
| | | X = Application.GetRealWidth(789), |
| | | UnSelectedImagePath = "ZigeeLogic/selected.png", |
| | | Visible = false, |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | sceneRow.AddChidren(selectedBtn); |
| | | var lineBtn = new Button |
| | | { |
| | | Y = sceneFramelayout.Height - 1, |
| | | Width = Application.GetRealWidth(850), |
| | | Height = 1, |
| | | X = Application.GetRealWidth(176 + 10), |
| | | BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor, |
| | | }; |
| | | sceneFramelayout.AddChidren(lineBtn); |
| | | EventHandler<MouseEventArgs> sceneclick = (sender, e) => |
| | | { |
| | | tempScene = scene; |
| | | clickTag = "yes"; |
| | | clickbutton.Visible = false; |
| | | clickbutton = selectedBtn; |
| | | selectedBtn.Visible = true; |
| | | if (actionsInfo.ContainsKey("DeviceAddr")) |
| | | { |
| | | actionsInfo.Remove("DeviceAddr"); |
| | | } |
| | | actionsInfo.Add("DeviceAddr", scene.Id); |
| | | }; |
| | | |
| | | sceneFramelayout.MouseUpEventHandler += sceneclick; |
| | | sceneIconBtn.MouseUpEventHandler += sceneclick; |
| | | sceneRow.MouseUpEventHandler += sceneclick; |
| | | scenename.MouseUpEventHandler += sceneclick; |
| | | selectedBtn.MouseUpEventHandler += sceneclick; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |