using System;
|
using System.Collections.Generic;
|
using Shared;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserDeviceListPage : Dialog
|
{
|
Room room;
|
string roomFilePath;
|
List<string> showList = new List<string> ();
|
VerticalScrolViewLayout deviceScrolView;
|
VerticalScrolViewLayout typeLayout;
|
string selectedDeviceType = "All";
|
|
List<string> roomSceneFilePathList = new List<string> ();
|
List<string> roomDeviceFilePathList = new List<string> ();
|
int show = 99;
|
FrameLayout bodyView;
|
public UserDeviceListPage (Room r, List<string> sl, string rfp)
|
{
|
room = r;
|
showList.Clear ();
|
roomFilePath = rfp;
|
roomSceneFilePathList.AddRange (room.SceneFilePathList);
|
roomDeviceFilePathList.AddRange (room.DeviceFilePathList);
|
showList.AddRange (roomSceneFilePathList);
|
showList.AddRange (roomDeviceFilePathList);
|
bodyView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (bodyView);
|
}
|
Action action;
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="action1"></param>
|
/// <param name="saveAction"></param>
|
public void ShowPage (Action action1, Action<List<string>, List<string>> saveAction)
|
{
|
action = action1;
|
#region ---TopView---
|
var topView = new RowLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
bodyView.AddChidren (topView);
|
|
var back = new Button () {
|
Height = Application.GetMinRealAverage (90),
|
Width = Application.GetMinRealAverage (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
Room.InitAllRoom ();
|
action ();
|
this.Close ();
|
};
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetMinReal (90),
|
TextID = R.MyInternationalizationString.AddNewDevice,
|
//Text = MainPage.SoftTitle,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
};
|
topView.AddChidren (NameButton);
|
|
var logo = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (logo);
|
#endregion
|
#region type view
|
var chooseTypeView = new RowLayout () {
|
Y = topView.Bottom,
|
Height = Application.GetRealHeight (110),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
bodyView.AddChidren (chooseTypeView);
|
Button btnEquipmentIcon = new Button () {
|
Width = Application.GetRealHeight (65),
|
Height = Application.GetRealHeight (65),
|
UnSelectedImagePath = "Item/LogicModule.png",
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
};
|
chooseTypeView.AddChidren (btnEquipmentIcon);
|
Button btnDrodIcon = new Button () {
|
X = Application.GetRealWidth (540),
|
Height = Application.GetRealHeight (46),
|
Width = Application.GetRealWidth (47),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
chooseTypeView.AddChidren (btnDrodIcon);
|
Button btnEquipmentType = new Button () {
|
Width = Application.GetRealHeight (460),
|
X = btnEquipmentIcon.Right + Application.GetRealWidth (20),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = Language.StringByID (R.MyInternationalizationString.All),
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.DialogTextColor
|
};
|
chooseTypeView.AddChidren (btnEquipmentType);
|
typeLayout = new VerticalScrolViewLayout () {
|
Y = chooseTypeView.Bottom,
|
Height = Application.GetRealHeight (0),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
EventHandler<MouseEventArgs> chooseTypeMethod = (sender, e) => {
|
if (show == 99) {
|
InitEquipmentTypeView (btnEquipmentType, btnEquipmentIcon, chooseTypeView);
|
show = 0;
|
} else if (show == 0) {
|
typeLayout.Height = Application.GetRealHeight (Application.DesignHeight - 126 - 110);
|
chooseTypeView.BackgroundColor = SkinStyle.Current.MainColor;
|
show = 1;
|
} else if (show == 1) {
|
typeLayout.Height = 0;
|
chooseTypeView.BackgroundColor = SkinStyle.Current.ViewColor;
|
show = 0;
|
}
|
};
|
btnEquipmentType.MouseUpEventHandler += chooseTypeMethod;
|
btnDrodIcon.MouseUpEventHandler += chooseTypeMethod;
|
chooseTypeView.MouseUpEventHandler += chooseTypeMethod;
|
#endregion
|
|
deviceScrolView = new VerticalScrolViewLayout () {
|
Y = chooseTypeView.Bottom,
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 110 - UserMiddle.userMenuItemHeight),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
bodyView.AddChidren (deviceScrolView);
|
|
InitDeviceList ();
|
|
var logoutButtonView = new FrameLayout () {
|
Y = deviceScrolView.Bottom,
|
Height = Application.GetRealHeight (UserMiddle.userMenuItemHeight + 3),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
bodyView.AddChidren (logoutButtonView);
|
|
|
var btnClose = new Button () {
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextID = R.MyInternationalizationString.confirm,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 16,
|
};
|
logoutButtonView.AddChidren (btnClose);
|
btnClose.MouseUpEventHandler += (sender, e) => {
|
saveAction (roomSceneFilePathList, roomDeviceFilePathList);
|
action ();
|
this.Close ();
|
};
|
}
|
|
/// <summary>
|
/// 显示在本地找到的所有设备
|
/// </summary>
|
void InitDeviceList ()
|
{
|
deviceScrolView.RemoveAll ();
|
System.Threading.Tasks.Task.Run (() => {
|
//找出需要显示的设备
|
var localEquipments = CommonUtlis.Current.GetAllLocalEquipments ();
|
|
var globalSceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
|
if (globalSceneFileList == null) {
|
globalSceneFileList = new List<string> ();
|
}
|
List<string> RoomsSceneFileList = new List<string> ();
|
//2020-07-24 增加房间场景
|
foreach (var r in Room.Lists) {
|
if (string.IsNullOrEmpty (r.Name)) {
|
continue;
|
}
|
if (r != null) {
|
RoomsSceneFileList.AddRange (r.SceneFilePathList);
|
}
|
}
|
List<string> TargetList = new List<string> ();
|
|
if (selectedDeviceType == "Scene") {
|
if (roomFilePath == Room.FavoriteRoom) {
|
TargetList.AddRange (globalSceneFileList);
|
TargetList.AddRange (RoomsSceneFileList);
|
} else {
|
Application.RunOnMainThread (() => {
|
new ScenePhoneMethod ().AddOrUpdataSceneBaseMassage (roomFilePath,null,null,action);
|
this.Close ();
|
});
|
}
|
} else {
|
TargetList.AddRange (localEquipments);
|
}
|
for (int i = 0; i < TargetList.Count;) {
|
var taget = TargetList [i];
|
var tacount = TargetList.FindAll ((obj) => obj == taget).Count;
|
if (tacount == 1) {
|
i++;
|
}
|
while (tacount > 1) {
|
TargetList.Remove (taget);
|
tacount--;
|
}
|
}
|
if (!string.IsNullOrEmpty(room.Name)) {
|
foreach (var r in Room.Lists) {
|
if (!string.IsNullOrEmpty (r.Name)) {
|
if (r != null) {
|
RoomsSceneFileList.AddRange (r.SceneFilePathList);
|
}
|
if (r.Name != room.Name) {
|
for (int i = 0; i < TargetList.Count;) {
|
var tl = TargetList [i];
|
if (r.DeviceFilePathList.Contains (tl)) {
|
TargetList.Remove (tl);
|
} else {
|
i++;
|
}
|
}
|
}
|
}
|
}
|
}
|
foreach (string deviceFilePath in TargetList) {
|
try {
|
string [] str = deviceFilePath.Split ('_');
|
if (selectedDeviceType != null && selectedDeviceType != "Scene" && selectedDeviceType != "All") {
|
//只显示当前选择的设备类型的设备
|
if (selectedDeviceType == "EC") {
|
if (str [1].Contains (DeviceType.LightSwitch.ToString ())) {
|
var b = IO.FileUtils.ReadFile (deviceFilePath);
|
LightSwitch c = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (b));
|
if (!c.IsSocket) {
|
continue;
|
}
|
} else
|
continue;
|
} else if (selectedDeviceType == "Light") {
|
if (str [1].Contains (DeviceType.LightSwitch.ToString ())) {
|
var b = IO.FileUtils.ReadFile (deviceFilePath);
|
LightSwitch c = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (b));
|
if (c.IsSocket) {
|
continue;
|
}
|
} else if (!str [1].Contains (selectedDeviceType))
|
continue;
|
} else {
|
if (!str [1].Contains (selectedDeviceType)) {
|
continue;
|
}
|
}
|
}
|
var commonBytes = IO.FileUtils.ReadFile (deviceFilePath);
|
if (commonBytes.Length == 0) {
|
Utlis.WriteLine ("length loss");
|
continue;
|
}
|
if (commonBytes.Length == 1) {
|
Utlis.WriteLine ("length loss 1");
|
continue;
|
}
|
if (str [1] == DeviceType.InfraredMode.ToString ()) {
|
InfraredMode c = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (c.InfraredType != InfraredType.TV) {
|
continue;
|
}
|
}
|
Common commonDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (commonBytes));
|
if (commonDevice.Type == DeviceType.OnePortBus || commonDevice.Type == DeviceType.OnePortWirelessFR || commonDevice.Type == DeviceType.OnePortMqttFR || commonDevice.Type == DeviceType.RCU
|
|| commonDevice.Type == DeviceType.A31MusicModel || commonDevice.Type == DeviceType.MusicA31) {
|
continue;
|
}
|
Application.RunOnMainThread (() => {
|
var deviceRow = new FrameLayout () {
|
Height = Application.GetRealHeight (120),
|
};
|
deviceScrolView.AddChidren (deviceRow);
|
|
var btnPoint = new Button () {
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
X = Application.GetRealWidth (50),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = SkinStyle.Current.TextColor1,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
deviceRow.AddChidren (btnPoint);
|
|
string deviceName = commonDevice.Name;
|
foreach (var r in Room.Lists) {
|
if (!string.IsNullOrEmpty (r.Name)) {
|
if (r.DeviceFilePathList.Contains (deviceFilePath)) {
|
deviceName = r.Name + " - " + commonDevice.Name;
|
}
|
}
|
}
|
|
Button btnEquipment = new Button () {
|
X = btnPoint.Right + Application.GetRealWidth (30),
|
Width = Application.GetRealWidth (310),
|
TextAlignment = TextAlignment.CenterLeft,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
SelectedTextColor = SkinStyle.Current.DialogTextColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = deviceName,
|
Tag = deviceFilePath,
|
IsMoreLines = true
|
};
|
deviceRow.AddChidren (btnEquipment);
|
|
if (commonDevice.Type.ToString ().Contains ("Light") || commonDevice.Type.ToString ().Contains ("Fan") || commonDevice.Type.ToString ().Contains ("Curtain")) {
|
var btnPositon = new Button () {
|
X = btnEquipment.Right,
|
Width = Application.GetMinRealAverage (75),
|
Height = Application.GetMinRealAverage (72),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "CrabtreeAdd/Position.png",
|
SelectedImagePath = "CrabtreeAdd/PositionOn.png",
|
};
|
deviceRow.AddChidren (btnPositon);
|
|
btnPositon.MouseUpEventHandler += (sdd, dds) => {
|
btnPositon.IsSelected = true;
|
Control.ControlBytesSend (Command.PositioningEquipment, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { 5 });
|
System.Threading.Tasks.Task.Run (() => {
|
System.Threading.Thread.Sleep (3000);
|
Application.RunOnMainThread (() => {
|
btnPositon.IsSelected = false;
|
});
|
});
|
};
|
}
|
|
var btnEdit = new Button () {
|
X = btnEquipment.Right + Application.GetRealWidth (80),
|
Width = Application.GetMinRealAverage (75),
|
Height = Application.GetMinRealAverage (72),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "CrabtreeAdd/Edit.png",
|
SelectedImagePath = "CrabtreeAdd/EditOn.png",
|
};
|
deviceRow.AddChidren (btnEdit);
|
btnEdit.MouseUpEventHandler += (sd, ds) => {
|
Dialog dialog = new Dialog ();
|
//修改设备备注
|
var dialogView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (300),
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
};
|
dialog.AddChidren (dialogView);
|
|
var etDeviceName = new EditText () {
|
Y = Application.GetRealHeight (80),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (350),
|
Height = Application.GetRealHeight (70),
|
//Text = commonDevice.Name,
|
Text = commonDevice.Name.TrimEnd (),
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor,
|
Radius = 1,
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
};
|
dialogView.AddChidren (etDeviceName);
|
etDeviceName.TextChangeEventHandler += (sender, e) => {
|
byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (etDeviceName.Text.Trim ());
|
|
if (remakeBytes.Length > 20) {
|
etDeviceName.Text = CommonPage.MyEncodingGB2312.GetString (remakeBytes, 0, 20);
|
new Alert ("", ErrorCode.RemarkLengthExceededTheLimit, "Close").Show ();
|
}
|
};
|
|
var dialogBottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (213),
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.Black50Transparent,
|
};
|
dialogView.AddChidren (dialogBottomView);
|
|
var btnClose = new Button () {
|
Width = Application.GetRealWidth (250),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.cancel,
|
TextColor = SkinStyle.Current.TextColor,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
};
|
dialogBottomView.AddChidren (btnClose);
|
btnClose.MouseUpEventHandler += (ddss, dddsss) => {
|
dialog.Close ();
|
};
|
|
var editor = new Button () {
|
X = btnClose.Right + 1,
|
Width = Application.GetRealWidth (250),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.SAVE,
|
TextColor = SkinStyle.Current.TextColor,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
};
|
dialogBottomView.AddChidren (editor);
|
|
editor.MouseUpEventHandler += (dff, ffd) => {
|
string remakeStr = etDeviceName.Text.Trim ();
|
if (string.IsNullOrEmpty (remakeStr)) {
|
//备注不能为空
|
new Alert ("", ErrorCode.RemarksCannotBeEmpty, "Close").Show ();
|
return;
|
}
|
|
byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (remakeStr);
|
if (remakeBytes.Length > 20) {
|
new Alert ("", ErrorCode.RemarkLengthExceededTheLimit, "Close").Show ();
|
return;
|
}
|
|
//修改云端备注
|
var cloudDataLoop = CommonConfig.Current.FunctionList.Find ((obj) => obj.bus.SubnetID == commonDevice.SubnetID
|
&& obj.bus.DeviceID == commonDevice.DeviceID && obj.bus.LoopId == commonDevice.LoopID);
|
if (cloudDataLoop == null) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), "Data is not synchronized to the cloud.", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
} else {
|
new System.Threading.Thread (() => {
|
var http = new HttpServerRequest ();
|
var pack = http.EditDeviceName (cloudDataLoop.deviceId, UserConfig.Instance.CurrentRegion.Id, remakeStr);
|
if (pack.Code != "0") {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), $"Cloud data modification failed({pack.Code}).", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
}
|
}) { IsBackground = true }.Start ();
|
}
|
|
MainPage.Loading.Start ();
|
//byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (etDeviceName.Text.Trim ());
|
System.Threading.Tasks.Task.Run (() => {
|
byte [] updateBytes = null;
|
if (commonDevice.Type == DeviceType.LightSwitchSocket) {
|
updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, 1, commonDevice.LoopID });
|
} else {
|
updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, commonDevice.MinClass, commonDevice.LoopID });
|
}
|
if (updateBytes == null) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
return;
|
}
|
byte [] uBytes = new byte [20];
|
Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20);
|
Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length);
|
byte [] reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, updateBytes);
|
if (reBytes != null) {
|
Application.RunOnMainThread (() => {
|
btnEquipment.Text = commonDevice.Name = etDeviceName.Text.Trim ();
|
if (commonDevice.Type == DeviceType.InfraredMode) {
|
//2020-07-03 修复红外电视修改后变红外模块问题
|
InfraredMode mTV = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (System.Text.Encoding.UTF8.GetString (commonBytes));
|
if (mTV == null) {
|
IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ());
|
} else {
|
mTV.Name = etDeviceName.Text.Trim ();
|
IO.FileUtils.SaveEquipmentMessage (mTV, mTV.LoopID.ToString ());
|
}
|
} else {
|
IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ());
|
}
|
|
|
|
|
//IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ());
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.FailureToModify), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
}
|
});
|
};
|
dialog.Show ();
|
};
|
|
var btnChoose = new Button () {
|
X = btnEdit.Right + Application.GetRealWidth (10),
|
Width = Application.GetMinRealAverage (75),
|
Height = Application.GetMinRealAverage (72),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "CrabtreeAdd/Choose.png",
|
SelectedImagePath = "CrabtreeAdd/ChooseOn.png",
|
IsSelected = showList.Contains (deviceFilePath),
|
Tag = deviceFilePath
|
};
|
deviceRow.AddChidren (btnChoose);
|
|
btnChoose.MouseUpEventHandler += (sendere, ee) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
if (selectedDeviceType == "Scene") {
|
roomSceneFilePathList.Add (((Button)sendere).Tag.ToString ());
|
} else {
|
roomDeviceFilePathList.Add (((Button)sendere).Tag.ToString ());
|
}
|
showList.Add (((Button)sendere).Tag.ToString ());
|
} else {
|
if (selectedDeviceType == "Scene") {
|
roomSceneFilePathList.Remove (((Button)sendere).Tag.ToString ());
|
} else {
|
roomDeviceFilePathList.Remove (((Button)sendere).Tag.ToString ());
|
}
|
showList.Remove (((Button)sendere).Tag.ToString ());
|
}
|
};
|
|
var btnRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
deviceScrolView.AddChidren (btnRowLine);
|
});
|
} catch (Exception ex) {
|
Utlis.WriteLine (ex.Message);
|
}
|
}
|
});
|
}
|
|
void InitEquipmentTypeView (Button btnEquipmentType, Button btnEquipmentIcon, RowLayout chooseTypeView)
|
{
|
bodyView.AddChidren (typeLayout);
|
|
//下拉列表的数据源(选项为设备类型有关)
|
List<string> typeTemp = new List<string>{
|
Language.StringByID(R.MyInternationalizationString.All),
|
Language.StringByID(R.MyInternationalizationString.Scenes),
|
Language.StringByID(R.MyInternationalizationString.Lights),
|
Language.StringByID(R.MyInternationalizationString.AC),
|
Language.StringByID(R.MyInternationalizationString.Curtains),
|
Language.StringByID(R.MyInternationalizationString.FoolHeat),
|
Language.StringByID(R.MyInternationalizationString.TV),
|
Language.StringByID(R.MyInternationalizationString.Fan),
|
Language.StringByID(R.MyInternationalizationString.ElectricalControl),
|
Language.StringByID (R.MyInternationalizationString.UniversalDevice),
|
Language.StringByID (R.MyInternationalizationString.LogicModule),
|
};
|
|
foreach (string typeName in typeTemp) {
|
var dialogRow = new FrameLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
typeLayout.AddChidren (dialogRow);
|
var btnPoint = new Button () {
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage (10),
|
Radius = (uint)Application.GetMinRealAverage (5),
|
X = Application.GetRealWidth (70),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = SkinStyle.Current.TextColor1,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
};
|
dialogRow.AddChidren (btnPoint);
|
|
Button btnTypeName = new Button () {
|
Width = Application.GetRealHeight (400),
|
X = btnPoint.Right + Application.GetRealWidth (30),
|
Text = typeName,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
dialogRow.AddChidren (btnTypeName);
|
EventHandler<MouseEventArgs> typeEvent = (sender1, e1) => {
|
typeLayout.Height = 0;
|
btnEquipmentType.Text = typeName;
|
if (typeName == Language.StringByID (R.MyInternationalizationString.Lights)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/Light.png";
|
selectedDeviceType = "Light";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Curtains)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
selectedDeviceType = "Curtain";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.AC)) {
|
btnEquipmentIcon.UnSelectedImagePath = "AC/AC.png";
|
selectedDeviceType = "AC";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.FoolHeat)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/FloorHeating.png";
|
selectedDeviceType = "FoolHeat";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.DryContactPanel)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/DryContact.png";
|
selectedDeviceType = "DryContact";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.MusicModel)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/Music.png";
|
selectedDeviceType = "Music";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.InfraredMode)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
selectedDeviceType = "InfraredMode";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.TV)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
selectedDeviceType = "InfraredMode";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.ElectricalControl)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Light/Socket.png";
|
selectedDeviceType = "EC";//电器控制
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Fan)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Fan/Fan.png";
|
selectedDeviceType = "Fan";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.LogicModule)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/LogicModule.png";
|
selectedDeviceType = "LogicModule";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Scenes)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Scene/Scene.png";
|
selectedDeviceType = "Scene";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.UniversalDevice)) {
|
btnEquipmentIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
selectedDeviceType = "UniversalDevice";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Sensor)) {
|
btnEquipmentIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
selectedDeviceType = "Sensor";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.FreshAir)) {
|
btnEquipmentIcon.UnSelectedImagePath = "FreshAir/FreshAir.png";
|
selectedDeviceType = "FreshAir";
|
} else {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/LogicModule.png";
|
selectedDeviceType = "All";
|
}
|
chooseTypeView.BackgroundColor = SkinStyle.Current.ViewColor;
|
InitDeviceList ();
|
};
|
dialogRow.MouseUpEventHandler += typeEvent;
|
btnTypeName.MouseUpEventHandler += typeEvent;
|
|
var btnRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
typeLayout.AddChidren (btnRowLine);
|
}
|
}
|
}
|
}
|