using System;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
public partial class ResidentialManagePage : FrameLayout
{
#region 区域控件列表
FrameLayout bodyView;
///
/// 住宅名称显示按钮
///
Button btnResidenceName;
///
/// 住宅名称编辑按钮
///
Button btnEditResidenceNameIcon;
///
/// 住宅地址编辑按钮
///
Button btnLocationAddressIcon;
///
/// 住宅地址
///
Button btnResidenceAddress;
///
/// 楼层管理Row
///
FrameLayout floorManagementRow;
///
/// 楼层管理跳转按钮
///
Button btnFloorManagementSkinIcon;
///
/// 楼层名称显示按钮
///
Button btnFloorManagementTitle;
///
/// 房间管理Row
///
FrameLayout roomManagementRow;
///
/// 房间管理跳转按钮
///
Button btnRoomManagementSkinIcon;
///
/// 房间名称
///
Button btnRoomManagementTitle;
///
/// 调试权限开关按钮
///
Button btnCommissioningAuthoritySwitchIcon;
#region 管理员权限迁移
FrameLayout administratorPermissionMigrationRow;
Button btnAdministratorPermissionMigrationTitle;
Button btnAdministratorPermissionMigrationExplan;
Button btnAdministratorPermissionMigrationSkinIcon;
#endregion
#region 过户
///
///
///
FrameLayout transferRow;
///
///
///
Button btnTransferTitle;
///
///
///
Button btnTrasferExplan;
///
///
///
Button btnTrasferSkinIcon;
#endregion
#endregion
///
/// 更新住宅名称的回调函数
///
Action upateResidenceName;
public ResidentialManagePage(Action action)
{
bodyView = this;
upateResidenceName = action;
}
public void LoadPage()
{
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
var topView = new TopViewDiv(bodyView, Language.StringByID(StringId.ResidenceManage));
topView.maginY = 10;
topView.LoadTopView();
VerticalScrolViewLayout contentView = new VerticalScrolViewLayout()
{
Y = Application.GetRealHeight(64+10),
Height = Application.GetRealHeight(667 - 64-10),
ScrollEnabled = false,
};
bodyView.AddChidren(contentView);
#region 住宅名称
FrameLayout residenceNameRow;
residenceNameRow = new FrameLayout()
{
Y = Application.GetRealHeight(72),
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(residenceNameRow);
Button btnResidenceNameTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(78),
TextID = StringId.ResidenceName,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
residenceNameRow.AddChidren(btnResidenceNameTitle);
btnResidenceName = new Button()
{
X = Application.GetRealWidth(2) + btnResidenceNameTitle.Right,
Width = Application.GetRealWidth(200),
Text = DB_ResidenceData.Instance.CurrentRegion.homeName,
TextSize = CSS_FontSize.TextFontSize,
TextAlignment = TextAlignment.CenterLeft,
TextColor = CSS_Color.TextualColor,
};
residenceNameRow.AddChidren(btnResidenceName);
btnEditResidenceNameIcon = new Button()
{
X = Application.GetRealWidth(333),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(28),
Height = Application.GetMinRealAverage(28),
UnSelectedImagePath = "Public/Edit.png",
};
residenceNameRow.AddChidren(btnEditResidenceNameIcon);
#endregion
residenceNameRow.AddChidren(
new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(49),
Height = Application.GetRealHeight(1),
Width = Application.GetRealWidth(343),
BackgroundColor = CSS_Color.DividingLineColor,
});
#region 住宅地址
var residenceAddressRow = new FrameLayout()
{
Y = residenceNameRow.Bottom,
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(residenceAddressRow);
var btnResidenceAddressTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(78),
TextID = StringId.ResidenceAddress,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
residenceAddressRow.AddChidren(btnResidenceAddressTitle);
btnLocationAddressIcon = new Button()
{
X = Application.GetRealWidth(333),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(28),
Height = Application.GetMinRealAverage(28),
//UnSelectedImagePath = "Public/LocationAddressIcon.png",
UnSelectedImagePath = "Public/Edit.png",
};
residenceAddressRow.AddChidren(btnLocationAddressIcon);
btnResidenceAddress = new Button()
{
X = Application.GetRealWidth(2) + btnResidenceNameTitle.Right,
Width = Application.GetRealWidth(200),
Text = DB_ResidenceData.Instance.CurrentRegion.homeAddress,
TextSize = CSS_FontSize.TextFontSize,
TextAlignment = TextAlignment.CenterLeft,
TextColor = CSS_Color.TextualColor,
};
residenceAddressRow.AddChidren(btnResidenceAddress);
#endregion
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
#region 楼层管理
floorManagementRow = new FrameLayout()
{
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(floorManagementRow);
btnFloorManagementTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(308),
TextID = StringId.FloorsManagement,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
floorManagementRow.AddChidren(btnFloorManagementTitle);
btnFloorManagementSkinIcon = new Button()
{
X = Application.GetRealWidth(343),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/RightIcon.png",
};
floorManagementRow.AddChidren(btnFloorManagementSkinIcon);
floorManagementRow.AddChidren(
new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(49),
Height = Application.GetRealHeight(1),
Width = Application.GetRealWidth(343),
BackgroundColor = CSS_Color.DividingLineColor,
});
#endregion
#region 房间管理
roomManagementRow = new FrameLayout()
{
Y = floorManagementRow.Bottom,
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(roomManagementRow);
btnRoomManagementTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(300),
TextID = StringId.RoomsManagement,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
roomManagementRow.AddChidren(btnRoomManagementTitle);
btnRoomManagementSkinIcon = new Button()
{
X = Application.GetRealWidth(343),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/RightIcon.png",
};
roomManagementRow.AddChidren(btnRoomManagementSkinIcon);
#endregion
//已经交付
if (DB_ResidenceData.Instance.CurrentRegion.deliverStatus == "Delivered" || DB_ResidenceData.Instance.CurrentRegion.deliverStatus == "SECONDARY_DEBUGGIN")
{
if (DB_ResidenceData.Instance.CurrentRegion.deliverStatus != "SECONDARY_DEBUGGIN")
{
#region 管理员权限迁移
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
administratorPermissionMigrationRow = new FrameLayout()
{
Height = Application.GetRealHeight(65),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false)
{
//是主账号本人才能显示这个菜单
contentView.AddChidren(administratorPermissionMigrationRow);
}
btnAdministratorPermissionMigrationTitle = new Button()
{
X = Application.GetRealWidth(16),
Y = Application.GetRealHeight(10),
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(24),
TextID = StringId.AdministratorPermissionMigration,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
administratorPermissionMigrationRow.AddChidren(btnAdministratorPermissionMigrationTitle);
btnAdministratorPermissionMigrationExplan = new Button()
{
X = Application.GetRealWidth(16),
Y = btnAdministratorPermissionMigrationTitle.Bottom,
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(21),
TextID = StringId.AdministratorPermissionMigrationExPlan,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
TextColor = CSS_Color.PromptingColor1,
};
administratorPermissionMigrationRow.AddChidren(btnAdministratorPermissionMigrationExplan);
btnAdministratorPermissionMigrationSkinIcon = new Button()
{
X = Application.GetRealWidth(343),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/RightIcon.png",
};
administratorPermissionMigrationRow.AddChidren(btnAdministratorPermissionMigrationSkinIcon);
administratorPermissionMigrationRow.AddChidren(
new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(1),
Width = Application.GetRealWidth(343),
BackgroundColor = CSS_Color.DividingLineColor,
});
#endregion
#region 过户
transferRow = new FrameLayout()
{
Y = administratorPermissionMigrationRow.Bottom,
Height = Application.GetRealHeight(65),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
//有网关才能过户
if (DB_ResidenceData.Instance.HomeGateway != null && string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId) == false
&& DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false)
{
contentView.AddChidren(transferRow);
}
btnTransferTitle = new Button()
{
X = Application.GetRealWidth(16),
Y = Application.GetRealHeight(10),
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(24),
TextID = StringId.Transfer,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
transferRow.AddChidren(btnTransferTitle);
btnTrasferExplan = new Button()
{
X = Application.GetRealWidth(16),
Y = btnTransferTitle.Bottom,
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(21),
TextID = StringId.TransferExPlan,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
TextColor = CSS_Color.PromptingColor1,
};
transferRow.AddChidren(btnTrasferExplan);
btnTrasferSkinIcon = new Button()
{
X = Application.GetRealWidth(343),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/RightIcon.png",
};
transferRow.AddChidren(btnTrasferSkinIcon);
#endregion
LoadEvent_SkipAdminMigrationConfirmPage();
LoadEvent_SkipTransferConfirmPage();
var btnRollBack = new Button()
{
Y = Application.GetRealHeight(623),
Height = Application.GetRealHeight(50),
TextAlignment = TextAlignment.Center,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.AuxiliaryColor2,
TextID = StringId.RollBack,
BackgroundColor = CSS_Color.MainBackgroundColor,
};
bodyView.AddChidren(btnRollBack);
if (MainPage.Increase)
{
btnRollBack.Y = Application.GetRealHeight(613);
btnRollBack.Height = Application.GetRealHeight(50);
bodyView.AddChidren(new Button() { Y = Application.GetRealHeight(663), Height = Application.GetRealHeight(20), BackgroundColor = CSS_Color.MainBackgroundColor });
}
btnRollBack.MouseUpEventHandler += (sender, e) =>
{
Action okAction = () =>
{
var waitPage = new Loading();
this.AddChidren(waitPage);
waitPage.Start("");
new System.Threading.Thread(() => {
try
{
var pack = Common.ApiUtlis.Ins.HttpRequest.RollBack();
Application.RunOnMainThread(() =>
{
if (pack != null)
{
if (pack.Code == StateCode.SUCCESS)
{
new PublicAssmebly().TipMsg(StringId.Tip, StringId.SuccessfullyUnboundTheResidence, () =>
{
Common.ApiUtlis.Ins.HttpRequest.GetHomePager();
});
}
else
{
IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
}
}
});
}
catch (Exception ex)
{
MainPage.Log($"住宅回滚异常:{ex.Message}");
}
finally
{
Application.RunOnMainThread(() =>
{
try
{
waitPage.Hide();
waitPage.RemoveFromParent();
waitPage = null;
}
catch { }
});
}
})
{ IsBackground = true }.Start();
};
new ConfirmDialog().ShowDialog(StringId.Tip, StringId.RollBackTipMsg, okAction);
};
}
#region 调试权限
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
FrameLayout commissioningAuthorityRow;
commissioningAuthorityRow = new FrameLayout()
{
Height = Application.GetRealHeight(65),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(commissioningAuthorityRow);
var btnCommissioningAuthorityTitle = new Button()
{
X = Application.GetRealWidth(16),
Y = Application.GetRealHeight(10),
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(24),
TextID = StringId.CommissioningAuthority,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
commissioningAuthorityRow.AddChidren(btnCommissioningAuthorityTitle);
var btnCommissioningAuthorityExplan = new Button()
{
X = Application.GetRealWidth(16),
Y = btnCommissioningAuthorityTitle.Bottom,
Width = Application.GetRealWidth(308),
Height = Application.GetRealHeight(21),
TextID = StringId.CommissioningAuthorityExPlan,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
TextColor = CSS_Color.PromptingColor1,
};
commissioningAuthorityRow.AddChidren(btnCommissioningAuthorityExplan);
btnCommissioningAuthoritySwitchIcon = new Button()
{
X = Application.GetRealWidth(314),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(48),
Height = Application.GetMinRealAverage(36),
UnSelectedImagePath = "Public/Switch.png",
SelectedImagePath = "Public/SwitchOn.png",
IsSelected = DB_ResidenceData.Instance.CurrentRegion.debugPerm
};
commissioningAuthorityRow.AddChidren(btnCommissioningAuthoritySwitchIcon);
btnCommissioningAuthoritySwitchIcon.MouseUpEventHandler = (sender, e) =>
{
DB_ResidenceData.Instance.CurrentRegion.debugPerm = !DB_ResidenceData.Instance.CurrentRegion.debugPerm;
btnCommissioningAuthoritySwitchIcon.IsSelected = DB_ResidenceData.Instance.CurrentRegion.debugPerm;
var waitPage = new Loading();
bodyView.AddChidren(waitPage);
waitPage.Start("");
new System.Threading.Thread(() =>
{
try
{
var pack = new DAL.Server.HttpServerRequest().ChangeResidenceDebugPerm(DB_ResidenceData.Instance.CurrentRegion.debugPerm);
if (pack != null)
{
if (pack.Code == DAL.Server.StateCode.SUCCESS)
{
DB_ResidenceData.Instance.CurrentRegion.debugStatus = DB_ResidenceData.Instance.CurrentRegion.debugPerm ? "SECONDARY_DEBUGGIN" : "Delivered";
Application.RunOnMainThread(() =>
{
bodyView.RemoveAll();
LoadPage();
});
}
else
{
Application.RunOnMainThread(() => {
IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
});
}
}
}catch(Exception ex)
{
}
finally
{
Application.RunOnMainThread(() => {
waitPage.Hide();
});
}
})
{ IsBackground = true }.Start();
};
#endregion
}
//调试完成 才能加载二维码
else if (DB_ResidenceData.Instance.CurrentRegion.deliverStatus == "WAIT_DELIVERED")
{
#region 交付二维码
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
var deliveryQRcodeRow = new FrameLayout()
{
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(deliveryQRcodeRow);
var btnDeliveryQRcodeTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(308),
TextID = StringId.ResidentialDelivery,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
deliveryQRcodeRow.AddChidren(btnDeliveryQRcodeTitle);
var btnDeliveryQRcodeRightIcon = new Button()
{
X = Application.GetRealWidth(343),
Gravity = Gravity.CenterVertical,
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
UnSelectedImagePath = "Public/RightIcon.png",
};
deliveryQRcodeRow.AddChidren(btnDeliveryQRcodeRightIcon);
EventHandler eventHandler = (sender, e) =>
{
var skipPage = new DeliveryQrCodePage();
MainPage.BasePageView.AddChidren(skipPage);
skipPage.LoadPage();
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
deliveryQRcodeRow.MouseUpEventHandler = eventHandler;
btnDeliveryQRcodeTitle.MouseUpEventHandler = eventHandler;
btnDeliveryQRcodeRightIcon.MouseUpEventHandler = eventHandler;
#endregion
}
else
{
#region 房屋状态提示
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
var houseStatusTipRow = new FrameLayout()
{
Height = Application.GetRealHeight(50),
BackgroundColor = CSS_Color.MainBackgroundColor,
};
contentView.AddChidren(houseStatusTipRow);
var btnHouseStatusTipTitle = new Button()
{
X = Application.GetRealWidth(16),
Width = Application.GetRealWidth(308),
TextID = StringId.HouseStatus,
TextAlignment = TextAlignment.CenterLeft,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
houseStatusTipRow.AddChidren(btnHouseStatusTipTitle);
switch (DB_ResidenceData.Instance.CurrentRegion.deliverStatus)
{
case "To_Be_Debugged"://待调试
btnHouseStatusTipTitle.Text += " : "+ Language.StringByID(StringId.To_Be_Debugged);
break;
case "Debugging"://调试中
btnHouseStatusTipTitle.Text += " : " + Language.StringByID(StringId.Debugging);
break;
case "INITIAL_TATE"://初始态
btnHouseStatusTipTitle.Text += " : " + Language.StringByID(StringId.INITIAL_TATE);
break;
case "ACCEPTANCE"://验收
btnHouseStatusTipTitle.Text += " : " + Language.StringByID(StringId.ACCEPTANCE);
break;
case "To_Be_Accepted"://待验收
btnHouseStatusTipTitle.Text += " : " + Language.StringByID(StringId.To_Be_Accepted);
break;
default:
btnHouseStatusTipTitle.Text += " : " + Language.StringByID(StringId.INITIAL_TATE);
break;
}
#endregion
}
LoadEventList();
}
}
}