using System;
|
using System.Collections.Generic;
|
using Shared.SimpleControl.Phone.Music;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public static class UserDeviceView
|
{
|
public static int LightingCount = 0;
|
public static int CurtainCount = 0;
|
public static int SwitchSocketBrightingCount = 0;
|
public static List<string> allLocationFiles = IO.FileUtils.ReadFiles (false);
|
public static void DeviceMode ()
|
{
|
allLocationFiles = IO.FileUtils.ReadFiles ();
|
|
FrameLayout topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
UserMiddle.DeviceBodyView.AddChidren (topView);
|
|
Button LogoButton = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (LogoButton);
|
|
LogoButton.MouseUpEventHandler += (sender, s) => {
|
|
};
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetMinReal (90),
|
TextID = R.MyInternationalizationString.Category,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
//FontName = "TitilliumText25L"
|
};
|
topView.AddChidren (NameButton);
|
|
|
UserMiddle.DeviceView.RemoveAll ();
|
Button btnRowLine = new Button () {
|
Height = Application.GetRealHeight (5),
|
BackgroundColor = SkinStyle.Current.UserMenuItemButton
|
};
|
UserMiddle.DeviceView.AddChidren (btnRowLine);
|
|
FrameLayout rowLayout = null;
|
int index = 0;
|
//for (int i = 0; i < UserConfig.Instance.DeviceTypes.Count - UserConfig.Instance.HideDeviceTypes.Count-1; i++) {
|
foreach(var deviceType in UserConfig.Instance.DeviceTypes) {
|
if (UserConfig.Instance.HideDeviceTypes.Contains (deviceType)) {
|
continue;
|
}
|
//2020-03-16 白色皮肤时不显示 毅面板、美林系统按钮
|
if (UserConfig.Instance.SkinCode == 1 && (deviceType == R.MyInternationalizationString.granite || deviceType == R.MyInternationalizationString.ACMerrill)) {
|
continue;
|
}
|
|
//var hostSavePaths = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 4 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.Thermostat.ToString ());
|
|
//if (deviceType == (int)DeviceType.Thermostat && hostSavePaths.Count < 1) {
|
// continue;
|
//}
|
|
if (deviceType == R.MyInternationalizationString.Thermostat) {
|
var hostSavePaths = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 4 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.Thermostat.ToString ());
|
if (hostSavePaths.Count < 1) {
|
continue;
|
}
|
|
}else if (deviceType == R.MyInternationalizationString.ACMerrill) {
|
var hostSavePaths = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.ACMerrill.ToString ());
|
if (hostSavePaths.Count < 1) {
|
continue;
|
}
|
|
}
|
|
|
|
|
if (index % 2 == 0) {
|
rowLayout = new FrameLayout () {
|
Height = Application.GetRealWidth (232),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.UserMenuItemButton
|
};
|
UserMiddle.DeviceView.AddChidren (rowLayout);
|
}
|
FrameLayout equipmentLayout = new FrameLayout () {
|
Width = Application.GetRealWidth (318),
|
Height = Application.GetRealWidth (227),
|
};
|
equipmentLayout.AddTag ("DeviceType", deviceType);
|
rowLayout.AddChidren (equipmentLayout);
|
if (index % 2 == 1) {
|
equipmentLayout.Width = Application.GetRealWidth (318);
|
equipmentLayout.X = Application.GetRealWidth (323);
|
}
|
|
Button btnEquipmentIcon = new Button () {
|
Width = Application.GetMinRealAverage (128),
|
Height = Application.GetMinRealAverage (136),
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (20),
|
};
|
equipmentLayout.AddChidren (btnEquipmentIcon);
|
|
Button btnEquipmentName = new Button () {
|
Width = Application.GetRealWidth (232),
|
Height = Application.GetRealHeight (45),
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnEquipmentIcon.Bottom,
|
Text = Language.StringByID(deviceType),
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
equipmentLayout.AddChidren (btnEquipmentName);
|
|
Button btnOpenNumber = new Button () {
|
Width = Application.GetRealWidth (55),
|
Height = Application.GetRealHeight (35),
|
X = Application.GetRealWidth (248),
|
Y = Application.GetRealHeight (30),
|
UnSelectedImagePath = "Item/LightingCount.png",
|
SelectedImagePath = "Item/LightingCountSelected.png",
|
Enable = false,
|
Text = "0",
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
btnOpenNumber.AddTag ("DeviceType", deviceType);
|
|
equipmentLayout.AddChidren (btnOpenNumber);
|
|
|
|
|
setEquipmentsBackGroud (Language.StringByID (deviceType), btnEquipmentIcon, equipmentLayout, btnOpenNumber, equipmentLayout);
|
++index;
|
|
//if (UserConfig.Instance.ShowFunctionBackground) {
|
// equipmentLayout.BackgroundImagePath = "Logo/1.png";
|
//}
|
}
|
//int clickCount = 0;
|
//NameButton.MouseUpEventHandler += (sender, e) => {
|
// if (clickCount == 8) {
|
// UserConfig.Instance.ShowFunctionBackground = !UserConfig.Instance.ShowFunctionBackground;
|
// UserConfig.Instance.SaveUserConfig ();
|
// clickCount = 0;
|
// }
|
//};
|
System.Threading.Tasks.Task.Run (() => {
|
UserDeviceToCurtains.readAllStatus ();
|
UserDeviceToLight.readAllStatus ();
|
UserDeviceToSocket.readAllStatus ();
|
UserDeviceToAC.readAllStatus ();
|
UserDeviceToFH.readAllStatus ();
|
UserFresAirList.readAllStatus ();
|
});
|
}
|
|
public static void UpdataDeviceCountNumber (int count, int tagFalg)
|
{
|
try {
|
Application.RunOnMainThread (() => {
|
for (int i = 0; i < UserMiddle.DeviceView.ChildrenCount; i++) {
|
if (UserMiddle.DeviceView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
FrameLayout rowView = (FrameLayout)UserMiddle.DeviceView.GetChildren (i);
|
for (int j = 0; j < rowView.ChildrenCount; j++) {
|
if (rowView.GetChildren (j).GetType () == typeof (FrameLayout)) {
|
FrameLayout frameView = (FrameLayout)rowView.GetChildren (j);
|
if (frameView.GetTagByKey ("DeviceType").ToString () == tagFalg.ToString()) {
|
for (int k = 0; k < frameView.ChildrenCount; k++) {
|
if (frameView.GetChildren (k).GetType () == typeof (Button)) {
|
Button btn = (Button)frameView.GetChildren (k);
|
if (btn.GetTagByKey ("DeviceType") != null && btn.GetTagByKey ("DeviceType").ToString () == tagFalg.ToString()) {
|
if (count > 0) {
|
btn.Text = count.ToString ();
|
btn.IsSelected = true;
|
switch (tagFalg) {
|
case 43:
|
CurtainCount = count;
|
break;
|
case 3:
|
LightingCount = count;
|
break;
|
case 265:
|
SwitchSocketBrightingCount = count;
|
break;
|
}
|
} else if ( count == 0) {
|
//Application.RunOnMainThread (() => {
|
try {
|
int eCount = 0;
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
if (tagFalg == R.MyInternationalizationString.Lights) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.LightDimming || obj.Type == DeviceType.LightSwitch || obj.Type == DeviceType.LightRGB ||
|
obj.Type == DeviceType.LightMixSwitch || obj.Type == DeviceType.LightMixDimming || obj.Type == DeviceType.LightDALI;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.ElectricalControl) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.LightSwitchSocket || obj.Type == DeviceType.LightEnergySwitch;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.AC) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.ElectricalControl) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.LightSwitchSocket;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.Fan) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.FanModule;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.FreshAir) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.FreshAir;
|
});
|
eCount += devices.Count;
|
} else if (tagFalg == R.MyInternationalizationString.Curtain) {
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.CurtainModel || obj.Type == DeviceType.CurtainRoller || obj.Type == DeviceType.CurtainTrietex;
|
});
|
eCount += devices.Count;
|
}
|
}
|
btn.Text = eCount.ToString ();
|
btn.IsSelected = false;
|
} catch {
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
} catch {
|
}
|
}
|
|
static void DelUserEquipmentView (int deviceCount, int deviceType)
|
{
|
if (deviceCount == 0) {
|
Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
|
Language.StringByID (R.MyInternationalizationString.DeleteDeviceCategories),
|
Language.StringByID (R.MyInternationalizationString.Cancel),
|
Language.StringByID (R.MyInternationalizationString.Confrim));
|
alert.Show ();
|
alert.ResultEventHandler += (sender2, e2) => {
|
if (e2) {
|
UserConfig.Instance.HideDeviceTypes.Add (deviceType);
|
UserConfig.Instance.SaveUserConfig ();
|
DeviceMode ();
|
}
|
};
|
}
|
}
|
|
/// <summary>
|
/// 设备到房间模式显示用户主界面的
|
/// </summary>
|
static void setEquipmentsBackGroud (string equipmentType, Button btnEquipment, FrameLayout fl, Button btnOpenNumber, FrameLayout equipmentLayout)
|
{
|
if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Lights)) {
|
btnEquipment.UnSelectedImagePath = "Item/Light.png";
|
btnEquipment.SelectedImagePath = "Item/LightSelected.png";
|
int eCount = 0;
|
int brighingCount = 0;
|
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.LightDimming || obj.Type == DeviceType.LightSwitch || obj.Type == DeviceType.LightRGB ||
|
obj.Type == DeviceType.LightMixSwitch || obj.Type == DeviceType.LightMixDimming || obj.Type == DeviceType.LightDALI;
|
});
|
eCount += devices.Count;
|
|
foreach (var updataCommon in room.DeviceList) {
|
if (updataCommon.Type == DeviceType.LightDimming || updataCommon.Type == DeviceType.LightMixDimming || updataCommon.Type == DeviceType.LightDALI) {
|
if ((updataCommon as LightDimming).CurrentBrightness > 0)
|
brighingCount++;
|
} else if (updataCommon.Type == DeviceType.LightSwitch || updataCommon.Type == DeviceType.LightMixSwitch) {
|
if ((updataCommon as LightSwitch).CurrentBrightness == 100) {
|
brighingCount++;
|
}
|
}else if (updataCommon.Type == DeviceType.LightRGB) {
|
if ((updataCommon as LightLogic).CurrentBrightness > 0) {
|
brighingCount++;
|
}
|
}
|
}
|
}
|
Application.RunOnMainThread (() => {
|
if (brighingCount > 0) {
|
eCount = brighingCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var lightView = new UserDeviceToLight ();
|
UserMiddle.DevicePageView.AddChidren (lightView);
|
lightView.showAllRoomLights ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
UserMiddle.DevicePageView.ScrollEnabled = false;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var lightView = new UserDeviceToLight ();
|
UserMiddle.DevicePageView.AddChidren (lightView);
|
lightView.showAllRoomLights ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
UserMiddle.DevicePageView.ScrollEnabled = false;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Lights);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Lights);
|
};
|
equipmentLayout.BackgroundImagePath = "Item/LightBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.AC)) {
|
btnEquipment.UnSelectedImagePath = "AC/AC.png";
|
btnEquipment.SelectedImagePath = "AC/ACSelected.png";
|
int eCount = 0;
|
int acOponeCount = 0;
|
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel || obj.Type == DeviceType.LongXiAC;
|
});
|
eCount += devices.Count;
|
foreach (var acTemp in room.DeviceList) {
|
if (acTemp.Type == DeviceType.HVAC || acTemp.Type == DeviceType.ACInfrared || acTemp.Type == DeviceType.ACPanel)
|
if ((acTemp as AC).Power == 1) {
|
acOponeCount++;
|
}
|
}
|
}
|
Application.RunOnMainThread (() => {
|
if (acOponeCount > 0) {
|
eCount = acOponeCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var acView = new UserDeviceToAC ();
|
UserMiddle.DevicePageView.AddChidren (acView);
|
acView.showAllRoomAC ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var acView = new UserDeviceToAC ();
|
UserMiddle.DevicePageView.AddChidren (acView);
|
acView.showAllRoomAC ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.AC);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.AC);
|
};
|
equipmentLayout.BackgroundImagePath = "AC/ACBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.TV)) {
|
btnEquipment.UnSelectedImagePath = "Item/TV.png";
|
btnEquipment.SelectedImagePath = "Item/TVSelected.png";
|
int eCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.InfraredMode;
|
});
|
eCount += devices.Count;
|
}
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToTV tvView = new UserDeviceToTV ();
|
UserMiddle.DevicePageView.AddChidren (tvView);
|
tvView.ShowAllRoomTV ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToTV tvView = new UserDeviceToTV ();
|
UserMiddle.DevicePageView.AddChidren (tvView);
|
tvView.ShowAllRoomTV ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.TV);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.TV);
|
};
|
equipmentLayout.BackgroundImagePath = "Item/TVBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.UniversalDevice)) {
|
btnEquipment.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
btnEquipment.SelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
int eCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.UniversalDevice;
|
});
|
eCount += devices.Count;
|
}
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToUniversalDevice tvView = new UserDeviceToUniversalDevice ();
|
UserMiddle.DevicePageView.AddChidren (tvView);
|
tvView.ShowUniversalDevice ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToUniversalDevice tvView = new UserDeviceToUniversalDevice ();
|
UserMiddle.DevicePageView.AddChidren (tvView);
|
tvView.ShowUniversalDevice ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.UniversalDevice);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.UniversalDevice);
|
};
|
equipmentLayout.BackgroundImagePath = "UniversalDevice/UniversalDeviceBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Curtain)) {
|
btnEquipment.UnSelectedImagePath = "Curtain/Curtain.png";
|
//btnEquipment.SelectedImagePath = "Item/CurtainSelected.png";
|
int eCount = 0;
|
if (CurtainCount > 0) {
|
btnOpenNumber.Text = CurtainCount.ToString ();
|
btnOpenNumber.IsSelected = true;
|
} else {
|
new System.Threading.Thread (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.CurtainModel || obj.Type == DeviceType.CurtainRoller || obj.Type == DeviceType.CurtainTrietex;
|
});
|
eCount += devices.Count;
|
}
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
}) { IsBackground = true}.Start();
|
}
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var curtainView = new UserDeviceToCurtains ();
|
UserMiddle.DevicePageView.AddChidren (curtainView);
|
curtainView.showAllRoomCurtain ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var curtainView = new UserDeviceToCurtains ();
|
UserMiddle.DevicePageView.AddChidren (curtainView);
|
curtainView.showAllRoomCurtain ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Curtain);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Curtain);
|
};
|
equipmentLayout.BackgroundImagePath = "Curtain/CurtainBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Scenes)) {
|
btnEquipment.UnSelectedImagePath = "Scene/Scene.png";
|
int eCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
if (room != null) {
|
foreach (var sceneFilePath in room.SceneFilePathList) {
|
var scene = Scene.GetSceneByFilePath (sceneFilePath);
|
if (scene != null)
|
eCount += scene.LoopCount;
|
}
|
}
|
}
|
var globalSceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
|
if (globalSceneList != null) {
|
foreach (var sceneFilePath in globalSceneList) {
|
var scene = Scene.GetSceneByFilePath (sceneFilePath);
|
if (scene == null)
|
continue;
|
eCount += scene.LoopCount;
|
}
|
}
|
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var userDeviceToSceneView = new UserDeviceToScene ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToSceneView);
|
userDeviceToSceneView.ShowAllScene ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var userDeviceToSceneView = new UserDeviceToScene ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToSceneView);
|
userDeviceToSceneView.ShowAllScene ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
equipmentLayout.BackgroundImagePath = "Item/SceneBackground.png";
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Scenes);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Scenes);
|
};
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Music) || equipmentType == Language.StringByID (R.MyInternationalizationString.Sonos)) {
|
btnEquipment.UnSelectedImagePath = "Item/Music.png";
|
btnEquipment.SelectedImagePath = "Item/MusicSelected.png";
|
int eCount = 0;
|
int brighingCount = 0;
|
if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Music)) {
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.MusicModel;
|
});
|
eCount += devices.Count;
|
brighingCount += devices.FindAll ((obj) => ((MusicModel)obj).PlayStatus == MusicModel.Status.Play).Count;
|
}
|
var a31List = A31MusicModel.A31MusicModelList.FindAll ((obj) => obj.IsCanShow);
|
eCount += a31List.Count;
|
brighingCount += a31List.FindAll ((obj) => obj.A31PlayStatus.status == "play").Count;
|
Application.RunOnMainThread (() => {
|
if (brighingCount > 0) {
|
eCount = brighingCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
//if (eCount > 0) {
|
// btnOpenNumber.Text = "1";
|
//}
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
MyMusic myMusic = new MyMusic ();
|
UserMiddle.DevicePageView.AddChidren (myMusic);
|
myMusic.Show (false);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
MyMusic myMusic = new MyMusic ();
|
UserMiddle.DevicePageView.AddChidren (myMusic);
|
myMusic.Show (false);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Music);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Music);
|
};
|
} else {
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var sonosmusic = new SonosMusicPage ();
|
UserMiddle.DevicePageView.AddChidren (sonosmusic);
|
sonosmusic.Show ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var sonosmusic = new SonosMusicPage ();
|
UserMiddle.DevicePageView.AddChidren (sonosmusic);
|
sonosmusic.Show ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (0, R.MyInternationalizationString.Sonos);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (0, R.MyInternationalizationString.Sonos);
|
};
|
}
|
equipmentLayout.BackgroundImagePath = "Item/MusicBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Security)) {
|
btnEquipment.UnSelectedImagePath = "Item/Security.png";
|
btnEquipment.SelectedImagePath = "Item/SecuritySelected.png";
|
equipmentLayout.BackgroundImagePath = "Item/SecurityBackground.png";
|
int eCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
eCount = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.SecurityModule.ToString ()).Count;
|
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToSecurity securityView = new UserDeviceToSecurity ();
|
UserMiddle.DevicePageView.AddChidren (securityView);
|
securityView.ShowSecurityView ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Security);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Security);
|
};
|
} else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.SuperWireless)) {
|
btnEquipment.UnSelectedImagePath = "Item/Security.png";
|
btnEquipment.SelectedImagePath = "Item/SecuritySelected.png";
|
equipmentLayout.BackgroundImagePath = "Item/SecurityBackground.png";
|
int eCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
eCount = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.SuperWireless.ToString ()).Count;
|
Application.RunOnMainThread (() => {
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var gateWay = SuperGateWay.GateWay.gateWay ();
|
SuperGateWay.GateWay.Instance = gateWay;
|
var superGateway = new SuperGateWay.ScenePage ();
|
MainPage.MainFrameLayout.AddChidren (superGateway);
|
superGateway.Show (gateWay);
|
SuperGateWay.ScenePage.SubnetID = gateWay.SubnetID;
|
SuperGateWay.ScenePage.DeviceID = gateWay.DeviceID;
|
|
};
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.SuperWireless);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.SuperWireless);
|
};
|
} else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Monitor)) {
|
btnEquipment.UnSelectedImagePath = "Item/Monitor.png";
|
btnEquipment.SelectedImagePath = "Item/MonitorSelected.png";
|
equipmentLayout.BackgroundImagePath = "Item/SecurityBackground.png";
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
MonitorType monitorView = new MonitorType ();
|
UserMiddle.DevicePageView.AddChidren (monitorView);
|
monitorView.ShowVideoMonitoring ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
MonitorType monitorView = new MonitorType ();
|
UserMiddle.DevicePageView.AddChidren (monitorView);
|
monitorView.ShowVideoMonitoring ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
if (MonitorInfo.FilePathList != null)
|
btnOpenNumber.Text = MonitorInfo.FilePathList.Count.ToString ();
|
else
|
btnOpenNumber.Text = "0";
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (0, R.MyInternationalizationString.Monitor);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (0, R.MyInternationalizationString.Monitor);
|
};
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Projector)) {
|
btnEquipment.UnSelectedImagePath = "Item/Projector.png";
|
btnEquipment.SelectedImagePath = "Item/ProjectorSelected.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.FoolHeat)) {
|
btnEquipment.UnSelectedImagePath = "Item/FloorHeating.png";
|
btnEquipment.SelectedImagePath = "Item/FloorHeatingSelected.png";
|
int eCount = 0;
|
int fhOponeCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.FoolHeat || obj.Type == DeviceType.FoolHeatPanel;
|
});
|
eCount += devices.Count;
|
foreach (var acTemp in room.DeviceList) {
|
if (acTemp.Type == DeviceType.FoolHeat || acTemp.Type == DeviceType.FoolHeatPanel)
|
if ((acTemp as FoolHeat).Status == 1) {
|
fhOponeCount++;
|
}
|
}
|
}
|
Application.RunOnMainThread (() => {
|
if (fhOponeCount > 0) {
|
eCount = fhOponeCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToFH userDeviceToFHView = new UserDeviceToFH ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToFHView);
|
userDeviceToFHView.showAllRoomFH ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToFH userDeviceToFHView = new UserDeviceToFH ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToFHView);
|
userDeviceToFHView.showAllRoomFH ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.FoolHeat);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.FoolHeat);
|
};
|
|
equipmentLayout.BackgroundImagePath = "Item/FloorHeatingBackground.png";
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.ElectricalControl)) {
|
btnEquipment.UnSelectedImagePath = "Light/Socket.png";
|
btnEquipment.SelectedImagePath = "Light/SocketOn.png";
|
equipmentLayout.BackgroundImagePath = "Light/SocketBackground.png";
|
int eCount = 0;
|
int brighingCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.LightEnergySwitch || obj.Type == DeviceType.LightSwitchSocket;
|
});
|
eCount += devices.Count;
|
brighingCount += devices.FindAll ((obj) => { return ((LightSwitch)obj).CurrentBrightness == 100; }).Count;
|
}
|
Application.RunOnMainThread (() => {
|
if (brighingCount > 0) {
|
eCount = brighingCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToSocket userDeviceToSocketView = new UserDeviceToSocket ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToSocketView);
|
userDeviceToSocketView.ShowAllRoomLights ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToSocket userDeviceToSocketView = new UserDeviceToSocket ();
|
UserMiddle.DevicePageView.AddChidren (userDeviceToSocketView);
|
userDeviceToSocketView.ShowAllRoomLights ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.ElectricalControl);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.ElectricalControl);
|
};
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Fan)) {
|
btnEquipment.UnSelectedImagePath = "Fan/Fan.png";
|
btnEquipment.SelectedImagePath = "Fan/FanOn.png";
|
equipmentLayout.BackgroundImagePath = "Fan/FanBackground.png";
|
int eCount = 0;
|
int brighingCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.FanModule;
|
});
|
brighingCount = devices.FindAll ((obj) => { return ((FanModule)obj).WindSpeed > 0; }).Count;
|
eCount += devices.Count;
|
}
|
Application.RunOnMainThread (() => {
|
if (brighingCount > 0) {
|
eCount = brighingCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToFan fanView = new UserDeviceToFan ();
|
UserMiddle.DevicePageView.AddChidren (fanView);
|
fanView.ShowAllRoomCurtain ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToFan fanView = new UserDeviceToFan ();
|
UserMiddle.DevicePageView.AddChidren (fanView);
|
fanView.ShowAllRoomCurtain ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Fan);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Fan);
|
};
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.DoorLock)) {
|
btnEquipment.UnSelectedImagePath = "DoorLockPic/doorLockHomePage.png";
|
btnEquipment.SelectedImagePath = "DoorLockPic/doorLockHomePage.png";
|
equipmentLayout.BackgroundImagePath = "DoorLockPic/door_lock_background.png";
|
List<string> doorLockList = allLocationFiles.FindAll ((obj) => {
|
string [] str = obj.Split ('_');
|
return obj.StartsWith ("Equipment_") && str.Length == 5 && ((str [1] == DeviceType.DoorLock.ToString ()|| str[1]== DeviceType.DoorLockRelay.ToString()));
|
});
|
|
|
EventHandler<MouseEventArgs> OpenDoorLockViewEventHandler = (sender, e) => {
|
|
if(doorLockList.Count == 1)
|
{
|
//2019-12-05 一个继电器门锁的时候直接跳转
|
if (doorLockList[0].Split ('_') [1] == DeviceType.DoorLockRelay.ToString ()) {
|
LightDoorLock mLightDoorLock = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDoorLock> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (doorLockList [0])));
|
DoorLockRelayPage mDoorLockRelayPage = new DoorLockRelayPage (mLightDoorLock);
|
UserMiddle.DevicePageView.AddChidren (mDoorLockRelayPage);
|
mDoorLockRelayPage.showmLightDoorLocksRoom ();
|
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
|
|
} else {
|
UserDeviceToDoorLock doorLockView = new UserDeviceToDoorLock ();
|
UserMiddle.DevicePageView.AddChidren (doorLockView);
|
doorLockView.ShowAllRoomDoorLock (doorLockList);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
}
|
|
} else
|
{
|
UserDeviceToDoorLock doorLockView = new UserDeviceToDoorLock ();
|
UserMiddle.DevicePageView.AddChidren (doorLockView);
|
doorLockView.ShowAllRoomDoorLock (doorLockList);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
}
|
|
|
};
|
|
btnOpenNumber.Text = doorLockList.Count.ToString ();
|
btnEquipment.MouseUpEventHandler += OpenDoorLockViewEventHandler;
|
fl.MouseUpEventHandler += OpenDoorLockViewEventHandler;
|
|
//btnEquipment.MouseUpEventHandler += (sender, e) => {
|
// UserDeviceToDoorLock doorLockView = new UserDeviceToDoorLock ();
|
// UserMiddle.DevicePageView.AddChidren (doorLockView);
|
// doorLockView.ShowAllRoomDoorLock (doorLockList);
|
// UserMiddle.DevicePageView.PageIndex = 1;
|
//};
|
//fl.MouseUpEventHandler += (sender, e) => {
|
// UserDeviceToDoorLock doorLockView = new UserDeviceToDoorLock ();
|
// UserMiddle.DevicePageView.AddChidren (doorLockView);
|
// doorLockView.ShowAllRoomDoorLock (doorLockList);
|
// UserMiddle.DevicePageView.PageIndex = 1;
|
//};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (doorLockList.Count, R.MyInternationalizationString.DoorLock);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (doorLockList.Count, R.MyInternationalizationString.DoorLock);
|
};
|
}
|
else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Environmental)) {
|
btnEquipment.SelectedImagePath = "Sensor/Sensor.png";
|
btnEquipment.UnSelectedImagePath = "Sensor/Sensor.png";
|
equipmentLayout.BackgroundImagePath = "Sensor/SensorBackground.png";
|
int eCount = 0;
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((common) => {
|
return (common.isMixBox = true && (common.Type == DeviceType.SensorTemperature || common.Type == DeviceType.SensorHumidity
|
|| common.Type == DeviceType.SensorTVOC || common.Type == DeviceType.SensorPM25 || common.Type == DeviceType.SensorCO2
|
// || common.Type == DeviceType.SensorLPG || common.Type == DeviceType.SensorCH4 || common.Type == DeviceType.SensorCOH2
|
//|| common.Type == DeviceType.SensorWater || common.Type == DeviceType.SensorSmoke || common.Type == DeviceType.SensorMobileDetection
|
//|| common.Type == DeviceType.SensorWindSpeed || common.Type == DeviceType.SensorWindPressure || common.Type == DeviceType.SensorLiquidFlow
|
//|| common.Type == DeviceType.SensorLiquidPressure || common.Type == DeviceType.SensorLiquidDepth || common.Type == DeviceType.SensorRainfall
|
//|| common.Type == DeviceType.SensorWeight || common.Type == DeviceType.SensorHeightLength || common.Type == DeviceType.SensorVelocity
|
//|| common.Type == DeviceType.SensorVibration || common.Type == DeviceType.SensorVoltage || common.Type == DeviceType.SensorCurrent || common.Type == DeviceType.SensorPower
|
//|| common.Type == DeviceType.SensorMenciAndwindowMagnetic || common.Type == DeviceType.SensorIllumination
|
));
|
});
|
eCount += devices.Count;
|
}
|
|
btnOpenNumber.Text = eCount.ToString ();
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToSensor doorLockView = new UserDeviceToSensor ();
|
UserMiddle.DevicePageView.AddChidren (doorLockView);
|
doorLockView.ShowAllSensor ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserDeviceToSensor doorLockView = new UserDeviceToSensor ();
|
UserMiddle.DevicePageView.AddChidren (doorLockView);
|
doorLockView.ShowAllSensor ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Environmental);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Environmental);
|
};
|
}
|
else if (equipmentType == Language.StringByID (R.MyInternationalizationString.VideoIntercom)) {
|
btnEquipment.SelectedImagePath = "VideoIntercom/VideoIntercom.png";
|
btnEquipment.UnSelectedImagePath = "VideoIntercom/VideoIntercom.png";
|
equipmentLayout.BackgroundImagePath = "VideoIntercom/VideoIntercomBackground.png";
|
int eCount = 0;
|
|
btnOpenNumber.Text = eCount.ToString ();
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
#if wallon
|
if (MainPage.LoginUser != null && !string.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.LogoutAccountTip), Language.StringByID (R.MyInternationalizationString.No), Language.StringByID (R.MyInternationalizationString.Yes));
|
alert.Show ();
|
alert.ResultEventHandler += (sender, e) => {
|
if (e) {
|
MainPage.LoginUser.AllVisionRegisterDevUserNameGuid = null;
|
};
|
};
|
}
|
#endif
|
};
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
#if wallon
|
if (MainPage.LoginUser == null || string.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) {
|
var dgLogin = new Dialog ();
|
var loginView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (550),
|
Height = Application.GetRealHeight (480),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
Radius = 5,
|
};
|
dgLogin.AddChidren (loginView);
|
|
var btnLoginTilte = new Button () {
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.AccoutLogin,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnLoginTilte);
|
|
var accountView = new FrameLayout () {
|
Width = Application.GetRealWidth (510),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (20),
|
Y = btnLoginTilte.Bottom + Application.GetRealHeight (30),
|
BackgroundImagePath = "Register/Register_Email_Address.png",
|
Radius = (uint)Application.GetRealHeight (0),
|
};
|
loginView.AddChidren (accountView);
|
|
var etAccount = new EditText () {
|
Width = Application.GetRealWidth (400),
|
X = Application.GetRealWidth (100),
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.EmailAddress),
|
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Radius = (uint)Application.GetRealHeight (0),
|
TextColor = SkinStyle.Current.TextColor1,
|
|
};
|
accountView.AddChidren (etAccount);
|
|
var passwrodView = new FrameLayout () {
|
Width = Application.GetRealWidth (510),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (20),
|
Y = accountView.Bottom + Application.GetRealHeight (50),
|
BackgroundImagePath = "Register/Register_Password_kuang.png",
|
};
|
loginView.AddChidren (passwrodView);
|
|
var etPasswrod = new EditText () {
|
Width = Application.GetRealWidth (400 - 73),
|
X = Application.GetRealWidth (100),
|
PlaceholderText = Language.StringByID (R.MyInternationalizationString.PleaseEnterPassword),
|
PlaceholderTextColor = SkinStyle.Current.PlaceholderTextColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
SecureTextEntry = true,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
passwrodView.AddChidren (etPasswrod);
|
|
Button btnShowPassword = new Button () {
|
X = etPasswrod.Right,
|
Y = etPasswrod.Y + Application.GetRealHeight (12),
|
Width = Application.GetRealWidth (73),
|
Height = Application.GetRealHeight (60),
|
SelectedImagePath = "CrabtreeAdd/ShowPW.png",
|
UnSelectedImagePath = "CrabtreeAdd/HidePW.png",
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 2,
|
Radius = 1
|
};
|
passwrodView.AddChidren (btnShowPassword);
|
btnShowPassword.MouseUpEventHandler += (dd, ff) => {
|
btnShowPassword.IsSelected = !btnShowPassword.IsSelected;
|
etPasswrod.SecureTextEntry = !btnShowPassword.IsSelected;
|
};
|
|
etAccount.EditorEnterAction += (obj) => {
|
Application.HideSoftInput ();
|
etPasswrod.Foucs = true;
|
};
|
etPasswrod.EditorEnterAction += (obj) => {
|
Application.HideSoftInput ();
|
};
|
|
var btnCloseLogin = new Button () {
|
Width = Application.GetRealWidth (274),
|
Height = Application.GetRealHeight (89),
|
Y = passwrodView.Bottom + Application.GetRealHeight (70),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.cancel,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnCloseLogin);
|
btnCloseLogin.MouseUpEventHandler += (sende2r, e2) => {
|
dgLogin.Close ();
|
};
|
|
Button btnLogin = new Button () {
|
Width = Application.GetRealWidth (274),
|
Height = Application.GetRealHeight (89),
|
X = btnCloseLogin.Right + 1,
|
Y = btnCloseLogin.Y,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextID = R.MyInternationalizationString.Login,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
loginView.AddChidren (btnLogin);
|
btnLogin.MouseDownEventHandler += (sende2r, e2) => {
|
btnLogin.IsSelected = true;
|
};
|
|
btnLogin.MouseUpEventHandler += (sender2, e2) => {
|
btnLogin.IsSelected = false;
|
var account = etAccount.Text.Trim ();
|
var password = etPasswrod.Text.Trim ();
|
if (string.IsNullOrEmpty (account) && string.IsNullOrEmpty (password)) {
|
Application.RunOnMainThread (() => {
|
new Tip () { Text = "Please enter your login details.", Direction = AMPopTipDirection.Up, CloseTime = 3 }.Show (btnLogin);
|
});
|
return;
|
}
|
if (string.IsNullOrEmpty (account)) {
|
Application.RunOnMainThread (() => {
|
new Tip () { Text = "Please enter your user id.", Direction = AMPopTipDirection.Up, CloseTime = 3 }.Show (btnLogin);
|
});
|
return;
|
}
|
if (string.IsNullOrEmpty (password)) {
|
Application.RunOnMainThread (() => {
|
new Tip () { Text = "Please enter your password.", Direction = AMPopTipDirection.Up, CloseTime = 3 }.Show (btnLogin);
|
});
|
return;
|
}
|
new System.Threading.Thread (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (Language.CurrentLanguage == "Chinese") {
|
MainPage.Loading.Start ("登陆中...");
|
} else {
|
MainPage.Loading.Start ("Login...");
|
}
|
});
|
if (UserConfig.Instance.internetStatus == 0 ) {
|
Application.RunOnMainThread (() => {
|
new Tip () { Text = Language.StringByID (R.MyInternationalizationString.NetworkAbnormal), Direction = AMPopTipDirection.Down, CloseTime = 3 }.Show (btnLogin);
|
});
|
return;
|
}
|
|
var revertConnectionObj = MainPage.RequestHttps ("Connection", "");
|
if (revertConnectionObj.StateCode == "SUCCESS") {
|
Application.RunOnMainThread (() => {
|
if (Language.CurrentLanguage == "Chinese") {
|
MainPage.Loading.Start ("链接服务器成功...");
|
} else {
|
MainPage.Loading.Start ("Link server successful...");
|
}
|
});
|
|
var requestObj = new LoginObj () { Account = account, Password = password, Company = MainPage.SoftSmsType };
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
|
var revertObj = MainPage.RequestHttps ("Login", requestJson, false);
|
if (revertObj.StateCode == "SUCCESS") {
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes> (revertObj.ResponseData.ToString ());
|
var revertData = responseDataObj;
|
MainPage.LoginUser = new UserInfo {
|
ID = revertData.UserId, MasterID = revertData.MainUserId, AccountType = revertData.UserType, AccountString = account, Password = password, LastTime = DateTime.Now,
|
AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid,
|
};
|
MainPage.LoginUser.SaveUserInfo ();
|
//可视对讲
|
Application.RunOnMainThread (() => {
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid);
|
}
|
});
|
});
|
System.Threading.Thread.Sleep (3000);
|
|
Application.RunOnMainThread (() => {
|
dgLogin.Close ();
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.ShowVideo ();
|
Console.WriteLine ("showvideo");
|
}
|
});
|
});
|
}
|
}
|
} catch (Exception ex) {
|
MainPage.FailureToServer ();
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
}) { IsBackground = true}.Start();
|
};
|
dgLogin.Show ();
|
} else {
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.ShowVideo ();
|
Console.WriteLine ("showvideo");
|
}
|
});
|
}
|
#else
|
#if Android
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.ShowVideo ();
|
Console.WriteLine ("showvideo");
|
}
|
});
|
#else
|
com.freeview.global.Video.ShowVideo ();
|
#endif
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
#if Android
|
(Application.Activity as BaseActivity).ReadWriteContact ((b) => {
|
if (b) {
|
com.freeview.global.Video.ShowVideo ();
|
Console.WriteLine ("showvideo");
|
}
|
});
|
#else
|
com.freeview.global.Video.ShowVideo ();
|
#endif
|
#endif
|
};
|
} else if (equipmentType == Language.StringByID (R.MyInternationalizationString.FreshAir)) {
|
btnEquipment.SelectedImagePath = "FreshAir/FreshAir.png";
|
btnEquipment.UnSelectedImagePath = "FreshAir/FreshAir.png";
|
equipmentLayout.BackgroundImagePath = "FreshAir/FreshAirBackground.png";
|
int eCount = 0;
|
int brighingCount = 0;
|
System.Threading.Tasks.Task.Run (() => {
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty(room.Name)) {
|
continue;
|
}
|
var devices = room.DeviceList.FindAll ((obj) => {
|
return obj.Type == DeviceType.FreshAir;
|
});
|
eCount += devices.Count;
|
brighingCount += devices.FindAll ((obj) => { return ((FreshAir)obj).SwitchStatus == 1; }).Count;
|
}
|
Application.RunOnMainThread (() => {
|
if (brighingCount > 0) {
|
eCount = brighingCount;
|
btnOpenNumber.IsSelected = true;
|
}
|
btnOpenNumber.Text = eCount.ToString ();
|
});
|
});
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
UserFresAirList freshAirListView = new UserFresAirList ();
|
UserMiddle.DevicePageView.AddChidren (freshAirListView);
|
freshAirListView.ShowAllRoomFreshAir ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
UserFresAirList freshAirListView = new UserFresAirList ();
|
UserMiddle.DevicePageView.AddChidren (freshAirListView);
|
freshAirListView.ShowAllRoomFreshAir ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.FreshAir);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.FreshAir);
|
};
|
} else if (equipmentType == Language.StringByID (R.MyInternationalizationString.granite)) {
|
btnEquipment.UnSelectedImagePath = "Item/PanelIcon.png";
|
btnEquipment.SelectedImagePath = "Item/PanelIcon.png";
|
equipmentLayout.BackgroundImagePath = "Item/PanelBackground.png";
|
int eCount = 0;
|
//foreach (var room in Room.Lists) {
|
// var devices = room.DeviceList.FindAll ((obj) => {
|
// return obj.Type == DeviceType.FanModule;
|
// });
|
// eCount += devices.Count;
|
//}
|
//btnOpenNumber.Text = eCount.ToString ();
|
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
var panelListPage = new SmartHome.UI.SimpleControl.Phone.PanelListPage ();
|
UserMiddle.DevicePageView.AddChidren (panelListPage);
|
panelListPage.Show ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
var panelListPage = new SmartHome.UI.SimpleControl.Phone.PanelListPage ();
|
UserMiddle.DevicePageView.AddChidren (panelListPage);
|
panelListPage.Show ();
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.granite);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.granite);
|
};
|
}
|
else if (equipmentType == Language.StringByID (R.MyInternationalizationString.Thermostat)) {
|
btnEquipment.UnSelectedImagePath = "CapillaryAC/CapillaryACIcon.png";
|
btnEquipment.SelectedImagePath = "CapillaryAC/CapillaryACIcon.png";
|
equipmentLayout.BackgroundImagePath = "CapillaryAC/CapillaryACBackground.png";
|
int eCount = 0;
|
eCount = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.Thermostat.ToString ()).Count;
|
var hostSavePaths = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 4 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.Thermostat.ToString ());
|
btnOpenNumber.Text = hostSavePaths.Count > 0 ? "1" : "0";
|
if (eCount > 0) {
|
btnEquipment.MouseUpEventHandler += (sender, e) => {
|
ThermostatHostPage acView = new ThermostatHostPage ();
|
UserMiddle.DevicePageView.AddChidren (acView);
|
acView.ShowPage (hostSavePaths);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
fl.MouseUpEventHandler += (sender, e) => {
|
ThermostatHostPage acView = new ThermostatHostPage ();
|
UserMiddle.DevicePageView.AddChidren (acView);
|
acView.ShowPage (hostSavePaths);
|
UserMiddle.DevicePageView.PageIndex = 1;
|
};
|
}
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Thermostat);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (eCount, R.MyInternationalizationString.Thermostat);
|
};
|
}
|
else if (equipmentType == Language.StringByID (R.MyInternationalizationString.ACMerrill)) {
|
btnEquipment.UnSelectedImagePath = "ACMerrill/AClogo.png";
|
btnEquipment.SelectedImagePath = "ACMerrill/AClogo.png";
|
equipmentLayout.BackgroundImagePath = "ACMerrill/ACBg.png";
|
|
|
//List<string> mACMerrillList = allLocationFiles.FindAll ((obj) => {
|
// string [] str = obj.Split ('_');
|
// return obj.StartsWith ("Equipment_") && str.Length == 4 && ((str [1] == DeviceType.ACMerrill.ToString ()));
|
//});
|
|
var mAC = Room.ReadACMerrill_Host ();
|
|
var Count = 0;
|
if (mAC != null) {
|
Count = 1;
|
} else {
|
Count = 0;
|
}
|
|
btnOpenNumber.Text = Count.ToString();
|
|
|
EventHandler<MouseEventArgs> OpenDoorLockViewEventHandler = (sender, e) => {
|
|
if (Count > 0) {
|
//if (mACMerrillList [0].Split ('_') [1] == DeviceType.ACMerrill.ToString ()) {
|
//ACMerrill mACMerrill = Newtonsoft.Json.JsonConvert.DeserializeObject<ACMerrill> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (mACMerrillList [0])));
|
if (Room.ACMerrillHost == null) return;
|
ACMerrillHomePage mACMerrillHomePage = new ACMerrillHomePage (Room.ACMerrillHost);
|
UserMiddle.DevicePageView.AddChidren (mACMerrillHomePage);
|
mACMerrillHomePage.ShowView ();
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
//}
|
|
}
|
|
};
|
|
//btnOpenNumber.Text = mACMerrillList.Count.ToString ();
|
btnEquipment.MouseUpEventHandler += OpenDoorLockViewEventHandler;
|
fl.MouseUpEventHandler += OpenDoorLockViewEventHandler;
|
|
btnEquipment.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (Count, R.MyInternationalizationString.ACMerrill);
|
};
|
fl.MouseLongEventHandler += (sender, e) => {
|
DelUserEquipmentView (Count, R.MyInternationalizationString.ACMerrill);
|
};
|
}
|
|
|
}
|
}
|
}
|