| | |
| | | |
| | | namespace Shared.Phone.Device.CommonForm |
| | | { |
| | | public class SelectZone : FrameLayout |
| | | public class SelectZone |
| | | { |
| | | public Action<Common.Room> ZoneAction; |
| | | |
| | | private UIPickerView pickView; |
| | | |
| | | private List<string> floorList = new List<string> { }; |
| | | private List<string> roomList = new List<string> { }; |
| | | private List<string> roomIdList = new List<string> { }; |
| | | private string currentId; |
| | | public SelectZone() |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// curRoom |
| | | /// </summary> |
| | | private Common.Room curRoom; |
| | | /// <summary> |
| | | /// 标题 |
| | | /// </summary> |
| | | public string title = Language.StringByID(R.MyInternationalizationString.BelongZone); |
| | | /// <summary> |
| | | /// Init |
| | | /// </summary> |
| | | public void Init() |
| | | { |
| | | var dialog = new FrameLayout() |
| | | List<string> floorIds = new List<string> { }; |
| | | List<string> floorNames = new List<string> { }; |
| | | List<List<string>> roomNames = new List<List<string>> { }; |
| | | List<List<Common.Room>> rooms = new List<List<Common.Room>> { }; |
| | | List<Common.Room> rs = new List<Common.Room> { }; |
| | | List<string> rNames = new List<string> { }; |
| | | if (Config.Instance.Home.FloorDics.Count > 0) |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor |
| | | }; |
| | | AddChidren(dialog); |
| | | foreach (var floor in Config.Instance.Home.FloorDics) |
| | | { |
| | | if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0) |
| | | { |
| | | floorIds.Add(floor.Key); |
| | | floorNames.Add(floor.Value); |
| | | |
| | | dialog.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | var backgroundFL = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(1115), |
| | | Height = Application.GetRealHeight(805), |
| | | 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.AddTo, |
| | | 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); |
| | | |
| | | pickView = new UIPickerView |
| | | { |
| | | Y = Application.GetRealHeight(20+138), |
| | | Height = Application.GetRealHeight(450) |
| | | }; |
| | | backgroundFL.AddChidren(pickView); |
| | | |
| | | foreach(var floor in Config.Instance.Home.FloorDics) |
| | | { |
| | | floorList.Add(floor.Value); |
| | | roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); |
| | | rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); |
| | | } |
| | | } |
| | | PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => |
| | | { |
| | | curRoom = rooms[index1][index2]; |
| | | ZoneAction?.Invoke(curRoom); |
| | | }, 0, 0, title, |
| | | Language.StringByID(R.MyInternationalizationString.Confrim), |
| | | Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | } |
| | | foreach(var room in Shared.Common.Room.Lists) |
| | | else |
| | | { |
| | | roomList.Add(room.Name); |
| | | roomIdList.Add(room.Id); |
| | | for (int i = 0; i < Common.Room.Lists.Count; i++) |
| | | { |
| | | var r = Common.Room.Lists[i]; |
| | | if (r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | rs.Add(r); |
| | | rNames.Add(r.Name); |
| | | } |
| | | PickerView.Show(rNames, (index1) => |
| | | { |
| | | curRoom = rs[index1]; |
| | | ZoneAction?.Invoke(curRoom); |
| | | }, 0, title, |
| | | Language.StringByID(R.MyInternationalizationString.Confrim), |
| | | Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | } |
| | | pickView.setNPicker(floorList, roomList, null); |
| | | |
| | | pickView.OnSelectChangeEvent += (l1, l2, l3) => |
| | | { |
| | | currentId = roomIdList[l2]; |
| | | }; |
| | | |
| | | cancle.MouseUpEventHandler += Close; |
| | | confrim.MouseUpEventHandler += Confrim_MouseEvent; |
| | | } |
| | | |
| | | /// <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); |
| | | |
| | | } |
| | | |
| | | /// <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) |
| | | { |
| | | ZoneAction?.Invoke(Shared.Common.Room.CurrentRoom.GetRoomById(currentId)); |
| | | RemoveFromParent(); |
| | | } |
| | | } |
| | | } |