using System;
using System.Collections.Generic;
using System.Globalization;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
public class DeviceDetailInfo : FrameLayout
{
#region ◆ 变量____________________________
///
/// bodyFrameLayout
///
private FrameLayout bodyFrameLayout;
///
/// 所属区域
///
private string roomName;
///
/// action
///
public Action action;
#endregion
#region ◆ 移除____________________________
///
/// RemoveFromParent
///
public override void RemoveFromParent()
{
action();
base.RemoveFromParent();
}
#endregion
#region ◆ 构造方法_________________________
///
/// DeviceDetailInfo
///
public DeviceDetailInfo()
{
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
}
#endregion
#region ◆ 显示界面_________________________
///
/// Show
///
///
///
public void Show(DeviceUI device, Common.Room room)
{
Init(device);
AddTop();
AddBodyView(device);
}
#endregion
#region Add____________________________________
///
/// AddTop
///
public void AddTop()
{
var top = new TopFrameLayout();
AddChidren(top);
top.InitTopview();
top.SetTopTitle(R.MyInternationalizationString.FunctionSetting);
top.backButton.MouseUpEventHandler += (sender, e) =>
{
RemoveFromParent();
};
}
///
/// AddBodyView
///
public void AddBodyView(DeviceUI device)
{
bodyFrameLayout = new FrameLayout()
{
Y = Application.GetRealHeight(184),
Height = Application.GetRealHeight(1737),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
};
AddChidren(bodyFrameLayout);
var deviceBG = new Button()
{
Y = Application.GetRealHeight(118),
Width = Application.GetMinRealAverage(207),
Height = Application.GetMinRealAverage(207),
Gravity = Gravity.CenterHorizontal,
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
Radius=(uint)Application.GetMinRealAverage(207)
};
bodyFrameLayout.AddChidren(deviceBG);
var deviceBG2 = new Button()
{
Y = Application.GetRealHeight(130),
Width = Application.GetMinRealAverage(184),
Height = Application.GetMinRealAverage(184),
Gravity = Gravity.CenterHorizontal,
BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
Radius = (uint)Application.GetMinRealAverage(184)
};
bodyFrameLayout.AddChidren(deviceBG2);
var deviceIMG = new Button()
{
Y = Application.GetRealHeight(161),
Width = Application.GetMinRealAverage(124),
Height = Application.GetMinRealAverage(124),
UnSelectedImagePath = device.IconPath,
Gravity = Gravity.CenterHorizontal
};
bodyFrameLayout.AddChidren(deviceIMG);
var deviceTypeName = new Button()
{
Y = Application.GetRealHeight(360),
Width = Application.GetRealWidth(900),
Height = Application.GetRealHeight(80),
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
Text = DeviceUI.GetDeviceTypeName(device.CommonDevice.Type),
Gravity = Gravity.CenterHorizontal
};
bodyFrameLayout.AddChidren(deviceTypeName);
var infoFL = new FrameLayout
{
Y = Application.GetRealHeight(540),
Height = Application.GetRealHeight(1195),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
bodyFrameLayout.AddChidren(infoFL);
var tipBtn = new Button
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Y = Application.GetRealHeight(81),
Width = Application.GetRealWidth(500),
Height = Application.GetRealHeight(60),
TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
TextAlignment = TextAlignment.CenterLeft,
TextSize = 15,
TextID = R.MyInternationalizationString.EditInfo
};
infoFL.AddChidren(tipBtn);
var nameRow = new DeviceInfoEditRow(170);
nameRow.Init();
nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : ");
nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceEpointName);
infoFL.AddChidren(nameRow);
var zoneRow = new DeviceInfoRow(308);
zoneRow.Init();
zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)} : ");
zoneRow.SetTitle(roomName);
infoFL.AddChidren(zoneRow);
var modelRow = new DeviceInfoRow(446);
modelRow.Init();
modelRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongModel)} : ");
modelRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName);
infoFL.AddChidren(modelRow);
var sharedRow = new DeviceInfoRow(585);
sharedRow.Init();
sharedRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.Share)} : ");
sharedRow.SetTitle("2人");
infoFL.AddChidren(sharedRow);
var confirmBtn = new CommonForm.CompleteButton(962, 907, 127);
confirmBtn.SetTitle(R.MyInternationalizationString.Confrim);
infoFL.AddChidren(confirmBtn);
#region event
EventHandler 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 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;
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.IconPath = deviceIMG.UnSelectedImagePath;
// device.IsCustomizeImage = true;
// device.ReSave();
// //改房间
// Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, roomNameList);
// RemoveFromParent();
// };
//}
//else
//{
// return;
// //CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
//}
};
#endregion
}
///
/// Init
///
///
public void Init(DeviceUI device)
{
roomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device.CommonDevice);
}
#endregion
}
}