using System;
|
using System.Collections.Generic;
|
using Shared.SimpleControl.Phone;
|
using System.Text;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserAddSceneDevice : FrameLayout
|
{
|
string roomFilePath;
|
string sceneFilePath;
|
Scene scene;
|
List<string> filesList;
|
Room room;
|
public UserAddSceneDevice ()
|
{
|
BackgroundColor = SkinStyle.Current.MainColor;
|
}
|
|
public UserAddSceneDevice (string roomFilePath, string sceneFilePath)
|
{
|
this.roomFilePath = roomFilePath;
|
room = Room.GetRoomByFilePath (roomFilePath);
|
this.sceneFilePath = sceneFilePath;
|
BackgroundColor = SkinStyle.Current.DialogColor;
|
// 当场景不存在时,可以NEW 一个场景,不然值一直是空的
|
if (scene == null) {
|
scene = new Scene ();
|
}
|
filesList = IO.FileUtils.ReadFiles ().FindAll ((obj) => { return obj.Split ('_').Length == 5; });
|
}
|
|
public void ShowScene (Action<string> action)
|
{
|
this.BackgroundColor = SkinStyle.Current.MainColor;
|
RemoveAll ();
|
scene = Scene.GetSceneByFilePath (sceneFilePath);
|
|
#region 标题
|
FrameLayout topView = new FrameLayout () {
|
Height = Application.GetRealHeight (126),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
AddChidren (topView);
|
|
var backButton = new Button () {
|
Y = Application.GetRealHeight (35),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
backButton.MouseUpEventHandler += (sender, e) => {
|
action (sceneFilePath);
|
this.RemoveFromParent ();
|
};
|
topView.AddChidren (backButton);
|
|
Button textButton = new Button () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (400),
|
TextAlignment = TextAlignment.Center,
|
Text = scene.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 19,
|
Gravity = Gravity.CenterHorizontal,
|
};
|
topView.AddChidren (textButton);
|
|
Button editor = new Button () {
|
X = Application.GetRealWidth (550),
|
Y = Application.GetRealHeight (40),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
};
|
topView.AddChidren (editor);
|
editor.MouseUpEventHandler += (sender, e) => {
|
if (editor.IsSelected == true) {
|
} else {
|
new ScenePhoneMethod ().AddOrUpdataSceneBaseMassage (roomFilePath, sceneFilePath, (newSceneFilePath) => {
|
sceneFilePath = newSceneFilePath;
|
scene = Scene.GetSceneByFilePath (sceneFilePath);
|
textButton.Text = scene.Name;
|
});
|
}
|
};
|
#endregion
|
var alldeviceframelayout = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.TitileView,
|
Y = topView.Bottom,
|
};
|
AddChidren (alldeviceframelayout);
|
|
var btnEquipmentModel = new Button () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (30),
|
TextID = R.MyInternationalizationString.DeviceList,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 15,
|
BackgroundColor = SkinStyle.Current.TitileView
|
};
|
alldeviceframelayout.AddChidren (btnEquipmentModel);
|
|
#region 根据添加设备的顺序排列设备
|
VerticalScrolViewLayout deviceListView = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 90 - 90),
|
Y = alldeviceframelayout.Bottom,
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
AddChidren (deviceListView);
|
InitAllDevice (deviceListView, action);
|
#endregion
|
|
Button btnAddDevice = new Button () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (80),
|
Y = Application.GetRealHeight (Application.DesignHeight - 80),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.AddNewDevice,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
btnAddDevice.MouseUpEventHandler += AddEquipment (() => {
|
ShowScene (action);
|
});
|
// new SystemRoomScenesMethod ().AddEquipment (roomFilePath, sceneFilePath, () => {
|
// ShowScene (action);
|
//});
|
|
AddChidren (btnAddDevice);
|
}
|
|
public void InitAllDevice (VerticalScrolViewLayout deviceListView, Action<string> action)
|
{
|
foreach (var deviceFilePath in scene.DeviceFilePathList) {
|
Common common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null == common) {
|
continue;
|
}
|
string iconPath = "";
|
|
if (common.Type == DeviceType.UniversalDevice) {
|
iconPath = "UniversalDevice/UniversalDevice.png";
|
} else if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightRGB ||
|
common.Type == DeviceType.LightDALI || common.Type == DeviceType.LightMixSwitch || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightEnergySwitch) {
|
iconPath = "Item/Light.png";
|
} else if (common.Type == DeviceType.CurtainModel || common.Type == DeviceType.CurtainTrietex || common.Type == DeviceType.CurtainRoller) {
|
iconPath = "Curtain/Curtain.png";
|
} else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared || common.Type == DeviceType.ACPanel) {
|
iconPath = @"AC/AC.png";
|
} else if (common.Type == DeviceType.FoolHeat) {
|
iconPath = @"Item/FloorHeating.png";
|
} else if (common.Type == DeviceType.DryContact) {
|
iconPath = @"Item/DryContact.png";
|
} else if (common.Type == DeviceType.FanModule) {
|
iconPath = @"Fan/Fan.png";
|
} else if (common.Type == DeviceType.LogicModule) {
|
iconPath = @"Item/LogicModule.png";
|
}
|
initDevice (common, action, iconPath, deviceFilePath, deviceListView);
|
}
|
}
|
|
public void initDevice (Common common, Action<string> action, string iconPath, string deviceFilePath, VerticalScrolViewLayout v)
|
{
|
string deviceType = common.Type.ToString ();
|
string remark = common.Name.ToString ();
|
RowLayout row = new RowLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
};
|
v.AddChidren (row);
|
|
Button btnDelFile = new Button () {
|
Text = "Del",
|
BackgroundColor = SkinStyle.Current.DelColor,
|
};
|
row.AddRightView (btnDelFile);
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
scene = Scene.GetSceneByFilePath (sceneFilePath);//找到所有的场景
|
if (scene == null)
|
return;
|
scene.DeviceFilePathList.Remove (deviceFilePath);//将场景中的设备路径删掉
|
if (deviceType != DeviceType.LogicModule.ToString ())
|
IO.FileUtils.DeleteFile (deviceFilePath);//将场景中的设备文件删掉
|
|
IO.FileUtils.WriteFileByBytes (sceneFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (scene)));
|
ShowScene (action);
|
};
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (43),
|
Height = Application.GetRealHeight (43),
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = iconPath,
|
Gravity = Gravity.CenterVertical,
|
};
|
row.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = remark,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
row.AddChidren (btnName);
|
|
Button btnRight = new Button () {
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth (580),
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
if (deviceType != DeviceType.LogicModule.ToString ())
|
row.AddChidren (btnRight);
|
|
EventHandler<MouseEventArgs> eventRoomScene = (sender, e) => {
|
if (deviceType == DeviceType.LogicModule.ToString ())
|
return;
|
//if (scene.busScene)
|
//return;
|
SetDialogForAddEquipment (deviceType, deviceFilePath);
|
};
|
|
row.MouseUpEventHandler += eventRoomScene;
|
btnRight.MouseUpEventHandler += eventRoomScene;
|
btnName.MouseUpEventHandler += eventRoomScene;
|
}
|
|
/// <summary>
|
/// 显示出对应的场景数据
|
/// </summary>
|
public void SetDialogForAddEquipment (string deviceType, string deviceFilePath)
|
{
|
#region initpublicView
|
var dialog = new Dialog ();
|
var dialogBodyLayout = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (560),
|
Radius = 5,
|
BorderWidth = 0,
|
BorderColor = SkinStyle.Current.Transparent,
|
Gravity = Gravity.Center
|
};
|
dialog.AddChidren (dialogBodyLayout);
|
|
var title = new Button () {
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.SceneDialogTitleColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.DialogTextColor,
|
};
|
dialogBodyLayout.AddChidren (title);
|
|
var bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (560 - 80),
|
BackgroundColor = SkinStyle.Current.LineColor2,
|
Height = Application.GetRealHeight (83),
|
};
|
dialogBodyLayout.AddChidren (bottomView);
|
var btnBack = new Button () {
|
Width = Application.GetRealWidth (238),
|
TextID = R.MyInternationalizationString.Cancel,
|
BackgroundColor = SkinStyle.Current.SceneDialogTitleColor,
|
};
|
bottomView.AddChidren (btnBack);
|
btnBack.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
var btnSave = new Button () {
|
Width = Application.GetRealWidth (240),
|
BackgroundColor = SkinStyle.Current.SceneDialogTitleColor,
|
X = Application.GetRealWidth (242),
|
TextID = R.MyInternationalizationString.SAVE,
|
};
|
bottomView.AddChidren (btnSave);
|
#endregion
|
|
if (deviceType == DeviceType.LightSwitch.ToString () || deviceType == DeviceType.LightEnergySwitch.ToString () || deviceType == DeviceType.LightSwitchSocket.ToString ()) {
|
LightSwitch lightSwitch = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null == lightSwitch) {
|
return;
|
}
|
#region
|
title.Text = lightSwitch.Name;
|
Button lblChangeName = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.DelayTime,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
if (!lightSwitch.IsSocket)
|
dialogBodyLayout.AddChidren (lblChangeName);
|
|
EditText etDelayTime = new EditText () {
|
X = lblChangeName.X,
|
Y = lblChangeName.Bottom + Application.GetRealHeight (10),
|
Width = lblChangeName.Width,
|
Height = lblChangeName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = " " + (lightSwitch.DelayTimeHeight * 256 + lightSwitch.DelayTimeLow),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
Radius = 5
|
};
|
if (!lightSwitch.IsSocket)
|
dialogBodyLayout.AddChidren (etDelayTime);
|
|
var btnOn = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (320),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 0,
|
Radius = 5,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.ON,
|
};
|
dialogBodyLayout.AddChidren (btnOn);
|
var btnOff = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (70),
|
X = btnOn.Right + Application.GetRealWidth (40),
|
Y = Application.GetRealHeight (320),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 0,
|
Radius = 5,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.OFF,
|
};
|
dialogBodyLayout.AddChidren (btnOff);
|
|
if (lightSwitch.CurrentBrightness == 0) {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
} else {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
}
|
|
btnOn.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
lightSwitch.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID,
|
new byte [] { lightSwitch.LoopID, lightSwitch.CurrentBrightness, 0, 0 }, SendCount.Zero);
|
};
|
btnOff.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
lightSwitch.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID,
|
new byte [] { lightSwitch.LoopID, lightSwitch.CurrentBrightness, 0, 0 }, SendCount.Zero);
|
};
|
|
#endregion
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
int dtime;
|
if (int.TryParse (etDelayTime.Text.Trim ().ToString (), out dtime)) {
|
if (dtime > 3600 || dtime < 0) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
lightSwitch.DelayTimeHeight = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) / 256);
|
lightSwitch.DelayTimeLow = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) % 256);
|
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightSwitch)));
|
dialog.Close ();
|
};
|
}
|
else if (deviceType == DeviceType.LightMixSwitch.ToString ()) {
|
LightMixSwitch lightSwitch = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
#region
|
title.Text = lightSwitch.Name;
|
Button lblChangeName = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.DelayTime,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
if (!lightSwitch.IsSocket)
|
dialogBodyLayout.AddChidren (lblChangeName);
|
|
EditText etDelayTime = new EditText () {
|
X = lblChangeName.X,
|
Y = lblChangeName.Bottom + Application.GetRealHeight (10),
|
Width = lblChangeName.Width,
|
Height = lblChangeName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = " " + (lightSwitch.DelayTimeHeight * 256 + lightSwitch.DelayTimeLow),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
Radius = 5
|
};
|
if (!lightSwitch.IsSocket)
|
dialogBodyLayout.AddChidren (etDelayTime);
|
|
var btnOn = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (320),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 0,
|
Radius = 5,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.ON,
|
};
|
dialogBodyLayout.AddChidren (btnOn);
|
var btnOff = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (70),
|
X = btnOn.Right + Application.GetRealWidth (40),
|
Y = Application.GetRealHeight (320),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 0,
|
Radius = 5,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.OFF,
|
};
|
dialogBodyLayout.AddChidren (btnOff);
|
|
if (lightSwitch.CurrentBrightness == 0) {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
} else {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
}
|
|
btnOn.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
lightSwitch.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID,
|
new byte [] { lightSwitch.PhysicsLoopID, lightSwitch.CurrentBrightness, 0, 0 }, SendCount.Zero);
|
};
|
btnOff.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
lightSwitch.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID,
|
new byte [] { lightSwitch.PhysicsLoopID, lightSwitch.CurrentBrightness, 0, 0 }, SendCount.Zero);
|
};
|
|
#endregion
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
int dtime;
|
if (int.TryParse (etDelayTime.Text.Trim ().ToString (), out dtime)) {
|
if (dtime > 3600 || dtime < 0) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
lightSwitch.DelayTimeHeight = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) / 256);
|
lightSwitch.DelayTimeLow = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) % 256);
|
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightSwitch)));
|
dialog.Close ();
|
};
|
}
|
else if (deviceType == DeviceType.LightDimming.ToString () ) {
|
LightDimming lightDimming = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null == lightDimming) {
|
return;
|
}
|
|
#region
|
title.Text = lightDimming.Name;
|
var lblChangeName = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.DelayTime,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (lblChangeName);
|
|
var etDelayTime = new EditText () {
|
X = lblChangeName.X,
|
Y = lblChangeName.Bottom + Application.GetRealHeight (10),
|
Width = lblChangeName.Width,
|
Height = lblChangeName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = " " + (lightDimming.DelayTimeHeight * 256 + lightDimming.DelayTimeLow),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
};
|
dialogBodyLayout.AddChidren (etDelayTime);
|
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (lightDimming.CommonLoopID)) {
|
var btnOn = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (300),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.ON,// "On",
|
};
|
dialogBodyLayout.AddChidren (btnOn);
|
var btnOff = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (50),
|
X = btnOn.Right + Application.GetRealWidth (40),
|
Y = Application.GetRealHeight (300),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.OFF, //"Off",
|
};
|
dialogBodyLayout.AddChidren (btnOff);
|
|
if (lightDimming.CurrentBrightness == 0) {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
} else {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
}
|
|
btnOn.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
lightDimming.CurrentBrightness = 100;
|
};
|
btnOff.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
lightDimming.CurrentBrightness = 0;
|
};
|
} else {
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (520 - 200),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (300),
|
};
|
dialogBodyLayout.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.ThumbColor2
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
horizontalSeekBar.Progress = lightDimming.CurrentBrightness;
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (300),
|
Text = lightDimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
dialogBodyLayout.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender, e) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID,
|
lightDimming.DeviceID, new byte [] { lightDimming.LoopID, (byte)e, 0, 0 }, SendCount.Zero);
|
});
|
if (horizontalSeekBar.Progress == 100 || horizontalSeekBar.Progress == 0)
|
lightDimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender, e) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
lightDimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID,
|
lightDimming.DeviceID, new byte [] { lightDimming.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
lightDimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
};
|
}
|
#endregion
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
int dtime;
|
if (int.TryParse (etDelayTime.Text.Trim ().ToString (), out dtime)) {
|
if (dtime > 3600 || dtime < 0) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
lightDimming.DelayTimeHeight = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) / 256);
|
lightDimming.DelayTimeLow = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) % 256);
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightDimming)));
|
dialog.Close ();
|
};
|
} else if ( deviceType == DeviceType.LightDALI.ToString ()) {
|
var lightDALI = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDALI> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null == lightDALI) {
|
return;
|
}
|
dialogBodyLayout = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (660),
|
Radius = 5,
|
BorderWidth = 0,
|
BorderColor = SkinStyle.Current.Transparent,
|
Gravity = Gravity.Center
|
};
|
dialog.AddChidren (dialogBodyLayout);
|
dialogBodyLayout.AddChidren (title);
|
bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (570),
|
BackgroundColor = SkinStyle.Current.LineColor2,
|
Height = Application.GetRealHeight (91),
|
};
|
dialogBodyLayout.AddChidren (bottomView);
|
btnBack = new Button () {
|
Width = Application.GetRealWidth (250),
|
TextID = R.MyInternationalizationString.Cancel,
|
BackgroundColor = SkinStyle.Current.SceneDialogTitleColor,
|
};
|
bottomView.AddChidren (btnBack);
|
btnBack.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
btnSave = new Button () {
|
Width = Application.GetRealWidth (250),
|
BackgroundColor = SkinStyle.Current.SceneDialogTitleColor,
|
X = Application.GetRealWidth (252),
|
TextID = R.MyInternationalizationString.SAVE,
|
};
|
bottomView.AddChidren (btnSave);
|
#region
|
title.Text = lightDALI.Name;
|
var lblChangeName = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.DelayTime,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (lblChangeName);
|
|
var etDelayTime = new EditText () {
|
X = lblChangeName.X,
|
Y = lblChangeName.Bottom + Application.GetRealHeight (10),
|
Width = lblChangeName.Width,
|
Height = lblChangeName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = " " + (lightDALI.DelayTimeHeight * 256 + lightDALI.DelayTimeLow),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
};
|
dialogBodyLayout.AddChidren (etDelayTime);
|
|
|
var btnCurBrightness = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = etDelayTime.Bottom + Application.GetRealHeight(10),
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + lightDALI.CurrentBrightness + "%"
|
};
|
dialogBodyLayout.AddChidren (btnCurBrightness);
|
|
var proessView = new FrameLayout () {
|
Y = btnCurBrightness.Bottom,
|
Height = Application.GetRealHeight (80),
|
};
|
dialogBodyLayout.AddChidren (proessView);
|
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = lightDALI.CurrentBrightness
|
};
|
proessView.AddChidren (horizontalSeekBar);
|
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
lightDALI.LastOpenBrightness = lightDALI.CurrentBrightness = (byte)e4;
|
if (e4 == 0 || e4 == 100) {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, lightDALI.SubnetID, lightDALI.DeviceID, new byte [] { lightDALI.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
lightDALI.LastOpenBrightness = lightDALI.CurrentBrightness = (byte)e4;
|
return;
|
}
|
|
new System.Threading.Thread (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, lightDALI.SubnetID,
|
lightDALI.DeviceID, new byte [] { lightDALI.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
}) { IsBackground = true }.Start ();
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
lightDALI.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, lightDALI.SubnetID, lightDALI.DeviceID, new byte [] { lightDALI.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
};
|
|
|
var btnCurTone = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = proessView.Bottom,
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + lightDALI.CurTone + "K"
|
};
|
dialogBodyLayout.AddChidren (btnCurTone);
|
|
var proessToneView = new FrameLayout () {
|
Y = btnCurTone.Bottom,
|
Height = Application.GetRealHeight (60),
|
};
|
dialogBodyLayout.AddChidren (proessToneView);
|
|
var horizontalToneSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Max = lightDALI.TonesRange / 100,
|
Progress = (lightDALI.CurTone - lightDALI.WarmTones) / 100
|
};
|
proessToneView.AddChidren (horizontalToneSeekBar);
|
|
var btnWarmToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
TextID = R.MyInternationalizationString.Warm,
|
Y = proessToneView.Bottom,
|
TextAlignment = TextAlignment.TopLeft,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
dialogBodyLayout.AddChidren (btnWarmToneText);
|
|
var btnColoToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (380),
|
Y = proessToneView.Bottom,
|
TextID = R.MyInternationalizationString.CoolTones,
|
TextAlignment = TextAlignment.TopRight,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (btnColoToneText);
|
horizontalToneSeekBar.ProgressChanged += (sender2, e4) => {
|
var tonesValues = e4 * 100 + lightDALI.WarmTones;
|
lightDALI.CurTones_High = (byte)(tonesValues / 256);
|
lightDALI.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + lightDALI.CurTone + "K";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, lightDALI.SubnetID, lightDALI.DeviceID, new byte [] { lightDALI.LoopID, lightDALI.CurTones_High, lightDALI.CurTones_Low }, SendCount.Zero);
|
});
|
};
|
horizontalToneSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
var tonesValues = horizontalToneSeekBar.Progress * 100 + lightDALI.WarmTones;
|
lightDALI.CurTones_High = (byte)(tonesValues / 256);
|
lightDALI.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + lightDALI.CurTone + "K";
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, lightDALI.SubnetID, lightDALI.DeviceID, new byte [] { lightDALI.LoopID, lightDALI.CurTones_High, lightDALI.CurTones_Low }, SendCount.Zero);
|
IO.FileUtils.SaveEquipmentMessage (lightDALI, lightDALI.LoopID.ToString ());
|
};
|
|
|
#endregion
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
int dtime;
|
if (int.TryParse (etDelayTime.Text.Trim ().ToString (), out dtime)) {
|
if (dtime > 3600 || dtime < 0) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
lightDALI.DelayTimeHeight = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) / 256);
|
lightDALI.DelayTimeLow = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) % 256);
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightDALI)));
|
dialog.Close ();
|
};
|
} else if( deviceType == DeviceType.LightMixDimming.ToString ()) {
|
LightMixDimming lightDimming = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null == lightDimming) {
|
return;
|
}
|
#region
|
title.Text = lightDimming.Name;
|
var lblChangeName = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (420),
|
Height = Application.GetRealHeight (70),
|
TextID = R.MyInternationalizationString.DelayTime,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (lblChangeName);
|
|
var etDelayTime = new EditText () {
|
X = lblChangeName.X,
|
Y = lblChangeName.Bottom + Application.GetRealHeight (10),
|
Width = lblChangeName.Width,
|
Height = lblChangeName.Height,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = " " + (lightDimming.DelayTimeHeight * 256 + lightDimming.DelayTimeLow),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
};
|
dialogBodyLayout.AddChidren (etDelayTime);
|
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (lightDimming.CommonLoopID)) {
|
var btnOn = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (300),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.ON,// "On",
|
};
|
dialogBodyLayout.AddChidren (btnOn);
|
var btnOff = new Button () {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (50),
|
X = btnOn.Right + Application.GetRealWidth (40),
|
Y = Application.GetRealHeight (300),
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
BorderWidth = 1,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.OFF, //"Off",
|
};
|
dialogBodyLayout.AddChidren (btnOff);
|
|
if (lightDimming.CurrentBrightness == 0) {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
} else {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
}
|
|
btnOn.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = true;
|
btnOff.IsSelected = false;
|
lightDimming.CurrentBrightness = 100;
|
};
|
btnOff.MouseUpEventHandler += (sender, e) => {
|
btnOn.IsSelected = false;
|
btnOff.IsSelected = true;
|
lightDimming.CurrentBrightness = 0;
|
};
|
} else {
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (520 - 200),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (70),
|
Y = Application.GetRealHeight (300),
|
};
|
dialogBodyLayout.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.ThumbColor2
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
horizontalSeekBar.Progress = lightDimming.CurrentBrightness;
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (300),
|
Text = lightDimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
dialogBodyLayout.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender, e) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID,lightDimming.DeviceID, new byte [] { lightDimming.PhysicsLoopID, (byte)e, 0, 0 }, SendCount.Zero);
|
});
|
lightDimming.CurrentBrightness = Convert.ToByte (horizontalSeekBar.Progress);
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender, e) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID,lightDimming.DeviceID, new byte [] { lightDimming.PhysicsLoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
|
};
|
}
|
#endregion
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
int dtime;
|
if (int.TryParse (etDelayTime.Text.Trim ().ToString (), out dtime)) {
|
if (dtime > 3600 || dtime < 0) {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
} else {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PleaseEnterTheNumberTwo), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
return;
|
}
|
lightDimming.DelayTimeHeight = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) / 256);
|
lightDimming.DelayTimeLow = (byte)(Convert.ToInt32 (etDelayTime.Text.Trim ()) % 256);
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightDimming)));
|
dialog.Close ();
|
};
|
}
|
else if (deviceType == DeviceType.LightRGB.ToString ()) {
|
LightLogic lightRGB = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (null != lightRGB) {
|
byte [] lightLigicBytes = new byte [] { lightRGB.LoopID,lightRGB.CurrentBrightness,254,lightRGB.CustomDelayTimeOpen,lightRGB.CustomDelayTimeClose,
|
3,lightRGB.RStatus,lightRGB.GStatus,lightRGB.BStatus,0,0};
|
if (lightLigicBytes == null) {
|
lightLigicBytes = new byte [11];
|
}
|
|
dialogBodyLayout.Height = Application.GetRealHeight (Application.DesignHeight);
|
dialogBodyLayout.Width = Application.GetRealHeight (640);
|
dialogBodyLayout.Gravity = Gravity.Center;
|
|
|
Button btnTopNull = new Button () {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
dialogBodyLayout.AddChidren (btnTopNull);
|
|
Button btnTitle = new Button () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Text = lightRGB.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextSize = 19
|
};
|
dialogBodyLayout.AddChidren (btnTitle);
|
|
Button btnColor = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = Application.GetRealWidth (20),
|
Y = btnTitle.Bottom + Application.GetRealHeight (50),
|
Radius = 5,
|
BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8])
|
};
|
dialogBodyLayout.AddChidren (btnColor);
|
Button btnColorText = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = btnColor.X,
|
Y = btnColor.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "Color"
|
};
|
dialogBodyLayout.AddChidren (btnColorText);
|
|
ColorPicker c = new ColorPicker () {
|
X = Application.GetRealWidth (140),
|
Y = btnTitle.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetMinRealAverage (440),
|
Height = Application.GetMinRealAverage (440),
|
ColorImagePath = "Item/PickerColorWheel.png",
|
};
|
dialogBodyLayout.AddChidren (c);
|
|
DateTime colorChangeTime = DateTime.MinValue;
|
c.ColorChaged += (sender2, e2) => {
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 50) {
|
lightLigicBytes [6] = e2 [0];
|
lightLigicBytes [7] = e2 [1];
|
lightLigicBytes [8] = e2 [2];
|
Control.ControlBytesSend (Command.SetLogicLoopColor, lightRGB.SubnetID, lightRGB.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnColor.BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]);
|
}
|
};
|
#region ---延时---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = c.Bottom + Application.GetRealHeight (20),
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTime
|
};
|
dialogBodyLayout.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeReduce = new Button () {
|
Width = Application.GetRealWidth (74),
|
Height = Application.GetRealHeight (72),
|
X = Application.GetRealWidth (140),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogBodyLayout.AddChidren (btnDelayTimeReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (220),
|
Height = Application.GetRealHeight (72),
|
X = btnDelayTimeReduce.Right,
|
Y = btnDelayTimeReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = lightRGB.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dialogBodyLayout.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeAdd = new Button () {
|
Width = Application.GetRealWidth (74),
|
Height = Application.GetRealHeight (72),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialogBodyLayout.AddChidren (btnDelayTimeAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTime = lightRGB.CustomDelayTimeOpen;
|
btnDelayTimeAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeAdd.IsSelected = true;
|
if (delayTime > 59)
|
return;
|
delayTime++;
|
btnDelayTimeOnText.Text = delayTime.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTime > 59)
|
break;
|
delayTime++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTime.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeReduce.IsSelected = true;
|
if (delayTime == 0)
|
return;
|
delayTime--;
|
btnDelayTimeOnText.Text = delayTime.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTime == 0)
|
break;
|
delayTime--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTime.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
HorizontalSeekBar seekBarLighting = new HorizontalSeekBar () {
|
X = Application.GetRealWidth (50),
|
Y = btnDelayTimeReduce.Bottom + Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (50),
|
Progress = lightLigicBytes [1],
|
ThumbColor = SkinStyle.Current.ThumbColor2,
|
Max = 100,
|
};
|
dialogBodyLayout.AddChidren (seekBarLighting);
|
Button btnLightingText = new Button () {
|
X = seekBarLighting.Right + Application.GetRealWidth (5),
|
Y = seekBarLighting.Y,
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (50),
|
TextColor = SkinStyle.Current.TextColor,
|
Text = lightLigicBytes [1].ToString () + "%",
|
TextSize = 12
|
};
|
dialogBodyLayout.AddChidren (btnLightingText);
|
seekBarLighting.ProgressChanged += (sender3, e3) => {
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 50) {
|
lightLigicBytes [1] = (byte)e3;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, lightRGB.SubnetID, lightRGB.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnLightingText.Text = e3.ToString () + "%";
|
lightRGB.CurrentBrightness = (byte)e3;
|
}
|
};
|
bottomView.RemoveFromParent ();
|
|
bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (Application.DesignHeight - 90),
|
Height = Application.GetRealHeight (95),
|
BackgroundColor = SkinStyle.Current.Black50Transparent,
|
};
|
dialogBodyLayout.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (318),
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Cancel,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
btnSave = new Button () {
|
Width = Application.GetRealWidth (318),
|
X = btnCancel.Right +1,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.SAVE,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
lightRGB.DelayTimeHeigh = (byte)(delayTime / 256);
|
lightRGB.DelayTimeLow = (byte)(delayTime % 256);
|
lightRGB.RStatus = lightLigicBytes [6];
|
lightRGB.GStatus = lightLigicBytes [7];
|
lightRGB.BStatus = lightLigicBytes [8];
|
lightRGB.CurrentBrightness = (byte)seekBarLighting.Progress;
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightRGB)));
|
dialog.Close ();
|
};
|
} else {
|
dialog.Close ();
|
}
|
}
|
else if (deviceType == DeviceType.CurtainModel.ToString ()|| deviceType == DeviceType.CurtainTrietex.ToString ()|| deviceType == DeviceType.CurtainRoller.ToString ()) {
|
if (deviceType == DeviceType.CurtainModel.ToString ()) {
|
#region CurtainModelView
|
CurtainModel curtainmodel = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (curtainmodel == null) {
|
return;
|
}
|
title.Text = curtainmodel.Name;
|
Button btnOpenCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
UnSelectedImagePath = "Curtain/CurtainOpen.png",
|
SelectedImagePath = "Curtain/CurtainOpenSelected.png",
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (155),
|
};
|
dialogBodyLayout.AddChidren (btnOpenCurtain);
|
Button btnOpenLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnOpenCurtain.X,
|
Y = btnOpenCurtain.Bottom + Application.GetRealHeight (5),
|
TextID = R.MyInternationalizationString.Open,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (btnOpenLbl);
|
Button btnStopCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth ((480 - 124) / 2),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainTimeOut.png",
|
SelectedImagePath = "Curtain/CurtainTimeOutSelected.png",
|
};
|
dialogBodyLayout.AddChidren (btnStopCurtain);
|
Button btnStopLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnStopCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Stop,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (btnStopLbl);
|
Button btnCloseCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth (480 - 124 - 35),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainClose.png",
|
SelectedImagePath = "Curtain/CurtainCloseSelected.png",
|
};
|
dialogBodyLayout.AddChidren (btnCloseCurtain);
|
Button btnCloseLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnCloseCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Close,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogBodyLayout.AddChidren (btnCloseLbl);
|
btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = true;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = false;
|
curtainmodel.Status = (CurtainStatus)2;
|
};
|
btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = true;
|
btnStopCurtain.IsSelected = false;
|
curtainmodel.Status = (CurtainStatus)1;
|
};
|
btnStopCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = true;
|
curtainmodel.Status = (CurtainStatus)0;
|
};
|
if (curtainmodel.Status == 0) {
|
btnStopCurtain.IsSelected = true;
|
} else if (curtainmodel.Status == (CurtainStatus)1) {
|
btnOpenCurtain.IsSelected = true;
|
} else if (curtainmodel.Status == (CurtainStatus)2) {
|
btnCloseCurtain.IsSelected = true;
|
}
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (curtainmodel)));
|
dialog.Close ();
|
};
|
#endregion
|
} else if (deviceType == DeviceType.CurtainTrietex.ToString ()) {
|
#region CurtainTrietexlView
|
CurtainTrietex curtaintretex = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (curtaintretex == null) {
|
return;
|
}
|
title.Text = curtaintretex.Name;
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (520 - 150),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (20),
|
Y = title.Bottom + Application.GetRealHeight (10),
|
};
|
dialogBodyLayout.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.ThumbColor2,
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Y = tempSeekBarFrame.Y,
|
Text = curtaintretex.CurtainProress + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dialogBodyLayout.AddChidren (btnMaxBrightness);
|
DateTime controlDateTime = DateTime.MinValue;
|
horizontalSeekBar.ProgressChanged += (sender, e) => {
|
if ((System.DateTime.Now - controlDateTime).TotalMilliseconds < 100) {
|
return;
|
}
|
controlDateTime = DateTime.Now;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintretex.SubnetID, curtaintretex.DeviceID,
|
new byte [] { 17, (byte)horizontalSeekBar.Progress });
|
btnMaxBrightness.Text = horizontalSeekBar.Progress.ToString () + "%";
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintretex.SubnetID, curtaintretex.DeviceID,
|
new byte [] { 17, (byte)horizontalSeekBar.Progress });
|
btnMaxBrightness.Text = horizontalSeekBar.Progress.ToString () + "%";
|
};
|
|
Button btnOpenCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
UnSelectedImagePath = "Curtain/CurtainOpen.png",
|
SelectedImagePath = "Curtain/CurtainOpenSelected.png",
|
X = Application.GetRealWidth (20),
|
Y = tempSeekBarFrame.Bottom + Application.GetRealHeight (40),
|
};
|
dialogBodyLayout.AddChidren (btnOpenCurtain);
|
|
Button btnOpenLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnOpenCurtain.X,
|
Y = btnOpenCurtain.Bottom + Application.GetRealHeight (5),
|
TextID = R.MyInternationalizationString.Open,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (btnOpenLbl);
|
Button btnStopCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth ((480 - 124) / 2),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainTimeOut.png",
|
SelectedImagePath = "Curtain/CurtainTimeOutSelected.png",
|
};
|
//dialogBodyLayout.AddChidren (btnStopCurtain);
|
Button btnStopLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnStopCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Stop,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
//dialogBodyLayout.AddChidren (btnStopLbl);
|
Button btnCloseCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth (480 - 124 - 35),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainClose.png",
|
SelectedImagePath = "Curtain/CurtainCloseSelected.png",
|
};
|
dialogBodyLayout.AddChidren (btnCloseCurtain);
|
|
Button btnCloseLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnCloseCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Close,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogBodyLayout.AddChidren (btnCloseLbl);
|
btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintretex.SubnetID, curtaintretex.DeviceID,
|
new byte [] { 17, 0 });
|
btnMaxBrightness.Text = "0%";
|
horizontalSeekBar.Progress = 0;
|
btnCloseCurtain.IsSelected = true;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = false;
|
curtaintretex.Status = (CurtainStatus)2;
|
};
|
btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintretex.SubnetID, curtaintretex.DeviceID,
|
new byte [] { 17, 100 });
|
btnMaxBrightness.Text = "100%";
|
horizontalSeekBar.Progress = 100;
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = true;
|
btnStopCurtain.IsSelected = false;
|
curtaintretex.Status = (CurtainStatus)1;
|
};
|
btnStopCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = true;
|
curtaintretex.Status = (CurtainStatus)0;
|
};
|
if (curtaintretex.Status == (CurtainStatus)0) {
|
btnStopCurtain.IsSelected = true;
|
} else if (curtaintretex.Status == (CurtainStatus)1) {
|
btnOpenCurtain.IsSelected = true;
|
} else if (curtaintretex.Status == (CurtainStatus)2) {
|
btnCloseCurtain.IsSelected = true;
|
}
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
curtaintretex.CurtainProress = (byte)horizontalSeekBar.Progress;
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (curtaintretex)));
|
dialog.Close ();
|
};
|
#endregion
|
} else if (deviceType == DeviceType.CurtainRoller.ToString ()) {
|
#region CurtainRollerlView
|
CurtainRoller curtainroller = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (curtainroller == null) {
|
return;
|
};
|
title.Text = curtainroller.Name;
|
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (520 - 160),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Y = title.Bottom + Application.GetRealHeight (10),
|
};
|
dialogBodyLayout.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.ThumbColor2,
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Y = tempSeekBarFrame.Y,
|
Text = curtainroller.CurtainProress + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dialogBodyLayout.AddChidren (btnMaxBrightness);
|
DateTime controlDateTime = DateTime.MinValue;
|
horizontalSeekBar.ProgressChanged += (sender, e) => {
|
if ((System.DateTime.Now - controlDateTime).TotalMilliseconds < 100) {
|
return;
|
}
|
controlDateTime = DateTime.Now;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID,
|
new byte [] { 17, (byte)horizontalSeekBar.Progress });
|
btnMaxBrightness.Text = horizontalSeekBar.Progress.ToString () + "%";
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID,
|
new byte [] { 17, (byte)horizontalSeekBar.Progress });
|
btnMaxBrightness.Text = horizontalSeekBar.Progress.ToString () + "%";
|
};
|
|
|
Button btnOpenCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
UnSelectedImagePath = "Curtain/CurtainRollerUp.png",
|
SelectedImagePath = "Curtain/CurtainRollerUpOn.png",
|
X = Application.GetRealWidth (20),
|
Y = tempSeekBarFrame.Bottom + Application.GetRealHeight (40),
|
};
|
dialogBodyLayout.AddChidren (btnOpenCurtain);
|
btnOpenCurtain.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 17, 100 });
|
horizontalSeekBar.Progress = 100;
|
btnMaxBrightness.Text = "100%";
|
};
|
Button btnOpenLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnOpenCurtain.X,
|
Y = btnOpenCurtain.Bottom + Application.GetRealHeight (5),
|
TextID = R.MyInternationalizationString.Open,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialogBodyLayout.AddChidren (btnOpenLbl);
|
Button btnStopCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth ((480 - 124) / 2),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainTimeOut.png",
|
SelectedImagePath = "Curtain/CurtainTimeOutSelected.png",
|
};
|
//dialogBodyLayout.AddChidren (btnStopCurtain);
|
Button btnStopLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnStopCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Stop,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
//dialogBodyLayout.AddChidren (btnStopLbl);
|
Button btnCloseCurtain = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (125),
|
X = Application.GetRealWidth (480 - 124 - 35),
|
Y = btnOpenCurtain.Y,
|
UnSelectedImagePath = "Curtain/CurtainRollerDown.png",
|
SelectedImagePath = "Curtain/CurtainRollerDownOn.png",
|
};
|
dialogBodyLayout.AddChidren (btnCloseCurtain);
|
btnCloseCurtain.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 17, 0 });
|
horizontalSeekBar.Progress = 0;
|
btnMaxBrightness.Text = "0%";
|
};
|
Button btnCloseLbl = new Button () {
|
Width = Application.GetRealWidth (124),
|
Height = Application.GetRealHeight (30),
|
X = btnCloseCurtain.X,
|
Y = btnOpenLbl.Y,
|
TextID = R.MyInternationalizationString.Close,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
};
|
dialogBodyLayout.AddChidren (btnCloseLbl);
|
btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = true;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = false;
|
curtainroller.Status = (CurtainStatus)2;
|
};
|
btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = true;
|
btnStopCurtain.IsSelected = false;
|
curtainroller.Status = (CurtainStatus)1;
|
};
|
btnStopCurtain.MouseUpEventHandler += (sender3, e3) => {
|
btnCloseCurtain.IsSelected = false;
|
btnOpenCurtain.IsSelected = false;
|
btnStopCurtain.IsSelected = true;
|
curtainroller.Status = (CurtainStatus)0;
|
};
|
if (curtainroller.Status == (CurtainStatus)0) {
|
btnStopCurtain.IsSelected = true;
|
} else if (curtainroller.Status == (CurtainStatus)1) {
|
btnOpenCurtain.IsSelected = true;
|
} else if (curtainroller.Status == (CurtainStatus)2) {
|
btnCloseCurtain.IsSelected = true;
|
}
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
curtainroller.CurtainProress = (byte)horizontalSeekBar.Progress;
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (curtainroller)));
|
dialog.Close ();
|
};
|
} else {
|
return;
|
}
|
#endregion
|
}
|
else if (deviceType == DeviceType.HVAC.ToString () || deviceType == DeviceType.ACInfrared.ToString () || deviceType == DeviceType.ACPanel.ToString ()) {
|
AC ac = Newtonsoft.Json.JsonConvert.DeserializeObject<AC> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (ac == null) {
|
return;
|
}
|
var acBLL = new ACMethod ();
|
|
#region View
|
title.Text = ac.Name;
|
var btnSetTemperature = new Button () {
|
X = Application.GetRealWidth (35),
|
Y = Application.GetRealHeight (85),
|
Width = Application.GetRealHeight (410),
|
Height = Application.GetRealHeight (50),
|
Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", ac.SetTemperature.ToString ()),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Enable = false,
|
};
|
dialogBodyLayout.AddChidren (btnSetTemperature);
|
|
Button btnReduceTemperature = new Button () {
|
Width = Application.GetRealWidth (94),
|
Height = Application.GetRealHeight (94),
|
X = Application.GetRealWidth (20),
|
Y = btnSetTemperature.Bottom + Application.GetRealHeight (20),
|
UnSelectedImagePath = "AC/AC-.png",
|
SelectedImagePath = "AC/AC-Selected.png",
|
};
|
dialogBodyLayout.AddChidren (btnReduceTemperature);
|
|
Button btnSwitchAC = new Button () {
|
Width = Application.GetRealWidth (94),
|
Height = Application.GetRealHeight (94),
|
X = Application.GetRealWidth ((480 - 94) / 2),
|
Y = btnReduceTemperature.Y,
|
UnSelectedImagePath = "AC/ACClose.png",
|
SelectedImagePath = "AC/ACCloseSelected.png",
|
};
|
dialogBodyLayout.AddChidren (btnSwitchAC);
|
btnSwitchAC.MouseUpEventHandler += (sender, e) => {
|
btnSwitchAC.IsSelected = !btnSwitchAC.IsSelected;
|
if (btnSwitchAC.IsSelected) {
|
btnSwitchAC.IsSelected = true;
|
ac.Power = 1;
|
} else {
|
ac.Power = 0;
|
btnSwitchAC.IsSelected = false;
|
}
|
acBLL.ControlAC (ac);
|
};
|
if (ac.Power == 1) {
|
btnSwitchAC.IsSelected = true;
|
} else {
|
btnSwitchAC.IsSelected = false;
|
}
|
|
Button btnAddTemperature = new Button () {
|
Width = Application.GetRealWidth (94),
|
Height = Application.GetRealHeight (94),
|
X = Application.GetRealWidth (480 - 20 - 94),
|
Y = btnReduceTemperature.Y,
|
UnSelectedImagePath = "AC/AC+.png",
|
SelectedImagePath = "AC/AC+Selected.png",
|
};
|
dialogBodyLayout.AddChidren (btnAddTemperature);
|
btnReduceTemperature.MouseDownEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = true;
|
};
|
btnReduceTemperature.MouseUpEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = false;
|
if (ac.SetTemperature > 16) {
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (--ac.SetTemperature).ToString ());
|
|
acBLL.ControlAC (ac);
|
}
|
};
|
btnAddTemperature.MouseDownEventHandler += (sender, e) => {
|
btnAddTemperature.IsSelected = true;
|
};
|
btnAddTemperature.MouseUpEventHandler += (sender, e) => {
|
btnAddTemperature.IsSelected = false;
|
btnReduceTemperature.IsSelected = false;
|
if (ac.SetTemperature < 30) {
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (++ac.SetTemperature).ToString ());
|
acBLL.ControlAC (ac);
|
}
|
};
|
#endregion
|
|
#region ModeView
|
FrameLayout acModeView = new FrameLayout () {
|
Height = Application.GetRealHeight (97),
|
Width = LayoutParams.MatchParent,
|
Y = btnReduceTemperature.Bottom + Application.GetRealHeight (7),
|
};
|
dialogBodyLayout.AddChidren (acModeView);
|
|
Button btnACModeLeft = new Button () {
|
Width = Application.GetRealWidth (129),
|
Height = Application.GetRealHeight (129),
|
X = btnReduceTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACLeft.png",
|
SelectedImagePath = "AC/ACLeft.png",
|
};
|
acModeView.AddChidren (btnACModeLeft);
|
|
Button btnModeIcon = new Button () {
|
Width = Application.GetRealWidth (105),
|
Height = Application.GetRealHeight (105),
|
Gravity = Gravity.Center,
|
UnSelectedImagePath = ac.Modepicture,
|
Enable = false,
|
};
|
acModeView.AddChidren (btnModeIcon);
|
Button btnACModeRight = new Button () {
|
Width = Application.GetRealWidth (129),
|
Height = Application.GetRealHeight (129),
|
X = btnAddTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACRight.png",
|
SelectedImagePath = "AC/ACRightSelected.png",
|
};
|
acModeView.AddChidren (btnACModeRight);
|
btnACModeRight.MouseDownEventHandler += (sender, e) => {
|
btnACModeRight.IsSelected = true;
|
};
|
btnACModeRight.MouseUpEventHandler += (sender, e) => {
|
btnACModeRight.IsSelected = false;
|
if (++ac.SetMode > 4)
|
ac.SetMode = 0;
|
acBLL.UpdataACHostModeIcon (ac.SetMode, btnModeIcon);
|
};
|
btnACModeLeft.MouseDownEventHandler += (sender, e) => {
|
btnACModeLeft.IsSelected = true;
|
};
|
btnACModeLeft.MouseUpEventHandler += (sender, e) => {
|
btnACModeLeft.IsSelected = false;
|
try {
|
ac.SetMode--;
|
if (ac.SetMode < 0 || ac.SetMode > 4)
|
ac.SetMode = 4;
|
} catch {
|
ac.SetMode = 4;
|
}
|
acBLL.UpdataACHostModeIcon (ac.SetMode, btnModeIcon);
|
acBLL.ControlAC (ac);
|
};
|
#endregion
|
|
#region WindView
|
FrameLayout acWindView = new FrameLayout () {
|
Height = Application.GetRealHeight (97),
|
Width = LayoutParams.MatchParent,
|
Y = acModeView.Bottom + Application.GetRealHeight (1),
|
};
|
dialogBodyLayout.AddChidren (acWindView);
|
|
Button btnACWindLeft = new Button () {
|
Width = Application.GetRealWidth (129),
|
Height = Application.GetRealHeight (129),
|
X = btnReduceTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACLeft.png",
|
SelectedImagePath = "AC/ACLeft.png",
|
};
|
acWindView.AddChidren (btnACWindLeft);
|
|
Button btnWindIcon = new Button () {
|
Width = Application.GetRealWidth (105),
|
Height = Application.GetRealHeight (105),
|
Gravity = Gravity.Center,
|
UnSelectedImagePath = ac.Windpicture,
|
Enable = false,
|
};
|
acWindView.AddChidren (btnWindIcon);
|
|
Button btnACWindRight = new Button () {
|
Width = Application.GetRealWidth (129),
|
Height = Application.GetRealHeight (129),
|
X = btnAddTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACRight.png",
|
SelectedImagePath = "AC/ACRightSelected.png",
|
};
|
btnACWindLeft.MouseDownEventHandler += (sender, e) => {
|
btnACWindLeft.IsSelected = true;
|
};
|
btnACWindLeft.MouseUpEventHandler += (sender, e) => {
|
btnACWindLeft.IsSelected = false;
|
try {
|
ac.SetFanSpeed--;
|
if (ac.SetFanSpeed < 0 || ac.SetFanSpeed > 3)
|
ac.SetFanSpeed = 3;
|
} catch {
|
ac.SetFanSpeed = 3;
|
}
|
acBLL.UpdataACHostWindIcon (ac.SetFanSpeed, btnWindIcon);
|
acBLL.ControlAC (ac);
|
};
|
acWindView.AddChidren (btnACWindRight);
|
btnACWindRight.MouseDownEventHandler += (sender, e) => {
|
btnACWindRight.IsSelected = true;
|
};
|
btnACWindRight.MouseUpEventHandler += (sender, e) => {
|
btnACWindRight.IsSelected = false;
|
if (++ac.SetFanSpeed > 3)
|
ac.SetFanSpeed = 0;
|
acBLL.UpdataACHostWindIcon (ac.SetFanSpeed, btnWindIcon);
|
acBLL.ControlAC (ac);
|
};
|
#endregion
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
acBLL.UpdataACHostModeIcon (ac.SetMode, btnModeIcon);
|
acBLL.UpdataACHostWindIcon (ac.SetFanSpeed, btnWindIcon);
|
|
switch (ac.SetMode) {
|
case 0://cooling
|
ac.CoolTemperature = ac.SetTemperature;
|
ac.Modepicture = "AC/ACRefrigeration.png";
|
break;
|
//Heating
|
case 1:
|
ac.HeatTemperature = ac.SetTemperature;
|
ac.Modepicture = "AC/ACHeating.png";
|
break;
|
//Fan
|
case 2:
|
ac.IndoorTemperature = ac.SetTemperature;
|
ac.Modepicture = "AC/ACModeAuto.png";
|
break;
|
// Auto
|
case 3:
|
ac.AutoTemperature = ac.SetTemperature;
|
ac.Modepicture = "AC/ACAuto.png";
|
break;
|
//Dry
|
case 4:
|
ac.ChuShiTemperature = ac.SetTemperature;
|
ac.Modepicture = "AC/ACDehumidification.png";
|
break;
|
}
|
|
btnSetTemperature.Text = ac.SetTemperature.ToString ();
|
btnModeIcon.UnSelectedImagePath = ac.Modepicture;
|
|
switch (ac.SetFanSpeed) {
|
case 0:
|
ac.Windpicture = "AC/ACAuto.png";
|
break;
|
case 3:
|
ac.Windpicture = "AC/ACLowWind.png";
|
break;
|
case 2:
|
ac.Windpicture = "AC/ACStroke.png";
|
break;
|
case 1:
|
ac.Windpicture = "AC/ACHighWind.png";
|
break;
|
}
|
btnModeIcon.UnSelectedImagePath = ac.Windpicture;
|
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (ac)));
|
dialog.Close ();
|
};
|
}
|
else if (deviceType == DeviceType.FoolHeat.ToString () || deviceType == DeviceType.FoolHeatPanel.ToString ()) {
|
FoolHeat fh = Newtonsoft.Json.JsonConvert.DeserializeObject<FoolHeat> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (fh == null)
|
return;
|
|
#region View
|
title.Text = fh.Name;
|
|
Button FH_Heat = new Button () {
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (120),
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (120),
|
UnSelectedImagePath = "FH/FH_Heat_on.png",
|
SelectedImagePath = "FH/FH_Cold_on.png",
|
};
|
if (deviceType == DeviceType.FoolHeat.ToString ())
|
dialogBodyLayout.AddChidren (FH_Heat);
|
if (fh.WorkingMode == 0) {
|
FH_Heat.IsSelected = false;
|
} else {
|
FH_Heat.IsSelected = true;
|
}
|
FH_Heat.MouseUpEventHandler += (sender, e) => {
|
if (FH_Heat.IsSelected == false) {
|
FH_Heat.IsSelected = true;
|
fh.WorkingMode = 1;
|
} else {
|
FH_Heat.IsSelected = false;
|
fh.WorkingMode = 0;
|
}
|
fh.Serverx_FH_CMD (FoolHeat.CommandType.WorkMode);
|
};
|
|
Button btnFHSwitch = new Button () {
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (480 - 40 - 80),
|
Y = Application.GetRealHeight (140),
|
UnSelectedImagePath = "AC/ACClose.png",
|
SelectedImagePath = "AC/ACCloseSelected.png",
|
};
|
dialogBodyLayout.AddChidren (btnFHSwitch);
|
if (fh.Status == 1) {
|
btnFHSwitch.IsSelected = true;
|
} else {
|
btnFHSwitch.IsSelected = false;
|
}
|
btnFHSwitch.MouseUpEventHandler += (sender, e) => {
|
if (btnFHSwitch.IsSelected == false) {
|
btnFHSwitch.IsSelected = true;
|
fh.Status = 1;
|
} else {
|
btnFHSwitch.IsSelected = false;
|
fh.Status = 0;
|
}
|
System.Threading.Tasks.Task.Run (() => {
|
fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch);
|
});
|
};
|
#endregion
|
|
#region ModeView
|
FrameLayout fhTemperatureView = new FrameLayout () {
|
Height = Application.GetRealHeight (97),
|
Width = LayoutParams.MatchParent,
|
Y = btnFHSwitch.Bottom + Application.GetRealHeight (60),
|
};
|
dialogBodyLayout.AddChidren (fhTemperatureView);
|
|
Button btnReduceTemperature = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/AC-.png",
|
SelectedImagePath = "Item/AC-Selected2.png",
|
};
|
fhTemperatureView.AddChidren (btnReduceTemperature);
|
|
Button btnSetTemperature = new Button () {
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (65),
|
Gravity = Gravity.Center,
|
Text = fh.WorkingTemperature.ToString () + "°",
|
TextSize = 22,
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
fhTemperatureView.AddChidren (btnSetTemperature);
|
Button BtnAddTemperature = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (480 - 90 - 40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/AC+.png",
|
SelectedImagePath = "AC/AC+Selected.png",
|
};
|
fhTemperatureView.AddChidren (BtnAddTemperature);
|
BtnAddTemperature.MouseDownEventHandler += (sender, e) => {
|
BtnAddTemperature.IsSelected = true;
|
};
|
BtnAddTemperature.MouseUpEventHandler += (sender, e) => {
|
BtnAddTemperature.IsSelected = false;
|
|
if (++fh.WorkingTemperature > 35) {
|
fh.WorkingTemperature = 35;
|
}
|
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
|
|
System.Threading.Tasks.Task.Run (() => {
|
fh.Serverx_FH_CMD (FoolHeat.CommandType.Temperatrue);
|
});
|
};
|
btnReduceTemperature.MouseDownEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = true;
|
};
|
btnReduceTemperature.MouseUpEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = false;
|
if (--fh.WorkingTemperature <= 5) {
|
fh.WorkingTemperature = 5;
|
}
|
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
|
System.Threading.Tasks.Task.Run (() => {
|
fh.Serverx_FH_CMD (FoolHeat.CommandType.Temperatrue);
|
});
|
};
|
#endregion
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (fh)));
|
dialog.Close ();
|
};
|
} else if (deviceType == DeviceType.DryContact.ToString ()) {
|
|
} else if (deviceType == DeviceType.MusicModel.ToString ()) {
|
|
} else if (deviceType == DeviceType.FanModule.ToString ()) {
|
#region FanModuleView
|
FanModule fanModule = Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (fanModule == null) {
|
return;
|
}
|
title.Text = fanModule.Name;
|
|
FrameLayout windBodyView = new FrameLayout () {
|
Height = Application.GetRealHeight (400),
|
Y = title.Bottom,
|
};
|
dialogBodyLayout.AddChidren (windBodyView);
|
|
Button btnWindSpeedTitle = new Button () {
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextID = R.MyInternationalizationString.WindSpeed
|
};
|
windBodyView.AddChidren (btnWindSpeedTitle);
|
|
Button btnWindSpeedReduce = new Button () {
|
X = Application.GetRealWidth (100),
|
Y = btnWindSpeedTitle.Bottom,
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
windBodyView.AddChidren (btnWindSpeedReduce);
|
|
Button btnWindSpeedText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
BackgroundColor = SkinStyle.Current.SceneDialogColor,
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor,
|
X = btnWindSpeedReduce.Right,
|
Y = btnWindSpeedReduce.Y,
|
Text = fanModule.WindSpeed.ToString (),
|
};
|
windBodyView.AddChidren (btnWindSpeedText);
|
|
Button btnWindSpeedAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
X = btnWindSpeedText.Right,
|
Y = btnWindSpeedReduce.Y,
|
};
|
windBodyView.AddChidren (btnWindSpeedAdd);
|
btnWindSpeedAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnWindSpeedAdd.IsSelected = true;
|
if (fanModule.WindSpeed < 8) {
|
fanModule.WindSpeed++;
|
Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID,
|
new byte [] { fanModule.LoopID, fanModule.WindSpeed });
|
btnWindSpeedText.Text = fanModule.WindSpeed.ToString ();
|
IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ());
|
}
|
};
|
btnWindSpeedAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnWindSpeedAdd.IsSelected = false;
|
};
|
|
btnWindSpeedReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnWindSpeedReduce.IsSelected = true;
|
if (fanModule.WindSpeed > 0) {
|
fanModule.WindSpeed--;
|
Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID,
|
new byte [] { fanModule.LoopID, fanModule.WindSpeed });
|
btnWindSpeedText.Text = fanModule.WindSpeed.ToString ();
|
IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ());
|
}
|
};
|
btnWindSpeedReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnWindSpeedReduce.IsSelected = false;
|
};
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (fanModule)));
|
dialog.Close ();
|
};
|
#endregion
|
} else if (deviceType == DeviceType.UniversalDevice.ToString ()) {
|
#region UniversalDevice
|
UniversalDevice udDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (udDevice == null) {
|
return;
|
}
|
title.Text = udDevice.Name;
|
|
FrameLayout windBodyView = new FrameLayout () {
|
Height = Application.GetRealHeight (400),
|
Y = title.Bottom,
|
};
|
dialogBodyLayout.AddChidren (windBodyView);
|
|
Button tempSiwtch = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
Radius = 2,
|
BorderColor = SkinStyle.Current.White20Transparent,
|
BorderWidth = 2,
|
Text = udDevice.ON_Text
|
};
|
windBodyView.AddChidren (tempSiwtch);
|
|
|
if (udDevice.ActionType == 0) {
|
tempSiwtch.Text = udDevice.ON_Text;
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.ActionType == 0) {
|
if (udDevice.SendBytes.Count == 0) {
|
udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
|
} else
|
udDevice.SendBytes [1] = 255;
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
}
|
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
|
}
|
};
|
} else if (udDevice.ActionType == 1) {
|
tempSiwtch.TextID = R.MyInternationalizationString.OFF;
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.ActionType == 1) {
|
|
if (udDevice.SendBytes.Count == 0) {
|
udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 0 };
|
} else
|
udDevice.SendBytes [1] = 0;
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
}
|
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
|
}
|
};
|
} else if (udDevice.ActionType == 2) {
|
tempSiwtch.TextID = R.MyInternationalizationString.OFF;
|
tempSiwtch.X = Application.GetRealWidth (100);
|
tempSiwtch.Y = Application.GetRealHeight (100);
|
|
Button tempON = new Button () {
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (270),
|
Y = tempSiwtch.Y,
|
Radius = 2,
|
BorderColor = SkinStyle.Current.White20Transparent,
|
BorderWidth = 2,
|
TextID = R.MyInternationalizationString.ON
|
};
|
windBodyView.AddChidren (tempON);
|
tempON.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.SendBytes.Count == 0) {
|
udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 255 };
|
} else
|
udDevice.SendBytes [1] = 255;
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
}
|
tempON.BorderColor = SkinStyle.Current.SelectedColor;
|
tempSiwtch.BorderColor = SkinStyle.Current.Transparent;
|
};
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.SendBytes.Count == 0) {
|
udDevice.SendBytes = new List<byte> () { udDevice.LoopID, 0 };
|
} else
|
udDevice.SendBytes [1] = 0;
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
}
|
tempSiwtch.BorderColor = SkinStyle.Current.SelectedColor;
|
tempON.BorderColor = SkinStyle.Current.Transparent;
|
};
|
}
|
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
IO.FileUtils.WriteFileByBytes (deviceFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (udDevice)));
|
dialog.Close ();
|
};
|
#endregion
|
}
|
dialog.Show ();
|
}
|
|
/// <summary>
|
/// 房间和场景添加设备的方法
|
/// </summary>
|
public EventHandler<MouseEventArgs> AddEquipment (Action action = null)
|
{
|
EventHandler<MouseEventArgs> eHandler = (sender, e) => {
|
List<string> targetDeviceList = new List<string> ();
|
//找出需要显示的设备
|
List<string> localEquipments = filesList.FindAll ((obj) => {
|
string [] str = obj.Split ('_');
|
return obj.StartsWith ("Equipment_") && str.Length == 5
|
&& (str [1] == DeviceType.LightSwitch.ToString ()
|
|| str [1] == DeviceType.LightSwitchSocket.ToString ()
|
|| str [1] == DeviceType.LightDimming.ToString ()
|
|| str [1] == DeviceType.LightDALI.ToString ()
|
|| str [1] == DeviceType.LightRGB.ToString ()
|
|| str [1] == DeviceType.LightMixDimming.ToString ()
|
|| str [1] == DeviceType.LightMixSwitch.ToString ()
|
|| str [1] == DeviceType.LightEnergySwitch.ToString ()
|
|| str [1] == DeviceType.CurtainModel.ToString ()
|
|| str [1] == DeviceType.CurtainRoller.ToString ()
|
|| str [1] == DeviceType.CurtainTrietex.ToString ()
|
|| str [1] == DeviceType.ACInfrared.ToString ()
|
|| str [1] == DeviceType.HVAC.ToString ()
|
|| str [1] == DeviceType.ACPanel.ToString ()
|
|| str [1] == DeviceType.FoolHeat.ToString ()
|
//|| (str [1] == DeviceType.InfraredMode.ToString () && sceneFilePath == null)
|
//|| (str [1] == DeviceType.MusicModel.ToString () && sceneFilePath == null)
|
|| str [1] == DeviceType.FanModule.ToString ()
|
|| (str [1] == DeviceType.LogicModule.ToString () && roomFilePath == Scene.GlobalSceneFilePath))
|
|| str [1] == DeviceType.UniversalDevice.ToString ()
|
;
|
});
|
if (roomFilePath == Scene.GlobalSceneFilePath) {
|
var sceneG = Scene.GetSceneByFilePath (sceneFilePath);
|
targetDeviceList = sceneG.DeviceFilePathList;
|
} else {
|
var sceneRoom = Scene.GetSceneByFilePath (sceneFilePath);
|
targetDeviceList = sceneRoom.DeviceFilePathList;
|
}
|
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogBodyView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (725),
|
Gravity = Gravity.Center,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
};
|
dialog.AddChidren (dialogBodyView);
|
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.AddNewDevice,
|
};
|
dialogBodyView.AddChidren (btnTitle);
|
|
FrameLayout dropDownLayout = new FrameLayout () {
|
Height = Application.GetRealHeight (85),
|
Y = btnTitle.Height,
|
BackgroundColor = SkinStyle.Current.SubtitleView,
|
};
|
dialogBodyView.AddChidren (dropDownLayout);
|
|
Button btnEquipmentIcon = new Button () {
|
Width = Application.GetRealHeight (65),
|
Height = Application.GetRealHeight (65),
|
UnSelectedImagePath = "Item/PointBig.png",
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
};
|
dropDownLayout.AddChidren (btnEquipmentIcon);
|
Button btnDrodIcon = new Button () {
|
X = dialogBodyView.Width - Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (46),
|
Width = Application.GetRealWidth (47),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
dropDownLayout.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.SelectedColor
|
};
|
dropDownLayout.AddChidren (btnEquipmentType);
|
//存放设备的view
|
VerticalScrolViewLayout DeviceListScrolView = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (470),
|
Y = dropDownLayout.Bottom + Application.GetRealHeight (5),
|
};
|
dialogBodyView.AddChidren (DeviceListScrolView);
|
FrameLayout inScrolView_DeviceListView = new FrameLayout ();
|
DeviceListScrolView.AddChidren (inScrolView_DeviceListView);
|
|
FrameLayout BottomView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle,
|
Y = dialogBodyView.Height - Application.GetRealHeight (80),
|
};
|
dialogBodyView.AddChidren (BottomView);
|
Button btnBack = new Button () {
|
Width = Application.GetRealWidth (260),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Cancel,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
BottomView.AddChidren (btnBack);
|
btnBack.MouseUpEventHandler += (sender1, e1) => {
|
dialog.Close ();
|
};
|
Button btnDline = new Button () {
|
Width = 1,
|
X = btnBack.Right,
|
BackgroundColor = SkinStyle.Current.White20Transparent
|
};
|
BottomView.AddChidren (btnDline);
|
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (250),
|
Height = LayoutParams.MatchParent,
|
X = btnDline.Right,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Confrim,
|
Radius = 1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
BottomView.AddChidren (btnSave);
|
btnSave.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
if (roomFilePath == Scene.GlobalSceneFilePath) {
|
if (action != null) {
|
Scene Gscen2 = Scene.GetSceneByFilePath (sceneFilePath);
|
Gscen2.DeviceFilePathList.Clear ();
|
foreach (string filp in targetDeviceList) {
|
if (!Gscen2.DeviceFilePathList.Contains (filp)) {
|
Gscen2.DeviceFilePathList.Add (filp);
|
}
|
}
|
Gscen2.Save (sceneFilePath);
|
action ();
|
}
|
} else {
|
Scene Gscen2 = Scene.GetSceneByFilePath (sceneFilePath);
|
Gscen2.DeviceFilePathList.Clear ();
|
foreach (string filp in targetDeviceList) {
|
if (!Gscen2.DeviceFilePathList.Contains (filp)) {
|
Gscen2.DeviceFilePathList.Add (filp);
|
}
|
}
|
Gscen2.Save (sceneFilePath);
|
action ();
|
}
|
};
|
|
// ---显示在本地找到的所有设备---
|
initAllLocalEquipment (targetDeviceList, inScrolView_DeviceListView, localEquipments);
|
VerticalScrolViewLayout typeLayout = new VerticalScrolViewLayout () {
|
Height = 0,
|
Y = dropDownLayout.Bottom,
|
};
|
dialogBodyView.AddChidren (typeLayout);
|
|
#region ---Add Device Dialog---
|
btnEquipmentType.MouseUpEventHandler += (sender33, e55) => {
|
//下拉列表的数据源(选项为设备类型有关)
|
List<string> typeTemp = new List<string>{
|
Language.StringByID(R.MyInternationalizationString.All),
|
Language.StringByID(R.MyInternationalizationString.Lights),
|
Language.StringByID(R.MyInternationalizationString.Curtains),
|
Language.StringByID(R.MyInternationalizationString.AC),
|
Language.StringByID(R.MyInternationalizationString.FoolHeat),
|
Language.StringByID(R.MyInternationalizationString.TV),
|
Language.StringByID(R.MyInternationalizationString.ElectricalControl),
|
Language.StringByID(R.MyInternationalizationString.Fan),
|
Language.StringByID(R.MyInternationalizationString.UniversalDevice),
|
Language.StringByID(R.MyInternationalizationString.LogicModule),
|
};
|
|
//如果当前显示的是所有的设备,就隐藏
|
if (DeviceListScrolView.Height != 0) {
|
DeviceListScrolView.Height = 0;
|
typeLayout.Height = Application.GetRealHeight (485);
|
btnEquipmentType.IsSelected = btnDrodIcon.IsSelected = true;
|
if (typeLayout.ChildrenCount != 0) {
|
return;
|
}
|
foreach (string typeName in typeTemp) {
|
FrameLayout typeDropDownLayout1 = new FrameLayout () {
|
Height = Application.GetRealHeight (82),
|
};
|
typeLayout.AddChidren (typeDropDownLayout1);
|
Button btnLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.Black50Transparent
|
};
|
typeLayout.AddChidren (btnLine);
|
Button btnEquipmentIcon2 = new Button () {
|
Width = Application.GetRealHeight (65),
|
Height = Application.GetRealHeight (65),
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = "Item/PointBig.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
typeDropDownLayout1.AddChidren (btnEquipmentIcon2);
|
Button btnTypeName = new Button () {
|
Width = Application.GetRealHeight (400),
|
Height = Application.GetRealHeight (82),
|
X = btnEquipmentIcon.Right + Application.GetRealWidth (10),
|
Text = typeName,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
typeDropDownLayout1.AddChidren (btnTypeName);
|
EventHandler<MouseEventArgs> typeEvent = (sender1, e1) => {
|
typeLayout.Height = 0;
|
DeviceListScrolView.Height = Application.GetRealHeight (470);
|
btnEquipmentType.IsSelected = btnDrodIcon.IsSelected = false;
|
btnEquipmentType.Text = typeName;
|
string deviceType = typeName;
|
if (typeName == Language.StringByID (R.MyInternationalizationString.Lights)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/Light.png";
|
deviceType = "Light";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Curtains)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
deviceType = "Curtain";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.AC)) {
|
btnEquipmentIcon.UnSelectedImagePath = "AC/AC.png";
|
deviceType = "AC";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.FoolHeat)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/FloorHeating.png";
|
deviceType = "FoolHeat";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.DryContactPanel)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/DryContact.png";
|
deviceType = "DryContact";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.MusicModel)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/Music.png";
|
deviceType = "Music";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.InfraredMode)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
deviceType = "InfraredMode";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.TV)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
deviceType = "InfraredMode";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.ElectricalControl)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Light/Socket.png";
|
deviceType = "EC";//电器控制
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.Fan)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Fan/Fan.png";
|
deviceType = "Fan";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.LogicModule)) {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/PointBig.png";
|
deviceType = "LogicModule";
|
} else if (typeName == Language.StringByID (R.MyInternationalizationString.UniversalDevice)) {
|
btnEquipmentIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
deviceType = "UniversalDevice";
|
} else {
|
btnEquipmentIcon.UnSelectedImagePath = "Item/LogicModule.png";
|
deviceType = "All";
|
}
|
initAllLocalEquipment (targetDeviceList, inScrolView_DeviceListView, localEquipments, deviceType);
|
};
|
typeDropDownLayout1.MouseUpEventHandler += typeEvent;
|
btnTypeName.MouseUpEventHandler += typeEvent;
|
btnEquipmentIcon2.MouseUpEventHandler += typeEvent;
|
}
|
|
} else {
|
typeLayout.Height = Application.GetRealHeight (0);
|
DeviceListScrolView.Height = Application.GetRealHeight (470);
|
btnEquipmentType.IsSelected = btnDrodIcon.IsSelected = false;
|
}
|
};
|
dialog.Show ();
|
#endregion
|
};
|
return eHandler;
|
}
|
|
/// <summary>
|
/// 显示在本地找到的所有设备
|
/// </summary>
|
void initAllLocalEquipment (List<string> addDeviceList, FrameLayout inScrolView_DeviceListView, List<string> localEquipments, string selectedDeviceType = null)
|
{
|
inScrolView_DeviceListView.RemoveAll ();
|
|
int btnEquipmentIndex = 0;
|
int i = 0;
|
foreach (string deviceFilePath in localEquipments) {
|
i++;
|
if (room != null && !room.DeviceFilePathList.Contains (deviceFilePath) && deviceFilePath.Split ('_') [1] != DeviceType.LogicModule.ToString ()) {
|
continue;
|
}
|
string [] str = deviceFilePath.Split ('_');
|
if (str [4].Length == 2 && str [4] [0] == '0') {
|
str [4] = str [4] [1].ToString ();
|
}
|
if (selectedDeviceType != null && 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 deviceType = str [1];
|
Button btnEquipment = new Button () {
|
Width = (inScrolView_DeviceListView.Width - Application.GetRealWidth (50)) / 2,
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealHeight (30),
|
Y = Application.GetRealHeight (5),
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = i.ToString ()
|
};
|
var commonBytes = IO.FileUtils.ReadFile (deviceFilePath);
|
if (commonBytes.Length == 0) {
|
Console.WriteLine ("length loss");
|
continue;
|
}
|
if (commonBytes.Length == 1) {
|
Console.WriteLine ("length loss 1");
|
continue;
|
}
|
Common commonDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (commonBytes));
|
if (deviceType == 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;
|
}
|
}
|
if (btnEquipmentIndex < 2) {
|
btnEquipment.X = btnEquipmentIndex * (btnEquipment.Width + Application.GetRealWidth (15)) + Application.GetRealWidth (20);
|
btnEquipment.Y = Application.GetRealHeight (10);
|
btnEquipmentIndex++;
|
} else {
|
btnEquipment.X = btnEquipmentIndex % 2 * (btnEquipment.Width + Application.GetRealWidth (15)) + Application.GetRealWidth (20);
|
btnEquipment.Y = (int)btnEquipmentIndex / 2 * (btnEquipment.Height + Application.GetRealHeight (10)) + Application.GetRealHeight (10);
|
btnEquipmentIndex++;
|
}
|
btnEquipment.Text = commonDevice.Name;
|
btnEquipment.Tag = deviceFilePath;
|
inScrolView_DeviceListView.AddChidren (btnEquipment);
|
|
if (sceneFilePath == Scene.GlobalSceneFilePath) {
|
foreach (var filePath in scene.DeviceFilePathList) {
|
System.Console.WriteLine (filePath);
|
if (filePath.EndsWith (deviceFilePath)) {
|
btnEquipment.IsSelected = true;
|
break;
|
}
|
}
|
} else {
|
foreach (var filePath in scene.DeviceFilePathList) {
|
if (filePath.EndsWith (deviceFilePath)) {
|
btnEquipment.IsSelected = true;
|
break;
|
}
|
}
|
}
|
|
btnEquipment.MouseUpEventHandler += (sendere, ee) => {
|
btnEquipment.IsSelected = !btnEquipment.IsSelected;
|
if (sceneFilePath.Contains (Scene.GlobalSceneFilePath)) {
|
if (btnEquipment.IsSelected) {
|
if (null == scene.DeviceFilePathList.Find ((obj) => { return obj.EndsWith (btnEquipment.Tag.ToString ()); })) {
|
var filePath = "GlobalScene" + DateTime.Now.Ticks + "_" + deviceType + "_" + btnEquipment.Tag.ToString ();
|
if (deviceType == DeviceType.LogicModule.ToString ()) {
|
filePath = btnEquipment.Tag.ToString ();
|
} else {
|
switch (commonDevice.Type) {
|
case DeviceType.LogicModule:
|
LogicModule lc = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lc)));
|
break;
|
case DeviceType.UniversalDevice:
|
var sssd = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (sssd)));
|
break;
|
default:
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (commonDevice)));
|
break;
|
}
|
}
|
addDeviceList.Add (filePath);
|
}
|
} else {
|
var filePath = scene.DeviceFilePathList.Find ((obj) => { return obj.EndsWith (btnEquipment.Tag.ToString ()); });
|
if (null != filePath) {
|
addDeviceList.Remove (filePath);
|
}
|
}
|
} else {
|
if (btnEquipment.IsSelected) {
|
if (null == scene.DeviceFilePathList.Find ((obj) => { return obj.EndsWith (btnEquipment.Tag.ToString ()); })) {
|
var filePath = "RoomScene" + DateTime.Now.Ticks + "_" + deviceType + "_" + btnEquipment.Tag.ToString ();
|
switch (commonDevice.Type) {
|
case DeviceType.LogicModule:
|
LogicModule lc = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lc)));
|
break;
|
case DeviceType.LightMixDimming:
|
LightMixDimming lmd = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lmd)));
|
break;
|
case DeviceType.LightMixSwitch:
|
LightMixSwitch lms = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lms)));
|
break;
|
case DeviceType.LightDALI://2020-03-05 修复DALI 不能调节色温
|
LightDALI mDALI = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDALI> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (mDALI)));
|
break;
|
default:
|
IO.FileUtils.WriteFileByBytes (filePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (commonDevice)));
|
break;
|
}
|
addDeviceList.Add (filePath);
|
}
|
|
} else {
|
var filePath = scene.DeviceFilePathList.Find ((obj) => { return obj.EndsWith (btnEquipment.Tag.ToString ()); });
|
if (null != filePath) {
|
addDeviceList.Remove (filePath);
|
}
|
}
|
}
|
};
|
|
if (btnEquipmentIndex > 8) {
|
inScrolView_DeviceListView.Height = (btnEquipmentIndex / 2 + 1) * Application.GetRealHeight (100) + Application.GetRealHeight (10);
|
} else {
|
inScrolView_DeviceListView.Height = Application.GetRealHeight (480);
|
}
|
}
|
}
|
}
|
}
|