From ce1feeeb0aaa2e53bca4e8d64953edaba2b41106 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期五, 19 六月 2020 17:27:49 +0800 Subject: [PATCH] 请合并最新版代码 --- Home0618/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorTemperatureCardControl.cs | 129 Home0618/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs | 364 ++ Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDeviceChange.cs | 608 +++ Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs | 386 ++ Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySearchForm.cs | 413 ++ Home0618/Shared/Phone/SmartSound/Widget/TextDialog.cs | 143 Home0618/Shared/Phone/ZigBee/Device/ColorTemperatureLight.cs | 109 Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDeviceChange.cs | 608 +++ Home0618/Shared/Phone/ZigBee/Device/Buzzer.cs | 18 Home0618/Shared/Common/Device.cs | 45 Home0618/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs | 511 +++ Home0618/Shared/Phone/UserCenter/Device/Light/MiniNightLightFunctionSettionForm.cs | 139 Home0618/Shared/Phone/SmartSound/Util/MyHttpWebResponse.cs | 163 + Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/TextDialog.cs | 143 Home0618/Shared/Phone/SmartSound/SmartSoundInfo.cs | 74 Home0618/Shared/Phone/SmartSound/Widget/SoundRowLayout.cs | 66 Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs | 501 +++ Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlContentForm.cs | 685 ++++ Home0618/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs | 380 ++ Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlForm.cs | 386 ++ Home0618/Shared/Phone/Device/Logic/SmartSound/Util/MyHttpWebResponse.cs | 163 + Home0618/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs | 38 Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDevice.cs | 501 +++ Home0618/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/ProgressRowBar.cs | 243 + Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundListForm.cs | 364 ++ Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/SoundRowLayout.cs | 66 Home0618/Shared/Phone/SmartSound/SmartSoundDataInfo.cs | 21 Home0618/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs | 4 Home0618/Shared/Phone/SmartSound/Widget/MyButton.cs | 49 Home0618/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs | 8 Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundInfo.cs | 74 Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs | 685 ++++ Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/MyButton.cs | 49 Home0618/Shared/Shared.projitems | 50 Home0618/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs | 298 - Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection2Form.cs | 119 Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySelectNetworkForm.cs | 143 Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection1Form.cs | 79 Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSound.cs | 91 Home0618/Shared/Phone/SmartSound/SmartSound.cs | 91 Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection3Form.cs | 112 Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundDataInfo.cs | 21 42 files changed, 8,750 insertions(+), 390 deletions(-) diff --git a/Home0618/Shared/Common/Device.cs b/Home0618/Shared/Common/Device.cs index fe6502f..07c1b89 100644 --- a/Home0618/Shared/Common/Device.cs +++ b/Home0618/Shared/Common/Device.cs @@ -1016,49 +1016,8 @@ }); return list; - } - - /// <summary> - /// 鏍规嵁MAC鍦板潃,鑾峰彇绠�绾﹂潰鏉垮叏閮ㄥ洖璺殑璁惧瀵硅薄 - /// </summary> - /// <param name="listDevice"></param> - /// <returns></returns> - public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true) - { - //鍜屽姜鍝ャ�佽澶囧拰浜у搧閮ㄥ悓浜嬬‘璁わ細 - //绠�绾﹀鍔熻兘闈㈡澘[涓嶆樉绀哄浣欑殑鍥炶矾锛屽彧鏄剧ず鎼哄甫鐨�2涓户鐢靛櫒鍜�1涓俯婀垮害浼犳劅鍣� - var list = new List<CommonDevice>(); - foreach (var dev in listDevice) - { - if (dev.Type == DeviceType.TemperatureSensor) - { - if (dev.DeviceEpoint == 64) - { - list.Add(dev); - } - } - else if (dev.Type == DeviceType.OnOffOutput) - { - list.Add(dev); - } - } - - if (sort == false) - { - return list; - } - list.Sort((obj1, obj2) => - { - if (obj1.DeviceEpoint > obj2.DeviceEpoint) - { - return 1; - } - return -1; - }); - - return list; - } - + } + /// <summary> /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭) /// </summary> diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDevice.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDevice.cs new file mode 100755 index 0000000..b2df8fa --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDevice.cs @@ -0,0 +1,501 @@ +锘縰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; + } + } + 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 IconViewControl 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 = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = scene.SceneName; + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + 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 = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.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 IconViewControl 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 = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = device.DeviceName; + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + 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 = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.png"; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDeviceChange.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDeviceChange.cs new file mode 100755 index 0000000..f457039 --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundContentForDeviceChange.cs @@ -0,0 +1,608 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Phone.UserCenter.SmartSound.Util; + +namespace Shared.Phone.UserCenter.SmartSound.Forms +{ + public class SmartSoundContentForDeviceChange : EditorCommonForm + { + + /// <summary> + /// 褰撳墠閫変腑鐨勬埧闂� + /// </summary> + private SmartSound.Room CurrentRoom = null; + + private FrameLayout ContentLayout = null; + + private FrameLayout DeviceListViewFrameLayout = null; + /// <summary> + /// 鍦烘櫙 listView + /// </summary> + private VerticalListControl SceneListView = null; + /// <summary> + /// 璁惧 listView + /// </summary> + private VerticalListControl DeviceListView = 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 SmartSoundContentForDeviceChange(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); + + } + + /// <summary> + /// 鍔犺浇鍦烘櫙鐣岄潰 + /// </summary> + private void LoadSceneView() + { + try + { + //3.璁惧鍒楄〃 ListView + ContentLayout.RemoveAll(); + + var tipLayout = new FrameLayout(); + ContentLayout.AddChidren(tipLayout); + tipLayout.Visible = false; + ShowNoFunctionTip(tipLayout); + + SceneListView = new VerticalListControl(); + ContentLayout.AddChidren(SceneListView); + SceneListView.Y = Application.GetRealHeight(40); + SceneListView.RemoveAll(); + + for (int i = 0; i < CurrentRoom.SceneList.Count; i++) + { + SmartSound.Scene scene = CurrentRoom.SceneList[i]; + var roomRowLayout = new SceneRowLayout(this, scene, i); + SceneListView.AddChidren(roomRowLayout); + roomRowLayout.InitControl(); + } + + if (SceneListView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + SceneListView.AddChidren(textView); + } + + if (SceneListView.ChildrenCount == 0) + { + tipLayout.Visible = true; + } + else + { + tipLayout.Visible = false; + } + } + catch (Exception ex) + { + string eoor = ex.Message; + } + } + + private void LoadFunction() + { + try + { + + 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); + + 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(); + }; + } + + //娣诲姞 ListView + DeviceListViewFrameLayout = new FrameLayout(); + ContentLayout.AddChidren(DeviceListViewFrameLayout); + DeviceListViewFrameLayout.Y = tab_layout.Height; + DeviceListViewFrameLayout.Height = ContentLayout.Height - tab_layout.Height; + + RefreshButtonState(); + RefreshFunctionListView(); + } + catch (Exception ex) + { + string error = ex.Message; + } + } + + private void RefreshFunctionListView() + { + try + { + + DeviceListViewFrameLayout.RemoveAll(); + + DeviceListView = new VerticalListControl(); + DeviceListViewFrameLayout.AddChidren(DeviceListView); + DeviceListView.Height = DeviceListViewFrameLayout.Height; + DeviceListView.RemoveAll(); + + switch (CurrentSelectIndex) + { + case 0:// 鐏厜 + { + int n = 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + case 1: // 绐楀笜 + { + int n = 0; + 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + case 2: // 绌鸿皟 + { + int n = 0; + 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + } + + if (DeviceListView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + DeviceListView.AddChidren(textView); + } + + if (DeviceListView.ChildrenCount == 0) + { + TipLayout.Visible = true; + } + else + { + TipLayout.Visible = false; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + /// <summary> + /// 淇敼鍦烘櫙鏄电О + /// </summary> + /// <param name="scene"></param> + /// <param name="sceneRowLayout"></param> + private void ShowSetNicknameDialog(SmartSound.Scene scene, SceneRowLayout sceneRowLayout) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //缂栬緫浣忓畢 + dialogForm.SetTitleText("鑷畾涔夋樀绉�"); + //璇疯緭鍏ヤ綇瀹呭悕绉� + dialogForm.SetTipText("璇疯緭鍏ユ樀绉�"); + dialogForm.Text = scene.NicksName; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + scene.NicksName = textValue; + string remark = scene.SceneName; + if (scene.NicksName.Trim() != string.Empty) + { + remark += "(" + scene.NicksName + ")"; + } + sceneRowLayout.btnCaption.Text = remark; + string json = await postBatchEdit(); + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }); + } + + /// <summary> + /// 淇敼璁惧鏄电О + /// </summary> + /// <param name="device"></param> + /// <param name="deviceRowLayout"></param> + private void ShowSetNicknameDialog(SmartSound.Device device, DeviceRowLayout deviceRowLayout) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //缂栬緫浣忓畢 + dialogForm.SetTitleText("鑷畾涔夋樀绉�"); + //璇疯緭鍏ヤ綇瀹呭悕绉� + dialogForm.SetTipText("璇疯緭鍏ユ樀绉�"); + dialogForm.Text = device.NicksName; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + device.NicksName = textValue; + string remark = device.DeviceName; + if (device.NicksName.Trim() != string.Empty) + { + remark += "(" + device.NicksName + ")"; + } + deviceRowLayout.btnCaption.Text = remark; + + string json = await postBatchEdit(); + + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }); + } + + /// <summary> + /// 鍦烘櫙鍒犻櫎 + /// </summary> + private void ShowSceneDelectDialog(SmartSound.Scene scene) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ帶鍒跺唴瀹癸紵", () => + { + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + CurrentRoom.SceneList.Remove(scene); + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + LoadSceneView(); + this.CloseProgressBar(); + }); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + /// <summary> + /// 璁惧鍒犻櫎 + /// </summary> + private void ShowDeviceDelectDialog(SmartSound.Device device) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ帶鍒跺唴瀹癸紵", () => + { + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + CurrentRoom.DeviceList.Remove(device); + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + RefreshFunctionListView(); + this.CloseProgressBar(); + }); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + /// <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; + } + } + + private async Task<string> postBatchEdit() + { + // 鎻愪氦鏁版嵁鑷虫湇鍔″櫒 + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + #region 鈻� 鑷畾涔夊満鏅�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鍦烘櫙鍒楄〃琛� + /// </summary> + private class SceneRowLayout : RowLayoutControl + { + private SmartSoundContentForDeviceChange smartSoundContentForDeviceChange = null; + + private SmartSound.Scene scene = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + public NormalViewControl btnCaption = null; + private int Index = 0; + + public SceneRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Scene _scene, int _index) + { + smartSoundContentForDeviceChange = _smartSoundContentForDeviceChange; + scene = _scene; + Index = _index; + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(175); + string remark = scene.SceneName; + if (scene.NicksName.Trim() != string.Empty) + { + remark += " (" + scene.NicksName + ")"; + } + btnCaption = frameTable.AddLeftCaption(remark, 2000); + + var nicknameIcon = frameTable.AddRightArrow();//58 + nicknameIcon.TextSize = 17; + + nicknameIcon.SelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.UnSelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.AddTag("obj", scene); + nicknameIcon.ButtonClickEvent += (sender, e) => + { + // 娣诲姞鏄电О + var btn = sender as IconViewControl; + SmartSound.Scene tmpScene = (SmartSound.Scene)btn.GetTagByKey("obj"); + smartSoundContentForDeviceChange.ShowSetNicknameDialog(tmpScene, this); + }; + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = Language.StringByID(R.MyInternationalizationString.Delete); + btnDelect.ButtonClickEvent += (sender, e) => + { + //鍒犻櫎鍦烘櫙 + smartSoundContentForDeviceChange.ShowSceneDelectDialog(scene); + }; + } + } + #endregion + + #region 鈻� 鑷畾鐏厜閫夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class DeviceRowLayout : RowLayoutControl + { + private SmartSoundContentForDeviceChange smartSoundContentForDeviceChange = null; + + private SmartSound.Device device = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + public NormalViewControl btnCaption = null; + private int Index = 0; + + public DeviceRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Device _device, int _index) + { + smartSoundContentForDeviceChange = _smartSoundContentForDeviceChange; + device = _device; + Index = _index; + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(175); + string remark = device.DeviceName; + if (device.NicksName.Trim() != string.Empty) + { + remark += " (" + device.NicksName + ")"; + } + btnCaption = frameTable.AddLeftCaption(remark, 2000); + + var nicknameIcon = frameTable.AddRightArrow();//58 + nicknameIcon.TextSize = 17; + + nicknameIcon.SelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.UnSelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.AddTag("obj", device); + nicknameIcon.ButtonClickEvent += (sender, e) => + { + var btn = sender as IconViewControl; + SmartSound.Device tmpDevice = (SmartSound.Device)btn.GetTagByKey("obj"); + smartSoundContentForDeviceChange.ShowSetNicknameDialog(tmpDevice, this); + }; + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "鍒犻櫎"; + btnDelect.ButtonClickEvent += (sender, e) => + { + smartSoundContentForDeviceChange.ShowDeviceDelectDialog(device); + }; + } + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlContentForm.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlContentForm.cs new file mode 100755 index 0000000..121602e --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlContentForm.cs @@ -0,0 +1,685 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Common; +using Shared.Phone.UserCenter.SmartSound.Util; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound.Forms +{ + public class SmartSoundControlContentForm : EditorCommonForm + { + /// <summary> + /// 涓存椂鏁版嵁 + /// </summary> + private List<SmartSound.Layer> TempDatas = new List<SmartSound.Layer>(); + + private SmartSoundInfo.SoundInfo mSoundInfo; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + + private FrameLayout contentLayout = null; + public int CurrentIndex = 0; + private BottomClickButton bottomClickButton = null; + + public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) + { + this.mSoundInfo = soundInfo; + } + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + IniFloorData();//鍏堝姞杞芥暟鎹� + TempDatas.Clear(); + + this.ScrollEnabled = false; + base.SetTitleText("閫夋嫨鎴块棿");//璁剧疆鏍囬淇℃伅 + + contentLayout = new FrameLayout(); + this.bodyFrameLayout.AddChidren(contentLayout); + + IniAllDataView(); + } + + #region 鍔犺浇鏈湴鎵�鏈夋暟鎹紝鐢熸垚渚涚敤鎴烽�夋嫨鎴块棿鐨勭晫闈� + + private void IniAllDataView() + { + contentLayout.RemoveAll(); + + var pullLayout = new MyPullControl(this, SmartSound.LocaData); + contentLayout.AddChidren(pullLayout); + pullLayout.InitControl(); + + LoadAllRoomListView(); + + bottomClickButton = new BottomClickButton(); + this.bodyFrameLayout.AddChidren(bottomClickButton); + bottomClickButton.Text = "纭"; + bottomClickButton.ButtonClickEvent += (sender, e) => + { + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + //淇濆瓨鏁版嵁 + if (SmartSound.getInstantiate().LayerList == null) + SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>(); + + SmartSound.getInstantiate().LayerList.Clear(); + SmartSound.getInstantiate().LayerList = CollateData(); + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID; + + //涓婁紶鏁版嵁鍒版湇鍔″櫒 + string str = await postBatchEdit(); + CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + CloseForm(); + }); + }); + }; + + bottomClickButton.Visible = false; + } + + private void LoadAllRoomListView() + { + try + { + + if (SmartSound.LocaData == null || SmartSound.LocaData.Count < 1) + return; + + // 鍔犺浇褰撳墠妤煎眰鐨勬墍鏈夋埧闂� ListView + SmartSound.Layer layer = SmartSound.LocaData[CurrentIndex]; + if (listView == null) + { + listView = new VerticalListControl(); + contentLayout.AddChidren(listView); + listView.Y = Application.GetRealHeight(173); + listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); + } + + listView.RemoveAll(); + + foreach(SmartSound.Room room in layer.RoomList) + { + var roomRowLayout = new RoomRowLayout(this, room); + listView.AddChidren(roomRowLayout); + roomRowLayout.InitControl(); + } + + //澶氫釜鐨勬椂鍊欙紝纭鎸夐挳浼氶伄鎸′竴閮ㄥ垎銆傝拷鍔犱笁涓┖鐨勮鐨勯珮搴︼紝鎶婂畠椤朵笂鏉� + if (listView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + listView.AddChidren(textView); + } + } + catch { } + } + + private async Task<string> postBatchEdit() + { + // The remote server returned an error: (400) Bad Request. + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + #endregion + + /// <summary> + /// 灏嗘暟鎹浆鎹负鏅鸿兘闊崇浣跨敤鐨勬暟鎹� + /// </summary> + private void IniFloorData() + { + + if (SmartSound.LocaData == null) + SmartSound.LocaData = new List<SmartSound.Layer>(); + + SmartSound.LocaData.Clear(); + + Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃 + + #region 鍒嗘ゼ灞� + if (floorDictionary.Count < 1) + { + //娌℃湁妤煎眰,妯℃嫙涓�涓� + SmartSound.Layer layer = new SmartSound.Layer(); + layer.LayerID = DateTime.Now.ToString("yyyyMMddHHmmssms"); + layer.LayerName = "涓�妤�"; + layer.RoomList.Clear(); + SmartSound.LocaData.Add(layer); + } + else + { + foreach (string layer_id in floorDictionary.Keys) + { + SmartSound.Layer layer = new SmartSound.Layer(); + layer.LayerID = layer_id; + layer.LayerName = floorDictionary[layer_id]; + layer.RoomList.Clear(); + SmartSound.LocaData.Add(layer); + } + } + #endregion + + #region 鎴块棿鍏ヤ綇瀵瑰簲鐨勬ゼ灞� + var roomList = HdlRoomLogic.Current.GetAllListRooms();//鑾峰彇鎵�鏈夋埧闂� + + for (int n = 0; n < SmartSound.LocaData.Count; n++) + { + SmartSound.Layer layer = SmartSound.LocaData[n]; + foreach (Room room in roomList) + { + try + { + if (layer.LayerID != room.FloorId && SmartSound.LocaData.Count > 1) + continue; + + //娣诲姞鎴块棿 + SmartSound.Room smartRoom = new SmartSound.Room(); + layer.RoomList.Add(smartRoom); + + smartRoom.RoomID = room.Id; + smartRoom.RoomName = room.Name; + smartRoom.DeviceList.Clear(); + smartRoom.SceneList.Clear(); + + #region 娣诲姞璁惧 鐏厜銆佺獥甯樸�佸満鏅�佺┖璋� + for (int j = 0; j < room.ListDevice.Count; j++) + { + string key = room.ListDevice[j].ToString(); + var device = LocalDevice.Current.GetDevice(key); + if (device == null) + continue; + + SmartSound.Device smartDevice = new SmartSound.Device(); + smartDevice.DeviceAddress = device.DeviceAddr;//璁惧 MAC + smartDevice.Epoint = device.DeviceEpoint;//璁惧绔彛 + smartDevice.DeviceName = Common.LocalDevice.Current.GetDeviceEpointName(device);//璁惧鍚嶇О + smartDevice.NicksName = ""; + smartDevice.DeviceType = GetDeviceType(device);//璁惧绫诲瀷 + if (smartDevice.DeviceType == 0) + continue; + + if(ZbGateway.GateWayBaseInfomations.ContainsKey(device.CurrentGateWayId) ==true) + { + smartDevice.GatewayID = ZbGateway.GateWayBaseInfomations[device.CurrentGateWayId].MacMark;//缃戝叧 Id + } + else + { + smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id + } + + if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty) + continue; + + smartRoom.DeviceList.Add(smartDevice); + } + #endregion + + var sceneList = HdlSceneLogic.Current.GetRoomSceneList(room); + + #region //娣诲姞鍦烘櫙 + for (int k = 0; k < sceneList.Count; k++) + { + try + { + SceneUI scene = sceneList[k]; + + if (scene == null) continue; + SmartSound.Scene smartScene = new SmartSound.Scene(); + smartScene.SceneName = scene.Name; + smartScene.SceneID = scene.Id; + smartScene.DelayTime = scene.DelayTime; + smartScene.NicksName = ""; + if (ZbGateway.GateWayBaseInfomations.ContainsKey(ZbGateway.MainGateWay.GwId) == true) + { + smartScene.GatewayID = ZbGateway.GateWayBaseInfomations[ZbGateway.MainGateWay.GwId].MacMark;//缃戝叧 Id + } + else + { + smartScene.GatewayID = ZbGateway.MainGateWay.GwId;//缃戝叧 Id + } + + if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty) + continue; + + smartRoom.SceneList.Add(smartScene); + } + catch (Exception e) { } + } + #endregion + + if (smartRoom.DeviceList.Count == 0 && sceneList.Count == 0) + layer.RoomList.Remove(smartRoom); + + } + catch (Exception e) + { + string errpr = e.Message; + } + } + } + #endregion + + } + + /// <summary> + /// Zigbee璁惧绫诲瀷杞崲涓烘櫤鑳介煶绠变娇鐢ㄧ殑绫诲瀷 + /// </summary> + /// <returns></returns> + private int GetDeviceType(ZigBee.Device.CommonDevice device) + { + int type = 0;//1=寮�鍏崇伅锛�2=璋冨厜鐏紝3=RGB 鐏紝4=绐楀笜妯″潡锛�5=寮�鍚堝笜锛�6=鍗峰笜锛�7=绌鸿皟锛�8=闈㈡澘锛�9=鏂伴 + + if (device.Type == DeviceType.OnOffOutput && device.DfunctionType == DeviceFunctionType.A鐏厜) + { + type = 1;//杩欓噷闈㈢殑灏辨槸缁х數鍣ㄧ伅鍏変簡 + } + else if (device.Type == DeviceType.DimmableLight) + { + type = 2;//璋冨厜 + } + else if (device.Type == DeviceType.ColorDimmableLight) + { + type = 3; + } + else if (device.Type == DeviceType.WindowCoveringDevice) + { + //绐楀笜 + if (((Rollershade)device).WcdType == 4)//寮�鍚堝笜 + { + type = 5; + } + else if (((Rollershade)device).WcdType == 0)//鍗峰笜 + type = 6;//鍗峰笜 + } + else if (device.Type == DeviceType.Thermostat) + { + type = 7; + } + else if (device.Type == DeviceType.FreshAir) + { + type = 9; + } + + return type; + } + + /// <summary> + /// 灏嗛�変腑鐨勬暟鎹坊鍔犲埌涓存椂鏁版嵁鍒楄〃涓紝渚夸簬鍚庢湡鐨�"淇濆瓨" + /// </summary> + private void AddData(SmartSound.Room room) + { + if (TempDatas == null) + TempDatas = new List<SmartSound.Layer>(); + + SmartSound.Layer tempLayer = SmartSound.LocaData[CurrentIndex]; + if (tempLayer == null) return; + + + + #region 娣诲姞妤煎眰 + + bool floor_exists = false; + // 杩囨护鐩稿悓鐨勬ゼ灞� + for (int i = 0; i < TempDatas.Count; i++) + { + if (tempLayer.LayerID == TempDatas[i].LayerID) + { + floor_exists = true; + break; + } + } + + if (!floor_exists) + { + tempLayer.RoomList.Clear(); + TempDatas.Add(tempLayer); + } + + + #endregion + + #region 娣诲姞鎴块棿 + + for (int i = 0; i < TempDatas.Count; i++) + { + if (SmartSound.LocaData[CurrentIndex].LayerID != TempDatas[i].LayerID) + continue; + + bool room_exists = false; + + for (int n = 0; n < TempDatas[i].RoomList.Count; n++) + { + if (room.RoomID == TempDatas[i].RoomList[n].RoomID) + { + room_exists = true; + break; + } + } + + if (!room_exists) + { + TempDatas[i].RoomList.Add(room); + CheckedAll(room);//娣诲姞鎴块棿鎴愬姛锛岄粯璁ら�変腑鎵�鏈夎澶� + break; + } + } + + #endregion + + } + + private void RemoveData(SmartSound.Room room) + { + try + { + for (int i = 0; i < TempDatas.Count; i++) + { + + for (int j = 0; j < TempDatas[i].RoomList.Count; j++) + { + if (TempDatas[i].RoomList[j].RoomID == room.RoomID) + { + TempDatas[i].RoomList.RemoveAt(j); + } + } + } + } + catch { } + } + + /// <summary> + /// 榛樿閫夋嫨鎵�鏈夎澶� + /// </summary> + /// <param name="room"></param> + private void CheckedAll(SmartSound.Room room) + { + // 鏍囪鎵�鏈夊満鏅� + for (int n = 0; n < room.SceneList.Count; n++) + { + SmartSound.Scene _scene = room.SceneList[n]; + _scene.Checked = true; + } + + //鏍囪鎵�鏈夎澶� + for (int k = 0; k < room.DeviceList.Count; k++) + { + + SmartSound.Device _device = room.DeviceList[k]; + _device.Checked = true; + } + } + + /// <summary> + /// 閲嶆柊鏁寸悊鏁版嵁锛屾妸娌℃湁閫変腑鐨勬暟鎹兘鍓旈櫎鎺� + /// </summary> + private List<SmartSound.Layer> CollateData() + { + try + { + //绉诲嚭鏈�変腑鐨勮澶囥�佸満鏅� + for (int i = 0; i < TempDatas.Count; i++) + { + SmartSound.Layer _layer = TempDatas[i]; + + for (int j = 0; j < _layer.RoomList.Count; j++) + { + SmartSound.Room _room = _layer.RoomList[j]; + if (_room.Checked) + { + #region 娓呴櫎鏈�変腑鐨勮澶� + for (int k = 0; k < _room.DeviceList.Count; k++) + { + SmartSound.Device _device = _room.DeviceList[k]; + if (!_device.Checked) + { + _room.DeviceList.Remove(_device); + k--; + } + } + #endregion + + #region 娓呴櫎鏈�変腑鐨勫満鏅� + for (int n = 0; n < _room.SceneList.Count; n++) + { + SmartSound.Scene _scene = _room.SceneList[n]; + if (!_scene.Checked) + { + _room.SceneList.Remove(_scene); + n--; + } + } + #endregion + } + else + { + _layer.RoomList.Remove(_room); + j--; + } + } + } + + //绉诲嚭娌℃湁璁惧鐨勬埧闂� + for (int j = 0; j < TempDatas.Count; j++) + { + SmartSound.Layer _layer = TempDatas[j]; + if (_layer.RoomList.Count < 1) + { + TempDatas.Remove(_layer); + j--; + } + } + } + catch { } + + return TempDatas; + } + + #region 鈻� 鑷畾涔夋ゼ灞傞�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class MyPullControl : FrameRowControl + { + + private SmartSoundControlContentForm smartSoundDataAdd = null; + private List<SmartSound.Layer> Layers = null; + /// <summary> + /// 鎴块棿鍒楄〃 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public MyPullControl(SmartSoundControlContentForm _SmartSoundDataAdd,List<SmartSound.Layer> _layers) + { + this.smartSoundDataAdd = _SmartSoundDataAdd; + this.Layers = _layers; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + 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[smartSoundDataAdd.CurrentIndex].LayerName, 300, false); + layout.Name = "pullLayout"; + layout.ButtonClickEvent += (sender, e) => + { + ShowPullList(); + }; + + if (Layers.Count == 1) + { + right_icon.Visible = false; + layout.Visible = false; + } + + } + + 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", () => + { + smartSoundDataAdd.CurrentIndex = i; + smartSoundDataAdd.LoadAllRoomListView(); + }); + } + } + } + #endregion + + #region 鈻� 鑷畾涔夋埧闂撮�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class RoomRowLayout : FrameRowControl + { + private SmartSoundControlContentForm smartSoundControlContentForm = null; + + private SmartSound.Room mRoom = null; + /// <summary> + /// 鎴块棿鍚嶇О + /// </summary> + private NormalViewControl btnName = null; + + private IconViewControl Right_icon = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public RoomRowLayout(SmartSoundControlContentForm _smartSoundControlContentForm,SmartSound.Room _room) + { + this.smartSoundControlContentForm = _smartSoundControlContentForm; + this.mRoom = _room; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 2000); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = mRoom.RoomName; + + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + btnName.ButtonClickEvent += (sender, e) => + { + mRoom.Checked = true; + RefreshRightIconState(mRoom.Checked); + SmartSoundContentForDevice deviceForm = new SmartSoundContentForDevice(mRoom); + deviceForm.AddForm(); + }; + + this.Right_icon.ButtonClickEvent += (sender, e) => + { + mRoom.Checked = !mRoom.Checked; + RefreshRightIconState(mRoom.Checked); + }; + + RefreshRightIconState(mRoom.Checked); + AddBottomLine(); + + } + + private void RefreshRightIconState(bool bol = false) + { + try + { + if (bol) + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + + smartSoundControlContentForm.AddData(mRoom); + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.png"; + + smartSoundControlContentForm.RemoveData(mRoom); + } + + bool isShow = false; + + if(smartSoundControlContentForm==null) return; + + foreach (SmartSound.Room _room in SmartSound.LocaData[smartSoundControlContentForm.CurrentIndex].RoomList) + { + if (_room.Checked) + { + isShow = true; + break; + } + } + + smartSoundControlContentForm.bottomClickButton.Visible = isShow; + } + catch(Exception e) + { + string error = e.Message; + } + } + + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlForm.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlForm.cs new file mode 100755 index 0000000..f85422e --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundControlForm.cs @@ -0,0 +1,386 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Common; +using Shared.Phone.UserCenter.SmartSound.Forms; +using Shared.Phone.UserCenter.SmartSound.Util; +using Shared.Phone.UserCenter.SmartSound.Widget; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound +{ + + public class SmartSoundControlForm : EditorCommonForm + { + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + private FrameLayout contentLayout = null; + public int CurrentIndex = 0; + private MostRightIconControl btnAddDeviceIcon = null; + /// <summary> + /// 鏅鸿兘闊崇鏁版嵁 + /// </summary> + private static SmartSoundInfo.SoundInfo mSoundInfo = null; + + public SmartSoundControlForm(SmartSoundInfo.SoundInfo soundInfo) + { + mSoundInfo = soundInfo; + } + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + 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(mSoundInfo); + smartSoundDataAdd.AddForm(); + }; + } + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + private void InitMiddleFrame() + { + this.ClearBodyFrame(); + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + + string json = await GetData();//鑾峰彇鏁版嵁 + SmartSoundDataInfo dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundDataInfo>(json); + if (dataInfo != null) + { + if (dataInfo.StateCode == "SUCCESS") + { + SmartSound.getInstantiate().LayerList = dataInfo.ResponseData.LayerList; + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID; + } + } + + HdlThreadLogic.Current.RunMainInThread(() => + { + if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.Count < 1) + { + this.CloseProgressBar(); + return; + } + + contentLayout = new FrameLayout(); + this.bodyFrameLayout.AddChidren(contentLayout); + contentLayout.RemoveAll(); + + var pullLayout = new MyPullControl(this, SmartSound.getInstantiate().LayerList); + contentLayout.AddChidren(pullLayout); + pullLayout.InitControl(); + + LoadAllRoomListView(); + + //鏃犳暟鎹殑鏃跺�欒鍋氫竴涓彁绀� + { + bool bol = false; + for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++) + { + if (SmartSound.getInstantiate().LayerList[i].RoomList.Count > 0) + { + bol = true; + break; + } + } + + if (!bol) + { + pullLayout.Visible = false; + this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "杩樻病鏈夋帶鍒跺唴瀹瑰摝锛�", "鐐瑰嚮\"+\"娣诲姞" }); + } + } + + this.CloseProgressBar(); + + }); + }); + } + + /// <summary> + /// 鍔犺浇鎴块棿鍒楄〃 + /// </summary> + private void LoadAllRoomListView() + { + try + { + if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.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.getInstantiate().LayerList[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) => + { + var delBtn = sender as NormalViewControl; + DelectRoom(delBtn); + }; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + private void DelectRoom(NormalViewControl delBtn) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ埧闂寸殑鎺у埗鍐呭锛�", async () => + { + + HdlThreadLogic.Current.RunThread(async () => + { + + this.ShowProgressBar("姝e湪鍒犻櫎鏁版嵁...."); + //鍒犻櫎鎴块棿 + var tag = (SmartSound.Room)delBtn.GetTagByKey("obj"); + + if (SmartSound.getInstantiate().LayerList == null) + return; + + for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++) + { + SmartSound.Layer _layer = SmartSound.getInstantiate().LayerList[i]; + + for (int j = 0; j < _layer.RoomList.Count; j++) + { + SmartSound.Room _room = _layer.RoomList[j]; + + if (_room.RoomName == tag.RoomName) + { + _layer.RoomList.Remove(_room); + } + } + } + + // 閲嶆柊涓婁紶鏁版嵁 + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //this.InitMiddleFrame(); + this.LoadAllRoomListView(); + }); + this.CloseProgressBar(); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + private async Task<string> GetData() + { + // 浠庢湇鍔″櫒鑾峰彇鏁版嵁 + string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit?Platform&UserID={0}&TokenID={1}", mSoundInfo.UserID, mSoundInfo.Id); + return await MyHttpWebResponse.GetWebRequest(url); + } + + private async Task<string> postBatchEdit() + { + // 鎻愪氦鏁版嵁鑷虫湇鍔″櫒 + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + public override int FormActionAgainEvent() + { + ShowForm(); + return base.FormActionAgainEvent(); + } + + #region 鈻� 鑷畾涔夋ゼ灞傞�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class MyPullControl : FrameRowControl + { + + private SmartSoundControlForm smartSoundControlData = null; + private List<SmartSound.Layer> Layers = null; + /// <summary> + /// 鎴块棿鍒楄〃 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public MyPullControl(SmartSoundControlForm _SmartSoundDataAdd, List<SmartSound.Layer> _layers) + { + this.smartSoundControlData = _SmartSoundDataAdd; + this.Layers = _layers; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + 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(); + }; + + if (SmartSound.getInstantiate().LayerList.Count < 2) + { + right_icon.Visible = false; + layout.Visible = false; + } + } + 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 鈻� 鑷畾涔夋櫤鑳介煶绠辨帶浠禵____________________ + + /// <summary> + /// 璇煶鎺у埗鎴块棿琛� + /// </summary> + private class RoomRowLayout : RowLayoutControl + { + + /// <summary> + /// 鎴块棿鍚嶅瓧 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + + private SmartSoundControlForm smartSoundControlForm; + private SmartSound.Room room; + + /// <summary> + /// 鑷畾闊崇鍏虫帶浠� + /// </summary> + public RoomRowLayout(SmartSoundControlForm _smartSoundControlForm, SmartSound.Room _room) + { + this.smartSoundControlForm = _smartSoundControlForm; + this.room = _room; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + //璁惧 + frameTable.AddLeftCaption(this.room.RoomName, 800); + frameTable.AddRightArrow(); + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "鍒犻櫎"; + btnDelect.AddTag("obj", room); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundListForm.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundListForm.cs new file mode 100755 index 0000000..5b1441d --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Forms/SmartSoundListForm.cs @@ -0,0 +1,364 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using Shared.Common; +using Shared.Phone.UserCenter.Device; +using Shared.Phone.UserCenter.SmartSound.Util; +using Shared.Phone.UserCenter.SmartSound.Widget; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound +{ + //鏅鸿兘闊崇鍒楄〃鐣岄潰 + public class SmartSoundListForm : EditorCommonForm + { + public SmartSoundListForm() + { + } + + private SmartSoundInfo smartSoundInfo = null; + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListRefreshControl listView = null; + /// <summary> + /// 鍓嶄竴娆℃樉绀哄嚭宸︽粦鑿滃崟鐨凴owLayout + /// </summary> + private RowLayoutControl oldShowRightMuneRow = null; + + private static string dataString = ""; + + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + + this.ScrollEnabled = false; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText("鏅鸿兘闊崇"); + Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃 + + var helpBtn = new MyButton(); + helpBtn.TextColor = UserCenterColor.Current.TextOrangeColor; + helpBtn.Text = "甯姪"; + helpBtn.Gravity = Gravity.CenterRight; + helpBtn.TextAlignment = TextAlignment.CenterRight; + topFrameLayout.AddChidren(helpBtn); + helpBtn.X -= Application.GetRealWidth(58); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + + helpBtn.MouseUpEventHandler += (sernder, e) => + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new TextDialog("缁戝畾鏅鸿兘闊崇鍒扮涓夋柟 APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�"); + dialogForm.SetTitleText("甯姪"); + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += () => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }; + }; + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤) + /// </summary> + /// <param name="i_reGetDeviceOnlineStatu">閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬�</param> + public void InitMiddleFrame() + { + this.ClearBodyFrame(); + + var frame = new FrameLayout(); + this.bodyFrameLayout.AddChidren(frame); + frame.BackgroundColor = UserCenterColor.Current.White; + frame.Y = 0; + frame.Height = this.bodyFrameLayout.Height; + + // 鍒濆鍖� lisetView + listView = new VerticalListRefreshControl(29); + listView.Y = 0; + listView.Height = bodyFrameLayout.Height; + frame.AddChidren(listView); + listView.BeginHeaderRefreshingAction += () => + { + HdlThreadLogic.Current.RunThread(() => + { + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + this.InitMiddleFrame(); + }); + }); + }; + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + await getData(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + iniView(); + + if (smartSoundInfo == null || smartSoundInfo.ResponseData == null || smartSoundInfo.ResponseData.RowCount == 0) + { + // show鍑烘病鏈夎澶囩殑鍥炬爣鏂囧瓧鎻愮ず + this.ShowNotDataImage(bodyFrameLayout, new string[] { "杩樻病鏈夐煶绠卞摝锛�", "缁戝畾鏅鸿兘闊崇璇峰墠寰�绗笁鏂� APP 杩涜鎿嶄綔" }); + } + + this.CloseProgressBar(); + }); + }); + } + + /// <summary> + /// 鑾峰彇闊崇鍒楄〃 + /// </summary> + /// <returns></returns> + private async Task getData() + { + string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/Auth?Platform&PageSetting.PageSize=100&PageSetting.PageIndex=1&UserID={0}&HomeID={1}", + Common.Config.Instance.Guid,Common.Config.Instance.Home.Id); + + dataString = await MyHttpWebResponse.GetWebRequest(url); + smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString); + } + + /// <summary> + /// 璁剧疆澶囨敞 + /// </summary> + /// <param name="soundInfo"></param> + /// <param name="new_remark"></param> + /// <returns></returns> + private async Task<string> setRemark(SmartSoundInfo.SoundInfo soundInfo, string new_remark) + { + if (soundInfo == null) + return ""; + + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth"; + string json = "{" + + "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," + + "\"Remark\":" + "\"" + new_remark + "\"" + "," + + "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; + + string response_str = MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8); + JObject jObject = JObject.Parse(response_str); + + return jObject["StateCode"].ToString(); + } + + private void iniView() + { + // + listView.RemoveAll(); + + if (smartSoundInfo == null) + return; + + for (int i = 0; i < smartSoundInfo.ResponseData.Data.Count; i++) + { + try + { + // + var smartSound = smartSoundInfo.ResponseData.Data[i]; + var row = new SoundRowLayout(); + listView.AddChidren(row); + + if (smartSound.PlatfromName == "Baidu") + { + string remark = "灏忓害"; + if (smartSound.Remark != null && smartSound.Remark.Trim() != "") + remark += "(" + smartSound.Remark + ")"; + + row.ImagePath = "SmartSound/Xiaodu.png"; + row.Remark = remark; + } + + row.InitControl(); + row.btnDelect.AddTag("index", i); + row.btnRename.AddTag("index", i); + row.frameTable.AddTag("index", i); + + //閲嶅懡鍚� + row.btnRename.ButtonClickEvent += (sender, e) => + { + int index = (int)((NormalViewControl)sender).GetTagByKey("index"); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowRenameDialog(row, smartSound1); + }; + + // 瑙i櫎缁戝畾 + row.btnDelect.ButtonClickEvent += (sender, e) => + { + int index = (int)(((NormalViewControl)sender).GetTagByKey("index")); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowDelectDialog(smartSound1); + }; + + //璺宠浆鍒版帶鍒跺唴瀹圭晫闈� FrameRowControl + row.frameTable.ButtonClickEvent += (sender, e) => + { + int index = (int)row.frameTable.GetTagByKey("index"); + if (SmartSound.getInstantiate().LayerList != null) + SmartSound.getInstantiate().LayerList.Clear(); + + var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]); + smartSoundControlForm.AddForm(); + }; + } + catch (Exception e) + { + this.ShowMassage(ShowMsgType.Tip, e.Message); + } + } + } + + /// <summary> + /// 瑙i櫎缁戝畾寮圭獥 + /// </summary> + private void ShowDelectDialog(SmartSoundInfo.SoundInfo smartSound) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new TextDialog("瑙i櫎缁戝畾闇�瑕佸埌绗笁鏂� APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�"); + dialogForm.SetTitleText("瑙i櫎缁戝畾"); + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += () => + { + HdlThreadLogic.Current.RunThread(() => + { + this.ShowProgressBar("鍒犻櫎鏈嶅姟鍣ㄨ褰�..."); + string json = DelectSmartSound(smartSound); + if (json == "SUCCESS") + { + smartSoundInfo.ResponseData.Data.Remove(smartSound); + } + this.CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + bool bol = false; + try + { +#if Android + bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp"); +#else + HDLUtils.OpenApp("xiaoduapp://"); +#endif + } + catch (Exception e) + { + string error = e.Message; + bol = false; + } + if (!bol) + { + this.ShowMassage(ShowMsgType.Tip, "鎵撳紑APP澶辫触"); + } + iniView(); + }); + }); + }; + } + /// <summary> + /// 閲嶅懡鍚嶅脊绐� + /// </summary> + /// <returns></returns> + private void ShowRenameDialog(SoundRowLayout soundRowLayout, SmartSoundInfo.SoundInfo smartSound) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //娣诲姞澶囦唤 + dialogForm.SetTitleText("閲嶅懡鍚�"); + //璇疯緭鍏ュ浠藉悕绉� + dialogForm.SetTipText("璇疯緭鍏ュ悕绉�"); + dialogForm.Text = smartSound.Remark; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + + string remark = textValue; + string str = await setRemark(smartSound, remark); //涓婁紶澶囦唤 + if (str == "SUCCESS") + { + smartSound.Remark = remark; + soundRowLayout.btnRemark.Text = "灏忓害" + "(" + textValue + ")"; + } + else + { + //閿欒寮圭獥鎻愮ず + ShowMassage(ShowMsgType.Tip, "淇敼澶囨敞涓嶆垚鍔燂紒", null, "纭"); + } + }); + } + + #endregion + + /// <summary> + /// 鍒犻櫎鏁版嵁 + /// </summary> + /// <param name="soundInfo"></param> + /// <returns></returns> + private string DelectSmartSound(SmartSoundInfo.SoundInfo soundInfo) + { + if (soundInfo == null) + return ""; + + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth"; + string json = "{" + + "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," + + "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; + + string response_str = MyHttpWebResponse.DeleteWebRequest(url, json, Encoding.UTF8); + JObject jObject = JObject.Parse(response_str); + + return jObject["StateCode"].ToString(); + } + +#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ + + /// <summary> + /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� + /// </summary> + public override int FormActionAgainEvent() + { + return 1; + } + +#endregion + +#region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + base.CloseFormBefore(); + } + +#endregion + + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSound.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSound.cs new file mode 100755 index 0000000..09bfefc --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSound.cs @@ -0,0 +1,91 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SmartSound + { + + /// <summary> + /// 鏈湴鎵�鏈夌殑鏁版嵁 + /// </summary> + public static List<Layer> LocaData = new List<Layer>(); + /// <summary> + /// 褰撳墠浣跨敤鐨勬暟鎹�(鏈嶅姟鍣ㄥ悓姝ヤ笅鏉ョ殑鏁版嵁/褰撳墠琚�変腑鐨勬暟鎹�) + /// </summary> + public List<Layer> LayerList = new List<Layer>(); + + public SmartSound() + { + } + + private static SmartSound smartSound = null; + public string UserID; + public string TokenID; + public string HomeID; + + public static SmartSound getInstantiate() + { + if (smartSound == null) + smartSound = new SmartSound(); + + return smartSound; + } + + public class Layer + { + public string LayerID; + public string LayerName; + public List<Room> RoomList = new List<Room>(); + } + + public class Room + { + /// <summary> + /// 閫変腑鐨勬埧闂� + /// </summary> + public bool Checked = false; + public string RoomID; + public string RoomName; + public List<Device> DeviceList = new List<Device>(); + public List<Scene> SceneList = new List<Scene>(); + } + + public class Device + { + /// <summary> + /// 閫変腑鐨勮澶� + /// </summary> + public bool Checked = false; + //public string Id; + public string DeviceAddress; + public int Epoint; + //public int ClusterID; + public string DeviceName; + public string NicksName; + public string GatewayID; + /// <summary> + /// 1=寮�鍏崇伅锛�2=璋冨厜鐏紝3=RGB 鐏紝4=绐楀笜妯″潡锛�5=寮�鍚堝笜锛�6=鍗峰笜锛�7=绌鸿皟锛�8=闈㈡澘锛�9=鏂伴 + /// </summary> + public int DeviceType; + //public string RoomID; + } + + public class Scene + { + /// <summary> + /// 閫変腑鐨勫満鏅� + /// </summary> + public bool Checked = false; + //public string Id; + public string SceneName; + public int SceneID; + public int DelayTime; + //public int ClusterID; + public string NicksName; + //public string RoomID; + public string GatewayID; + } + + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundDataInfo.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundDataInfo.cs new file mode 100755 index 0000000..dd87af7 --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundDataInfo.cs @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SmartSoundDataInfo + { + public SmartSoundDataInfo() + { + } + + public string StateCode { get; set; } + public string ErrorInfo { get; set; } + public Info ResponseData { get; set; } + + public class Info + { + public List<SmartSound.Layer> LayerList { get; set; } + } + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundInfo.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundInfo.cs new file mode 100755 index 0000000..9be9dbd --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/SmartSoundInfo.cs @@ -0,0 +1,74 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + /// <summary> + /// 鏅鸿兘闊崇绫伙紝灏忓害銆佸皬鐖便�佸ぉ鐚簿鐏甸�氱敤姝ょ被 + /// </summary> + public class SmartSoundInfo + { + + public SmartSoundInfo() + { + } + + public string StateCode { get; set; } + public string ErrorInfo { get; set; } + public Info ResponseData { get; set; } + + public class Info + { + public int PageSize { get; set; } + public int PageIndex { get; set; } + public int RowCount { get; set; } + public int PageTotal { get; set; } + public List<SoundInfo> Data { get; set; } + } + + public class SoundInfo + { + public string UserID { get; set; } + public string AuthCode { get; set; } + public string Token { get; set; } + public string RefreshToken { get; set; } + /// <summary> + /// Baidu + /// </summary> + public string PlatfromName { get; set; } + public string HomeID { get; set; } + public string OpenUID { get; set; } + /// <summary> + /// 鏅鸿兘闊崇澶囨敞 + /// </summary> + public string Remark { get; set; } = "鎴戠殑闊崇"; + public string Id { get; set; } + public bool IsDeleted { get; set; } + public string CreatedOnUtc { get; set; } + /// <summary> + /// 鏅鸿兘闊崇鐨勭敤鎴峰悕锛堝皬搴︼細123456@qq.com锛� + /// </summary> + public string UserName { get; set; } = "123456@qq.com"; + } + + public class Auth + { + public string Platform { get; set; } + public string UserID { get; set; } + public string HomeID { get; set; } + + public PageSetting PageSetting { get; set; } + public Auth() + { + this.PageSetting = new PageSetting(); + } + + } + + public class PageSetting + { + public int PageSize { get; set; } = 100; + public int PageIndex { get; set; } = 1; + } + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Util/MyHttpWebResponse.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Util/MyHttpWebResponse.cs new file mode 100755 index 0000000..511b1c2 --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Util/MyHttpWebResponse.cs @@ -0,0 +1,163 @@ +锘縰sing System; +using System.IO; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.Phone.UserCenter.SmartSound.Util +{ + public class MyHttpWebResponse + { + public MyHttpWebResponse() + { + } + + /// <summary> + /// Get鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="getUrl">鎺ュ彛鍦板潃</param> + /// <returns></returns> + public static async Task<string> GetWebRequest(string getUrl) + { + + string responseContent = ""; + + try + { + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getUrl); + request.ContentType = "application/json"; + request.Method = "GET"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (Stream resStream = response.GetResponseStream()) + { + using (StreamReader reader = new StreamReader(resStream, Encoding.UTF8)) + { + responseContent = reader.ReadToEnd().ToString(); + } + } + } + catch (Exception e) { } + return responseContent; + } + + /// <summary> + /// Post鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string PostWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "POST"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + reqStream.Close(); + } + + //var ssss = webReq.GetResponse(); + + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + + /// <summary> + /// Put鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string PutWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "PUT"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + //reqStream.Close(); + } + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + + /// <summary> + /// delete鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string DeleteWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "DELETE"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + //reqStream.Close(); + } + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/MyButton.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/MyButton.cs new file mode 100755 index 0000000..e9528ff --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/MyButton.cs @@ -0,0 +1,49 @@ +锘縰sing System; +namespace Shared.Phone.UserCenter.SmartSound +{ + public class MyButton:Button + { + //榛樿瀛椾綋澶у皬 + private float textSize = 15; + + public MyButton() + { + base.TextSize = textSize; + } + + public new float TextSize + { + get => base.TextSize; + set + { + textSize = value; + base.TextSize = textSize; + } + } + + public new string Text { + get { + return base.Text; + } + set { + base.Text = value; + recalculateWidth(); + } + } + + public override uint BackgroundColor + { + get { return base.BackgroundColor; } + set + { + base.BackgroundColor = value; + recalculateWidth(); + } + } + + private void recalculateWidth() { + + this.Width = this.GetTextWidth()+Application.GetRealWidth(50); + } + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/SoundRowLayout.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/SoundRowLayout.cs new file mode 100755 index 0000000..8569384 --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/SoundRowLayout.cs @@ -0,0 +1,66 @@ +锘縰sing System; +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SoundRowLayout : RowLayoutControl + { + + /// <summary> + /// 閲嶅懡鍚嶆寜閽� + /// </summary> + public NormalViewControl btnRename = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + /// <summary> + /// 澶囨敞 + /// </summary> + public NormalViewControl btnRemark = null; + /// <summary> + /// 鍥剧墖璺緞 + /// </summary> + public string ImagePath = "SmartSound/SoundIcon.png"; + + /// <summary> + /// 鏅鸿兘闊崇澶囨敞鍚嶇О + /// </summary> + public string Remark = ""; + + + public SoundRowLayout() + { + // this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + try + { + //鍥炬爣 + var btnIcon = frameTable.AddLeftIcon(81); + + btnIcon.UnSelectedImagePath = ImagePath; + btnIcon.SelectedImagePath = ImagePath; + + //澶囨敞鍚嶇О鎸夐挳 + btnRemark = frameTable.AddLeftCaption(Remark, 800); + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnRename = base.AddEditorControl(); + btnRename.Text = "閲嶅懡鍚�"; + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "瑙i櫎缁戝畾"; + } + catch (Exception e) + { + // + } + } + } +} diff --git a/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/TextDialog.cs b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/TextDialog.cs new file mode 100755 index 0000000..523da8f --- /dev/null +++ b/Home0618/Shared/Phone/Device/Logic/SmartSound/Widget/TextDialog.cs @@ -0,0 +1,143 @@ +锘縰sing System; + +namespace Shared.Phone.UserCenter.SmartSound.Widget +{ + + public class TextDialog : FrameLayout + { + + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 纭鎸夐挳浜嬩欢 + /// </summary> + public Action ComfirmClickEvent; + + /// <summary> + /// 鏍囬鎺т欢 + /// </summary> + private NormalViewControl btnTitle = null; + /// <summary> + /// 鍙栨秷鎸夐挳 + /// </summary> + private BottomLeftClickButton btnCancel = null; + /// <summary> + /// 纭鎸夐挳 + /// </summary> + private BottomRightClickButton btnConfirm = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// + /// </summary> + /// <param name="msg">鎻愮ず鍐呭</param> + /// <param name="btnText">纭鎸夐挳 Text</param> + public TextDialog(string msg,string btnText) + { + //娣诲姞鐣岄潰 + var nowForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1); + if (nowForm == null || (nowForm is ViewGroup) == false) + { + return; + } + this.BackgroundColor = UserCenterColor.Current.DialogBackColor; + ((ViewGroup)nowForm).AddChidren(this); + + //鐧借壊鑳屾櫙妗� + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(507); + frameBack.Width = Application.GetRealWidth(792); + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Y = Application.GetRealHeight(691); + frameBack.Gravity = Gravity.CenterHorizontal; + frameBack.Radius = (uint)Application.GetRealHeight(17); + this.AddChidren(frameBack); + + //鏍囬淇℃伅 + this.btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false); + btnTitle.Y = Application.GetRealHeight(68); + btnTitle.TextColor = UserCenterColor.Current.TextColor1; + btnTitle.TextSize = 16; + btnTitle.TextAlignment = TextAlignment.Center; + frameBack.AddChidren(btnTitle); + + //娑堟伅 + var btnMsg = new NormalViewControl(frameBack.Width - Application.GetRealWidth(55 * 2), Application.GetRealHeight(180), false); + btnMsg.Y = Application.GetRealHeight(141); + btnMsg.IsMoreLines = true; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg.Gravity = Gravity.CenterHorizontal; + btnMsg.Text = msg; + frameBack.AddChidren(btnMsg); + + //鍙栨秷 + this.btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127)); + frameBack.AddChidren(btnCancel); + btnCancel.InitControl(Language.StringByID(R.MyInternationalizationString.uCancel)); + btnCancel.ButtonClickEvent += (sender, e) => + { + //绉婚櫎鐣岄潰 + this.CloseDialog(); + }; + + //纭 + this.btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height); + frameBack.AddChidren(btnConfirm); + btnConfirm.InitControl(btnText); + btnConfirm.ButtonClickEvent += (sender, e) => + { + //鍥炶皟鍑芥暟 + this.ComfirmClickEvent?.Invoke(); + }; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public void CloseDialog() + { + this.ComfirmClickEvent = null; + this.RemoveFromParent(); + } + + #endregion + + #region 鈻� 璁剧疆淇℃伅___________________________ + + /// <summary> + /// 璁剧疆鏍囬淇℃伅 + /// </summary> + /// <param name="txtValue"></param> + public void SetTitleText(string txtValue) + { + this.btnTitle.Text = txtValue; + } + /// <summary> + /// 璁剧疆鍙栨秷鎸夐挳鐨勬枃鏈俊鎭� + /// </summary> + /// <param name="txtValue"></param> + public void SetCancelButtonText(string txtValue) + { + this.btnCancel.SetButtonText(txtValue); + } + + /// <summary> + /// 璁剧疆纭畾鎸夐挳鐨勬枃鏈俊鎭� + /// </summary> + /// <param name="txtValue"></param> + public void SetOkButtonText(string txtValue) + { + this.btnConfirm.SetButtonText(txtValue); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs b/Home0618/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs new file mode 100755 index 0000000..833d002 --- /dev/null +++ b/Home0618/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs @@ -0,0 +1,380 @@ +锘縰sing Shared.Common; +using Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.MainPage.ControlForm +{ + /// <summary> + /// 鑹叉俯鐏被鍨嬬殑娣卞害鍗$墖鐣岄潰 + /// </summary> + public class DeviceColorTemperatureLightDetailCardForm : DeviceDetailCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鐣岄潰涓婂彲浠ユ搷浣滅殑鎺т欢 + /// </summary> + private List<ButtonBase> listControl = new List<ButtonBase>(); + /// <summary> + /// MaxLevel + /// </summary> + private const int MaxLevel = 254; + /// <summary> + /// 褰╃伅鎺т欢 + /// </summary> + private WaveSeekBar waveSeekBar = null; + /// <summary> + /// 杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓� + /// </summary> + private bool isProgressing = false; + /// <summary> + /// 鑳藉惁鍙戦�佽繘搴﹀�� + /// </summary> + private bool canSetProgressValue = true; + /// <summary> + /// 褰╃伅鏄惁鏄墦寮�鐘舵��(涓嶈兘鐢ㄦ帶浠剁殑Select鏉ュ垽鏂�,澶潙) + /// </summary> + private bool IsLightOpen = false; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 搴曞眰鍒濆鍖栦腑閮ㄦ帶浠跺畬鎴愪箣鍚� + /// </summary> + /// <param name="frameWhiteBack"></param> + public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack) + { + //宸︽粦涓嶈兘 + this.ScrollEnabled = false; + //鍏堟竻绌� + this.listControl = new List<ButtonBase>(); + //璁剧疆鐘舵�佹枃瀛� + if (((LightBase)this.device).OnOffStatus == 1) + { + //浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + else + { + //鍏抽棴 + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + } + + //褰╃伅鎺т欢 + this.waveSeekBar = new WaveSeekBar(); + waveSeekBar.Y = Application.GetRealHeight(233); + waveSeekBar.Width = this.GetPictrueRealSize(253); + waveSeekBar.Height = this.GetPictrueRealSize(516); + waveSeekBar.Gravity = Gravity.CenterHorizontal; + waveSeekBar.WavePadding = Application.GetRealWidth(8); + waveSeekBar.MaxValue = 100; + waveSeekBar.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100); + waveSeekBar.CornerRadius = Application.GetRealHeight(58); + frameWhiteBack.AddChidren(waveSeekBar); + + //寮�鍏� + var btnSwitch = new IconViewControl(81); + btnSwitch.UnSelectedImagePath = "Item/Switch.png"; + btnSwitch.SelectedImagePath = "Item/SwitchSelected.png"; + btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(418); + btnSwitch.Gravity = Gravity.CenterHorizontal; + frameWhiteBack.AddChidren(btnSwitch); + listControl.Add(btnSwitch); + btnSwitch.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetSwitchCommand(!btnSwitch.IsSelected); + }; + + //璁剧疆鍒濆鐘舵�� + this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1; + this.canSetProgressValue = this.IsLightOpen; + if (IsLightOpen == true) + { + btnSwitch.IsSelected = true; + waveSeekBar.IsClickable = true; + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); + } + else + { + waveSeekBar.IsClickable = false; + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); + } + + //褰╃伅鎺т欢閲岄潰鐨勯偅涓樉绀虹櫨鍒嗘瘮鐨勬帶浠� + int progressY = waveSeekBar.Y - Application.GetMinReal(154); + var btnProgress = new NormalViewControl(Application.GetMinReal(135), Application.GetMinReal(104), false); + btnProgress.Y = progressY; + btnProgress.UnSelectedImagePath = "Item/ProgressBubbles.png"; + btnProgress.IsBold = true; + btnProgress.TextColor = UserCenterColor.Current.White; + btnProgress.Gravity = Gravity.CenterHorizontal; + btnProgress.TextAlignment = TextAlignment.Center; + frameWhiteBack.AddChidren(btnProgress); + btnProgress.Visible = false; + + //寮�濮嬫粦鍔ㄧ殑浜嬩欢 + waveSeekBar.OnStartTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬪彉鏇� + this.isProgressing = true; + //鍙樻洿杩涘害鐧惧垎姣旂殑鏄剧ず + btnProgress.Y = progressY + waveSeekBar.NowProgressY; + btnProgress.Text = waveSeekBar.Progress + "%"; + waveSeekBar.IsProgressTextShow = false; + if (btnProgress.Visible == false) + { + btnProgress.Visible = true; + } + }; + + //缁撴潫婊戝姩鐨勪簨浠� + waveSeekBar.OnStopTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬬粨鏉� + this.isProgressing = false; + btnProgress.Visible = false; + waveSeekBar.IsProgressTextShow = true; + }; + + //婊戝姩杩囩▼涓� + int oldProgressValue = waveSeekBar.Progress;//涔嬪墠鐨勫�� + int nowProgressValue = oldProgressValue;//鍙樻洿鐨勫�� + waveSeekBar.OnProgressChangedEvent += (sender, value) => + { + //鍙樻洿杩涘害鐧惧垎姣旂殑鏄剧ず + btnProgress.Y = progressY + waveSeekBar.NowProgressY; + btnProgress.Text = value + "%"; + if (Common.Config.Instance.Home.IsVirtually == false) + { + nowProgressValue = value; + } + else + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛� + ((ColorTemperatureLight)this.device).Level = value * MaxLevel / 100; + //浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + }; + + //鑹叉俯 + var btnColor = new NormalViewControl(300, 50, true); + btnColor.X = Application.GetRealWidth(132); + btnColor.Y = Application.GetRealHeight(829); + btnColor.TextSize = 12; + btnColor.Text = Language.StringByID(R.MyInternationalizationString.uColorTemperature) + "锛�"; + btnColor.TextColor = UserCenterColor.Current.TextGrayColor3; + frameWhiteBack.AddChidren(btnColor); + //涓婇儴鏄剧ず鏂囨湰 + var btnColorView = new NormalViewControl(150, 60, true); + btnColorView.Y = btnColor.Bottom; + btnColorView.TextAlignment = TextAlignment.Center; + btnColorView.TextSize = 15; + btnColorView.Gravity = Gravity.CenterHorizontal; + btnColorView.TextColor = UserCenterColor.Current.TextGrayColor3; + frameWhiteBack.AddChidren(btnColorView); + //杩涘害鏉�(鑹叉俯鐨勮寖鍥存槸 3400~6000) + var seekBar1 = new SeekBarControl(683); + seekBar1.Y = btnColorView.Bottom; + seekBar1.MinValue = 34; + seekBar1.MaxValue = 60; + seekBar1.ProgressBarColor = 0xff707070; + seekBar1.SeekBarViewHeight = Application.GetRealHeight(19); + frameWhiteBack.AddChidren(seekBar1); + + int oldColorValue = 0; + int nowColorValue = 0; + seekBar1.ProgressChangedEvent += (div, value) => + { + //鏁版嵁鍙樻洿 + btnColorView.Text = value * 100 + "K"; + if (Common.Config.Instance.Home.IsVirtually == false) + { + nowColorValue = value; + } + }; + //璁剧疆鍒濆鍊� + int colorValue = ((ColorTemperatureLight)this.device).ColorTemperature; + if (colorValue == 0) { colorValue = 3400; } + seekBar1.Progress = colorValue / 100; + btnColorView.Text = colorValue + "K"; + + //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆� + HdlThreadLogic.Current.RunThread(() => + { + while (this.Parent != null) + { + System.Threading.Thread.Sleep(1000); + //鑳藉鍙戦�� + if (this.canSetProgressValue == true) + { + //鍙戦�佷寒搴﹀�� + if (nowProgressValue != oldProgressValue) + { + oldProgressValue = nowProgressValue; + ((ColorTemperatureLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0)); + } + //鍙戦�佽壊娓╁�� + if (nowColorValue != oldColorValue) + { + oldColorValue = nowColorValue; + ((ColorTemperatureLight)this.device).SetColorTemperature(oldColorValue * 100); + } + } + } + //鐣岄潰鍏抽棴鏃� + if (nowProgressValue != oldProgressValue) + { + //鍙戦�佷寒搴﹀�� + ((ColorTemperatureLight)this.device).SetLevel((int)(nowProgressValue * MaxLevel / 100.0)); + } + if (nowColorValue != oldColorValue) + { + //鍙戦�佽壊娓╁�� + ((ColorTemperatureLight)this.device).SetColorTemperature(nowColorValue * 100); + } + }); + } + + #endregion + + #region 鈻� 鍙戦�佸紑鍏冲懡浠______________________ + + /// <summary> + /// 鍙戦�佸紑鍏冲懡浠� + /// </summary> + /// <param name="isOpen"></param> + private void SetSwitchCommand(bool isOpen) + { + //濡傛灉浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0; + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(isOpen); + return; + } + + //褰撴寜涓嬪紑鍏虫寜閽椂,涓嶈兘鍐嶅彂閫佽繘搴﹀�� + this.canSetProgressValue = false; + + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(this.listControl, (result) => + { + HdlThreadLogic.Current.RunMain(() => + { + bool statu = ((LightBase)this.device).OnOffStatus == 1; + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) + { + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(statu); + //鐘舵�佸彇鍙� + listControl[0].IsSelected = statu; + } + if (statu == true) + { + //绛夊緟缁撴灉缁撴潫鍚�,褰╃伅鎺т欢鍙互婊戝姩 + waveSeekBar.IsClickable = true; + } + }); + }); + + //鍙戦�佺瓑寰呯殑鏃堕棿鍐�,涓嶈兘婊戝姩褰╃伅鎺т欢 + waveSeekBar.IsClickable = false; + if (isOpen == true) + { + //鎵撳紑 + this.device.SwitchControl(1); + } + else + { + //鍏抽棴 + this.device.SwitchControl(0); + } + } + + #endregion + + #region 鈻� 鏄惁鑾峰彇缃戝叧鍙嶉鐨勭粨鏋淿____________ + + /// <summary> + /// 妫�娴嬬綉鍏崇殑鍙嶉缁撴灉(灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport) + /// </summary> + /// <param name="comandDiv">鍛戒护鍖哄垎</param> + /// <param name="report">涓婃姤鏁版嵁</param> + /// <returns></returns> + public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report) + { + if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1); + }); + return true; + } + return false; + } + + #endregion + + #region 鈻� 鍒锋柊寮�鍏崇姸鎬乢______________________ + + /// <summary> + /// 鍒锋柊寮�鍏崇姸鎬� + /// </summary> + /// <param name="isOpen">鎵撳紑鐘舵��</param> + private void RefreshSwitchStatu(bool isOpen) + { + if (isOpen == true) + { + //浜害鏄繀椤昏鍒锋柊鐨� 浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + if (this.isProgressing == false) + { + //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫� + waveSeekBar.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100); + } + } + if (isOpen == false && this.IsLightOpen == true) + { + //鐘舵�佷笉涓�鏍�,鎵嶅彉鏇村瓧鏍�:鍏抽棴 + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + } + + if (listControl[0].IsSelected != isOpen) + { + //寮�鍏崇姸鎬佸彉鏇� + listControl[0].IsSelected = isOpen; + } + + //鐘舵�佷笉涓�鏍锋墠鍙樻洿 + if (this.IsLightOpen != isOpen) + { + if (isOpen == true) + { + waveSeekBar.IsClickable = true; + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); + } + else + { + waveSeekBar.IsClickable = false; + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); + } + } + this.IsLightOpen = isOpen; + //鍥炲鐨勭粨鏋滆,澶勪簬鎵撳紑鐘舵�佹墠鑳藉彂閫� + this.canSetProgressValue = this.IsLightOpen; + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs b/Home0618/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs new file mode 100755 index 0000000..9493372 --- /dev/null +++ b/Home0618/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs @@ -0,0 +1,511 @@ +锘縰sing Shared.Common; +using Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.MainPage.ControlForm +{ + /// <summary> + /// mini澶滅伅鐨勬繁搴﹀崱鐗囩晫闈� + /// </summary> + public class DeviceMiniLightDetailCardForm : DeviceDetailCardCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 铚傞福鍣ㄧ殑寮�鍏虫帶浠� + /// </summary> + private IconBigViewControl btnBuzzerSwitch = null; + /// <summary> + /// mini澶滅伅鐨勫紑鍏虫帶浠� + /// </summary> + private IconBigViewControl btnMiniSwitch = null; + /// <summary> + /// 浜害鐨勮繘搴︽潯鎺т欢 + /// </summary> + private SeekBarControl seekBarLight = null; + /// <summary> + /// 鑹叉俯鐨勮繘搴︽潯鎺т欢 + /// </summary> + private SeekBarControl seekBarColor = null; + /// <summary> + /// MaxLevel + /// </summary> + private const int MaxLevel = 254; + /// <summary> + /// 浜害杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓� + /// </summary> + private bool isLightProgressing = false; + /// <summary> + /// 鑹叉俯杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓� + /// </summary> + private bool isColorProgressing = false; + /// <summary> + /// 鑳藉惁鍙戦�佽繘搴﹀�� + /// </summary> + private bool canSetProgressValue = true; + /// <summary> + /// 1:鍙戦�佺殑鏄皬澶滅伅 2:鍙戦�佺殑鏄渹楦e櫒 + /// </summary> + private int sendDiv = 0; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 搴曞眰鍒濆鍖栦腑閮ㄦ帶浠跺畬鎴愪箣鍚� + /// </summary> + /// <param name="frameWhiteBack"></param> + public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack) + { + //娣诲姞鎺ユ敹铚傞福鍣ˋck涓婚 + this.AddReceiveBuzzerAckEvent(); + + //宸︽粦涓嶈兘 + this.ScrollEnabled = false; + //璁剧疆鐘舵�佹枃瀛� + if (((LightBase)this.device).OnOffStatus == 1) + { + //浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + else + { + //鍏抽棴 + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + } + + //浜害 + var btnLightView = new NormalViewControl(300, 60, true); + btnLightView.Text = Language.StringByID(R.MyInternationalizationString.uBrightness) + ":"; + btnLightView.X = Application.GetRealWidth(43); + btnLightView.Y = Application.GetRealHeight(320); + frameWhiteBack.AddChidren(btnLightView); + //搴曠嚎 + var btnLightLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false); + btnLightLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + btnLightLine.X = btnLightView.X; + btnLightLine.Y = btnLightView.Bottom + Application.GetRealHeight(37); + frameWhiteBack.AddChidren(btnLightLine); + //杩涘害鏉�(+60鐨勫亸绉婚噺) + this.seekBarLight = new SeekBarControl(611 + 120); + seekBarLight.Y = Application.GetRealHeight(280); + seekBarLight.X = Application.GetRealWidth(266 - 60); + seekBarLight.Height = Application.GetRealHeight(144); + seekBarLight.SeekBarViewHeight = Application.GetRealHeight(20); + seekBarLight.SeekBarPadding = Application.GetRealWidth(60); + seekBarLight.IsProgressTextShow = true; + seekBarLight.ProgressBarColor = 0xffff6c2c; + seekBarLight.ProgressTextSize = 14; + seekBarLight.ProgressTextColor = UserCenterColor.Current.TextGrayColor2; + seekBarLight.Gravity = Gravity.Frame; + seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100); + frameWhiteBack.AddChidren(seekBarLight); + + //鑹叉俯 + var btnColorView = new NormalViewControl(300, 60, true); + btnColorView.Text = Language.StringByID(R.MyInternationalizationString.uColorTemperature) + ":"; + btnColorView.X = Application.GetRealWidth(43); + btnColorView.Y = btnLightLine.Y + Application.GetRealHeight(107); + frameWhiteBack.AddChidren(btnColorView); + //搴曠嚎 + var btnColorLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false); + btnColorLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + btnColorLine.X = btnColorView.X; + btnColorLine.Y = btnColorView.Bottom + Application.GetRealHeight(37); + frameWhiteBack.AddChidren(btnColorLine); + //鑹叉俯鐨勬笎鍙樿壊鑳屾櫙 + var btnColorBack = new PicViewControl(611, 20); + btnColorBack.UnSelectedImagePath = "Item/ColorTemperatureBar.png"; + btnColorBack.X = Application.GetRealWidth(266); + btnColorBack.Y = btnColorView.Y + btnColorView.Height / 2 - HdlControlLogic.Current.GetPictrueRealSize(20) / 2; + frameWhiteBack.AddChidren(btnColorBack); + //杩涘害鏉�(+60鐨勫亸绉婚噺,鑹叉俯鐨勮寖鍥存槸 3400~6000) + this.seekBarColor = new SeekBarControl(611 + 120); + seekBarColor.Y = btnLightLine.Bottom + Application.GetRealHeight(58); + seekBarColor.X = Application.GetRealWidth(266 - 60); + seekBarColor.Height = Application.GetRealHeight(144); + seekBarColor.SeekBarViewHeight = Application.GetRealHeight(20); + seekBarColor.SeekBarPadding = Application.GetRealWidth(60); + seekBarColor.IsProgressTextShow = true; + seekBarColor.ProgressBarColor = UserCenterColor.Current.Transparent; + seekBarColor.SeekBarBackgroundColor = UserCenterColor.Current.Transparent; + seekBarColor.ProgressTextSize = 14; + seekBarColor.ProgressTextColor = UserCenterColor.Current.TextGrayColor2; + seekBarColor.Gravity = Gravity.Frame; + seekBarColor.ProgressBarUnitSring = "K"; + seekBarColor.MinValue = 34; + seekBarColor.MaxValue = 60; + frameWhiteBack.AddChidren(seekBarColor); + //璁剧疆鍒濆鍊� + int colorValue = ((ColorTemperatureLight)this.device).ColorTemperature; + if (colorValue == 0) { colorValue = 3400; } + seekBarColor.Progress = colorValue / 100; + + //铚傞福鍣ㄥ紑鍏筹細 + var btnBuzzerView = new NormalViewControl(300, 60, true); + btnBuzzerView.Text = Language.StringByID(R.MyInternationalizationString.uBuzzerSwitch) + ":"; + btnBuzzerView.X = Application.GetRealWidth(43); + btnBuzzerView.Y = btnColorLine.Y + Application.GetRealHeight(107); + frameWhiteBack.AddChidren(btnBuzzerView); + //搴曠嚎 + var btnBuzzerLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false); + btnBuzzerLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + btnBuzzerLine.X = btnBuzzerView.X; + btnBuzzerLine.Y = btnBuzzerView.Bottom + Application.GetRealHeight(37); + frameWhiteBack.AddChidren(btnBuzzerLine); + //寮�鍏� + this.btnBuzzerSwitch = new IconBigViewControl(81, 81); + btnBuzzerSwitch.UnSelectedImagePath = "Item/Switch.png"; + btnBuzzerSwitch.SelectedImagePath = "Item/SwitchSelected.png"; + frameWhiteBack.AddChidren(btnBuzzerSwitch); + btnBuzzerSwitch.InitControl(); + btnBuzzerSwitch.UseClickStatu = false; + btnBuzzerSwitch.X = Application.GetRealWidth(795) - btnBuzzerSwitch.XOffset; + btnBuzzerSwitch.Y = btnColorLine.Y + Application.GetRealHeight(98) - btnBuzzerSwitch.YOffset; + btnBuzzerSwitch.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetBuzzerSwitchCommand(!btnBuzzerSwitch.IsSelected); + }; + + //灏忓鐏紑鍏筹細 + var btnMiniView = new NormalViewControl(300, 60, true); + btnMiniView.Text = Language.StringByID(R.MyInternationalizationString.uMiniLightSwitch) + ":"; + btnMiniView.X = Application.GetRealWidth(43); + btnMiniView.Y = btnBuzzerLine.Y + Application.GetRealHeight(107); + frameWhiteBack.AddChidren(btnMiniView); + //搴曠嚎 + var btnMiniLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false); + btnMiniLine.BackgroundColor = UserCenterColor.Current.ButtomLine; + btnMiniLine.X = btnMiniView.X; + btnMiniLine.Y = btnMiniView.Bottom + Application.GetRealHeight(37); + frameWhiteBack.AddChidren(btnMiniLine); + //寮�鍏� + this.btnMiniSwitch = new IconBigViewControl(81, 81); + btnMiniSwitch.UnSelectedImagePath = "Item/Switch.png"; + btnMiniSwitch.SelectedImagePath = "Item/SwitchSelected.png"; + frameWhiteBack.AddChidren(btnMiniSwitch); + btnMiniSwitch.InitControl(); + btnMiniSwitch.UseClickStatu = false; + btnMiniSwitch.X = Application.GetRealWidth(795) - btnMiniSwitch.XOffset; + btnMiniSwitch.Y = btnBuzzerLine.Y + Application.GetRealHeight(98) - btnMiniSwitch.YOffset; + btnMiniSwitch.ButtonClickEvent += (sender, e) => + { + //鍙戦�佸紑鍏冲懡浠� + this.SetLightSwitchCommand(!btnMiniSwitch.IsSelected); + }; + btnMiniSwitch.IsSelected = ((LightBase)this.device).OnOffStatus == 1; + this.canSetProgressValue = btnMiniSwitch.IsSelected; + + //浜害寮�濮嬫粦鍔ㄧ殑浜嬩欢 + seekBarLight.OnStartTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬪彉鏇� + this.isLightProgressing = true; + }; + + //浜害缁撴潫婊戝姩鐨勪簨浠� + seekBarLight.OnStopTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬬粨鏉� + this.isLightProgressing = false; + }; + + //浜害婊戝姩杩囩▼涓� + int oldLightValue = seekBarLight.Progress;//涔嬪墠鐨勫�� + int nowLightValue = oldLightValue;//鍙樻洿鐨勫�� + seekBarLight.OnProgressChangedEvent += (sender, value) => + { + if (Common.Config.Instance.Home.IsVirtually == false) + { + if (this.canSetProgressValue == true) + { + //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰� + nowLightValue = value; + } + } + else + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛� + ((ColorTemperatureLight)this.device).Level = value * MaxLevel / 100; + //浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } + }; + + + //鑹叉俯寮�濮嬫粦鍔ㄧ殑浜嬩欢 + seekBarColor.OnStartTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬪彉鏇� + this.isColorProgressing = true; + }; + + //鑹叉俯缁撴潫婊戝姩鐨勪簨浠� + seekBarColor.OnStopTrackingTouchEvent += (sender, e) => + { + //杩涘害鍊煎紑濮嬬粨鏉� + this.isColorProgressing = false; + }; + + //鑹叉俯婊戝姩杩囩▼涓� + int oldColorValue = seekBarColor.Progress;//涔嬪墠鐨勫�� + int nowColorValue = oldColorValue;//鍙樻洿鐨勫�� + seekBarColor.OnProgressChangedEvent += (sender, value) => + { + if (Common.Config.Instance.Home.IsVirtually == false) + { + if (this.canSetProgressValue == true) + { + //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰� + nowColorValue = value; + } + } + else + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛� + ((ColorTemperatureLight)this.device).ColorTemperature = value * 100; + } + }; + + //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆� + HdlThreadLogic.Current.RunThread(() => + { + while (this.Parent != null) + { + System.Threading.Thread.Sleep(1000); + //鍙戦�佷寒搴﹀�� + if (nowLightValue != oldLightValue) + { + oldLightValue = nowLightValue; + ((ColorTemperatureLight)this.device).SetLevel((int)(oldLightValue * MaxLevel / 100.0)); + } + //鍙戦�佽壊娓╁�� + if (nowColorValue != oldColorValue) + { + oldColorValue = nowColorValue; + ((ColorTemperatureLight)this.device).SetColorTemperature(oldColorValue * 100); + } + } + if (this.canSetProgressValue == true) + { + //鐣岄潰鍏抽棴鏃� + if (nowLightValue != oldLightValue) + { + //鍙戦�佷寒搴﹀�� + ((ColorTemperatureLight)this.device).SetLevel((int)(nowLightValue * MaxLevel / 100.0)); + } + if (nowColorValue != oldColorValue) + { + //鍙戦�佽壊娓╁�� + ((ColorTemperatureLight)this.device).SetColorTemperature(nowColorValue * 100); + } + } + }); + } + + #endregion + + #region 鈻� 鍙戦�佸鐏紑鍏冲懡浠__________________ + + /// <summary> + /// 鍙戦�佸鐏紑鍏冲懡浠� + /// </summary> + /// <param name="isOpen"></param> + private void SetLightSwitchCommand(bool isOpen) + { + //濡傛灉浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0; + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(isOpen); + return; + } + + //褰撴寜涓嬪紑鍏虫寜閽椂,涓嶈兘鍐嶅彂閫佽繘搴﹀�� + this.canSetProgressValue = false; + + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(new List<ButtonBase> { this.btnMiniSwitch.btnIcon }, (result) => + { + HdlThreadLogic.Current.RunMain(() => + { + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) + { + bool statu = ((LightBase)this.device).OnOffStatus == 1; + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(statu); + if (statu == true) + { + //褰撴槸鎵撳紑鐘舵�佹椂,缃戝叧璇村畠浼氶粯璁ゆ妸浜害鍙樻垚100% + //浠ラ槻涓囦竴,杩欓噷鍐嶆璇诲彇涓�涓� + ((ColorTemperatureLight)device).ReadLevel(); + } + } + }); + }); + + this.sendDiv = 1; + if (isOpen == true) + { + //鎵撳紑 + this.device.SwitchControl(1); + } + else + { + //鍏抽棴 + this.device.SwitchControl(0); + } + } + + #endregion + + #region 鈻� 鍙戦�佽渹楦e櫒寮�鍏冲懡浠________________ + + /// <summary> + /// 鍙戦�佽渹楦e櫒寮�鍏冲懡浠� + /// </summary> + /// <param name="isOpen"></param> + private void SetBuzzerSwitchCommand(bool isOpen) + { + //濡傛灉浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + //((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0; + ////鍒锋柊寮�鍏崇姸鎬� + //this.RefreshSwitchStatu(isOpen); + return; + } + + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(new List<ButtonBase> { this.btnBuzzerSwitch.btnIcon }, (result) => + { + HdlThreadLogic.Current.RunMain(() => + { + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) + { + this.btnBuzzerSwitch.IsSelected = isOpen; + //bool statu = ((LightBase)this.device).OnOffStatus == 1; + ////鍒锋柊寮�鍏崇姸鎬� + //this.RefreshSwitchStatu(statu); + } + }); + }); + //鍙戦�佸懡浠� + this.sendDiv = 2; + ((ColorTemperatureLight)this.device).SendBuzzerSwitchControl(isOpen); + } + + /// <summary> + /// 娣诲姞鎺ユ敹铚傞福鍣ˋck涓婚 + /// </summary> + private void AddReceiveBuzzerAckEvent() + { + //Ack涓婚涓婃姤 + string mainKeys = LocalDevice.Current.GetDeviceMainKeys(this.device); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceBuzzerDetailCardACK", ReceiveComandDiv.A鑺傜偣鎺у埗鍙嶉, (report) => + { + string mainKey2 = LocalDevice.Current.GetDeviceMainKeys(report); + if (mainKeys != mainKey2) + { + //涓嶆槸鍚屼竴涓笢瑗� + return; + } + //杩欓噷鍙鐞嗚渹楦e櫒鐨� + if (this.sendDiv == 2) + { + //缁撴灉宸茬粡鎺ユ敹鍒� + this.ResponeResult = 1; + } + }); + } + + #endregion + + #region 鈻� 鏄惁鑾峰彇缃戝叧鍙嶉鐨勭粨鏋淿____________ + + /// <summary> + /// 妫�娴嬬綉鍏崇殑鍙嶉缁撴灉(灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport) + /// </summary> + /// <param name="comandDiv">鍛戒护鍖哄垎</param> + /// <param name="report">涓婃姤鏁版嵁</param> + /// <returns></returns> + public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report) + { + if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1); + }); + return true; + } + return false; + } + + #endregion + + #region 鈻� 鍒锋柊寮�鍏崇姸鎬乢______________________ + + /// <summary> + /// 鍒锋柊寮�鍏崇姸鎬� + /// </summary> + /// <param name="isOpen">鎵撳紑鐘舵��</param> + private void RefreshSwitchStatu(bool isOpen) + { + if (this.isColorProgressing == true) + { + //濡傛灉鏄壊娓╂粦鍔ㄧ殑璇�,涓嶉渶瑕佸埛鏂扮晫闈� + return; + } + if (isOpen == true) + { + //浜害鏄繀椤昏鍒锋柊鐨� 浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + if (this.isLightProgressing == false) + { + //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫� + seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100); + } + if (this.isColorProgressing == false) + { + //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫� + seekBarColor.Progress = (int)(((ColorTemperatureLight)this.device).ColorTemperature / 100); + } + this.btnMiniSwitch.IsSelected = true; + } + else + { + //鍙樻洿瀛楁牱:鍏抽棴 + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + this.btnMiniSwitch.IsSelected = false; + } + + //鍥炲鐨勭粨鏋滆,澶勪簬鎵撳紑鐘舵�佹墠鑳藉彂閫� + this.canSetProgressValue = isOpen; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + base.CloseFormBefore(); + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceBuzzerDetailCardACK"); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorTemperatureCardControl.cs b/Home0618/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorTemperatureCardControl.cs new file mode 100755 index 0000000..633c0ff --- /dev/null +++ b/Home0618/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorTemperatureCardControl.cs @@ -0,0 +1,129 @@ +锘縰sing Shared.Phone.UserCenter; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.MainPage.Controls +{ + /// <summary> + /// 鑹叉俯鐏崱鐗囨帶浠� + /// </summary> + public class DeviceColorTemperatureCardControl : DeviceCardCommon + { + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + /// <param name="i_device"></param> + public override void InitControl(CommonDevice i_device, Common.Room i_nowSelectRoom) + { + base.InitControl(i_device, i_nowSelectRoom); + + //娣诲姞璺宠浆娣卞害鍗$墖淇℃伅浜嬩欢 + this.AddDetailInfoEvent(i_device); + + //娣诲姞寮�鍏虫帶浠� + var btnSwitch = this.AddSwitchControl(); + btnSwitch.ButtonClickEvent += (sender, e) => + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + //鐩存帴鍙樻洿缂撳瓨 + ((LightBase)i_device).OnOffStatus = btnSwitch.IsSelected == true ? 0 : 1; + this.RefreshControlInfo(this.device); + return; + } + bool setStatu = !btnSwitch.IsSelected; + //鍙樻洿鍗$墖鐘舵�� + this.SetCardOpenStatu(setStatu); + //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 + this.StartCheckResponeResult(!setStatu); + + if (setStatu == true) + { + //鎵撳紑 + this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1)); + i_device.SwitchControl(1); + } + else + { + //鍏抽棴 + this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.Close)); + i_device.SwitchControl(0); + } + }; + } + + #endregion + + #region 鈻� 娣卞害鍗$墖淇℃伅_______________________ + + /// <summary> + /// 娣诲姞璺宠浆娣卞害鍗$墖淇℃伅浜嬩欢 + /// </summary> + private void AddDetailInfoEvent(CommonDevice i_device) + { + //娣卞害鍗$墖淇℃伅 + this.ButtonClickEvent += (sender, e) => + { + Common.CommonPage.Instance.IsDrawerLockMode = true; + + if (Common.LocalDevice.Current.IsMiniLight(this.device) == false) + { + var form = new ControlForm.DeviceColorTemperatureLightDetailCardForm(); + form.RowOrCardControl = this; + form.AddForm(i_device, this.nowSelectRoom, 965, 1466); + form.FormCloseEvent += this.CardDetailInfoBackEvent; + } + else + { + //mini澶滅伅 + var form = new ControlForm.DeviceMiniLightDetailCardForm(); + form.RowOrCardControl = this; + form.AddForm(i_device, this.nowSelectRoom, 965, 1466); + form.FormCloseEvent += this.CardDetailInfoBackEvent; + } + }; + } + + #endregion + + #region 鈻� 妫�娴嬭澶囨墦寮�鐘舵�乢__________________ + + /// <summary> + /// 妫�娴嬭澶囨墦寮�鐘舵�� + /// </summary> + /// <param name="i_device"></param> + /// <returns></returns> + public override bool CheckIsOpenStatu(CommonDevice i_device) + { + return ((LightBase)i_device).OnOffStatus == 1; + } + + #endregion + + #region 鈻� 鍙戦�佽幏鍙栫姸鎬佸懡浠__________________ + + /// <summary> + /// 鍙戦�佽幏鍙栫姸鎬佸懡浠� + /// </summary> + public override void SendStatuComand() + { + if (Common.Config.Instance.Home.IsVirtually == true) + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鍒欐鍔熻兘鏃犳晥 + return; + } + //妫�娴嬭兘鍚﹀彂閫佽幏鍙栫姸鎬佸懡浠� + if (this.CheckCanSendStatuComand() == true) + { + HdlDeviceAttributeLogic.Current.SendColorTemperatureLightStatuComand(this.device); + } + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs new file mode 100755 index 0000000..b2df8fa --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDevice.cs @@ -0,0 +1,501 @@ +锘縰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; + } + } + 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 IconViewControl 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 = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = scene.SceneName; + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + 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 = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.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 IconViewControl 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 = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = device.DeviceName; + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + 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 = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.png"; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDeviceChange.cs b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDeviceChange.cs new file mode 100755 index 0000000..f457039 --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundContentForDeviceChange.cs @@ -0,0 +1,608 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Phone.UserCenter.SmartSound.Util; + +namespace Shared.Phone.UserCenter.SmartSound.Forms +{ + public class SmartSoundContentForDeviceChange : EditorCommonForm + { + + /// <summary> + /// 褰撳墠閫変腑鐨勬埧闂� + /// </summary> + private SmartSound.Room CurrentRoom = null; + + private FrameLayout ContentLayout = null; + + private FrameLayout DeviceListViewFrameLayout = null; + /// <summary> + /// 鍦烘櫙 listView + /// </summary> + private VerticalListControl SceneListView = null; + /// <summary> + /// 璁惧 listView + /// </summary> + private VerticalListControl DeviceListView = 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 SmartSoundContentForDeviceChange(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); + + } + + /// <summary> + /// 鍔犺浇鍦烘櫙鐣岄潰 + /// </summary> + private void LoadSceneView() + { + try + { + //3.璁惧鍒楄〃 ListView + ContentLayout.RemoveAll(); + + var tipLayout = new FrameLayout(); + ContentLayout.AddChidren(tipLayout); + tipLayout.Visible = false; + ShowNoFunctionTip(tipLayout); + + SceneListView = new VerticalListControl(); + ContentLayout.AddChidren(SceneListView); + SceneListView.Y = Application.GetRealHeight(40); + SceneListView.RemoveAll(); + + for (int i = 0; i < CurrentRoom.SceneList.Count; i++) + { + SmartSound.Scene scene = CurrentRoom.SceneList[i]; + var roomRowLayout = new SceneRowLayout(this, scene, i); + SceneListView.AddChidren(roomRowLayout); + roomRowLayout.InitControl(); + } + + if (SceneListView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + SceneListView.AddChidren(textView); + } + + if (SceneListView.ChildrenCount == 0) + { + tipLayout.Visible = true; + } + else + { + tipLayout.Visible = false; + } + } + catch (Exception ex) + { + string eoor = ex.Message; + } + } + + private void LoadFunction() + { + try + { + + 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); + + 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(); + }; + } + + //娣诲姞 ListView + DeviceListViewFrameLayout = new FrameLayout(); + ContentLayout.AddChidren(DeviceListViewFrameLayout); + DeviceListViewFrameLayout.Y = tab_layout.Height; + DeviceListViewFrameLayout.Height = ContentLayout.Height - tab_layout.Height; + + RefreshButtonState(); + RefreshFunctionListView(); + } + catch (Exception ex) + { + string error = ex.Message; + } + } + + private void RefreshFunctionListView() + { + try + { + + DeviceListViewFrameLayout.RemoveAll(); + + DeviceListView = new VerticalListControl(); + DeviceListViewFrameLayout.AddChidren(DeviceListView); + DeviceListView.Height = DeviceListViewFrameLayout.Height; + DeviceListView.RemoveAll(); + + switch (CurrentSelectIndex) + { + case 0:// 鐏厜 + { + int n = 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + case 1: // 绐楀笜 + { + int n = 0; + 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + case 2: // 绌鸿皟 + { + int n = 0; + 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, n); + DeviceListView.AddChidren(deviceRowLayout); + deviceRowLayout.InitControl(); + n++; + } + } + } + break; + } + + if (DeviceListView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + DeviceListView.AddChidren(textView); + } + + if (DeviceListView.ChildrenCount == 0) + { + TipLayout.Visible = true; + } + else + { + TipLayout.Visible = false; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + /// <summary> + /// 淇敼鍦烘櫙鏄电О + /// </summary> + /// <param name="scene"></param> + /// <param name="sceneRowLayout"></param> + private void ShowSetNicknameDialog(SmartSound.Scene scene, SceneRowLayout sceneRowLayout) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //缂栬緫浣忓畢 + dialogForm.SetTitleText("鑷畾涔夋樀绉�"); + //璇疯緭鍏ヤ綇瀹呭悕绉� + dialogForm.SetTipText("璇疯緭鍏ユ樀绉�"); + dialogForm.Text = scene.NicksName; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + scene.NicksName = textValue; + string remark = scene.SceneName; + if (scene.NicksName.Trim() != string.Empty) + { + remark += "(" + scene.NicksName + ")"; + } + sceneRowLayout.btnCaption.Text = remark; + string json = await postBatchEdit(); + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }); + } + + /// <summary> + /// 淇敼璁惧鏄电О + /// </summary> + /// <param name="device"></param> + /// <param name="deviceRowLayout"></param> + private void ShowSetNicknameDialog(SmartSound.Device device, DeviceRowLayout deviceRowLayout) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //缂栬緫浣忓畢 + dialogForm.SetTitleText("鑷畾涔夋樀绉�"); + //璇疯緭鍏ヤ綇瀹呭悕绉� + dialogForm.SetTipText("璇疯緭鍏ユ樀绉�"); + dialogForm.Text = device.NicksName; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + device.NicksName = textValue; + string remark = device.DeviceName; + if (device.NicksName.Trim() != string.Empty) + { + remark += "(" + device.NicksName + ")"; + } + deviceRowLayout.btnCaption.Text = remark; + + string json = await postBatchEdit(); + + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }); + } + + /// <summary> + /// 鍦烘櫙鍒犻櫎 + /// </summary> + private void ShowSceneDelectDialog(SmartSound.Scene scene) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ帶鍒跺唴瀹癸紵", () => + { + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + CurrentRoom.SceneList.Remove(scene); + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + LoadSceneView(); + this.CloseProgressBar(); + }); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + /// <summary> + /// 璁惧鍒犻櫎 + /// </summary> + private void ShowDeviceDelectDialog(SmartSound.Device device) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ帶鍒跺唴瀹癸紵", () => + { + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + CurrentRoom.DeviceList.Remove(device); + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + RefreshFunctionListView(); + this.CloseProgressBar(); + }); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + /// <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; + } + } + + private async Task<string> postBatchEdit() + { + // 鎻愪氦鏁版嵁鑷虫湇鍔″櫒 + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + #region 鈻� 鑷畾涔夊満鏅�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鍦烘櫙鍒楄〃琛� + /// </summary> + private class SceneRowLayout : RowLayoutControl + { + private SmartSoundContentForDeviceChange smartSoundContentForDeviceChange = null; + + private SmartSound.Scene scene = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + public NormalViewControl btnCaption = null; + private int Index = 0; + + public SceneRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Scene _scene, int _index) + { + smartSoundContentForDeviceChange = _smartSoundContentForDeviceChange; + scene = _scene; + Index = _index; + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(175); + string remark = scene.SceneName; + if (scene.NicksName.Trim() != string.Empty) + { + remark += " (" + scene.NicksName + ")"; + } + btnCaption = frameTable.AddLeftCaption(remark, 2000); + + var nicknameIcon = frameTable.AddRightArrow();//58 + nicknameIcon.TextSize = 17; + + nicknameIcon.SelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.UnSelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.AddTag("obj", scene); + nicknameIcon.ButtonClickEvent += (sender, e) => + { + // 娣诲姞鏄电О + var btn = sender as IconViewControl; + SmartSound.Scene tmpScene = (SmartSound.Scene)btn.GetTagByKey("obj"); + smartSoundContentForDeviceChange.ShowSetNicknameDialog(tmpScene, this); + }; + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = Language.StringByID(R.MyInternationalizationString.Delete); + btnDelect.ButtonClickEvent += (sender, e) => + { + //鍒犻櫎鍦烘櫙 + smartSoundContentForDeviceChange.ShowSceneDelectDialog(scene); + }; + } + } + #endregion + + #region 鈻� 鑷畾鐏厜閫夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class DeviceRowLayout : RowLayoutControl + { + private SmartSoundContentForDeviceChange smartSoundContentForDeviceChange = null; + + private SmartSound.Device device = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + public NormalViewControl btnCaption = null; + private int Index = 0; + + public DeviceRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Device _device, int _index) + { + smartSoundContentForDeviceChange = _smartSoundContentForDeviceChange; + device = _device; + Index = _index; + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(175); + string remark = device.DeviceName; + if (device.NicksName.Trim() != string.Empty) + { + remark += " (" + device.NicksName + ")"; + } + btnCaption = frameTable.AddLeftCaption(remark, 2000); + + var nicknameIcon = frameTable.AddRightArrow();//58 + nicknameIcon.TextSize = 17; + + nicknameIcon.SelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.UnSelectedImagePath = "SmartSound/Nickname.png"; + nicknameIcon.AddTag("obj", device); + nicknameIcon.ButtonClickEvent += (sender, e) => + { + var btn = sender as IconViewControl; + SmartSound.Device tmpDevice = (SmartSound.Device)btn.GetTagByKey("obj"); + smartSoundContentForDeviceChange.ShowSetNicknameDialog(tmpDevice, this); + }; + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "鍒犻櫎"; + btnDelect.ButtonClickEvent += (sender, e) => + { + smartSoundContentForDeviceChange.ShowDeviceDelectDialog(device); + }; + } + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs new file mode 100755 index 0000000..121602e --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs @@ -0,0 +1,685 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Common; +using Shared.Phone.UserCenter.SmartSound.Util; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound.Forms +{ + public class SmartSoundControlContentForm : EditorCommonForm + { + /// <summary> + /// 涓存椂鏁版嵁 + /// </summary> + private List<SmartSound.Layer> TempDatas = new List<SmartSound.Layer>(); + + private SmartSoundInfo.SoundInfo mSoundInfo; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + + private FrameLayout contentLayout = null; + public int CurrentIndex = 0; + private BottomClickButton bottomClickButton = null; + + public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo) + { + this.mSoundInfo = soundInfo; + } + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + IniFloorData();//鍏堝姞杞芥暟鎹� + TempDatas.Clear(); + + this.ScrollEnabled = false; + base.SetTitleText("閫夋嫨鎴块棿");//璁剧疆鏍囬淇℃伅 + + contentLayout = new FrameLayout(); + this.bodyFrameLayout.AddChidren(contentLayout); + + IniAllDataView(); + } + + #region 鍔犺浇鏈湴鎵�鏈夋暟鎹紝鐢熸垚渚涚敤鎴烽�夋嫨鎴块棿鐨勭晫闈� + + private void IniAllDataView() + { + contentLayout.RemoveAll(); + + var pullLayout = new MyPullControl(this, SmartSound.LocaData); + contentLayout.AddChidren(pullLayout); + pullLayout.InitControl(); + + LoadAllRoomListView(); + + bottomClickButton = new BottomClickButton(); + this.bodyFrameLayout.AddChidren(bottomClickButton); + bottomClickButton.Text = "纭"; + bottomClickButton.ButtonClickEvent += (sender, e) => + { + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + //淇濆瓨鏁版嵁 + if (SmartSound.getInstantiate().LayerList == null) + SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>(); + + SmartSound.getInstantiate().LayerList.Clear(); + SmartSound.getInstantiate().LayerList = CollateData(); + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID; + + //涓婁紶鏁版嵁鍒版湇鍔″櫒 + string str = await postBatchEdit(); + CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + CloseForm(); + }); + }); + }; + + bottomClickButton.Visible = false; + } + + private void LoadAllRoomListView() + { + try + { + + if (SmartSound.LocaData == null || SmartSound.LocaData.Count < 1) + return; + + // 鍔犺浇褰撳墠妤煎眰鐨勬墍鏈夋埧闂� ListView + SmartSound.Layer layer = SmartSound.LocaData[CurrentIndex]; + if (listView == null) + { + listView = new VerticalListControl(); + contentLayout.AddChidren(listView); + listView.Y = Application.GetRealHeight(173); + listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173); + } + + listView.RemoveAll(); + + foreach(SmartSound.Room room in layer.RoomList) + { + var roomRowLayout = new RoomRowLayout(this, room); + listView.AddChidren(roomRowLayout); + roomRowLayout.InitControl(); + } + + //澶氫釜鐨勬椂鍊欙紝纭鎸夐挳浼氶伄鎸′竴閮ㄥ垎銆傝拷鍔犱笁涓┖鐨勮鐨勯珮搴︼紝鎶婂畠椤朵笂鏉� + if (listView.ChildrenCount > 5) + { + TextView textView = new TextView(); + textView.Height = Application.GetRealHeight(127 * 3); + listView.AddChidren(textView); + } + } + catch { } + } + + private async Task<string> postBatchEdit() + { + // The remote server returned an error: (400) Bad Request. + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + #endregion + + /// <summary> + /// 灏嗘暟鎹浆鎹负鏅鸿兘闊崇浣跨敤鐨勬暟鎹� + /// </summary> + private void IniFloorData() + { + + if (SmartSound.LocaData == null) + SmartSound.LocaData = new List<SmartSound.Layer>(); + + SmartSound.LocaData.Clear(); + + Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃 + + #region 鍒嗘ゼ灞� + if (floorDictionary.Count < 1) + { + //娌℃湁妤煎眰,妯℃嫙涓�涓� + SmartSound.Layer layer = new SmartSound.Layer(); + layer.LayerID = DateTime.Now.ToString("yyyyMMddHHmmssms"); + layer.LayerName = "涓�妤�"; + layer.RoomList.Clear(); + SmartSound.LocaData.Add(layer); + } + else + { + foreach (string layer_id in floorDictionary.Keys) + { + SmartSound.Layer layer = new SmartSound.Layer(); + layer.LayerID = layer_id; + layer.LayerName = floorDictionary[layer_id]; + layer.RoomList.Clear(); + SmartSound.LocaData.Add(layer); + } + } + #endregion + + #region 鎴块棿鍏ヤ綇瀵瑰簲鐨勬ゼ灞� + var roomList = HdlRoomLogic.Current.GetAllListRooms();//鑾峰彇鎵�鏈夋埧闂� + + for (int n = 0; n < SmartSound.LocaData.Count; n++) + { + SmartSound.Layer layer = SmartSound.LocaData[n]; + foreach (Room room in roomList) + { + try + { + if (layer.LayerID != room.FloorId && SmartSound.LocaData.Count > 1) + continue; + + //娣诲姞鎴块棿 + SmartSound.Room smartRoom = new SmartSound.Room(); + layer.RoomList.Add(smartRoom); + + smartRoom.RoomID = room.Id; + smartRoom.RoomName = room.Name; + smartRoom.DeviceList.Clear(); + smartRoom.SceneList.Clear(); + + #region 娣诲姞璁惧 鐏厜銆佺獥甯樸�佸満鏅�佺┖璋� + for (int j = 0; j < room.ListDevice.Count; j++) + { + string key = room.ListDevice[j].ToString(); + var device = LocalDevice.Current.GetDevice(key); + if (device == null) + continue; + + SmartSound.Device smartDevice = new SmartSound.Device(); + smartDevice.DeviceAddress = device.DeviceAddr;//璁惧 MAC + smartDevice.Epoint = device.DeviceEpoint;//璁惧绔彛 + smartDevice.DeviceName = Common.LocalDevice.Current.GetDeviceEpointName(device);//璁惧鍚嶇О + smartDevice.NicksName = ""; + smartDevice.DeviceType = GetDeviceType(device);//璁惧绫诲瀷 + if (smartDevice.DeviceType == 0) + continue; + + if(ZbGateway.GateWayBaseInfomations.ContainsKey(device.CurrentGateWayId) ==true) + { + smartDevice.GatewayID = ZbGateway.GateWayBaseInfomations[device.CurrentGateWayId].MacMark;//缃戝叧 Id + } + else + { + smartDevice.GatewayID = device.CurrentGateWayId;//缃戝叧 Id + } + + if (smartDevice.DeviceName == "" || smartDevice.DeviceName == string.Empty) + continue; + + smartRoom.DeviceList.Add(smartDevice); + } + #endregion + + var sceneList = HdlSceneLogic.Current.GetRoomSceneList(room); + + #region //娣诲姞鍦烘櫙 + for (int k = 0; k < sceneList.Count; k++) + { + try + { + SceneUI scene = sceneList[k]; + + if (scene == null) continue; + SmartSound.Scene smartScene = new SmartSound.Scene(); + smartScene.SceneName = scene.Name; + smartScene.SceneID = scene.Id; + smartScene.DelayTime = scene.DelayTime; + smartScene.NicksName = ""; + if (ZbGateway.GateWayBaseInfomations.ContainsKey(ZbGateway.MainGateWay.GwId) == true) + { + smartScene.GatewayID = ZbGateway.GateWayBaseInfomations[ZbGateway.MainGateWay.GwId].MacMark;//缃戝叧 Id + } + else + { + smartScene.GatewayID = ZbGateway.MainGateWay.GwId;//缃戝叧 Id + } + + if (smartScene.SceneName == "" || smartScene.SceneName == string.Empty) + continue; + + smartRoom.SceneList.Add(smartScene); + } + catch (Exception e) { } + } + #endregion + + if (smartRoom.DeviceList.Count == 0 && sceneList.Count == 0) + layer.RoomList.Remove(smartRoom); + + } + catch (Exception e) + { + string errpr = e.Message; + } + } + } + #endregion + + } + + /// <summary> + /// Zigbee璁惧绫诲瀷杞崲涓烘櫤鑳介煶绠变娇鐢ㄧ殑绫诲瀷 + /// </summary> + /// <returns></returns> + private int GetDeviceType(ZigBee.Device.CommonDevice device) + { + int type = 0;//1=寮�鍏崇伅锛�2=璋冨厜鐏紝3=RGB 鐏紝4=绐楀笜妯″潡锛�5=寮�鍚堝笜锛�6=鍗峰笜锛�7=绌鸿皟锛�8=闈㈡澘锛�9=鏂伴 + + if (device.Type == DeviceType.OnOffOutput && device.DfunctionType == DeviceFunctionType.A鐏厜) + { + type = 1;//杩欓噷闈㈢殑灏辨槸缁х數鍣ㄧ伅鍏変簡 + } + else if (device.Type == DeviceType.DimmableLight) + { + type = 2;//璋冨厜 + } + else if (device.Type == DeviceType.ColorDimmableLight) + { + type = 3; + } + else if (device.Type == DeviceType.WindowCoveringDevice) + { + //绐楀笜 + if (((Rollershade)device).WcdType == 4)//寮�鍚堝笜 + { + type = 5; + } + else if (((Rollershade)device).WcdType == 0)//鍗峰笜 + type = 6;//鍗峰笜 + } + else if (device.Type == DeviceType.Thermostat) + { + type = 7; + } + else if (device.Type == DeviceType.FreshAir) + { + type = 9; + } + + return type; + } + + /// <summary> + /// 灏嗛�変腑鐨勬暟鎹坊鍔犲埌涓存椂鏁版嵁鍒楄〃涓紝渚夸簬鍚庢湡鐨�"淇濆瓨" + /// </summary> + private void AddData(SmartSound.Room room) + { + if (TempDatas == null) + TempDatas = new List<SmartSound.Layer>(); + + SmartSound.Layer tempLayer = SmartSound.LocaData[CurrentIndex]; + if (tempLayer == null) return; + + + + #region 娣诲姞妤煎眰 + + bool floor_exists = false; + // 杩囨护鐩稿悓鐨勬ゼ灞� + for (int i = 0; i < TempDatas.Count; i++) + { + if (tempLayer.LayerID == TempDatas[i].LayerID) + { + floor_exists = true; + break; + } + } + + if (!floor_exists) + { + tempLayer.RoomList.Clear(); + TempDatas.Add(tempLayer); + } + + + #endregion + + #region 娣诲姞鎴块棿 + + for (int i = 0; i < TempDatas.Count; i++) + { + if (SmartSound.LocaData[CurrentIndex].LayerID != TempDatas[i].LayerID) + continue; + + bool room_exists = false; + + for (int n = 0; n < TempDatas[i].RoomList.Count; n++) + { + if (room.RoomID == TempDatas[i].RoomList[n].RoomID) + { + room_exists = true; + break; + } + } + + if (!room_exists) + { + TempDatas[i].RoomList.Add(room); + CheckedAll(room);//娣诲姞鎴块棿鎴愬姛锛岄粯璁ら�変腑鎵�鏈夎澶� + break; + } + } + + #endregion + + } + + private void RemoveData(SmartSound.Room room) + { + try + { + for (int i = 0; i < TempDatas.Count; i++) + { + + for (int j = 0; j < TempDatas[i].RoomList.Count; j++) + { + if (TempDatas[i].RoomList[j].RoomID == room.RoomID) + { + TempDatas[i].RoomList.RemoveAt(j); + } + } + } + } + catch { } + } + + /// <summary> + /// 榛樿閫夋嫨鎵�鏈夎澶� + /// </summary> + /// <param name="room"></param> + private void CheckedAll(SmartSound.Room room) + { + // 鏍囪鎵�鏈夊満鏅� + for (int n = 0; n < room.SceneList.Count; n++) + { + SmartSound.Scene _scene = room.SceneList[n]; + _scene.Checked = true; + } + + //鏍囪鎵�鏈夎澶� + for (int k = 0; k < room.DeviceList.Count; k++) + { + + SmartSound.Device _device = room.DeviceList[k]; + _device.Checked = true; + } + } + + /// <summary> + /// 閲嶆柊鏁寸悊鏁版嵁锛屾妸娌℃湁閫変腑鐨勬暟鎹兘鍓旈櫎鎺� + /// </summary> + private List<SmartSound.Layer> CollateData() + { + try + { + //绉诲嚭鏈�変腑鐨勮澶囥�佸満鏅� + for (int i = 0; i < TempDatas.Count; i++) + { + SmartSound.Layer _layer = TempDatas[i]; + + for (int j = 0; j < _layer.RoomList.Count; j++) + { + SmartSound.Room _room = _layer.RoomList[j]; + if (_room.Checked) + { + #region 娓呴櫎鏈�変腑鐨勮澶� + for (int k = 0; k < _room.DeviceList.Count; k++) + { + SmartSound.Device _device = _room.DeviceList[k]; + if (!_device.Checked) + { + _room.DeviceList.Remove(_device); + k--; + } + } + #endregion + + #region 娓呴櫎鏈�変腑鐨勫満鏅� + for (int n = 0; n < _room.SceneList.Count; n++) + { + SmartSound.Scene _scene = _room.SceneList[n]; + if (!_scene.Checked) + { + _room.SceneList.Remove(_scene); + n--; + } + } + #endregion + } + else + { + _layer.RoomList.Remove(_room); + j--; + } + } + } + + //绉诲嚭娌℃湁璁惧鐨勬埧闂� + for (int j = 0; j < TempDatas.Count; j++) + { + SmartSound.Layer _layer = TempDatas[j]; + if (_layer.RoomList.Count < 1) + { + TempDatas.Remove(_layer); + j--; + } + } + } + catch { } + + return TempDatas; + } + + #region 鈻� 鑷畾涔夋ゼ灞傞�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class MyPullControl : FrameRowControl + { + + private SmartSoundControlContentForm smartSoundDataAdd = null; + private List<SmartSound.Layer> Layers = null; + /// <summary> + /// 鎴块棿鍒楄〃 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public MyPullControl(SmartSoundControlContentForm _SmartSoundDataAdd,List<SmartSound.Layer> _layers) + { + this.smartSoundDataAdd = _SmartSoundDataAdd; + this.Layers = _layers; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + 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[smartSoundDataAdd.CurrentIndex].LayerName, 300, false); + layout.Name = "pullLayout"; + layout.ButtonClickEvent += (sender, e) => + { + ShowPullList(); + }; + + if (Layers.Count == 1) + { + right_icon.Visible = false; + layout.Visible = false; + } + + } + + 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", () => + { + smartSoundDataAdd.CurrentIndex = i; + smartSoundDataAdd.LoadAllRoomListView(); + }); + } + } + } + #endregion + + #region 鈻� 鑷畾涔夋埧闂撮�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class RoomRowLayout : FrameRowControl + { + private SmartSoundControlContentForm smartSoundControlContentForm = null; + + private SmartSound.Room mRoom = null; + /// <summary> + /// 鎴块棿鍚嶇О + /// </summary> + private NormalViewControl btnName = null; + + private IconViewControl Right_icon = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public RoomRowLayout(SmartSoundControlContentForm _smartSoundControlContentForm,SmartSound.Room _room) + { + this.smartSoundControlContentForm = _smartSoundControlContentForm; + this.mRoom = _room; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + public void InitControl() + { + //鏄剧ず鏂囨湰 + btnName = this.AddLeftCaption(string.Empty, 2000); + btnName.Height = Application.GetRealHeight(60); + btnName.TextSize = 17; + btnName.Y = Application.GetRealHeight(57); + btnName.Text = mRoom.RoomName; + + Right_icon = this.AddRightArrow(); + Right_icon.Width = Application.GetRealWidth(115); + Right_icon.Height = Application.GetRealHeight(115); + Right_icon.Gravity = Gravity.CenterVertical; + Right_icon.X = Right_icon.X - Application.GetRealWidth(60); + + btnName.ButtonClickEvent += (sender, e) => + { + mRoom.Checked = true; + RefreshRightIconState(mRoom.Checked); + SmartSoundContentForDevice deviceForm = new SmartSoundContentForDevice(mRoom); + deviceForm.AddForm(); + }; + + this.Right_icon.ButtonClickEvent += (sender, e) => + { + mRoom.Checked = !mRoom.Checked; + RefreshRightIconState(mRoom.Checked); + }; + + RefreshRightIconState(mRoom.Checked); + AddBottomLine(); + + } + + private void RefreshRightIconState(bool bol = false) + { + try + { + if (bol) + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxSel.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxSel.png"; + + smartSoundControlContentForm.AddData(mRoom); + } + else + { + Right_icon.SelectedImagePath = "SmartSound/CheckBoxDef.png"; + Right_icon.UnSelectedImagePath = "SmartSound/CheckBoxDef.png"; + + smartSoundControlContentForm.RemoveData(mRoom); + } + + bool isShow = false; + + if(smartSoundControlContentForm==null) return; + + foreach (SmartSound.Room _room in SmartSound.LocaData[smartSoundControlContentForm.CurrentIndex].RoomList) + { + if (_room.Checked) + { + isShow = true; + break; + } + } + + smartSoundControlContentForm.bottomClickButton.Visible = isShow; + } + catch(Exception e) + { + string error = e.Message; + } + } + + } + #endregion + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs new file mode 100755 index 0000000..f85422e --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs @@ -0,0 +1,386 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Shared.Common; +using Shared.Phone.UserCenter.SmartSound.Forms; +using Shared.Phone.UserCenter.SmartSound.Util; +using Shared.Phone.UserCenter.SmartSound.Widget; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound +{ + + public class SmartSoundControlForm : EditorCommonForm + { + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + private FrameLayout contentLayout = null; + public int CurrentIndex = 0; + private MostRightIconControl btnAddDeviceIcon = null; + /// <summary> + /// 鏅鸿兘闊崇鏁版嵁 + /// </summary> + private static SmartSoundInfo.SoundInfo mSoundInfo = null; + + public SmartSoundControlForm(SmartSoundInfo.SoundInfo soundInfo) + { + mSoundInfo = soundInfo; + } + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + 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(mSoundInfo); + smartSoundDataAdd.AddForm(); + }; + } + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + private void InitMiddleFrame() + { + this.ClearBodyFrame(); + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + + string json = await GetData();//鑾峰彇鏁版嵁 + SmartSoundDataInfo dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundDataInfo>(json); + if (dataInfo != null) + { + if (dataInfo.StateCode == "SUCCESS") + { + SmartSound.getInstantiate().LayerList = dataInfo.ResponseData.LayerList; + SmartSound.getInstantiate().TokenID = mSoundInfo.Id; + SmartSound.getInstantiate().UserID = mSoundInfo.UserID; + SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID; + } + } + + HdlThreadLogic.Current.RunMainInThread(() => + { + if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.Count < 1) + { + this.CloseProgressBar(); + return; + } + + contentLayout = new FrameLayout(); + this.bodyFrameLayout.AddChidren(contentLayout); + contentLayout.RemoveAll(); + + var pullLayout = new MyPullControl(this, SmartSound.getInstantiate().LayerList); + contentLayout.AddChidren(pullLayout); + pullLayout.InitControl(); + + LoadAllRoomListView(); + + //鏃犳暟鎹殑鏃跺�欒鍋氫竴涓彁绀� + { + bool bol = false; + for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++) + { + if (SmartSound.getInstantiate().LayerList[i].RoomList.Count > 0) + { + bol = true; + break; + } + } + + if (!bol) + { + pullLayout.Visible = false; + this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "杩樻病鏈夋帶鍒跺唴瀹瑰摝锛�", "鐐瑰嚮\"+\"娣诲姞" }); + } + } + + this.CloseProgressBar(); + + }); + }); + } + + /// <summary> + /// 鍔犺浇鎴块棿鍒楄〃 + /// </summary> + private void LoadAllRoomListView() + { + try + { + if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.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.getInstantiate().LayerList[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) => + { + var delBtn = sender as NormalViewControl; + DelectRoom(delBtn); + }; + } + } + catch (Exception e) + { + string error = e.Message; + } + } + + private void DelectRoom(NormalViewControl delBtn) + { + this.ShowMassage(ShowMsgType.Confirm, "纭鍒犻櫎璇ユ埧闂寸殑鎺у埗鍐呭锛�", async () => + { + + HdlThreadLogic.Current.RunThread(async () => + { + + this.ShowProgressBar("姝e湪鍒犻櫎鏁版嵁...."); + //鍒犻櫎鎴块棿 + var tag = (SmartSound.Room)delBtn.GetTagByKey("obj"); + + if (SmartSound.getInstantiate().LayerList == null) + return; + + for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++) + { + SmartSound.Layer _layer = SmartSound.getInstantiate().LayerList[i]; + + for (int j = 0; j < _layer.RoomList.Count; j++) + { + SmartSound.Room _room = _layer.RoomList[j]; + + if (_room.RoomName == tag.RoomName) + { + _layer.RoomList.Remove(_room); + } + } + } + + // 閲嶆柊涓婁紶鏁版嵁 + string json = await postBatchEdit(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //this.InitMiddleFrame(); + this.LoadAllRoomListView(); + }); + this.CloseProgressBar(); + }); + + }, Language.StringByID(R.MyInternationalizationString.OkMsg)); + } + + private async Task<string> GetData() + { + // 浠庢湇鍔″櫒鑾峰彇鏁版嵁 + string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit?Platform&UserID={0}&TokenID={1}", mSoundInfo.UserID, mSoundInfo.Id); + return await MyHttpWebResponse.GetWebRequest(url); + } + + private async Task<string> postBatchEdit() + { + // 鎻愪氦鏁版嵁鑷虫湇鍔″櫒 + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit"; + string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate()); + string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8); + return response_str; + } + + public override int FormActionAgainEvent() + { + ShowForm(); + return base.FormActionAgainEvent(); + } + + #region 鈻� 鑷畾涔夋ゼ灞傞�夋嫨鎺т欢_____________________ + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + private class MyPullControl : FrameRowControl + { + + private SmartSoundControlForm smartSoundControlData = null; + private List<SmartSound.Layer> Layers = null; + /// <summary> + /// 鎴块棿鍒楄〃 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鎴块棿鍒楄〃琛� + /// </summary> + public MyPullControl(SmartSoundControlForm _SmartSoundDataAdd, List<SmartSound.Layer> _layers) + { + this.smartSoundControlData = _SmartSoundDataAdd; + this.Layers = _layers; + this.UseClickStatu = false; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + 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(); + }; + + if (SmartSound.getInstantiate().LayerList.Count < 2) + { + right_icon.Visible = false; + layout.Visible = false; + } + } + 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 鈻� 鑷畾涔夋櫤鑳介煶绠辨帶浠禵____________________ + + /// <summary> + /// 璇煶鎺у埗鎴块棿琛� + /// </summary> + private class RoomRowLayout : RowLayoutControl + { + + /// <summary> + /// 鎴块棿鍚嶅瓧 + /// </summary> + private NormalViewControl btnName = null; + + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + + private SmartSoundControlForm smartSoundControlForm; + private SmartSound.Room room; + + /// <summary> + /// 鑷畾闊崇鍏虫帶浠� + /// </summary> + public RoomRowLayout(SmartSoundControlForm _smartSoundControlForm, SmartSound.Room _room) + { + this.smartSoundControlForm = _smartSoundControlForm; + this.room = _room; + this.BackgroundColor = UserCenterColor.Current.White; + this.Height = Application.GetRealHeight(173); + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + //璁惧 + frameTable.AddLeftCaption(this.room.RoomName, 800); + frameTable.AddRightArrow(); + //搴曠嚎 + frameTable.AddBottomLine(); + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "鍒犻櫎"; + btnDelect.AddTag("obj", room); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs new file mode 100755 index 0000000..5b1441d --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Forms/SmartSoundListForm.cs @@ -0,0 +1,364 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using Shared.Common; +using Shared.Phone.UserCenter.Device; +using Shared.Phone.UserCenter.SmartSound.Util; +using Shared.Phone.UserCenter.SmartSound.Widget; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.SmartSound +{ + //鏅鸿兘闊崇鍒楄〃鐣岄潰 + public class SmartSoundListForm : EditorCommonForm + { + public SmartSoundListForm() + { + } + + private SmartSoundInfo smartSoundInfo = null; + + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListRefreshControl listView = null; + /// <summary> + /// 鍓嶄竴娆℃樉绀哄嚭宸︽粦鑿滃崟鐨凴owLayout + /// </summary> + private RowLayoutControl oldShowRightMuneRow = null; + + private static string dataString = ""; + + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + + this.ScrollEnabled = false; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText("鏅鸿兘闊崇"); + Dictionary<string, string> floorDictionary = Config.Instance.Home.FloorDics;//妤煎眰鍒楄〃 + + var helpBtn = new MyButton(); + helpBtn.TextColor = UserCenterColor.Current.TextOrangeColor; + helpBtn.Text = "甯姪"; + helpBtn.Gravity = Gravity.CenterRight; + helpBtn.TextAlignment = TextAlignment.CenterRight; + topFrameLayout.AddChidren(helpBtn); + helpBtn.X -= Application.GetRealWidth(58); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + + helpBtn.MouseUpEventHandler += (sernder, e) => + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new TextDialog("缁戝畾鏅鸿兘闊崇鍒扮涓夋柟 APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�"); + dialogForm.SetTitleText("甯姪"); + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += () => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + }; + }; + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠�(澶栭儴鍙互璋冪敤) + /// </summary> + /// <param name="i_reGetDeviceOnlineStatu">閲嶆柊鑾峰彇璁惧鐨勫湪绾跨姸鎬�</param> + public void InitMiddleFrame() + { + this.ClearBodyFrame(); + + var frame = new FrameLayout(); + this.bodyFrameLayout.AddChidren(frame); + frame.BackgroundColor = UserCenterColor.Current.White; + frame.Y = 0; + frame.Height = this.bodyFrameLayout.Height; + + // 鍒濆鍖� lisetView + listView = new VerticalListRefreshControl(29); + listView.Y = 0; + listView.Height = bodyFrameLayout.Height; + frame.AddChidren(listView); + listView.BeginHeaderRefreshingAction += () => + { + HdlThreadLogic.Current.RunThread(() => + { + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + this.InitMiddleFrame(); + }); + }); + }; + + HdlThreadLogic.Current.RunThread(async () => + { + this.ShowProgressBar(); + await getData(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + iniView(); + + if (smartSoundInfo == null || smartSoundInfo.ResponseData == null || smartSoundInfo.ResponseData.RowCount == 0) + { + // show鍑烘病鏈夎澶囩殑鍥炬爣鏂囧瓧鎻愮ず + this.ShowNotDataImage(bodyFrameLayout, new string[] { "杩樻病鏈夐煶绠卞摝锛�", "缁戝畾鏅鸿兘闊崇璇峰墠寰�绗笁鏂� APP 杩涜鎿嶄綔" }); + } + + this.CloseProgressBar(); + }); + }); + } + + /// <summary> + /// 鑾峰彇闊崇鍒楄〃 + /// </summary> + /// <returns></returns> + private async Task getData() + { + string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/Auth?Platform&PageSetting.PageSize=100&PageSetting.PageIndex=1&UserID={0}&HomeID={1}", + Common.Config.Instance.Guid,Common.Config.Instance.Home.Id); + + dataString = await MyHttpWebResponse.GetWebRequest(url); + smartSoundInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<SmartSoundInfo>(dataString); + } + + /// <summary> + /// 璁剧疆澶囨敞 + /// </summary> + /// <param name="soundInfo"></param> + /// <param name="new_remark"></param> + /// <returns></returns> + private async Task<string> setRemark(SmartSoundInfo.SoundInfo soundInfo, string new_remark) + { + if (soundInfo == null) + return ""; + + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth"; + string json = "{" + + "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," + + "\"Remark\":" + "\"" + new_remark + "\"" + "," + + "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; + + string response_str = MyHttpWebResponse.PutWebRequest(url, json, Encoding.UTF8); + JObject jObject = JObject.Parse(response_str); + + return jObject["StateCode"].ToString(); + } + + private void iniView() + { + // + listView.RemoveAll(); + + if (smartSoundInfo == null) + return; + + for (int i = 0; i < smartSoundInfo.ResponseData.Data.Count; i++) + { + try + { + // + var smartSound = smartSoundInfo.ResponseData.Data[i]; + var row = new SoundRowLayout(); + listView.AddChidren(row); + + if (smartSound.PlatfromName == "Baidu") + { + string remark = "灏忓害"; + if (smartSound.Remark != null && smartSound.Remark.Trim() != "") + remark += "(" + smartSound.Remark + ")"; + + row.ImagePath = "SmartSound/Xiaodu.png"; + row.Remark = remark; + } + + row.InitControl(); + row.btnDelect.AddTag("index", i); + row.btnRename.AddTag("index", i); + row.frameTable.AddTag("index", i); + + //閲嶅懡鍚� + row.btnRename.ButtonClickEvent += (sender, e) => + { + int index = (int)((NormalViewControl)sender).GetTagByKey("index"); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowRenameDialog(row, smartSound1); + }; + + // 瑙i櫎缁戝畾 + row.btnDelect.ButtonClickEvent += (sender, e) => + { + int index = (int)(((NormalViewControl)sender).GetTagByKey("index")); + var smartSound1 = smartSoundInfo.ResponseData.Data[index]; + ShowDelectDialog(smartSound1); + }; + + //璺宠浆鍒版帶鍒跺唴瀹圭晫闈� FrameRowControl + row.frameTable.ButtonClickEvent += (sender, e) => + { + int index = (int)row.frameTable.GetTagByKey("index"); + if (SmartSound.getInstantiate().LayerList != null) + SmartSound.getInstantiate().LayerList.Clear(); + + var smartSoundControlForm = new SmartSoundControlForm(smartSoundInfo.ResponseData.Data[index]); + smartSoundControlForm.AddForm(); + }; + } + catch (Exception e) + { + this.ShowMassage(ShowMsgType.Tip, e.Message); + } + } + } + + /// <summary> + /// 瑙i櫎缁戝畾寮圭獥 + /// </summary> + private void ShowDelectDialog(SmartSoundInfo.SoundInfo smartSound) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new TextDialog("瑙i櫎缁戝畾闇�瑕佸埌绗笁鏂� APP 杩涜鎿嶄綔", "璺宠浆鑷冲皬搴�"); + dialogForm.SetTitleText("瑙i櫎缁戝畾"); + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += () => + { + HdlThreadLogic.Current.RunThread(() => + { + this.ShowProgressBar("鍒犻櫎鏈嶅姟鍣ㄨ褰�..."); + string json = DelectSmartSound(smartSound); + if (json == "SUCCESS") + { + smartSoundInfo.ResponseData.Data.Remove(smartSound); + } + this.CloseProgressBar(); + + HdlThreadLogic.Current.RunMainInThread(() => + { + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + bool bol = false; + try + { +#if Android + bol = HDLUtils.OpenAppWithPackageName("com.baidu.duer.superapp"); +#else + HDLUtils.OpenApp("xiaoduapp://"); +#endif + } + catch (Exception e) + { + string error = e.Message; + bol = false; + } + if (!bol) + { + this.ShowMassage(ShowMsgType.Tip, "鎵撳紑APP澶辫触"); + } + iniView(); + }); + }); + }; + } + /// <summary> + /// 閲嶅懡鍚嶅脊绐� + /// </summary> + /// <returns></returns> + private void ShowRenameDialog(SoundRowLayout soundRowLayout, SmartSoundInfo.SoundInfo smartSound) + { + //鐢熸垚涓�涓脊绐楃敾闈� + var dialogForm = new DialogInputControl(); + //娣诲姞澶囦唤 + dialogForm.SetTitleText("閲嶅懡鍚�"); + //璇疯緭鍏ュ浠藉悕绉� + dialogForm.SetTipText("璇疯緭鍏ュ悕绉�"); + dialogForm.Text = smartSound.Remark; + + //鎸変笅纭鎸夐挳 + dialogForm.ComfirmClickEvent += (async (textValue) => + { + + //鐢婚潰鍏抽棴 + dialogForm.CloseDialog(); + + string remark = textValue; + string str = await setRemark(smartSound, remark); //涓婁紶澶囦唤 + if (str == "SUCCESS") + { + smartSound.Remark = remark; + soundRowLayout.btnRemark.Text = "灏忓害" + "(" + textValue + ")"; + } + else + { + //閿欒寮圭獥鎻愮ず + ShowMassage(ShowMsgType.Tip, "淇敼澶囨敞涓嶆垚鍔燂紒", null, "纭"); + } + }); + } + + #endregion + + /// <summary> + /// 鍒犻櫎鏁版嵁 + /// </summary> + /// <param name="soundInfo"></param> + /// <returns></returns> + private string DelectSmartSound(SmartSoundInfo.SoundInfo soundInfo) + { + if (soundInfo == null) + return ""; + + string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/Auth"; + string json = "{" + + "\"AuthID\":" + "\"" + soundInfo.Id + "\"" + "," + + "\"UserID\":" + "\"" + soundInfo.UserID + "\"" + "," + + "\"HomeID\":" + "\"" + soundInfo.HomeID + "\"" + "}"; + + string response_str = MyHttpWebResponse.DeleteWebRequest(url, json, Encoding.UTF8); + JObject jObject = JObject.Parse(response_str); + + return jObject["StateCode"].ToString(); + } + +#region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ + + /// <summary> + /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� + /// </summary> + public override int FormActionAgainEvent() + { + return 1; + } + +#endregion + +#region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + base.CloseFormBefore(); + } + +#endregion + + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/SmartSound/SmartSound.cs b/Home0618/Shared/Phone/SmartSound/SmartSound.cs new file mode 100755 index 0000000..09bfefc --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/SmartSound.cs @@ -0,0 +1,91 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SmartSound + { + + /// <summary> + /// 鏈湴鎵�鏈夌殑鏁版嵁 + /// </summary> + public static List<Layer> LocaData = new List<Layer>(); + /// <summary> + /// 褰撳墠浣跨敤鐨勬暟鎹�(鏈嶅姟鍣ㄥ悓姝ヤ笅鏉ョ殑鏁版嵁/褰撳墠琚�変腑鐨勬暟鎹�) + /// </summary> + public List<Layer> LayerList = new List<Layer>(); + + public SmartSound() + { + } + + private static SmartSound smartSound = null; + public string UserID; + public string TokenID; + public string HomeID; + + public static SmartSound getInstantiate() + { + if (smartSound == null) + smartSound = new SmartSound(); + + return smartSound; + } + + public class Layer + { + public string LayerID; + public string LayerName; + public List<Room> RoomList = new List<Room>(); + } + + public class Room + { + /// <summary> + /// 閫変腑鐨勬埧闂� + /// </summary> + public bool Checked = false; + public string RoomID; + public string RoomName; + public List<Device> DeviceList = new List<Device>(); + public List<Scene> SceneList = new List<Scene>(); + } + + public class Device + { + /// <summary> + /// 閫変腑鐨勮澶� + /// </summary> + public bool Checked = false; + //public string Id; + public string DeviceAddress; + public int Epoint; + //public int ClusterID; + public string DeviceName; + public string NicksName; + public string GatewayID; + /// <summary> + /// 1=寮�鍏崇伅锛�2=璋冨厜鐏紝3=RGB 鐏紝4=绐楀笜妯″潡锛�5=寮�鍚堝笜锛�6=鍗峰笜锛�7=绌鸿皟锛�8=闈㈡澘锛�9=鏂伴 + /// </summary> + public int DeviceType; + //public string RoomID; + } + + public class Scene + { + /// <summary> + /// 閫変腑鐨勫満鏅� + /// </summary> + public bool Checked = false; + //public string Id; + public string SceneName; + public int SceneID; + public int DelayTime; + //public int ClusterID; + public string NicksName; + //public string RoomID; + public string GatewayID; + } + + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/SmartSound/SmartSoundDataInfo.cs b/Home0618/Shared/Phone/SmartSound/SmartSoundDataInfo.cs new file mode 100755 index 0000000..dd87af7 --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/SmartSoundDataInfo.cs @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SmartSoundDataInfo + { + public SmartSoundDataInfo() + { + } + + public string StateCode { get; set; } + public string ErrorInfo { get; set; } + public Info ResponseData { get; set; } + + public class Info + { + public List<SmartSound.Layer> LayerList { get; set; } + } + } +} diff --git a/Home0618/Shared/Phone/SmartSound/SmartSoundInfo.cs b/Home0618/Shared/Phone/SmartSound/SmartSoundInfo.cs new file mode 100755 index 0000000..9be9dbd --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/SmartSoundInfo.cs @@ -0,0 +1,74 @@ +锘縰sing System; +using System.Collections.Generic; + +namespace Shared.Phone.UserCenter.SmartSound +{ + /// <summary> + /// 鏅鸿兘闊崇绫伙紝灏忓害銆佸皬鐖便�佸ぉ鐚簿鐏甸�氱敤姝ょ被 + /// </summary> + public class SmartSoundInfo + { + + public SmartSoundInfo() + { + } + + public string StateCode { get; set; } + public string ErrorInfo { get; set; } + public Info ResponseData { get; set; } + + public class Info + { + public int PageSize { get; set; } + public int PageIndex { get; set; } + public int RowCount { get; set; } + public int PageTotal { get; set; } + public List<SoundInfo> Data { get; set; } + } + + public class SoundInfo + { + public string UserID { get; set; } + public string AuthCode { get; set; } + public string Token { get; set; } + public string RefreshToken { get; set; } + /// <summary> + /// Baidu + /// </summary> + public string PlatfromName { get; set; } + public string HomeID { get; set; } + public string OpenUID { get; set; } + /// <summary> + /// 鏅鸿兘闊崇澶囨敞 + /// </summary> + public string Remark { get; set; } = "鎴戠殑闊崇"; + public string Id { get; set; } + public bool IsDeleted { get; set; } + public string CreatedOnUtc { get; set; } + /// <summary> + /// 鏅鸿兘闊崇鐨勭敤鎴峰悕锛堝皬搴︼細123456@qq.com锛� + /// </summary> + public string UserName { get; set; } = "123456@qq.com"; + } + + public class Auth + { + public string Platform { get; set; } + public string UserID { get; set; } + public string HomeID { get; set; } + + public PageSetting PageSetting { get; set; } + public Auth() + { + this.PageSetting = new PageSetting(); + } + + } + + public class PageSetting + { + public int PageSize { get; set; } = 100; + public int PageIndex { get; set; } = 1; + } + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/SmartSound/Util/MyHttpWebResponse.cs b/Home0618/Shared/Phone/SmartSound/Util/MyHttpWebResponse.cs new file mode 100755 index 0000000..511b1c2 --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Util/MyHttpWebResponse.cs @@ -0,0 +1,163 @@ +锘縰sing System; +using System.IO; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Shared.Phone.UserCenter.SmartSound.Util +{ + public class MyHttpWebResponse + { + public MyHttpWebResponse() + { + } + + /// <summary> + /// Get鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="getUrl">鎺ュ彛鍦板潃</param> + /// <returns></returns> + public static async Task<string> GetWebRequest(string getUrl) + { + + string responseContent = ""; + + try + { + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(getUrl); + request.ContentType = "application/json"; + request.Method = "GET"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (Stream resStream = response.GetResponseStream()) + { + using (StreamReader reader = new StreamReader(resStream, Encoding.UTF8)) + { + responseContent = reader.ReadToEnd().ToString(); + } + } + } + catch (Exception e) { } + return responseContent; + } + + /// <summary> + /// Post鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string PostWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "POST"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + reqStream.Close(); + } + + //var ssss = webReq.GetResponse(); + + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + + /// <summary> + /// Put鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string PutWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "PUT"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + //reqStream.Close(); + } + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + + /// <summary> + /// delete鏁版嵁鎺ュ彛 + /// </summary> + /// <param name="postUrl">鎺ュ彛鍦板潃</param> + /// <param name="paramData">鎻愪氦json鏁版嵁</param> + /// <param name="dataEncode">缂栫爜鏂瑰紡(Encoding.UTF8)</param> + /// <returns></returns> + public static string DeleteWebRequest(string postUrl, string paramData, Encoding dataEncode) + { + string responseContent = string.Empty; + try + { + byte[] byteArray = dataEncode.GetBytes(paramData); //杞寲 + HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); + webReq.Method = "DELETE"; + webReq.ContentType = "application/json"; + webReq.ContentLength = byteArray.Length; + using (Stream reqStream = webReq.GetRequestStream()) + { + reqStream.Write(byteArray, 0, byteArray.Length);//鍐欏叆鍙傛暟 + //reqStream.Close(); + } + using (HttpWebResponse response = (HttpWebResponse)webReq.GetResponse()) + { + //鍦ㄨ繖閲屽鎺ユ敹鍒扮殑椤甸潰鍐呭杩涜澶勭悊 + using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default)) + { + responseContent = sr.ReadToEnd().ToString(); + } + } + } + catch (Exception ex) + { + return ex.Message; + } + return responseContent; + } + } +} \ No newline at end of file diff --git a/Home0618/Shared/Phone/SmartSound/Widget/MyButton.cs b/Home0618/Shared/Phone/SmartSound/Widget/MyButton.cs new file mode 100755 index 0000000..e9528ff --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Widget/MyButton.cs @@ -0,0 +1,49 @@ +锘縰sing System; +namespace Shared.Phone.UserCenter.SmartSound +{ + public class MyButton:Button + { + //榛樿瀛椾綋澶у皬 + private float textSize = 15; + + public MyButton() + { + base.TextSize = textSize; + } + + public new float TextSize + { + get => base.TextSize; + set + { + textSize = value; + base.TextSize = textSize; + } + } + + public new string Text { + get { + return base.Text; + } + set { + base.Text = value; + recalculateWidth(); + } + } + + public override uint BackgroundColor + { + get { return base.BackgroundColor; } + set + { + base.BackgroundColor = value; + recalculateWidth(); + } + } + + private void recalculateWidth() { + + this.Width = this.GetTextWidth()+Application.GetRealWidth(50); + } + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Widget/SoundRowLayout.cs b/Home0618/Shared/Phone/SmartSound/Widget/SoundRowLayout.cs new file mode 100755 index 0000000..8569384 --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Widget/SoundRowLayout.cs @@ -0,0 +1,66 @@ +锘縰sing System; +namespace Shared.Phone.UserCenter.SmartSound +{ + public class SoundRowLayout : RowLayoutControl + { + + /// <summary> + /// 閲嶅懡鍚嶆寜閽� + /// </summary> + public NormalViewControl btnRename = null; + /// <summary> + /// 鍒犻櫎鎸夐挳 + /// </summary> + public NormalViewControl btnDelect = null; + /// <summary> + /// 澶囨敞 + /// </summary> + public NormalViewControl btnRemark = null; + /// <summary> + /// 鍥剧墖璺緞 + /// </summary> + public string ImagePath = "SmartSound/SoundIcon.png"; + + /// <summary> + /// 鏅鸿兘闊崇澶囨敞鍚嶇О + /// </summary> + public string Remark = ""; + + + public SoundRowLayout() + { + // this.Height = Application.GetRealHeight(170); + } + + /// <summary> + /// 鍒濆鍖栧唴閮ㄦ帶浠� + /// </summary> + public void InitControl() + { + try + { + //鍥炬爣 + var btnIcon = frameTable.AddLeftIcon(81); + + btnIcon.UnSelectedImagePath = ImagePath; + btnIcon.SelectedImagePath = ImagePath; + + //澶囨敞鍚嶇О鎸夐挳 + btnRemark = frameTable.AddLeftCaption(Remark, 800); + + //搴曠嚎 + frameTable.AddBottomLine(); + + btnRename = base.AddEditorControl(); + btnRename.Text = "閲嶅懡鍚�"; + + btnDelect = base.AddDeleteControl(); + btnDelect.Text = "瑙i櫎缁戝畾"; + } + catch (Exception e) + { + // + } + } + } +} diff --git a/Home0618/Shared/Phone/SmartSound/Widget/TextDialog.cs b/Home0618/Shared/Phone/SmartSound/Widget/TextDialog.cs new file mode 100755 index 0000000..523da8f --- /dev/null +++ b/Home0618/Shared/Phone/SmartSound/Widget/TextDialog.cs @@ -0,0 +1,143 @@ +锘縰sing System; + +namespace Shared.Phone.UserCenter.SmartSound.Widget +{ + + public class TextDialog : FrameLayout + { + + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 纭鎸夐挳浜嬩欢 + /// </summary> + public Action ComfirmClickEvent; + + /// <summary> + /// 鏍囬鎺т欢 + /// </summary> + private NormalViewControl btnTitle = null; + /// <summary> + /// 鍙栨秷鎸夐挳 + /// </summary> + private BottomLeftClickButton btnCancel = null; + /// <summary> + /// 纭鎸夐挳 + /// </summary> + private BottomRightClickButton btnConfirm = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// + /// </summary> + /// <param name="msg">鎻愮ず鍐呭</param> + /// <param name="btnText">纭鎸夐挳 Text</param> + public TextDialog(string msg,string btnText) + { + //娣诲姞鐣岄潰 + var nowForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1); + if (nowForm == null || (nowForm is ViewGroup) == false) + { + return; + } + this.BackgroundColor = UserCenterColor.Current.DialogBackColor; + ((ViewGroup)nowForm).AddChidren(this); + + //鐧借壊鑳屾櫙妗� + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(507); + frameBack.Width = Application.GetRealWidth(792); + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Y = Application.GetRealHeight(691); + frameBack.Gravity = Gravity.CenterHorizontal; + frameBack.Radius = (uint)Application.GetRealHeight(17); + this.AddChidren(frameBack); + + //鏍囬淇℃伅 + this.btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false); + btnTitle.Y = Application.GetRealHeight(68); + btnTitle.TextColor = UserCenterColor.Current.TextColor1; + btnTitle.TextSize = 16; + btnTitle.TextAlignment = TextAlignment.Center; + frameBack.AddChidren(btnTitle); + + //娑堟伅 + var btnMsg = new NormalViewControl(frameBack.Width - Application.GetRealWidth(55 * 2), Application.GetRealHeight(180), false); + btnMsg.Y = Application.GetRealHeight(141); + btnMsg.IsMoreLines = true; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg.Gravity = Gravity.CenterHorizontal; + btnMsg.Text = msg; + frameBack.AddChidren(btnMsg); + + //鍙栨秷 + this.btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127)); + frameBack.AddChidren(btnCancel); + btnCancel.InitControl(Language.StringByID(R.MyInternationalizationString.uCancel)); + btnCancel.ButtonClickEvent += (sender, e) => + { + //绉婚櫎鐣岄潰 + this.CloseDialog(); + }; + + //纭 + this.btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height); + frameBack.AddChidren(btnConfirm); + btnConfirm.InitControl(btnText); + btnConfirm.ButtonClickEvent += (sender, e) => + { + //鍥炶皟鍑芥暟 + this.ComfirmClickEvent?.Invoke(); + }; + } + + #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public void CloseDialog() + { + this.ComfirmClickEvent = null; + this.RemoveFromParent(); + } + + #endregion + + #region 鈻� 璁剧疆淇℃伅___________________________ + + /// <summary> + /// 璁剧疆鏍囬淇℃伅 + /// </summary> + /// <param name="txtValue"></param> + public void SetTitleText(string txtValue) + { + this.btnTitle.Text = txtValue; + } + /// <summary> + /// 璁剧疆鍙栨秷鎸夐挳鐨勬枃鏈俊鎭� + /// </summary> + /// <param name="txtValue"></param> + public void SetCancelButtonText(string txtValue) + { + this.btnCancel.SetButtonText(txtValue); + } + + /// <summary> + /// 璁剧疆纭畾鎸夐挳鐨勬枃鏈俊鎭� + /// </summary> + /// <param name="txtValue"></param> + public void SetOkButtonText(string txtValue) + { + this.btnConfirm.SetButtonText(txtValue); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/ProgressRowBar.cs b/Home0618/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/ProgressRowBar.cs new file mode 100755 index 0000000..91b3ada --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/ProgressRowBar.cs @@ -0,0 +1,243 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 琛屾潯绫诲瀷鐨勮繘搴︽潯鎺т欢 + /// </summary> + public class ProgressRowBar : FrameLayout + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 杩涘浘鏉¤兘鍚﹀線鍥炶蛋(榛樿鍙互) + /// </summary> + public bool ProgressBarGoback = true; + /// <summary> + /// 浼氱Щ鍔ㄧ殑杩涘害鏉� + /// </summary> + private FrameLayout btnProgressBar = null; + /// <summary> + /// 鏁板�肩櫨鍒嗘瘮鏂囨湰鐨勫鍣� + /// </summary> + private FrameLayout frameProgressBack = null; + /// <summary> + /// 鏄剧ず鏁板�肩櫨鍒嗘瘮鐨勬帶浠� + /// </summary> + private NormalViewControl btnProgressTextView = null; + /// <summary> + /// 绾跨▼鏄惁杩愯 + /// </summary> + private bool isThreadAction = false; + /// <summary> + /// 妯″紡鍖哄垎 + /// </summary> + private int m_ModeDiv = -1; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 琛屾潯绫诲瀷鐨勮繘搴︽潯鎺т欢 + /// </summary> + /// <param name="width"> + /// <para>妯″紡1:浼氬姩鐨勯偅涓繘搴︽潯鐨勫搴�(闈炵湡瀹炲��)</para> + /// <para>妯″紡2:杩涘害鏉″湪鎸佺画鏃犻檺鐨勬潵鍥炵Щ鍔ㄧ殑鍖哄煙瀹藉害(闈炵湡瀹炲��)</para> + /// </param> + /// <param name="height"> + /// <para>妯″紡1:浼氬姩鐨勯偅涓繘搴︽潯鐨勯珮搴�(闈炵湡瀹炲��)</para> + /// <para>妯″紡2:杩涘害鏉″湪鎸佺画鏃犻檺鐨勬潵鍥炵Щ鍔ㄧ殑楂樺害(闈炵湡瀹炲��)</para> + /// </param> + public ProgressRowBar(int width, int height) + { + this.Height = Application.GetRealHeight(height); + this.Width = Application.GetRealWidth(width); + this.BackgroundColor = 0xffe6e6e6; + this.Radius = (uint)Application.GetRealHeight(height) / 2; + } + + #endregion + + #region 鈻� 妯″紡1______________________________ + + /// <summary> + /// 妯″紡1 璇ユā寮忎负锛氭墜鍔ㄥ~鍐欒繘搴﹀�� + /// </summary> + /// <param name="showText"> + /// <para>鏄惁鍦ㄨ繘搴︽潯涓婃柟鏄剧ず鏁板�肩櫨鍒嗘瘮</para> + /// <para>璇风‘淇濇帶浠剁殑涓婃柟鏈夎冻澶熺殑鍖哄煙(娉�:璇蜂笉瑕佹墿澶ф鎺т欢鐨勯珮搴�)</para> + /// </param> + public void StartMode1(bool showText = false) + { + if (m_ModeDiv != -1) { return; } + this.m_ModeDiv = 1; + + //浼氱Щ鍔ㄧ殑杩涘害鏉� + this.btnProgressBar = new FrameLayout(); + btnProgressBar.Width = 0; + btnProgressBar.Height = this.Height; + btnProgressBar.BackgroundColor = 0xfffb744a; + btnProgressBar.Radius = (uint)this.Height / 2; + this.AddChidren(btnProgressBar); + + if (showText == true) + { + //杩涘害鍊兼枃鏈� + this.frameProgressBack = new FrameLayout(); + frameProgressBack.Width = Application.GetRealWidth(120); + frameProgressBack.Height = Application.GetRealHeight(60); + frameProgressBack.Y = this.Y - Application.GetRealHeight(60); + frameProgressBack.X = this.X - Application.GetRealWidth(84) / 2; + this.Parent.AddChidren(frameProgressBack); + + var btnProgressPic = new PicViewControl(84, 60); + btnProgressPic.UnSelectedImagePath = "Item/ProgressMsg.png"; + btnProgressPic.Gravity = Gravity.CenterHorizontal; + frameProgressBack.AddChidren(btnProgressPic); + this.btnProgressTextView = new NormalViewControl(120, 45, true); + btnProgressTextView.TextSize = 10; + btnProgressTextView.TextAlignment = TextAlignment.Center; + btnProgressTextView.Text = "0%"; + btnProgressTextView.Gravity = Gravity.CenterHorizontal; + frameProgressBack.AddChidren(btnProgressTextView); + } + } + + /// <summary> + /// 閲嶇疆杩涘害鏉�(鍙妯″紡1鏈夋晥) + /// </summary> + public void ResetProgressBar() + { + if (this.m_ModeDiv == 1 && this.btnProgressBar != null) + { + this.btnProgressBar.Width = 0; + } + } + + /// <summary> + /// 璁剧疆杩涘害鍊� + /// </summary> + /// <param name="value">姝ゅ�间负鐧惧垎姣斿��(涔熷氨鏄皬浜庢垨鑰呯瓑浜�1鐨�)</param> + public void SetValue(decimal value) + { + this.SetValueEx(value); + } + + /// <summary> + /// 璁剧疆杩涘害鍊� + /// </summary> + /// <param name="value">杩涘害鍊�,鍐呴儴浼氶櫎浠axValue</param> + /// <param name="maxValue">鏈�澶у��</param> + public void SetValue(decimal value, decimal maxValue) + { + decimal result = value / maxValue; + this.SetValueEx(result); + } + + /// <summary> + /// 璁剧疆杩涘害鍊� + /// </summary> + /// <param name="value"></param> + private void SetValueEx(decimal value) + { + if (btnProgressBar == null || this.m_ModeDiv != 1 || value > 1) + { + return; + } + HdlThreadLogic.Current.RunMain(() => + { + int width = (int)(value * this.Width); + if (this.ProgressBarGoback == false && btnProgressBar.Width >= width) + { + //涓嶈兘璁╄繘搴︽潯寰�鍥炶蛋 + return; + } + btnProgressBar.Width = width; + if (this.btnProgressTextView != null) + { + //鏂囨湰鏄剧ず + btnProgressTextView.Text = ((int)(value * 100)) + "%"; + //鏂囨湰鏄剧ず鐨勯偅涓浘鐗囨绉诲姩 + this.frameProgressBack.X = this.X + btnProgressBar.Right - frameProgressBack.Width / 2; + } + }); + } + + #endregion + + #region 鈻� 妯″紡2______________________________ + + /// <summary> + /// 妯″紡2 璇ユā寮忎负锛氫笉鑳芥墜鍔ㄦ寚瀹氳繘搴﹀��,鐢卞唴閮ㄧ嚎绋嬪鐞�,杩涘害鏉″湪鎸佺画鏃犻檺鐨勬潵鍥炵Щ鍔� + /// </summary> + /// <param name="proWidth">鎸佺画鏃犻檺鐨勬潵鍥炵Щ鍔ㄧ殑杩涘害鏉$殑瀹藉害(闈炵湡瀹炲��)</param> + public void StartMode2(int proWidth = 100) + { + if (m_ModeDiv != -1) { return; } + this.m_ModeDiv = 2; + + //浼氱Щ鍔ㄧ殑杩涘害鏉� + this.btnProgressBar = new FrameLayout(); + btnProgressBar.Width = Application.GetRealWidth(proWidth); + btnProgressBar.Height = this.Height; + btnProgressBar.BackgroundColor = 0xfffb744a; + btnProgressBar.Radius = (uint)this.Height / 2; + this.AddChidren(btnProgressBar); + + //寮�鍚ā寮�2鐨勭嚎绋� + this.StartMode2Thread(); + } + + /// <summary> + /// 閲嶆柊寮�鍚ā寮�2 + /// </summary> + public void ReStartMode2() + { + //寮�鍚ā寮�2鐨勭嚎绋� + this.StartMode2Thread(); + } + + /// <summary> + /// 鏆傚仠妯″紡2 + /// </summary> + public void StopMode2() + { + this.isThreadAction = false; + } + + /// <summary> + /// 寮�鍚ā寮�2鐨勭嚎绋� + /// </summary> + private void StartMode2Thread() + { + if (this.isThreadAction == true) + { + return; + } + this.isThreadAction = true; + int moveLength = Application.GetRealWidth(30); + HdlThreadLogic.Current.RunThread(() => + { + while (this.Parent != null && isThreadAction == true) + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.btnProgressBar.X >= this.Width) + { + //瓒呭嚭鍙宠竟涔嬪悗,鍐嶆浠庡乏杈瑰惊鐜� + this.btnProgressBar.X = -this.btnProgressBar.Width; + return; + } + this.btnProgressBar.X += moveLength; + }, ShowErrorMode.NO); + System.Threading.Thread.Sleep(150); + } + }); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/Home0618/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs old mode 100755 new mode 100644 index 73b1c56..34f9db9 --- a/Home0618/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs +++ b/Home0618/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs @@ -316,304 +316,10 @@ return false; } - /// <summary> - /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍� - /// </summary> - public static HdlDeviceBindLogic Current - { - get - { - if (m_Current == null) - { - m_Current = new HdlDeviceBindLogic(); - } - return m_Current; - } - } - #endregion - - #region 鈻� 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶嘷____________ - - /// <summary> - /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull),杩欎釜鏄粰pir浼犳劅鍣ㄧ敤鐨� - /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> - /// <returns></returns> - public List<CommonDevice> GetBindTargetDevice(CommonDevice mainDevice) - { - var result = this.GetDeviceBindAsync(mainDevice); - if (result == null || result.getAllBindResponseData == null) - { - //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐� - string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceBindTargetFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); - - this.ShowErrorMsg(msg); - return null; - } - var listDevice = new List<CommonDevice>(); - foreach (var data in result.getAllBindResponseData.BindList) - { - CommonDevice deviceTemp = Common.LocalDevice.Current.GetDevice(data.BindMacAddr, data.BindEpoint); - if (deviceTemp == null) - { - continue; - } - listDevice.Add(deviceTemp); - } - return listDevice; - } - - /// <summary> - ///鑾峰彇鎵�鏈夌粦瀹� - /// </summary> - public BindObj.GetDeviceBindResponseAllData GetDeviceBindAsync(CommonDevice device) - { - //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� - if (Common.Config.Instance.Home.IsVirtually == true) - { - var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind"); - return new BindObj.GetDeviceBindResponseAllData() - { - getAllBindResponseData = new BindObj.GetDeviceBindResponseData - { - Result = 0, - BindList = listBind - } - }; - } - - var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } }; - string sendData = jObject.ToString(); - //鍙戦�� - var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/GetDeviceBind", sendData, "Bind/GetDeviceBind_Respon", 6); - if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) - { - return null; - } - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.GetDeviceBindResponseData>(result.ReceiptData); - return new BindObj.GetDeviceBindResponseAllData() { getAllBindResponseData = tempData }; - } - - #endregion - - #region 鈻� 鎵ц缁戝畾璁惧鐩爣___________________ - - /// <summary> - /// 缁戝畾璁惧鐨勭洰鏍�(杩斿洖鎴愬姛璁剧疆鐨勮澶�,閿欒鏃讹紝杩斿洖null) - /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> - /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param> - /// <param name="BindCluster">BindCluster</param> - /// <returns></returns> - public List<CommonDevice> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6) - { - if (listDevice.Count == 0) - { - return new List<CommonDevice>(); - } - - var dicDevice = new Dictionary<string, CommonDevice>(); - - //缁勮鏁版嵁 - var addData = new IASZone.AddBindData(); - addData.DeviceAddr = mainDevice.DeviceAddr; - addData.Epoint = mainDevice.DeviceEpoint; - foreach (var device in listDevice) - { - var info = new IASZone.AddBindListObj(); - info.BindCluster = BindCluster; - info.BindMacAddr = device.DeviceAddr; - info.BindEpoint = device.DeviceEpoint; - info.BindType = 0; - - addData.BindList.Add(info); - - //杩斿洖鎴愬姛璁惧鐨勬椂鍊欎娇鐢� - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); - dicDevice[mainkeys] = device; - } - //鎵ц缁戝畾 - var result = this.AddDeviceBindAsync(addData); - if (result == null || result.addedDeviceBindResponseData == null) - { - //缁戝畾鐩爣璁剧疆澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); - - this.ShowErrorMsg(msg); - return null; - } - - var listSuccess = new List<CommonDevice>(); - foreach (var data in result.addedDeviceBindResponseData.BindList) - { - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); - if (dicDevice.ContainsKey(mainkeys) == true) - { - listSuccess.Add(dicDevice[mainkeys]); - } - } - - if (listSuccess.Count == 0) - { - //缁戝畾鐩爣璁剧疆澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail); - this.ShowTipMsg(msg); - } - return listSuccess; - } - - /// <summary> - ///璁惧缁戝畾 - /// </summary> - public BindObj.AddedDeviceBindResponseAllData AddDeviceBindAsync(BindObj.AddBindData addBindData) - { - //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹� - if (Common.Config.Instance.Home.IsVirtually == true) - { - return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind"); - } - - var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); - //鑾峰彇鍙戦�佺殑鍛戒护瀛楃 - var sendData = this.GetAddDeviceListBindCommandText(addBindData); - //鍙戦�� - var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetBind", sendData, "Bind/SetBind_Respon", 20); - if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) - { - return null; - } - - //淇敼缂撳瓨 - ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind"); - - var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData); - return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData }; - } - - /// <summary> - /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗� - /// </summary> - /// <param name="addBindData"></param> - /// <returns></returns> - public string GetAddDeviceListBindCommandText(BindObj.AddBindData addBindData) - { - var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } }; - var bindList = new JArray { }; - foreach (var bindInfo in addBindData.BindList) - { - if (bindInfo.BindType == 0) - { - var dInfo = new JObject{{ "BindMacAddr",bindInfo.BindMacAddr},{ "BindEpoint", bindInfo.BindEpoint} , - { "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}}; - bindList.Add(dInfo); - } - else if (bindInfo.BindType == 1) - { - var dInfo = new JObject{{ "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}, - { "BindScenesId", bindInfo.BindScenesId}}; - bindList.Add(dInfo); - } - } - var data = new JObject { { "BindName", addBindData.BindName }, { "BindList", bindList } }; - jObject.Add("Data", data); - return jObject.ToString(); - } - - #endregion - + #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________ - - /// <summary> - /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍� - /// </summary> - /// <param name="mainDevice">璁惧瀵硅薄</param> - /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param> - /// <param name="BindCluster">BindCluster</param> - /// <returns></returns> - public bool DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6) - { - //缁勮鏁版嵁 - var deleteData = new IASZone.DelDeviceBindData(); - deleteData.DeviceAddr = mainDevice.DeviceAddr; - deleteData.Epoint = mainDevice.DeviceEpoint; - - var info = new IASZone.RemoveBindListObj(); - info.BindCluster = BindCluster; - info.BindMacAddr = deleteDevice.DeviceAddr; - info.BindEpoint = deleteDevice.DeviceEpoint; - info.BindType = 0; - - deleteData.RemoveBindList.Add(info); - - //鎵ц鍒犻櫎 - var result = this.DelDeviceBindAsync(deleteData); - if (result == null || result.delDeviceBindResponseData == null) - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); - - this.ShowErrorMsg(msg); - return false; - } - - foreach (var data in result.delDeviceBindResponseData.RemoveBindList) - { - //0:鎴愬姛 1:璁惧涓嶅湪缁戝畾鍒楄〃涓� 锛屼篃鍙互浠h〃鎴愬姛 - if (data.Result == 0 || data.Result == 1 || data.Result == 5) - { - return true; - } - //3:澶辫触锛屽湪绛夊緟鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛 - else if (data.Result == 3) - { - //鍏朵粬缁戝畾鐩爣姝e湪鍒犻櫎涓紝璇风◢鍚庡啀璇� - string msg = Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait); - this.ShowErrorMsg(msg); - return false; - } - //2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔� - else if (data.Result == 2) - { - if (result.removeBindResultResponseData == null) - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - this.ShowErrorMsg(msg); - return false; - } - else - { - //鎴愬姛 - if (result.removeBindResultResponseData.Result == 0) - { - return true; - } - //136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾 - else if (result.removeBindResultResponseData.Result == 136) - { - //杩欎釜鍙互褰撳仛鎴愬姛 - return true; - } - else - { - //鍒犻櫎缁戝畾鐩爣澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); - this.ShowErrorMsg(msg); - return false; - } - } - } - } - return false; - } - + /// <summary> /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍� /// </summary> diff --git a/Home0618/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs b/Home0618/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs index ff185f2..d6e3492 100644 --- a/Home0618/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs +++ b/Home0618/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs @@ -602,38 +602,13 @@ var form = new DevicePanel.PanelSimpleEnvironmentButtonSettionForm(); form.AddForm(listNewDevice[0]); }; - } - - #region 鈻� 绠�绾︾幆澧�(闈㈡澘)_____________________ - - /// <summary> - /// 娣诲姞銆愭寜閿缃�戣绠�绾︾幆澧�(闈㈡澘) - /// </summary> - private void AddSimplePanelSettionRow() - { - //鎸夐敭璁剧疆 - string caption = Language.StringByID(R.MyInternationalizationString.uPanelSettion); - var btnFunction = new FrameRowControl(listview.rowSpace / 2); - listview.AddChidren(btnFunction); - btnFunction.AddLeftCaption(caption, 600); - //鍚戝彸鍥炬爣 - btnFunction.AddRightArrow(); - //搴曠嚎 - btnFunction.AddBottomLine(); - btnFunction.ButtonClickEvent += (sender, e) => - { - var form = new DeviceBind.PanelSimpleEnvironmentTargetsForm(); - - }; - } - - #endregion - + } + #endregion #endregion - + #region 鈻� 鎸夐敭璁剧疆(鏂规偊)_____________________ - + /// <summary> /// 娣诲姞銆愭寜閿缃�戣(鏂规偊) /// </summary> @@ -1101,9 +1076,8 @@ }); }; }; - } - #endregion - + } + /// <summary> /// 娓╁害鏉ユ簮琛� /// </summary> diff --git a/Home0618/Shared/Phone/UserCenter/Device/Light/MiniNightLightFunctionSettionForm.cs b/Home0618/Shared/Phone/UserCenter/Device/Light/MiniNightLightFunctionSettionForm.cs new file mode 100755 index 0000000..9ad3a8f --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Device/Light/MiniNightLightFunctionSettionForm.cs @@ -0,0 +1,139 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.DeviceLight +{ + /// <summary> + /// mini澶滅伅鐨勫姛鑳借缃晫闈� + /// </summary> + public class MiniNightLightFunctionSettionForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 璁惧鐨勬煇涓�鍥炶矾 + /// </summary> + private CommonDevice device = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param> + public void ShowForm(CommonDevice i_device) + { + this.device = i_device; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍥剧墖 + var btnPic = new PicViewControl(508, 204); + btnPic.Y = Application.GetRealHeight(179); + btnPic.Gravity = Gravity.CenterHorizontal; + btnPic.UnSelectedImagePath = "DeviceItem/MiniNightLightDevice.png"; + bodyFrameLayout.AddChidren(btnPic); + + var listBackControl = new VerticalFrameControl(); + listBackControl.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listBackControl); + + //鍒濆鍖栨甯� + var tableContr = new InformationEditorControl(); + var listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1166); + + //鍥炶矾澶囨敞 + string caption = Language.StringByID(R.MyInternationalizationString.uDeviceEpointNote); + string nameValue = Common.LocalDevice.Current.GetDeviceEpointName(this.device); + var btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2); + listview.AddChidren(btnDeviceName); + btnDeviceName.InitControl(); + btnDeviceName.AddBottomLine(); + btnDeviceName.txtInput.FinishInputEvent += () => + { + string oldName = Common.LocalDevice.Current.GetDeviceEpointName(this.device); + if (btnDeviceName.Text.Trim() == string.Empty) + { + //灏嗗悕瀛楄繕鍘� + btnDeviceName.Text = oldName; + } + if (oldName != btnDeviceName.Text.Trim()) + { + //璁惧鍚嶇О淇敼 + var result = Common.LocalDevice.Current.ReName(this.device, btnDeviceName.Text.Trim()); + if (result == false) + { + return; + } + //鍥炶矾澶囨敞淇敼鎴愬姛! + string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess); + this.ShowMassage(ShowMsgType.Tip, msg); + } + }; + + //鎵�灞炲尯鍩� + var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2); + listview.AddChidren(rowBeloneArea); + rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.device); + //搴曠嚎 + rowBeloneArea.AddBottomLine(); + rowBeloneArea.SelectRoomEvent += (roomKeys) => + { + //鍙樻洿鎴块棿 + HdlRoomLogic.Current.ChangedRoom(this.device, roomKeys); + }; + + //鑷畾涔夊姛鑳界被鍨嬫帶浠� + var rowFunction = new DeviceFunctionTypeRowControl(this.device, listview.rowSpace / 2); + if (rowFunction.CanShowRow == true) + { + listview.AddChidren(rowFunction); + rowFunction.InitControl(); + //搴曠嚎 + rowFunction.AddBottomLine(); + } + //鍒濆鍖栨甯冨畬鎴� + tableContr.FinishInitControl(); + + //淇濆瓨 + var btnFinish = new BottomClickButton(); + btnFinish.TextID = R.MyInternationalizationString.uSave; + bodyFrameLayout.AddChidren(btnFinish); + btnFinish.ButtonClickEvent += (sender, e) => + { + string newName = btnDeviceName.Text.Trim(); + string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device); + if (oldName != newName) + { + //璁惧鍚嶇О淇敼 + var result = Common.LocalDevice.Current.ReName(device, newName); + if (result == false) + { + return; + } + } + //鍏抽棴鑷韩 + this.CloseForm(); + }; + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs b/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs index b0970a5..18418cc 100644 --- a/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs +++ b/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs @@ -339,7 +339,7 @@ btnColorView.Y = Application.GetRealHeight(5); btnColorView.TextColor = UserCenterColor.Current.TextGrayColor1; btnColorView.TextID = R.MyInternationalizationString.uColor; - frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEventOnly); + frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEvent); int R1 = Convert.ToInt32(this.keyColorData.OpenColorR, 16); int G1 = Convert.ToInt32(this.keyColorData.OpenColorG, 16); @@ -354,19 +354,19 @@ btnColorLine.Radius = (uint)this.GetPictrueRealSize(79) / 2; btnColorLine.BorderWidth = 1; btnColorLine.BorderColor = 0xffcccccc; - frameColor.AddChidren(btnColorLine, ChidrenBindMode.BindEventOnly); + frameColor.AddChidren(btnColorLine, ChidrenBindMode.BindEvent); var btnColor = new NormalViewControl(this.GetPictrueRealSize(69), this.GetPictrueRealSize(69), false); btnColor.Gravity = Gravity.Center; btnColor.Radius = (uint)this.GetPictrueRealSize(69) / 2; btnColor.BackgroundColor = backColor; - btnColorLine.AddChidren(btnColor, ChidrenBindMode.BindEventOnly); + btnColorLine.AddChidren(btnColor, ChidrenBindMode.BindEvent); var btnRight = new NormalViewControl(this.GetPictrueRealSize(58), this.GetPictrueRealSize(58), false); btnRight.UnSelectedImagePath = "Item/RightNext.png"; btnRight.Y = Application.GetRealHeight(5); btnRight.X = frameColor.Width - this.GetPictrueRealSize(58); - frameColor.AddChidren(btnRight, ChidrenBindMode.BindEventOnly); + frameColor.AddChidren(btnRight, ChidrenBindMode.BindEvent); btnRight.Y += this.GetPictrueRealSize(8); frameColor.ButtonClickEvent += (sender, e) => diff --git a/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs b/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs old mode 100755 new mode 100644 index 1a244e1..00efa20 --- a/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs +++ b/Home0618/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionTargetsForm.cs @@ -384,7 +384,7 @@ var rowLayout = new RowLayoutControl(midVerticalScrolViewLayout.rowSpace / 2); rowLayout.BackgroundColor = ZigbeeColor.Current.XMWhite; - midVerticalScrolViewLayout.AddChidrenRow(rowLayout); + midVerticalScrolViewLayout.AddChidren(rowLayout); rowLayout.frameTable.UseClickStatu = false; var devicePic = rowLayout.frameTable.AddLeftIcon(); devicePic.Y = Application.GetRealHeight(25);//49 @@ -485,7 +485,7 @@ //鑾峰彇鎴块棿鐨勫悕瀛� var tempDevRoomName = tempDevRoom.Name; //鑾峰彇妤煎眰鐨勫悕瀛� - var tempDevFloorName = Common.Config.Instance.Home.GetFloorNameById(tempDevFloorId); + var tempDevFloorName = HdlResidenceLogic .Current.GetFloorNameById(tempDevFloorId); if (string.IsNullOrEmpty(tempDevFloorName)) { if (string.IsNullOrEmpty(tempDevRoomName)) diff --git a/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection1Form.cs b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection1Form.cs new file mode 100755 index 0000000..76609fd --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection1Form.cs @@ -0,0 +1,79 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// Mini缃戝叧鐨勮鏄庢寚绀虹晫闈�1 + /// </summary> + public class MiniGatewayDirection1Form : EditorCommonForm + { + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍥剧墖 + var framePic = new FrameLayout(); + framePic.Width = this.GetPictrueRealSize(395); + framePic.Height = this.GetPictrueRealSize(223); + framePic.Gravity = Gravity.CenterHorizontal; + framePic.Y = Application.GetRealHeight(464); + framePic.BackgroundImagePath = "Gateway/MiniGatewayDirection.png"; + bodyFrameLayout.AddChidren(framePic); + + //鎻掔數鍚�,闀挎寜缃戝叧HID/WCFG鎸夐敭5绉抺0}绯荤粺鐏父浜�60绉掑悗鍒欒繘鍏ラ厤缃戠姸鎬� + string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddMiniGatewayMsg1).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); + int yy = framePic.Bottom + Application.GetRealHeight(291); + foreach (var msg in ArryMsg) + { + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.Text = msg; + btnMsg.Y = yy; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + bodyFrameLayout.AddChidren(btnMsg); + yy = btnMsg.Bottom; + } + + //鏌ョ湅甯姪 + var btnHelp = this.AddHelpControl(); + btnHelp.ButtonClickEvent += (sender, e) => + { + var form = new AddGatewayHelpForm(); + form.AddForm("Mini"); + }; + + //涓嬩竴姝� + var btnNext = new BottomClickButton(); + btnNext.TextID = R.MyInternationalizationString.uNextway; + bodyFrameLayout.AddChidren(btnNext); + btnNext.ButtonClickEvent += (sender, e) => + { + this.CloseForm(); + var form = new MiniGatewayDirection2Form(); + form.AddForm(); + }; + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection2Form.cs b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection2Form.cs new file mode 100755 index 0000000..6163a3c --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection2Form.cs @@ -0,0 +1,119 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// Mini缃戝叧鐨勮鏄庢寚绀虹晫闈�1 + /// </summary> + public class MiniGatewayDirection2Form : EditorCommonForm + { + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //涓嬩竴姝� + var btnNext = new BottomClickButton(); + btnNext.TextID = R.MyInternationalizationString.uNextway; + bodyFrameLayout.AddChidren(btnNext); + btnNext.ButtonClickEvent += (sender, e) => + { + //濡傛灉涓嶆槸鐑偣妯″紡 + if (HdlWifiLogic.Current.IsMiniGatewayHotspot == false) + { + //璇烽�夋嫨hdlZigbeeGW-xxxx缃戠粶 + this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uPleaseSelectGatewayXXNet)); + return; + } + var errorMsg = HdlWifiLogic.Current.StartApTcpConnection(); + if (errorMsg != null) + { + //鎷ユ湁閿欒 + this.ShowMassage(ShowMsgType.Tip, errorMsg); + return; + } + this.CloseForm(); + var form = new MiniGatewaySelectNetworkForm(); + form.AddForm(); + }; + //濡傛灉涓嶆槸Mini缃戝叧鐑偣 + if (HdlWifiLogic.Current.IsMiniGatewayHotspot == false) + { + btnNext.Visible = false; + } + + //鍥剧墖 + var framePic = new FrameLayout(); + framePic.Width = this.GetPictrueRealSize(852); + framePic.Height = this.GetPictrueRealSize(478); + framePic.Gravity = Gravity.CenterHorizontal; + framePic.Y = Application.GetRealHeight(285); + framePic.BackgroundImagePath = "Gateway/WirelessGatewaySearching.png"; + bodyFrameLayout.AddChidren(framePic); + + //鎵嬫満鍘昏缃繛鎺ョ綉鍏崇儹鐐箋0}鍗砲dlZigbeeGW-xxxx,瀵嗙爜hdl123456{0}鍙煡鐪嬬綉鍏宠儗闈㈡爣绛炬煡鐪嬬儹鐐瑰悕瀛楀拰瀵嗙爜 + string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddApWirelessGatewayMsg2).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); + int yy = framePic.Bottom + Application.GetRealHeight(213); + foreach (var msg in ArryMsg) + { + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.Text = msg; + btnMsg.Y = yy; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + bodyFrameLayout.AddChidren(btnMsg); + yy = btnMsg.Bottom; + } + + //鍘昏缃� + var btnSettion = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false); + btnSettion.Y = yy + Application.GetRealHeight(12); + btnSettion.TextSize = 12; + btnSettion.TextAlignment = TextAlignment.Center; + btnSettion.TextColor = 0xff0075ff; + btnSettion.Text = Language.StringByID(R.MyInternationalizationString.uGotoSettion); + btnSettion.ButtonClickEvent += (sender, e) => + { + HdlWifiLogic.Current.OpenAppWifiSettion(); + btnNext.Visible = true; + }; + bodyFrameLayout.AddChidren(btnSettion); + //搴曠嚎 + int lineWidth = btnSettion.GetRealWidthByText(); + var btnLine1 = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false); + btnLine1.BackgroundColor = 0xff0075ff; + btnLine1.Gravity = Gravity.CenterHorizontal; + btnLine1.Y = btnSettion.Bottom - Application.GetRealHeight(8); + bodyFrameLayout.AddChidren(btnLine1); + + //鏌ョ湅甯姪 + var btnHelp = this.AddHelpControl(); + btnHelp.ButtonClickEvent += (sender, e) => + { + var form = new AddGatewayHelpForm(); + form.AddForm("Mini"); + }; + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection3Form.cs b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection3Form.cs new file mode 100755 index 0000000..5acc2e1 --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewayDirection3Form.cs @@ -0,0 +1,112 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// Mini缃戝叧鐨勮鏄庢寚绀虹晫闈�3 + /// </summary> + public class MiniGatewayDirection3Form : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鏌ョ湅甯姪 + var btnHelp = this.AddHelpControl(); + btnHelp.ButtonClickEvent += (sender, e) => + { + var form = new AddGatewayHelpForm(); + form.AddForm("Mini"); + }; + + //涓嬩竴姝� + var btnNext = new BottomClickButton(); + btnNext.TextID = R.MyInternationalizationString.uNextway; + bodyFrameLayout.AddChidren(btnNext); + btnNext.ButtonClickEvent += (sender, e) => + { + //濡傛灉杩樻槸鐑偣妯″紡 + if (HdlWifiLogic.Current.IsMiniGatewayHotspot == true) + { + //璇烽摼鎺ュ搴璚ifi + this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uPleaseLinkHomeWifi)); + return; + } + this.CloseForm(); + var form = new MiniGatewaySearchForm(); + form.AddForm(); + }; + btnNext.Visible = false; + + //鍥剧墖 + var framePic = new FrameLayout(); + framePic.Width = this.GetPictrueRealSize(857); + framePic.Height = this.GetPictrueRealSize(239); + framePic.Gravity = Gravity.CenterHorizontal; + framePic.Y = Application.GetRealHeight(366); + framePic.BackgroundImagePath = "Gateway/MiniGatewaySearching.png"; + bodyFrameLayout.AddChidren(framePic); + + //鎵嬫満鍘昏缃繛鎺ヨ矾鐢卞櫒 + string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddApWirelessGatewayMsg3).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); + int yy = framePic.Bottom + Application.GetRealHeight(369); + foreach (var msg in ArryMsg) + { + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.Text = msg; + btnMsg.Y = yy; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + bodyFrameLayout.AddChidren(btnMsg); + yy = btnMsg.Bottom; + } + + //鍘昏缃� + var btnSettion = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false); + btnSettion.Y = yy + Application.GetRealHeight(12); + btnSettion.TextSize = 12; + btnSettion.TextAlignment = TextAlignment.Center; + btnSettion.TextColor = 0xff0075ff; + btnSettion.Text = Language.StringByID(R.MyInternationalizationString.uGotoSettion); + btnSettion.ButtonClickEvent += (sender, e) => + { + HdlWifiLogic.Current.OpenAppWifiSettion(); + btnNext.Visible = true; + }; + bodyFrameLayout.AddChidren(btnSettion); + //搴曠嚎 + int lineWidth = btnSettion.GetRealWidthByText(); + var btnLine1 = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false); + btnLine1.BackgroundColor = 0xff0075ff; + btnLine1.Gravity = Gravity.CenterHorizontal; + btnLine1.Y = btnSettion.Bottom - Application.GetRealHeight(8); + bodyFrameLayout.AddChidren(btnLine1); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySearchForm.cs b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySearchForm.cs new file mode 100755 index 0000000..7102037 --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySearchForm.cs @@ -0,0 +1,413 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// Mini缃戝叧鐨勬悳绱㈢晫闈� + /// </summary> + public class MiniGatewaySearchForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鎼滅储鍒扮殑缃戝叧鍒楄〃 + /// </summary> + private List<ZbGateway> listZbGateway = new List<ZbGateway>(); + /// <summary> + /// 鎼滅储鍒扮殑缃戝叧绫诲埆 0:绗竴娆$粦瀹� 1:宸茬粡缁戝畾 2:闇�瑕佹崲缁� + /// </summary> + private Dictionary<string, int> dicZbGatewayDiv = new Dictionary<string, int>(); + /// <summary> + /// 鑾峰彇寰楀埌浜嗘柊缃戝叧 + /// </summary> + private bool newGatewayGetting = false; + /// <summary> + /// 缃戝叧妫�娴嬩腑 + /// </summary> + private string isGatewayChecking = "0"; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway)); + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitDefultMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitDefultMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //缃戝叧濡傛灉姝e父杩炴帴璺敱鍣▄0}绯荤粺鎸囩ず鐏細1绉掗棯鐑� + string[] ArryMsg = Language.StringByID(R.MyInternationalizationString.uAddApWirelessGatewayMsg4).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); + int yy = Application.GetRealHeight(1066); + foreach (var msg in ArryMsg) + { + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.Text = msg; + btnMsg.Y = yy; + btnMsg.TextAlignment = TextAlignment.Center; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg); + yy = btnMsg.Bottom; + } + + //鍒濆鍖栬繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉 + this.InitConcetionAnimete(); + } + + /// <summary> + /// 鍒濆鍖栧け璐ユā寮忕殑涓儴鎺т欢 + /// </summary> + private void InitFailMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍥炬爣 + var picGwImage = new FrameLayout(); + picGwImage.Width = this.GetPictrueRealSize(857); + picGwImage.Height = this.GetPictrueRealSize(239); + picGwImage.Y = Application.GetRealWidth(236); + picGwImage.Gravity = Gravity.CenterHorizontal; + picGwImage.BackgroundImagePath = "Gateway/MiniGatewaySearching.png"; + bodyFrameLayout.AddChidren(picGwImage); + var btnFailIcon = new PicViewControl(66, 66); + btnFailIcon.UnSelectedImagePath = "Item/FailIcon.png"; + btnFailIcon.Gravity = Gravity.CenterHorizontal; + btnFailIcon.Y = this.GetPictrueRealSize(110); + picGwImage.AddChidren(btnFailIcon); + //鎼滅储澶辫触 + var btnFailView = new NormalViewControl(300, 60, true); + btnFailView.TextAlignment = TextAlignment.Center; + btnFailView.Y = picGwImage.Bottom - Application.GetRealHeight(15); + btnFailView.Gravity = Gravity.CenterHorizontal; + btnFailView.TextColor = UserCenterColor.Current.TextGrayColor3; + btnFailView.TextID = R.MyInternationalizationString.uSearchFail; + bodyFrameLayout.AddChidren(btnFailView); + + //瑙e喅鏂规硶锛屽彲閫夋嫨鎵ц浠ヤ笅浠绘剰涓�绉嶆柟寮忥細 + var btnMsg1 = new NormalViewControl(930, 60, true); + btnMsg1.X = Application.GetRealWidth(75); + btnMsg1.Y = picGwImage.Bottom + Application.GetRealHeight(112); + btnMsg1.TextID = R.MyInternationalizationString.uSearchGatewayFailMsg1; + bodyFrameLayout.AddChidren(btnMsg1); + //1.鐭寜HID/WCFG鎸夐敭锛岀郴缁熸寚绀虹伅蹇棯3绉掞紝缃戝叧杩涘叆鎹㈢粦妯″紡锛屽己鍒剁綉鍏崇粦瀹氬埌褰撳墠APP + var btnMsg2 = new NormalViewControl(930, 100, true); + btnMsg2.X = Application.GetRealWidth(75); + btnMsg2.Y = btnMsg1.Bottom + Application.GetRealHeight(35); + btnMsg2.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg2).Replace("{0}", "\r\n"); + btnMsg2.TextSize = 12; + btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg2.IsMoreLines = true; + bodyFrameLayout.AddChidren(btnMsg2); + //2.闀挎寜缃戝叧ZB/RST鎸夐敭20绉掍互涓婏紝鐩村埌鎵�鏈夋寚绀虹伅鍚屾椂鐏紝鍗虫仮澶嶅嚭鍘傝缃苟閲嶅惎 + var btnMsg3 = new NormalViewControl(930, 100, true); + btnMsg3.X = Application.GetRealWidth(75); + btnMsg3.Y = btnMsg2.Bottom + Application.GetRealHeight(12); + btnMsg3.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg3).Replace("{0}", "\r\n"); + btnMsg3.TextSize = 12; + btnMsg3.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg3.IsMoreLines = true; + bodyFrameLayout.AddChidren(btnMsg3); + //3.璇烽噸璇曪紝閲嶆柊娣诲姞缃戝叧銆� + var btnMsg4 = new NormalViewControl(930, 50, true); + btnMsg4.X = Application.GetRealWidth(75); + btnMsg4.Y = btnMsg3.Bottom + Application.GetRealHeight(12); + btnMsg4.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg4); + btnMsg4.TextSize = 12; + btnMsg4.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg4); + //4.杩斿洖缃戝叧绠$悊銆� + var btnMsg5 = new NormalViewControl(930, 50, true); + btnMsg5.X = Application.GetRealWidth(75); + btnMsg5.Y = btnMsg4.Bottom + Application.GetRealHeight(12); + btnMsg5.Text = Language.StringByID(R.MyInternationalizationString.uSearchGatewayFailMsg5); + btnMsg5.TextSize = 12; + btnMsg5.TextColor = UserCenterColor.Current.TextGrayColor1; + bodyFrameLayout.AddChidren(btnMsg5); + + //閲嶈瘯 + var frameback = new FrameLayoutStatuControl(); + frameback.UseClickStatu = false; + frameback.Y = Application.GetRealHeight(1259); + frameback.Gravity = Gravity.CenterHorizontal; + frameback.Width = Application.GetRealWidth(746); + frameback.Height = Application.GetRealHeight(184); + frameback.BackgroundImagePath = "Item/BottomButtonGround.png"; + bodyFrameLayout.AddChidren(frameback); + var btnReDo = new NormalViewControl(300, 65, true); + btnReDo.IsBold = true; + btnReDo.TextColor = UserCenterColor.Current.White; + btnReDo.TextSize = 16; + btnReDo.Y = Application.GetRealHeight(49); + btnReDo.Gravity = Gravity.CenterHorizontal; + btnReDo.TextAlignment = TextAlignment.Center; + btnReDo.TextID = R.MyInternationalizationString.uReDoAgain; + frameback.AddChidren(btnReDo, ChidrenBindMode.BindEvent); + frameback.ButtonClickEvent += (sender, e) => + { + //鍒濆鍖栧垵濮嬩腑閮ㄦ帶浠� + this.InitDefultMiddleFrame(); + }; + + //杩斿洖缃戝叧绠$悊 + var btnGoBack = new BottomClickButton(688); + btnGoBack.Y = Application.GetRealHeight(1495); + btnGoBack.TextID = R.MyInternationalizationString.uGobackGatewayManage; + if (UserCenterResourse.DicActionForm.ContainsKey("GatewayListForm") == false) + { + //杩斿洖涓婚〉 + btnGoBack.TextID = R.MyInternationalizationString.uGobackToHomePage; + } + bodyFrameLayout.AddChidren(btnGoBack); + btnGoBack.ButtonClickEvent += (sender, e) => + { + this.CloseForm(); + //鍏抽棴鎸囧畾鐣岄潰 + this.CloseFormByFormName("NewGateWayMenuSelectForm"); + }; + } + + #endregion + + #region 鈻� 鍋囨兂鍔ㄧ敾___________________________ + + /// <summary> + /// 鍒濆鍖栬繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉 + /// </summary> + private void InitConcetionAnimete() + { + //鍥炬爣 + var btnGwImage = new FrameLayout(); + btnGwImage.Width = this.GetPictrueRealSize(857); + btnGwImage.Height = this.GetPictrueRealSize(239); + btnGwImage.Y = Application.GetRealHeight(360); + btnGwImage.Gravity = Gravity.CenterHorizontal; + btnGwImage.BackgroundImagePath = "Gateway/MiniGatewaySearching.png"; + bodyFrameLayout.AddChidren(btnGwImage); + + //姝e湪鎼滅储缃戝叧鈥� + var btnMsg = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); + btnMsg.TextID = R.MyInternationalizationString.uGatewaySearching; + btnMsg.Y = Application.GetRealHeight(821); + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; + btnMsg.TextAlignment = TextAlignment.Center; + bodyFrameLayout.AddChidren(btnMsg); + + //棣栨牸鐨刋杞� + int firstPoint = this.GetPictrueRealSize(275); + //涓�鏍肩殑瀹藉害 + int width = this.GetPictrueRealSize(22); + //闂磋窛澶у皬 + int space = this.GetPictrueRealSize(12); + + //鐢熸垚鏍煎瓙鍧愭爣 + var listPoint = new List<int>(); + for (int i = 0; i < 9; i++) + { + listPoint.Add(firstPoint + (width + space) * i); + } + + //寮�鍚繛鎺ョ殑鍋囨兂鍔ㄧ敾鏁堟灉绾跨▼ + var btnRound = new PicViewControl(width, width, false); + btnRound.Radius = (uint)width / 2; + btnRound.BackgroundColor = UserCenterColor.Current.ConcetionRoundColor; + btnRound.Y = this.GetPictrueRealSize(132); + btnRound.X = listPoint[0]; + btnGwImage.AddChidren(btnRound); + + string strMsg = btnMsg.Text; + HdlThreadLogic.Current.RunThread(() => + { + //娓呯┖鍏ㄩ儴鍒楄〃 + HdlGatewayLogic.Current.ClearAllRealGateway(); + ZigBee.Common.Application.IsSearchingGateway = true; + + int index = 1; + //璁℃椂鏃堕棿 + int timeCount = 0; + //瓒呮椂鏃堕棿 + int timeOut = 240; + while (btnGwImage.Parent != null) + { + timeCount++; + if (timeCount == 10) + { + //5绉掑悗娓呯┖缃戝叧鍒楄〃 + HdlGatewayLogic.Current.ClearAllRealGateway(); + ZigBee.Common.Application.IsSearchingGateway = true; + } + if (timeCount % 4 == 0 && timeCount >= 10) + { + lock (isGatewayChecking) + { + if (isGatewayChecking != "1") + { + isGatewayChecking = "1"; + HdlThreadLogic.Current.RunThread(async () => + { + //姣�2绉掓娴嬫悳绱㈠埌鐨勭綉鍏� + await this.CheckZbGatewayAndSetRow(); + lock (isGatewayChecking) + { + isGatewayChecking = "0"; + } + }); + } + } + } + if (timeCount % 2 == 0) + { + timeOut--; + } + if (this.newGatewayGetting == true || timeOut <= 0) + { + //鑾峰彇寰楀埌鏂扮綉鍏�,鍒欎腑鏂嚎绋� + break; + } + + Application.RunOnMainThread(() => + { + btnRound.X = listPoint[index]; + index++; + if (index == listPoint.Count) + { + index = 0; + } + //姝e湪鎼滅储缃戝叧鈥Xs + btnMsg.Text = strMsg + timeOut + "s"; + }); + + System.Threading.Thread.Sleep(500); + } + if (timeOut <= 0) + { + HdlThreadLogic.Current.RunMain(() => + { + //鍒濆鍖栧け璐ユā寮忕殑涓儴鎺т欢 + this.InitFailMiddleFrame(); + }); + } + else if (newGatewayGetting == true) + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.Parent != null) + { + var form = new GatewayManage.GatewaySearchListForm(); + this.AddFromAndRemoveNowForm(form, listZbGateway, dicZbGatewayDiv); + } + }); + } + }); + } + + #endregion + + #region 鈻� 缃戝叧妫�娴媉__________________________ + + /// <summary> + /// 妫�娴嬫悳绱㈠埌鐨勭綉鍏� + /// </summary> + private async Task<bool> CheckZbGatewayAndSetRow() + { + for (int i = 0; i < ZbGateway.GateWayList.Count; i++) + { + var way = ZbGateway.GateWayList[i]; + var wayId = way.GwId; + if (dicZbGatewayDiv.ContainsKey(wayId) == true) + { + //宸茬粡澶勭悊浜� + continue; + } + + //缃戝叧缁戝畾妯″紡 + GatewayBindMode mode = GatewayBindMode.BindAgain; + //濡傛灉鏄涓�娆$粦瀹�,鎴栬�呮槸浠ュ墠宸茬粡缁戝畾杩囦簡鐨� + if (HdlGatewayLogic.Current.HomeIdIsEmpty(way) == true + || way.HomeId == Common.Config.Instance.HomeId) + { + if (way.HomeId != Common.Config.Instance.HomeId) + { + //绗竴娆$粦瀹�,涔熷氨鏄綉鍏充綇瀹匢D涓虹┖ + mode = GatewayBindMode.First; + } + else + { + //宸茬粡缁戝畾杩囦簡 + mode = GatewayBindMode.Binded; + } + //娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮紦瀛�(鎵ц缃戝叧淇濆瓨鎿嶄綔) + var result = await HdlGatewayLogic.Current.AddNewGateway(way, ShowErrorMode.NO); + if (result == false) + { + continue; + } + } + //鏀堕泦缃戝叧瀵硅薄 + this.listZbGateway.Add(way); + + //鍏ㄩ儴澶勭悊OK鍚庯紝鎵嶈兘璁剧疆flage + if (mode == GatewayBindMode.First) + { + //绗竴娆$粦瀹� + this.dicZbGatewayDiv[wayId] = 0; + //鑾峰彇鍒颁簡鏂扮綉鍏� + this.newGatewayGetting = true; + } + else if (mode == GatewayBindMode.Binded) + { + //宸茬粡缁戝畾杩� + this.dicZbGatewayDiv[wayId] = 1; + } + else + { + //闇�瑕侀噸鏂扮粦瀹� + this.dicZbGatewayDiv[wayId] = 2; + //鑾峰彇鍒颁簡鏂扮綉鍏� + this.newGatewayGetting = true; + } + + if (mode == GatewayBindMode.First) + { + //鎴戣寰楄繖閲岄渶瑕佽幏鍙栦竴涓嬫柊缃戝叧鐨勮澶囧垪琛� + Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(way); + } + } + return true; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + ZigBee.Common.Application.IsSearchingGateway = false; + + base.CloseFormBefore(); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySelectNetworkForm.cs b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySelectNetworkForm.cs new file mode 100755 index 0000000..c959bbf --- /dev/null +++ b/Home0618/Shared/Phone/UserCenter/Gateway/Add/MiniGatewaySelectNetworkForm.cs @@ -0,0 +1,143 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// Mini缃戝叧閫夋嫨缃戠粶鐨勭晫闈� + /// </summary> + public class MiniGatewaySelectNetworkForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm() + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddMiniGateway)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + bodyFrameLayout.RemoveAll(); + + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(409); + frameBack.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(frameBack); + + //璇烽�夋嫨缃戠粶 + var btnTitle = new NormalViewControl(600, 64, true); + btnTitle.X = ControlCommonResourse.XXLeft; + btnTitle.Y = Application.GetRealHeight(30); + btnTitle.TextSize = 15; + btnTitle.TextID = R.MyInternationalizationString.uPleaseSelectNetwork; + frameBack.AddChidren(btnTitle); + + //WIFI + var rowWifi = new FrameCaptionInputControl("WiFi", ""); + rowWifi.Y = Application.GetRealHeight(124); + frameBack.AddChidren(rowWifi); + rowWifi.InitControl(); + rowWifi.AddBottomLine(); + rowWifi.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputHomeWifiAccount); + + //瀵嗙爜 + var btnPsw = new FrameCaptionInputControl(Language.StringByID(R.MyInternationalizationString.uPassword), string.Empty); + btnPsw.Y = rowWifi.Bottom + Application.GetRealHeight(9); + frameBack.AddChidren(btnPsw); + btnPsw.InitControl(); + btnPsw.txtInput.SecureTextEntry = true; + btnPsw.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputWifiPassword); + var btnView = btnPsw.AddMostRightEmptyIcon(81, 81); + btnView.UnSelectedImagePath = "Item/HidenPWD.png"; + btnView.SelectedImagePath = "Item/UnHidenPWD.png"; + btnPsw.ChangedChidrenBindMode(btnView, ChidrenBindMode.NotBind); + btnView.ButtonClickEvent += (sender, e) => + { + btnView.IsSelected = !btnView.IsSelected; + btnPsw.txtInput.SecureTextEntry = !btnPsw.txtInput.SecureTextEntry; + }; + + var btnMsg = new NormalViewControl(btnPsw.txtInput.Width, false); + btnMsg.X = ControlCommonResourse.XXLeft; + btnMsg.Y = frameBack.Bottom + Application.GetRealHeight(23); + btnMsg.TextSize = 12; + btnMsg.Height = Application.GetRealHeight(40); + btnMsg.TextColor = UserCenterColor.Current.ErrorColor; + bodyFrameLayout.AddChidren(btnMsg); + + //鏌ョ湅甯姪 + var btnHelp = this.AddHelpControl(); + btnHelp.ButtonClickEvent += (sender, e) => + { + var form = new AddGatewayHelpForm(); + form.AddForm("Mini"); + }; + + //涓嬩竴姝� + var btnNext = new BottomClickButton(); + btnNext.TextID = R.MyInternationalizationString.uNextway; + bodyFrameLayout.AddChidren(btnNext); + + btnNext.MouseUpEventHandler += (sender, e) => + { + btnMsg.Text = string.Empty; + if (rowWifi.Text == string.Empty) + { + //璇疯緭鍏ュ搴璚IFI璐﹀彿 + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputHomeWifiAccount); + return; + } + if (btnPsw.Text == string.Empty) + { + //璇疯緭鍏ifi瀵嗙爜 + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uPleaseInputWifiPassword); + return; + } + //鍙戦�佸瘑鐮� + var result = HdlWifiLogic.Current.SendApHomeWifiPassword(rowWifi.Text, btnPsw.Text); + if (result == false) + { + //瀵嗙爜鍙戦�佸け璐� + this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uSendPasswordFail)); + return; + } + + this.CloseForm(); + var form = new MiniGatewayDirection3Form(); + form.AddForm(); + }; + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + //鍏抽棴Tcp閾炬帴 + HdlWifiLogic.Current.CloseApTcpConnection(); + + base.CloseFormBefore(); + } + + #endregion + } +} diff --git a/Home0618/Shared/Phone/ZigBee/Device/Buzzer.cs b/Home0618/Shared/Phone/ZigBee/Device/Buzzer.cs new file mode 100755 index 0000000..a72e90d --- /dev/null +++ b/Home0618/Shared/Phone/ZigBee/Device/Buzzer.cs @@ -0,0 +1,18 @@ +锘縰sing Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZigBee.Device +{ + /// <summary> + /// 铚傞福鍣ㄧ殑瀵硅薄绫� + /// </summary> + public class Buzzer: CommonDevice + { + public Buzzer() + { + this.Type = DeviceType.Buzzer; + } + } +} diff --git a/Home0618/Shared/Phone/ZigBee/Device/ColorTemperatureLight.cs b/Home0618/Shared/Phone/ZigBee/Device/ColorTemperatureLight.cs new file mode 100755 index 0000000..7645945 --- /dev/null +++ b/Home0618/Shared/Phone/ZigBee/Device/ColorTemperatureLight.cs @@ -0,0 +1,109 @@ +锘縰sing Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ZigBee.Device +{ + /// <summary> + /// 鑹叉俯鐏� + /// </summary> + public class ColorTemperatureLight : LightBase + { + public ColorTemperatureLight() + { + this.Type = DeviceType.ColorTemperatureLight; + } + + /// <summary> + ///浜害锛屾暣褰紝鍙栧�艰寖鍥达細0-254琛ㄧず0%-100% + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int Level = 0; + + /// <summary> + ///鑹叉俯锛屽彇鍊艰寖鍥达細3400~6000 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public int ColorTemperature = 0; + + /// <summary> + /// 璇诲彇浜害 + /// </summary> + public void ReadLevel() + { + ReadAttri(Device.Cluster_ID.LevelControl, AttriButeId.LevelControl); + } + + /// <summary> + /// 璇诲彇鑹叉俯 + /// </summary> + public void ReadColorTemperature() + { + ReadAttri(Device.Cluster_ID.ColorControl, AttriButeId.LevelControl); + } + + ///<summary > + ///璁剧疆璁惧浜害锛圠evel锛� + ///<para>value:浜害鍊煎彇鍊艰寖鍥达細0-254</para> + /// </summary> + public void SetLevel(int value) + { + var jObject = new JObject { + { "DeviceAddr", DeviceAddr}, + { "Epoint", DeviceEpoint}, + { "Cluster_ID", 8 }, + { "Command", 4}, + { "SendMode", 2 } + }; + var data = new JObject { + { "Level", value }, + { "TransitionTime", 0 } + }; + jObject.Add("Data", data); + Gateway?.Send("DeviceControl", jObject.ToString()); + } + + ///<summary > + ///璁剧疆璁惧鑹叉俯 + ///<para>value:鑹叉俯鍊煎彇鍊艰寖鍥达細3400-6000</para> + /// </summary> + public void SetColorTemperature(int value) + { + var jObject = new JObject { + { "DeviceAddr", DeviceAddr}, + { "Epoint", DeviceEpoint}, + { "Cluster_ID", 768 }, + { "Command", 10}, + { "SendMode", 2 } + }; + var data = new JObject { + { "ColorTemperature", value }, + { "TransitionTime", 0 } + }; + jObject.Add("Data", data); + Gateway?.Send("DeviceControl", jObject.ToString()); + } + + /// <summary> + /// 鍙戦�佹墦寮�鑾峰彇鍏抽棴铚傞福鍣ㄧ殑鍛戒护(鐩墠鍏堣繖鏍峰惂,灏忓鐏殑铚傞福鍣�) + /// </summary> + /// <param name="isOpen"></param> + public void SendBuzzerSwitchControl(bool isOpen) + { + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 1282 }, { "Command", 0 } }; + var data = new JObject { + { "WarningMode", isOpen==true?1:0 },//0:鍏抽棴鎶ヨ 1:鎵撳紑鎶ヨ + { "Strobe", 0 },//鏄惁鍚姩鎶ヨ鐏� 0:涓嶅惎鍔� 1:鍚姩 + { "SirenLevel", 0 },//鎶ヨ闊抽噺 0锛歀ow 1锛歁edium 2锛歨igh 3: very high + { "WarningDuration", isOpen==true?10:0 }, //鎶ヨ鏃堕暱 0 -65535 鍗曚綅锛氱 + { "StrobeDutyCycle", 50 }, //鎶ヨ绛夐棯鐑佸崰绌烘瘮 0-100 + { "StrobeLevel", 1 } //鎶ヨ鐏寒搴� 0锛歀ow 1锛歁edium 2锛歨igh 3: very high + }; + jObject.Add("Data", data); + + //涓婚鍙互涔卞啓鐨� + Gateway.Send("SendSwitchCommand", jObject.ToString()); + } + } +} diff --git a/Home0618/Shared/Shared.projitems b/Home0618/Shared/Shared.projitems index dfe4ebf..fd45c5f 100644 --- a/Home0618/Shared/Shared.projitems +++ b/Home0618/Shared/Shared.projitems @@ -355,18 +355,6 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Update\GatewayVirtualDriveInfoForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Update\GatewayHistoryFirmwareVersionForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Update\GatewayLinuxInfoForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpSelectNetworkForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\NewGateWayMenuSelectForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApSelectNetworkForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection3Form.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpSearchForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection1Form.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WiredGatewaySearchForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WiredGatewayDirectionForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\AddGatewayHelpForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection2Form.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpDirectionForm.cs" /> - <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApSearchForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Manage\GatewayInfoEditorForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Manage\GatewayAddSuccessForm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Manage\GatewayListForm.cs" /> @@ -491,6 +479,43 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Bind\BindCommonLayout.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Bind\BindInfo.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Panel\PanelBrightnessAdjustForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\SmartSoundInfo.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\SmartSound.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\SmartSoundDataInfo.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Forms\SmartSoundContentForDeviceChange.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Forms\SmartSoundContentForDevice.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Forms\SmartSoundControlContentForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Forms\SmartSoundListForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Forms\SmartSoundControlForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Widget\TextDialog.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Widget\MyButton.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Widget\SoundRowLayout.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\SmartSound\Util\MyHttpWebResponse.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\CommonBase\Controls\CompoundControls\ProgressRowBar.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\Buzzer.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\ColorTemperatureLight.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpSelectNetworkForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\NewGateWayMenuSelectForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApSelectNetworkForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection3Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpSearchForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection1Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WiredGatewaySearchForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\MiniGatewaySearchForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\MiniGatewayDirection1Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\MiniGatewaySelectNetworkForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WiredGatewayDirectionForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\MiniGatewayDirection3Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\AddGatewayHelpForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApDirection2Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessUdpDirectionForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\MiniGatewayDirection2Form.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Gateway\Add\WirelessApSearchForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\Controls\DeviceCard\DeviceColorTemperatureCardControl.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\ControlForm\DeviceColorTemperatureLightDetailCardForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\MainPage\ControlForm\DeviceMiniLightDetailCardForm.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\CommonForm\Category\Controls\DeviceRow\DeviceColorTemperatureRowControl.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\Light\MiniNightLightFunctionSettionForm.cs" /> </ItemGroup> <ItemGroup> <None Include="$(MSBuildThisFileDirectory)DLL\Android\Shared.Droid.dll" /> @@ -519,6 +544,5 @@ <None Include="$(MSBuildThisFileDirectory)DLL\Security.dll" /> <None Include="$(MSBuildThisFileDirectory)DLL\ZigBee.Droid.dll" /> <None Include="$(MSBuildThisFileDirectory)DLL\ZigBee.Ios.xml" /> - <None Include="$(MSBuildThisFileDirectory)Phone\UserCenter\Device\.DS_Store" /> </ItemGroup> </Project> -- Gitblit v1.8.0