using System;
|
using System.Collections.Generic;
|
using EZMonitor;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class MonitorAddSceneList : FrameLayout
|
{
|
public MonitorAddSceneList ()
|
{
|
BackgroundColor = SkinStyle.Current.MainColor;
|
}
|
|
public string SceneType;//场景类型
|
|
public void showVideoMonitoring (Com.Hdl.ON.MonitorData data)
|
{
|
#region 标题
|
var topView = new FrameLayout () {
|
Height = Application.GetRealHeight (136),
|
};
|
AddChidren (topView);
|
|
var title = new Button () {
|
TextAlignment = TextAlignment.Center,
|
Text = Language.StringByID (R.MyInternationalizationString.EZVIZ),
|
TextSize = 19,
|
TextColor = SkinStyle.Current.TextColor1,
|
Y = Application.GetRealHeight (10),
|
};
|
topView.AddChidren (title);
|
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
Y = Application.GetRealHeight (30),
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
CommonList.Save ();
|
CommonList.CameraList ();
|
this.RemoveFromParent ();
|
};
|
#endregion
|
|
#region middleVerticalScrolViewLayout
|
var middleVerticalScrolViewLayout = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 98),
|
Y = topView.Bottom,
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
AddChidren (middleVerticalScrolViewLayout);
|
|
#region test
|
//全部类型的场景列表
|
var allSceneFilePaths = new List<string> ();
|
//全局场景中所有的场景
|
var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
|
allSceneFilePaths.AddRange (sceneFileList);
|
|
//房间的所有场景
|
foreach (var room in Room.Lists) {
|
if (room.Name == "") {
|
continue;
|
}
|
allSceneFilePaths.AddRange (room.SceneFilePathList);
|
}
|
|
foreach (var sceneFilePathsType in allSceneFilePaths) {
|
var scene = Scene.GetSceneByFilePath (sceneFilePathsType);
|
if (scene == null) {
|
continue;
|
}
|
var frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (93),
|
};
|
middleVerticalScrolViewLayout.AddChidren (frameLayout);
|
|
var btnRemarkName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = scene.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
};
|
frameLayout.AddChidren (btnRemarkName);
|
|
var Check = new Button () {
|
X = Application.GetRealWidth (540),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (80),
|
UnSelectedImagePath = "Item/Check.png",
|
SelectedImagePath = "Item/CheckSelected.png",
|
Tag = sceneFilePathsType
|
};
|
frameLayout.AddChidren (Check);
|
if (CommonList.MonitorScenePathList.Count > 0) {
|
for (int i = 0; i < CommonList.MonitorScenePathList.Count; i++) {
|
var monitorData = CommonList.MonitorScenePathList [i];
|
if (monitorData.FileName == sceneFilePathsType && monitorData.Id == data.Id) {
|
Check.IsSelected = true;
|
break;
|
} else {
|
Check.IsSelected = false;
|
}
|
}
|
}
|
EventHandler<MouseEventArgs> hander = (sender, e) => {
|
int tempIndex = -1;
|
for (int i = 0; i < CommonList.MonitorScenePathList.Count; i++) {
|
var monitorData = CommonList.MonitorScenePathList [i];
|
if (monitorData.FileName == sceneFilePathsType && monitorData.Id == data.Id) {
|
Check.IsSelected = true;
|
tempIndex = i;
|
break;
|
}
|
}
|
if (Check.IsSelected) {
|
if (tempIndex != -1) {
|
CommonList.MonitorScenePathList.RemoveAt (tempIndex);
|
}
|
Check.IsSelected = false;
|
} else {
|
if (tempIndex == -1) {
|
if (sceneFilePathsType.Contains ("RoomLightScene")) {
|
SceneType = "房间灯光场景";
|
} else if (sceneFilePathsType.Contains ("GlobalScene")) {
|
SceneType = "全局场景";
|
} else {
|
SceneType = "房间场景";
|
}
|
CommonList.MonitorScenePathList.Add (new Com.Hdl.ON.MonitorData { Remark = scene.Name, ControlType = SceneType, FileName = sceneFilePathsType, Type = data.Type, Id = data.Id });
|
}
|
Check.IsSelected = true;
|
}
|
};
|
frameLayout.MouseDownEventHandler += hander;
|
btnRemarkName.MouseUpEventHandler += hander;
|
Check.MouseUpEventHandler += hander;
|
}
|
#endregion
|
#endregion
|
|
#region bottomFrameLayout
|
var bottomFrameLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (98),
|
Y = Application.GetRealHeight (Application.DesignHeight - 98),
|
};
|
AddChidren (bottomFrameLayout);
|
|
var btnSave = new Button () {
|
Height = Application.GetRealHeight (97),
|
TextID = R.MyInternationalizationString.SAVE,
|
TextSize = 15,
|
BackgroundColor = SkinStyle.Current.TitileView,
|
};
|
bottomFrameLayout.AddChidren (btnSave);
|
btnSave.MouseUpEventHandler += (sender, e) => {
|
CommonList.Save ();
|
CommonList.CameraList ();
|
this.RemoveFromParent ();
|
};
|
#endregion
|
}
|
}
|
}
|