using System;
|
using System.Collections.Generic;
|
using System.Globalization;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.CommonForm
|
{
|
public class DeviceDetailInfo : FrameLayout
|
{
|
public List<string> RoomNameList;
|
public string BelongZoneStr;
|
public Action action;
|
public override void RemoveFromParent()
|
{
|
action();
|
base.RemoveFromParent();
|
}
|
public DeviceDetailInfo()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
}
|
public void Show(DeviceUI device, Common.Room room)
|
{
|
RoomNameList = new List<string> { };
|
RoomNameList = Common.Room.CurrentRoom.GetRoomListNameByDevice(device.CommonDevice);
|
#region topview
|
var topBGView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(CommonPage.Navigation_Height),
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
|
};
|
AddChidren(topBGView);
|
var topView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
|
Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
|
};
|
AddChidren(topView);
|
|
var title = new Button()
|
{
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.ChangeDeviceInfo,
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
|
Gravity = Gravity.CenterHorizontal
|
};
|
topView.AddChidren(title);
|
|
var back = new BackButton() { };
|
topView.AddChidren(back);
|
back.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
};
|
#endregion
|
|
#region midFL
|
var midFL = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
|
Y = topView.Bottom,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
};
|
this.AddChidren(midFL);
|
var r = new R.MyInternationalizationString();
|
object t;
|
try
|
{
|
t = r.GetType().InvokeMember(device.CommonDevice.Type.ToString(), System.Reflection.BindingFlags.GetField, null, r, null);
|
}
|
catch
|
{
|
t = 11070;
|
}
|
var deviceIMG = new Button()
|
{
|
Y = Application.GetRealHeight(30),
|
Width = Application.GetMinRealAverage(320),
|
Height = Application.GetMinRealAverage(320),
|
UnSelectedImagePath = device.IconPath,
|
SelectedImagePath = device.OnlineIconPath,
|
IsSelected=device.CommonDevice.IsOnline==1,
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFL.AddChidren(deviceIMG);
|
var deviceTypeName = new Button()
|
{
|
Y = deviceIMG.Bottom,
|
Width = Application.GetRealWidth(900),
|
Height = Application.GetRealHeight(100),
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextID = (int)t,
|
Gravity = Gravity.CenterHorizontal
|
};
|
midFL.AddChidren(deviceTypeName);
|
|
var deviceNameFL = new FrameLayout()
|
{
|
Y = deviceTypeName.Bottom,
|
Height = Application.GetRealHeight(170),
|
};
|
midFL.AddChidren(deviceNameFL);
|
var deviceNameTip = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Height = Application.GetRealHeight(70),
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
TextColor = ZigbeeColor.Current.GXCButtonTipColor,
|
TextID = R.MyInternationalizationString.DeviceName,
|
};
|
deviceNameFL.AddChidren(deviceNameTip);
|
var deviceName = new EditText()
|
{
|
X = Application.GetRealWidth(50),
|
Y = deviceNameTip.Bottom,
|
Height = Application.GetRealHeight(100) - 1,
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Text = device.CommonDevice.DeviceEpointName,
|
};
|
deviceNameFL.AddChidren(deviceName);
|
var deviceNameLine = new Button()
|
{
|
Y = deviceName.Bottom,
|
Height = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
deviceNameFL.AddChidren(deviceNameLine);
|
|
var zoneFL = new FrameLayout()
|
{
|
Y = deviceNameFL.Bottom,
|
Height = Application.GetRealHeight(170),
|
};
|
midFL.AddChidren(zoneFL);
|
var zoneTip = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Height = Application.GetRealHeight(70),
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
TextColor = ZigbeeColor.Current.GXCButtonTipColor,
|
TextID = R.MyInternationalizationString.BelongZone,
|
};
|
zoneFL.AddChidren(zoneTip);
|
var zone = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Y = deviceNameTip.Bottom,
|
Height = Application.GetRealHeight(100) - 1,
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Text = Common.Room.CurrentRoom.GetRoomName(RoomNameList),
|
};
|
zoneFL.AddChidren(zone);
|
var zoneRight = new SelectedStatuButton()
|
{
|
X = Application.GetRealWidth(1080 - 150),
|
Width = Application.GetMinRealAverage(110),
|
Height = Application.GetMinRealAverage(110),
|
UnSelectedImagePath = "Item/Next.png",
|
SelectedImagePath="Item/NextSelected.png",
|
Gravity = Gravity.CenterVertical
|
};
|
zoneFL.AddChidren(zoneRight);
|
var zoneLine = new Button()
|
{
|
Y = zone.Bottom,
|
Height = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
zoneFL.AddChidren(zoneLine);
|
|
var modelFL = new FrameLayout()
|
{
|
Y = zoneFL.Bottom,
|
Height = Application.GetRealHeight(170),
|
};
|
midFL.AddChidren(modelFL);
|
var modelTip = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Height = Application.GetRealHeight(70),
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12,
|
TextColor = ZigbeeColor.Current.GXCButtonTipColor,
|
TextID = R.MyInternationalizationString.BelongModel,
|
};
|
modelFL.AddChidren(modelTip);
|
var model = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Y = deviceNameTip.Bottom,
|
Height = Application.GetRealHeight(100) - 1,
|
Width = Application.GetRealWidth(900),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Text = device.CommonDevice.DeviceName==""?Language.StringByID(R.MyInternationalizationString.UNKnown):device.CommonDevice.DeviceName
|
};
|
modelFL.AddChidren(model);
|
var modelLine = new Button()
|
{
|
Y = model.Bottom,
|
Height = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
modelFL.AddChidren(modelLine);
|
|
var sharedFL = new FrameLayout()
|
{
|
Y = modelFL.Bottom,
|
Height = Application.GetRealHeight(170),
|
};
|
//midFL.AddChidren(sharedFL);
|
var sharedBtn = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Y = Application.GetRealHeight(70),
|
Height = Application.GetRealHeight(100) - 1,
|
Width = Application.GetRealWidth(500),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextID = R.MyInternationalizationString.Shared
|
};
|
sharedFL.AddChidren(sharedBtn);
|
|
var sharedRight = new Button()
|
{
|
X = Application.GetRealWidth(1080 - 150),
|
Width = Application.GetMinRealAverage(110),
|
Height = Application.GetMinRealAverage(110),
|
UnSelectedImagePath = "Item/Next.png",
|
Gravity = Gravity.CenterVertical
|
};
|
sharedFL.AddChidren(sharedRight);
|
|
var sharedNum = new Button()
|
{
|
X = Application.GetRealWidth(1080 - 150 - 110),
|
Width = Application.GetRealWidth(110),
|
Height = Application.GetRealHeight(110),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = 12,
|
TextColor = ZigbeeColor.Current.GXCButtonTipColor,
|
Text = "1人",
|
Gravity = Gravity.CenterVertical
|
};
|
sharedFL.AddChidren(sharedNum);
|
|
var sharedLine = new Button()
|
{
|
Y = sharedBtn.Bottom,
|
Height = 1,
|
BackgroundColor = ZigbeeColor.Current.GXCLineColor
|
};
|
sharedFL.AddChidren(sharedLine);
|
|
var confirmBtn = new CommonForm.CompleteButton()
|
{
|
};
|
AddChidren(confirmBtn);
|
|
confirmBtn.MouseUpEventHandler += async (sender, e) =>
|
{
|
if (device.CommonDevice == null)
|
{
|
CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
|
return;
|
}
|
var result = await Shared.Common.LocalDevice.Current.ReName(device.CommonDevice, deviceName.Text.Trim());
|
if (result)
|
{
|
var alertSuccess = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.Success), Language.StringByID(R.MyInternationalizationString.Confrim));
|
alertSuccess.Show();
|
alertSuccess.ResultEventHandler += (senderSuccess, eSuccess) =>
|
{
|
//改图片
|
device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath;
|
device.CommonDevice.IsCustomizeImage = true;
|
device.CommonDevice.ReSave();
|
//改房间
|
Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, RoomNameList);
|
RemoveFromParent();
|
};
|
}
|
else
|
{
|
return;
|
//CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
|
}
|
};
|
#endregion
|
|
#region event
|
EventHandler<MouseEventArgs> selectZoneEvent = (sender, e) =>
|
{
|
UserCenter.SelectRoomForm selectedRoom = new UserCenter.SelectRoomForm();
|
selectedRoom.AddForm(selectedRoom, RoomNameList);
|
selectedRoom.ActionSelectRoom += ((rList) =>
|
{
|
RoomNameList = rList;
|
zone.Text = Shared.Common.Room.CurrentRoom.GetRoomName(RoomNameList);
|
});
|
};
|
zoneRight.MouseUpEventHandler += selectZoneEvent;
|
zoneFL.MouseUpEventHandler += selectZoneEvent;
|
zone.MouseUpEventHandler += selectZoneEvent;
|
|
EventHandler<MouseEventArgs> selectDeviceIconEvent = (sender, e) =>
|
{
|
var localPic = new DeviceIconSelectedIMGByLocal();
|
UserView.HomePage.Instance.AddChidren(localPic);
|
UserView.HomePage.Instance.PageIndex += 1;
|
localPic.Show();
|
localPic.action = (unSelectedImagePath,selectedImagePath) =>
|
{
|
deviceIMG.UnSelectedImagePath = unSelectedImagePath;
|
deviceIMG.SelectedImagePath = selectedImagePath;
|
};
|
};
|
deviceIMG.MouseUpEventHandler += selectDeviceIconEvent;
|
|
#endregion
|
}
|
}
|
}
|