lss
2020-06-10 f37f3a667bd81f78736e381717b82f632cb1fdeb
ZigbeeApp/Shared/Phone/UserCenter/SmartSound/Forms/SmartSoundContentForDeviceChange.cs
@@ -1,11 +1,14 @@
using 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>
@@ -27,10 +30,9 @@
        /// </summary>
        private FrameLayout TipLayout = null;
        private List<string> TabList = new List<string>() { "灯光", "窗帘" };
        private List<string> TabList = new List<string>() { Language.StringByID(R.MyInternationalizationString.uLight), Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100) };
        private int CurrentSelectIndex = 0;
        private int imageWith = 683;
        private int imageHeight = 392;
@@ -63,8 +65,7 @@
            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);
@@ -92,7 +93,8 @@
            };
            //开始初始化
            switchContr.InitControl(listTitle);
            switchContr.InitControl(listTitle);
        }
        /// <summary>
@@ -123,6 +125,13 @@
                    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;
@@ -142,8 +151,7 @@
        {
            try
            {
                //2.功能类型选择(灯光、遮阳、空调)
                //3.设备列表 ListView
                ContentLayout.RemoveAll();
                FrameLayout tab_layout = new FrameLayout();
@@ -245,6 +253,13 @@
                        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;
@@ -260,6 +275,11 @@
            }
        }
        /// <summary>
        /// 修改场景昵称
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="sceneRowLayout"></param>
        private void ShowSetNicknameDialog(SmartSound.Scene scene, SceneRowLayout sceneRowLayout)
        {
            //生成一个弹窗画面
@@ -271,7 +291,7 @@
            dialogForm.Text = scene.NicksName;
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            dialogForm.ComfirmClickEvent += (async (textValue) =>
            {
                scene.NicksName = textValue;
                string remark = scene.SceneName;
@@ -280,11 +300,17 @@
                    remark += "(" + scene.NicksName + ")";
                }
                sceneRowLayout.btnCaption.Text = remark;
                string json = await postBatchEdit();
                //画面关闭
                dialogForm.CloseDialog();
                dialogForm.CloseDialog();
            });
        }
        /// <summary>
        /// 修改设备昵称
        /// </summary>
        /// <param name="device"></param>
        /// <param name="deviceRowLayout"></param>
        private void ShowSetNicknameDialog(SmartSound.Device device, DeviceRowLayout deviceRowLayout)
        {
            //生成一个弹窗画面
@@ -296,61 +322,65 @@
            dialogForm.Text = device.NicksName;
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            {
                device.NicksName = textValue;
                string remark = device.DeviceName;
                if (device.NicksName.Trim() != string.Empty)
                {
                    remark += "(" + device.NicksName + ")";
                }
                deviceRowLayout.btnCaption.Text = remark;
                //画面关闭
                dialogForm.CloseDialog();
            });
            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, "确认删除该控制内容?", () =>
            this.ShowMassage(ShowMsgType.Confirm, "确认删除该控制内容?", async () =>
            {
                try
                {
                    CurrentRoom.SceneList.Remove(scene);
                    LoadSceneView();
                    //SceneListView.RemoveAt(index);
                    string json = await postBatchEdit();
                }
                catch (Exception e)
                {
                    string sss = e.Message;
                }
            }, "确认");
            }, Language.StringByID(R.MyInternationalizationString.OkMsg));
        }
        /// <summary>
        /// 解除绑定弹窗
        /// 设备删除
        /// </summary>
        private void ShowDeviceDelectDialog(SmartSound.Device device)
        {
            this.ShowMassage(ShowMsgType.Confirm, "确认删除该控制内容?", () =>
            {
                try
                {
            this.ShowMassage(ShowMsgType.Confirm, "确认删除该控制内容?", async () =>
             {
                 try
                 {
                    //DeviceListView.RemoveAt(index);
                    CurrentRoom.DeviceList.Remove(device);
                    RefreshFunctionListView();
                }
                catch (Exception e)
                {
                    string sss = e.Message;
                }
                     RefreshFunctionListView();
            }, "确认");
                     string json = await postBatchEdit();
                 }
                 catch (Exception e)
                 {
                     string sss = e.Message;
                 }
             }, Language.StringByID(R.MyInternationalizationString.OkMsg));
        }
        /// <summary>
@@ -411,6 +441,15 @@
            }
        }
        private async Task<string> postBatchEdit()
        {
            // 提交数据至服务器
            string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit";
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate());
            string response_str = await MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8);
            return response_str;
        }
        #region ■ 自定义场景选择控件_____________________
        /// <summary>
@@ -428,7 +467,7 @@
            public NormalViewControl btnCaption = null;
            private int Index = 0;
            public SceneRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Scene _scene,int _index)
            public SceneRowLayout(SmartSoundContentForDeviceChange _smartSoundContentForDeviceChange, SmartSound.Scene _scene, int _index)
            {
                smartSoundContentForDeviceChange = _smartSoundContentForDeviceChange;
                scene = _scene;
@@ -451,12 +490,13 @@
                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);
@@ -464,11 +504,12 @@
                //底线
                frameTable.AddBottomLine();
                btnDelect = base.AddDeleteControl();
                btnDelect.Text = "删除";
                btnDelect.Text = Language.StringByID(R.MyInternationalizationString.Delete);
                btnDelect.ButtonClickEvent += (sender, e) =>
                {
                    //删除场景
                    smartSoundContentForDeviceChange.ShowSceneDelectDialog(scene);
                };
            }