From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs | 502 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 502 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs new file mode 100755 index 0000000..ddf78a0 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs @@ -0,0 +1,502 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound.Forms +{ + public class SmartSoundContentForDevice : EditorCommonForm + { + /// <summary> + /// 褰撳墠閫変腑鐨勬埧闂� + /// </summary> + private SmartSound.Room CurrentRoom = null; + + private FrameLayout ContentLayout = null; + + private VerticalListControl listView = null; + + /// <summary> + /// 娌℃湁鏁版嵁鐨勬椂鍊欙紝鎻愮ず鐢� + /// </summary> + private FrameLayout TipLayout = null; + + private List<string> TabList = new List<string>() + { + Language.StringByID(R.MyInternationalizationString.uLight), + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100), + Language.StringByID(R.MyInternationalizationString.AC) + }; + + private int CurrentSelectIndex = 0; + + private int imageWith = 683; + private int imageHeight = 392; + + /// <summary> + /// 閫夋嫨鎴块棿涓殑璁惧 + /// </summary> + /// <param name="_room"> 褰撳墠鎴块棿</param> + public SmartSoundContentForDevice(SmartSound.Room _room) + { + this.CurrentRoom = _room; + } + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(CurrentRoom.RoomName); + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + private void InitMiddleFrame() + { + //1.鍦烘櫙銆佸姛鑳藉鑸潯 + var switchContr = new SceneFunctionSwitchControl(); + this.bodyFrameLayout.AddChidren(switchContr); + switchContr.Gravity = Gravity.CenterVertical; + switchContr.Width = Application.GetRealWidth(650); + switchContr.Y = Application.GetRealHeight(40); + + ContentLayout = new FrameLayout(); + this.bodyFrameLayout.AddChidren(ContentLayout); + ContentLayout.Height = this.bodyFrameLayout.Height - switchContr.Height - Application.GetRealHeight(40); + ContentLayout.Y = switchContr.Height + Application.GetRealHeight(40); + + var listTitle = new List<string>(); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence)); + listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction)); + + //璁剧疆鍒濆鍊� + switchContr.SetDefultIndex(0); + + //閫夋嫨浜嬩欢 + switchContr.SelectTabEvent += (selectIndex) => + { + //鍒锋柊bodyView + if (selectIndex == 0) + { + LoadSceneView(); + } + else + { + LoadFunction(); + } + }; + + //寮�濮嬪垵濮嬪寲 + switchContr.InitControl(listTitle); + + //娣诲姞纭鎸夐挳 + BottomClickButton bottomClickButton = new BottomClickButton(); + this.bodyFrameLayout.AddChidren(bottomClickButton); + bottomClickButton.Text = "纭"; + bottomClickButton.ButtonClickEvent += (sender, e) => + { + //淇濆瓨鏁版嵁 + base.CloseForm(); + }; + } + + /// <summary> + /// 鍔犺浇鍦烘櫙鐣岄潰 + /// </summary> + private void LoadSceneView() + { + try + { + //3.璁惧鍒楄〃 ListView + ContentLayout.RemoveAll(); + + var tipLayout = new FrameLayout(); + ContentLayout.AddChidren(tipLayout); + tipLayout.Visible = false; + ShowNoFunctionTip(tipLayout); + + listView = new VerticalListControl(); + ContentLayout.AddChidren(listView); + listView.Y = Application.GetRealHeight(40); + listView.RemoveAll(); + + for (int i = 0; i < CurrentRoom.SceneList.Count; i++) + { + SmartSound.Scene scene = CurrentRoom.SceneList[i]; + var roomRowLayout = new SceneRowLayout(this, scene); + listView.AddChidren(roomRowLayout); + roomRowLayout.InitControl(); + } + + if (listView.ChildrenCount == 0) + { + tipLayout.Visible = true; + } + else + { + tipLayout.Visible = false; + } + + if (listView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + listView.AddChidren(textView); + } + } + catch (Exception ex) + { + string eoor = ex.Message; + } + } + + private void LoadFunction() + { + try + { + //2.鍔熻兘绫诲瀷閫夋嫨锛堢伅鍏夈�侀伄闃炽�佺┖璋冿級 + //3.璁惧鍒楄〃 ListView + this.ContentLayout.RemoveAll(); + + FrameLayout tab_layout = new FrameLayout(); + ContentLayout.AddChidren(tab_layout); + tab_layout.Height = Application.GetRealHeight(170); + tab_layout.Y = 0; + + //娣诲姞 ListView 鎻愮ず + TipLayout = new FrameLayout(); + ContentLayout.AddChidren(TipLayout); + TipLayout.Visible = false; + TipLayout.Y= tab_layout.Height; + ShowNoFunctionTip(TipLayout); + + //娣诲姞 ListView + listView = new VerticalListControl(); + ContentLayout.AddChidren(listView); + listView.Y= tab_layout.Height; + listView.Height=ContentLayout.Height- tab_layout.Height; + + Buttons.Clear(); + + //娣诲姞鍔熻兘椤� + for (int i = 0; i < TabList.Count; i++) + { + Button button = new Button(); + tab_layout.AddChidren(button); + button.Width = Application.GetRealWidth(250); + button.Text = TabList[i]; + button.X = ControlCommonResourse.XXLeft/2 + i * button.Width; + button.AddTag("Index", i); + Buttons.Add(button); + + button.MouseUpEventHandler += (sender, e) => + { + Button btn = sender as Button; + CurrentSelectIndex = (int)btn.GetTagByKey("Index"); + RefreshButtonState(); + RefreshFunctionListView(); + }; + } + + RefreshButtonState(); + RefreshFunctionListView(); + } + catch (Exception ex) + { + string error = ex.Message; + } + } + + private void RefreshFunctionListView() + { + try + { + listView.RemoveAll(); + + switch (CurrentSelectIndex) + { + case 0: // 鐏厜 + { + for (int i = 0; i < CurrentRoom.DeviceList.Count; i++) + { + SmartSound.Device device = CurrentRoom.DeviceList[i]; + // 鐏厜 + if (device.DeviceType == 1 || device.DeviceType == 2 || device.DeviceType == 3) + { + var deviceRowLayout = new DeviceRowLayout(this, device); + listView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + } + } + } + break; + case 1: // 绐楀笜 + { + for (int i = 0; i < CurrentRoom.DeviceList.Count; i++) + { + SmartSound.Device device = CurrentRoom.DeviceList[i]; + // + if (device.DeviceType == 4 || device.DeviceType == 5 || device.DeviceType == 6) + { + var deviceRowLayout = new DeviceRowLayout(this, device); + listView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + } + } + } + break; + case 2: // 绌鸿皟 + { + for (int i = 0; i < CurrentRoom.DeviceList.Count; i++) + { + SmartSound.Device device = CurrentRoom.DeviceList[i]; + // + if (device.DeviceType == 7) + { + var deviceRowLayout = new DeviceRowLayout(this, device); + listView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + } + } + } + break; + } + + if (listView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + listView.AddChidren(textView); + } + + if (listView.ChildrenCount == 0) + { + TipLayout.Visible = true; + } + else + { + TipLayout.Visible = false; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + /// <summary> + /// 鎻愮ず娌℃湁鍔熻兘 + /// </summary> + private void ShowNoFunctionTip(FrameLayout layout,string tip="娌℃湁鏁版嵁鍝�") + { + var noFunction = new Button() + { + Y = Application.GetRealHeight(320), + Width = Application.GetMinRealAverage(757), + Height = Application.GetMinRealAverage(435), + UnSelectedImagePath = "Item/NoFunction.png", + Gravity = Gravity.CenterHorizontal + }; + layout.AddChidren(noFunction); + + var noFunctionTip = new Button() + { + Y = noFunction.Bottom + Application.GetRealHeight(32), + Height = Application.GetRealHeight(200), + Width = Application.GetRealWidth(700), + Gravity = Gravity.CenterHorizontal, + Text = tip, + TextColor = UserCenterColor.Current.TextGrayColor1, + TextAlignment = TextAlignment.Center, + IsMoreLines = true + }; + layout.AddChidren(noFunctionTip); + } + + //涓轰簡鏂逛究鏇存柊鐘舵�侊紝瀛樿捣鏉� + private List<Button> Buttons = new List<Button>(); + private void RefreshButtonState() + { + try + { + for (int i = 0; i < Buttons.Count; i++) + { + Button btn = Buttons[i]; + if (i == CurrentSelectIndex) + { + btn.SelectedImagePath = "Item/RoomIconBackgroundSelected.png"; + btn.UnSelectedImagePath = "Item/RoomIconBackgroundSelected.png"; + btn.TextColor = UserCenterColor.Current.White; + } + else + { + btn.SelectedImagePath = "Item/RoomIconBackground.png"; + btn.UnSelectedImagePath = "Item/RoomIconBackground.png"; + btn.TextColor=UserCenterColor.Current.TextGrayColor1; + } + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + #region 鈻� 鑷畾涔夊満鏅�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class SceneRowLayout : FrameRowControl + { + private SmartSoundContentForDevice smartSoundControlForDevice = null; + + private SmartSound.Scene scene = null; + /// <summary> + /// 鎴块棿鍚嶇О + /// </summary> + private NormalViewControl btnName = null; + + private MostRightIconControl Right_icon = null; + + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public SceneRowLayout(SmartSoundContentForDevice _smartSoundControlForDevice, SmartSound.Scene _scene) + { + this.smartSoundControlForDevice = _smartSoundControlForDevice; + this.scene = _scene; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 700); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 14; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = scene.SceneName; + Right_icon = this.AddMostRightEmptyIcon(58, 58); + Right_icon.Gravity = Gravity.CenterVertical; + + this.ButtonClickEvent += (sender, e) => + { + scene.Checked = !scene.Checked; + RefreshRightIconState(scene.Checked); + }; + + RefreshRightIconState(scene.Checked); + AddBottomLine(); + + } + + private void RefreshRightIconState(bool bol = false) + { + try + { + if (bol) + { + Right_icon.SelectedImagePath = "Item/ItemSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemSelected.png"; + } + else + { + Right_icon.SelectedImagePath = "Item/ItemUnSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemUnSelected.png"; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + } + #endregion + + #region 鈻� 鑷畾鐏厜閫夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class DeviceRowLayout : FrameRowControl + { + private SmartSoundContentForDevice smartSoundControlForDevice = null; + + private SmartSound.Device device = null; + /// <summary> + /// 鎴块棿鍚嶇О + /// </summary> + private NormalViewControl btnName = null; + + private MostRightIconControl Right_icon = null; + + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public DeviceRowLayout(SmartSoundContentForDevice _smartSoundControlForDevice, SmartSound.Device _device) + { + this.smartSoundControlForDevice = _smartSoundControlForDevice; + this.device = _device; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 700); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 14; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = device.DeviceName; + Right_icon = this.AddMostRightEmptyIcon(58, 58); + Right_icon.Gravity = Gravity.CenterVertical; + + this.ButtonClickEvent += (sender, e) => + { + device.Checked = !device.Checked; + RefreshRightIconState(device.Checked); + }; + + RefreshRightIconState(device.Checked); + AddBottomLine(); + + } + + private void RefreshRightIconState(bool bol = false) + { + try + { + if (bol) + { + Right_icon.SelectedImagePath = "Item/ItemSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemSelected.png"; + } + else + { + Right_icon.SelectedImagePath = "Item/ItemUnSelected.png"; + Right_icon.UnSelectedImagePath = "Item/ItemUnSelected.png"; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + } + #endregion + } +} -- Gitblit v1.8.0