using System; using System.Collections.Generic; using Shared.Common; using Shared.Phone.UserCenter.SmartSound.Forms; using ZigBee.Device; namespace Shared.Phone.UserCenter.SmartSound { public class SmartSoundControlForm : EditorCommonForm { /// /// 列表控件 /// private VerticalListControl listView = null; private FrameLayout contentLayout = null; public int CurrentIndex = 0; private MostRightIconControl btnAddDeviceIcon = null; public SmartSoundControlForm() { } /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置标题信息 base.SetTitleText("语音控制"); //右上添加按钮 if (btnAddDeviceIcon == null) { btnAddDeviceIcon = new MostRightIconControl(69, 69); btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png"; topFrameLayout.AddChidren(btnAddDeviceIcon); btnAddDeviceIcon.InitControl(); btnAddDeviceIcon.ButtonClickEvent += (sender, e) => { var smartSoundDataAdd = new SmartSoundControlContentForm(); smartSoundDataAdd.AddForm(); }; } //初始化中部控件 this.InitMiddleFrame(); } private void InitMiddleFrame() { if (SmartSound.CurretnData == null || SmartSound.CurretnData.Count < 1) return; // 添加数据 if (contentLayout != null) { contentLayout.RemoveAll(); contentLayout = null; } contentLayout = new FrameLayout(); this.bodyFrameLayout.AddChidren(contentLayout); contentLayout.RemoveAll(); var pullLayout = new MyPullControl(this, SmartSound.CurretnData); contentLayout.AddChidren(pullLayout); pullLayout.InitControl(); LoadAllRoomListView(); } private void LoadAllRoomListView() { try { if (SmartSound.CurretnData == null || SmartSound.CurretnData.Count < 1) return; // 加载当前楼层的所有房间 ListView if (listView == null) { listView = new VerticalListControl(); contentLayout.AddChidren(listView); listView.Y = Application.GetRealHeight(173); listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(173); } else if (listView.Parent == null) { listView = new VerticalListControl(); contentLayout.AddChidren(listView); listView.Y = Application.GetRealHeight(173); listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(173); } listView.RemoveAll(); SmartSound.Layer layer = SmartSound.CurretnData[CurrentIndex]; foreach (SmartSound.Room room in layer.RoomList) { var roomRowLayout = new RoomRowLayout(this, room); listView.AddChidren(roomRowLayout); roomRowLayout.InitControl(); roomRowLayout.frameTable.ButtonClickEvent += (sender, e) => { var deviceChange = new SmartSoundContentForDeviceChange(room); deviceChange.AddForm(); }; roomRowLayout.btnDelect.ButtonClickEvent += (sender, e) => { try { var delBtn = sender as NormalViewControl; var tag = (SmartSound.Room)delBtn.GetTagByKey("obj"); if (SmartSound.CurretnData == null) return; for (int i = 0; i < SmartSound.CurretnData.Count; i++) { SmartSound.Layer _layer = SmartSound.CurretnData[i]; for (int j = 0; j < _layer.RoomList.Count; j++) { SmartSound.Room _room = _layer.RoomList[j]; if (_room.RoomID == tag.RoomID) { _layer.RoomList.Remove(_room); this.LoadAllRoomListView(); } } } } catch(Exception ex) { string error = ex.Message; } }; } } catch(Exception e) { string error = e.Message; } } public override int FormActionAgainEvent() { ShowForm(); return base.FormActionAgainEvent(); } #region ■ 自定义楼层选择控件_____________________ /// /// 房间列表行 /// private class MyPullControl : FrameRowControl { private SmartSoundControlForm smartSoundControlData = null; private List Layers = null; /// /// 房间列表 /// private NormalViewControl btnName = null; /// /// 房间列表行 /// public MyPullControl(SmartSoundControlForm _SmartSoundDataAdd, List _layers) { this.smartSoundControlData = _SmartSoundDataAdd; this.Layers = _layers; this.UseClickStatu = false; this.BackgroundColor = UserCenterColor.Current.White; this.Height = Application.GetRealHeight(173); } /// /// 初始化控件 /// public void InitControl() { try { //显示文本 btnName = this.AddLeftCaption(string.Empty, 700); btnName.Height = Application.GetRealHeight(60); btnName.TextSize = 17; btnName.Y = Application.GetRealHeight(57); btnName.Text = "房间列表"; var right_icon = this.AddRightArrow(); right_icon.SelectedImagePath = "SmartSound/PullDown.png"; right_icon.UnSelectedImagePath = "SmartSound/PullDown.png"; right_icon.ButtonClickEvent += (sender, e) => { ShowPullList(); }; var layout = this.AddMostRightView(Layers[smartSoundControlData.CurrentIndex].LayerName, 300, false); layout.Name = "pullLayout"; layout.ButtonClickEvent += (sender, e) => { ShowPullList(); }; } catch(Exception e) { string error = e.Message; } } private void ShowPullList() { //房间列表行{房间列表 textView,楼层下拉窗} //显示房间{带选择框的;当选中了房间后需要在底部弹出确认按钮,点击确认跳转到新的界面} var pull_frame = new TopRightMenuControl(Layers.Count, 2); pull_frame.Y = this.Height; for (int i = 0; i < Layers.Count; i++) { //创建楼层 pull_frame.AddRowMenu(Layers[i].LayerName, "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () => { smartSoundControlData.CurrentIndex = i; smartSoundControlData.LoadAllRoomListView(); }); } } } #endregion #region ■ 自定义智能音箱控件_____________________ /// /// 语音控制房间行 /// private class RoomRowLayout : RowLayoutControl { /// /// 房间名字 /// private NormalViewControl btnName = null; /// /// 删除按钮 /// public NormalViewControl btnDelect = null; private SmartSoundControlForm smartSoundControlForm; private SmartSound.Room room; /// /// 自定音箱关控件 /// public RoomRowLayout(SmartSoundControlForm _smartSoundControlForm, SmartSound.Room _room) { this.smartSoundControlForm = _smartSoundControlForm; this.room = _room; this.BackgroundColor = UserCenterColor.Current.White; this.Height = Application.GetRealHeight(173); } /// /// 初始化内部控件 /// public void InitControl() { //设备 frameTable.AddLeftCaption(this.room.RoomName, 800); frameTable.AddRightArrow(); //底线 frameTable.AddBottomLine(); btnDelect = base.AddDeleteControl(); btnDelect.Text = "删除"; btnDelect.AddTag("obj", room); } } #endregion } }