//using System;
|
//using Shared;
|
//using HDL_ON.UI.CSS;
|
//using System.Collections.Generic;
|
//using System.Threading;
|
//using HDL_ON.DAL.Server;
|
|
//namespace HDL_ON.UI
|
//{
|
|
// /// <summary>
|
// /// 管理配置给音箱的设备列表
|
// /// </summary>
|
// public class SmartSpeakerSelectDevicesPage : FrameLayout
|
// {
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// FrameLayout bodyView;
|
// /// <summary>
|
// /// 全选按钮
|
// /// </summary>
|
// Button btnChooseAll;
|
// /// <summary>
|
// /// 当前
|
// /// </summary>
|
// VerticalScrolViewLayout bodyScrolView;
|
// ///// <summary>
|
// ///// 底部保存操作按钮
|
// ///// </summary>
|
// //Button btnSave;
|
|
// /// <summary>
|
// /// 音箱参数
|
// /// </summary>
|
// SpeakerInfo speakerInfo;
|
|
// /// <summary>
|
// /// 设备、场景列表
|
// /// </summary>
|
// List<SpeakerTargetInfo> targetInfoList = new List<SpeakerTargetInfo>();
|
// ///// <summary>
|
// ///// 管理当前选择选的设备、场景列表
|
// ///// </summary>
|
// //List<SpeakerTargetInfo> selectInfoList = new List<SpeakerTargetInfo>();
|
|
// /// <summary>
|
// /// 当前房间的设备和场景
|
// /// </summary>
|
// List<SpeakerTargetInfo> roomFunctionOrSceneList = new List<SpeakerTargetInfo>();
|
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// /// <param name="speakerInfo"></param>
|
// /// <param name="roomFunctionOrSceneList"></param>
|
// public SmartSpeakerSelectDevicesPage(SpeakerInfo speakerInfo, List<SpeakerTargetInfo> roomFunctionOrSceneList)
|
// {
|
// bodyView = this;
|
// bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
// this.speakerInfo = speakerInfo;
|
// this.roomFunctionOrSceneList = roomFunctionOrSceneList;
|
// }
|
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// public void LoadPage()
|
// {
|
// new TopViewDiv(bodyView, Language.StringByID(StringId.DataManagement)).LoadTopView();
|
|
// //顶部全选按钮
|
// var allRoomView = new FrameLayout()
|
// {
|
// Y = Application.GetRealHeight(64),
|
// Height = Application.GetRealHeight(50),
|
// BackgroundColor = CSS_Color.MainBackgroundColor,
|
// };
|
// bodyView.AddChidren(allRoomView);
|
|
// Button btnAllRoomText = new Button()
|
// {
|
// X = Application.GetRealWidth(16),
|
// Width = Application.GetRealWidth(280),
|
// TextID = StringId.SelectedAll,
|
// TextSize = CSS_FontSize.SubheadingFontSize,
|
// TextColor = CSS_Color.FirstLevelTitleColor,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// };
|
// allRoomView.AddChidren(btnAllRoomText);
|
|
// btnChooseAll = new Button()
|
// {
|
// X = Application.GetRealWidth(331),
|
// Gravity = Gravity.CenterVertical,
|
// Width = Application.GetMinRealAverage(28),
|
// Height = Application.GetMinRealAverage(28),
|
// UnSelectedImagePath = "Public/ChooseIcon.png",
|
// SelectedImagePath = "Public/ChooseOnIcon.png",
|
// IsSelected = true,
|
// };
|
// allRoomView.AddChidren(btnChooseAll);
|
|
// allRoomView.AddChidren(new Button()
|
// {
|
// Gravity = Gravity.CenterHorizontal,
|
// Y = Application.GetRealHeight(49),
|
// Height = Application.GetMinReal(1),
|
// Width = Application.GetRealWidth(343),
|
// BackgroundColor = CSS_Color.DividingLineColor,
|
// });
|
|
// bodyScrolView = new VerticalScrolViewLayout()
|
// {
|
// Y = allRoomView.Bottom,
|
// Height = Application.GetRealHeight(450),
|
// };
|
// bodyView.AddChidren(bodyScrolView);
|
|
// var btnSave = new ConfirmButton()
|
// {
|
// Y = Application.GetRealHeight(519 + 64),
|
// TextID = StringId.Save
|
// };
|
// bodyView.AddChidren(btnSave);
|
|
// //全选按钮点击事件
|
// LoadEvent_AllSharedDataChange(allRoomView, btnChooseAll);
|
// LoadEvent_Save(btnSave);
|
|
// GetDeviceAndSceneList();
|
// }
|
|
|
// /// <summary>
|
// /// 全选按钮点击事件
|
// /// </summary>
|
// void LoadEvent_AllSharedDataChange(FrameLayout allRoomView, Button btnChooseAll)
|
// {
|
// EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
// {
|
// btnChooseAll.IsSelected = !btnChooseAll.IsSelected;
|
// if(selectInfoList == null)
|
// {
|
// selectInfoList = new List<SpeakerTargetInfo>();
|
// }
|
|
// if (btnChooseAll.IsSelected)
|
// {
|
// foreach (var info in roomFunctionOrSceneList)
|
// {
|
// selectInfoList.Add(info);
|
// }
|
// }
|
// RefreshListView();
|
// };
|
// btnChooseAll.MouseUpEventHandler = eventHandler;
|
// allRoomView.MouseUpEventHandler = eventHandler;
|
|
// }
|
|
// /// <summary>
|
// /// 保存按钮点击事件
|
// /// </summary>
|
// /// <param name="btnSave"></param>
|
// void LoadEvent_Save(Button btnSave)
|
// {
|
// EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
// {
|
// AddDevicesSceneList(targetInfoList);
|
// };
|
|
// btnSave.MouseUpEventHandler = eventHandler;
|
// }
|
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// /// <param name="updateList"></param>
|
// void AddDevicesSceneList(List<SpeakerTargetInfo> updateList)
|
// {
|
// var waitPage = new Loading();
|
// bodyView.AddChidren(waitPage);
|
// waitPage.Start(Language.StringByID(StringId.PleaseWait));
|
|
// System.Threading.Tasks.Task.Run(() =>
|
// {
|
// try
|
// {
|
// var updateSpeakerDeviceListObj = new UpdateSpeakerDeviceListObj()
|
// {
|
// homeId = speakerInfo.homeId,
|
// tokenId = speakerInfo.tokenId,
|
// targetInfos = updateList
|
// };
|
|
// var revertObj = new HttpServerRequest().UpdateSpeakerDeviceList(updateSpeakerDeviceListObj);
|
// if (revertObj.Code == StateCode.SUCCESS)
|
// {
|
// Application.RunOnMainThread(() =>
|
// {
|
// //保存成功、页面关闭
|
// Utlis.ShowTip(Language.StringByID(StringId.SavedSuccessfully));
|
// if (bodyView != null)
|
// {
|
// bodyView.RemoveFromParent();
|
// }
|
// });
|
|
// }
|
// else
|
// {
|
// //提示错误
|
// IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code);
|
// }
|
// }
|
// catch
|
// {
|
|
// }
|
// finally
|
// {
|
// Application.RunOnMainThread(() =>
|
// {
|
// if (waitPage != null)
|
// {
|
// waitPage.RemoveFromParent();
|
// waitPage = null;
|
// }
|
// });
|
// }
|
// });
|
// }
|
|
// /// <summary>
|
// /// 加载房间的设备和场景列表
|
// /// </summary>
|
// void GetDeviceAndSceneList()
|
// {
|
// bodyScrolView.RemoveAll();
|
|
// var waitPage = new Loading();
|
// bodyView.AddChidren(waitPage);
|
// waitPage.Start(Language.StringByID(StringId.PleaseWait));
|
|
// System.Threading.Tasks.Task.Run(() =>
|
// {
|
// try
|
// {
|
// var revertObj = new HttpServerRequest().GetSpeakerDeviceList(0, speakerInfo.tokenId);
|
// if (revertObj.Code == StateCode.SUCCESS)
|
// {
|
// var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpeakerTargetInfo>>(revertObj.Data.ToString());
|
// Application.RunOnMainThread(() => {
|
// if (list != null && list.Count > 0)
|
// {
|
// targetInfoList = list;
|
// }
|
// else
|
// {
|
// targetInfoList = new List<SpeakerTargetInfo>();
|
// }
|
// RefreshListView();
|
// });
|
|
// }
|
// else
|
// {
|
// //提示错误
|
// IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code);
|
// }
|
// }
|
// catch
|
// {
|
|
// }
|
// finally
|
// {
|
// Application.RunOnMainThread(() =>
|
// {
|
// if (waitPage != null)
|
// {
|
// waitPage.RemoveFromParent();
|
// waitPage = null;
|
// }
|
// });
|
// }
|
// });
|
// }
|
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// void RefreshListView()
|
// {
|
// bodyScrolView.RemoveAll();
|
|
// if (roomFunctionOrSceneList == null) return;
|
|
// foreach (var roomData in roomFunctionOrSceneList)
|
// {
|
// AddRowView(roomData);
|
// }
|
|
|
// }
|
|
|
// /// <summary>
|
// ///
|
// /// </summary>
|
// /// <param name="info"></param>
|
// void AddRowView(SpeakerTargetInfo info)
|
// {
|
|
// var roomView = new FrameLayout()
|
// {
|
// Height = Application.GetRealHeight(50),
|
// BackgroundColor = CSS_Color.MainBackgroundColor,
|
// Tag = "row"
|
// };
|
// bodyScrolView.AddChidren(roomView);
|
|
// Button btnRoomText = new Button()
|
// {
|
// X = Application.GetRealWidth(16),
|
// Width = Application.GetRealWidth(280),
|
// TextSize = CSS_FontSize.SubheadingFontSize,
|
// TextColor = CSS_Color.FirstLevelTitleColor,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Text = info.targetName,
|
// };
|
// roomView.AddChidren(btnRoomText);
|
|
// Button btnChoose = new Button()
|
// {
|
// X = Application.GetRealWidth(331),
|
// Gravity = Gravity.CenterVertical,
|
// Width = Application.GetMinRealAverage(28),
|
// Height = Application.GetMinRealAverage(28),
|
// UnSelectedImagePath = "Public/ChooseIcon.png",
|
// SelectedImagePath = "Public/ChooseOnIcon.png",
|
// Tag = "ChooseIcon"
|
// };
|
// roomView.AddChidren(btnChoose);
|
|
// var targetData = selectInfoList.Find((obj) => obj.targetId == info.targetId);
|
// if (targetData != null)
|
// {
|
// btnChoose.IsSelected = true;
|
// //刷新属于当前房间的分享统计
|
// //funs_New.Add(shareData);
|
// }
|
// else
|
// {
|
// if (btnChooseAll.IsSelected)
|
// btnChooseAll.IsSelected = false;
|
// }
|
|
|
// var btnLine = new Button()
|
// {
|
// Gravity = Gravity.CenterHorizontal,
|
// //Y = Application.GetRealHeight(49),
|
// Height = Application.GetRealHeight(1),
|
// Width = Application.GetRealWidth(343),
|
// BackgroundColor = CSS_Color.DividingLineColor,
|
// };
|
// bodyScrolView.AddChidren(btnLine);
|
|
|
// EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
// {
|
// btnChoose.IsSelected = !btnChoose.IsSelected;
|
// var sd = selectInfoList.Find((obj) => obj.targetId == info.targetId);
|
// if (btnChoose.IsSelected)
|
// {
|
// try
|
// {
|
// if (null == sd)
|
// {
|
// selectInfoList.Add(info);
|
// }
|
// btnChooseAll.IsSelected = true;
|
|
// foreach (var f in roomFunctionOrSceneList)
|
// {
|
// if (selectInfoList.Find((obj) => obj.targetId == f.targetId) == null)
|
// {
|
// btnChooseAll.IsSelected = false;
|
// break;
|
// }
|
// }
|
// }
|
// catch (Exception ex)
|
// {
|
// MainPage.Log($"Evhaaa {ex.Message}");
|
// }
|
// }
|
// else
|
// {
|
// if (null != sd)
|
// {
|
// selectInfoList.Remove(sd);
|
// }
|
// btnChooseAll.IsSelected = false;
|
// }
|
// };
|
|
// btnChoose.MouseUpEventHandler = eventHandler;
|
// roomView.MouseUpEventHandler = eventHandler;
|
// btnRoomText.MouseUpEventHandler = eventHandler;
|
|
|
// }
|
|
|
// }
|
|
|
|
//}
|