using System;
|
using Shared;
|
using HDL_ON.Entity;
|
|
namespace HDL_ON.UI
|
{
|
public partial class RoomEditPage
|
{
|
/// <summary>
|
/// 加载事件列表
|
/// </summary>
|
void LoadEventList()
|
{
|
LoadEvent_PictureOptionView();
|
LoadEvent_EditRoomName();
|
LoadEvent_SkinBindFloor();
|
LoadEvent_SkipEditFunctionList();
|
LoadEvent_Option();
|
}
|
|
/// <summary>
|
/// 底部按钮事件
|
/// </summary>
|
void LoadEvent_Option()
|
{
|
btnOption.MouseUpEventHandler += (sender, e) =>
|
{
|
if (btnOption.TextID == StringId.Save)
|
{
|
foreach (var tempRoom in DB_ResidenceData.residenceData.rooms)
|
{
|
if (room.name == tempRoom.name)
|
{
|
new PublicAssmebly().TipMsg(StringId.Tip, StringId.AddingFailed_RoomAlreadyExists);
|
return;
|
}
|
}
|
room.sid = Guid.NewGuid().ToString();
|
DB_ResidenceData.residenceData.rooms.Add(room);
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
backAction();
|
this.RemoveFromParent();
|
}
|
if (btnOption.TextID == StringId.DeleteRoom)
|
{
|
Action action = () =>
|
{
|
foreach (var f in DB_ResidenceData.residenceData.functionList.functions)
|
{
|
if (f.roomIdList.Contains(room.sid))
|
{
|
f.roomIdList.Remove(room.sid);
|
room.sid = "";
|
}
|
}
|
DB_ResidenceData.residenceData.rooms.Remove(room);
|
backAction();
|
this.RemoveFromParent();
|
};
|
new PublicAssmebly().TipMsg(StringId.Tip, StringId.DeleteRoomTip, action);
|
};
|
};
|
}
|
|
/// <summary>
|
/// 显示背景图选择选项
|
/// </summary>
|
void LoadEvent_PictureOptionView()
|
{
|
btnRoomBg.MouseUpEventHandler = (sender, e) =>
|
{
|
LoadPictureOptionView();
|
};
|
}
|
|
/// <summary>
|
/// 加载修改房间名称窗口事件
|
/// </summary>
|
void LoadEvent_EditRoomName()
|
{
|
Action<string> callBack = (str) =>
|
{
|
btnRoomName.Text = btnTipRoomName.Text = str;
|
room.name = str;
|
if (pageTitleId == StringId.EditRoomInfo)
|
{
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
}
|
};
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
new PublicAssmebly().LoadDialog_EditParater(StringId.RoomName, room.name, callBack);
|
};
|
btnEditRoomNameIcon.MouseUpEventHandler = eventHandler;
|
roomNameRow.MouseUpEventHandler = eventHandler;
|
btnRoomName.MouseUpEventHandler = eventHandler;
|
}
|
|
/// <summary>
|
/// 跳转绑定楼层界面
|
/// </summary>
|
void LoadEvent_SkinBindFloor()
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
Action floorsCallBackAction = () =>
|
{
|
btnFloorInfo.Text = room.floor;
|
};
|
var residentialManagePage = new FloorsManagementPage(floorsCallBackAction);
|
MainPage.BasePageView.AddChidren(residentialManagePage);
|
residentialManagePage.LoadPage(room);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
btnFloorInfo.MouseUpEventHandler = eventHandler;
|
floorView.MouseUpEventHandler = eventHandler;
|
}
|
|
/// <summary>
|
/// 跳转到编辑房间功能界面
|
/// </summary>
|
void LoadEvent_SkipEditFunctionList()
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
|
var residentialManagePage = new RoomEditFunctionPage(room.sid);
|
MainPage.BasePageView.AddChidren(residentialManagePage);
|
residentialManagePage.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
btnFunctionManagementRight.MouseUpEventHandler = eventHandler;
|
functionManagemantView.MouseUpEventHandler = eventHandler;
|
}
|
|
|
/// <summary>
|
/// 加载背景图选择区域事件列表
|
/// </summary>
|
void LoadEvent_PictureOptionViewEventList()
|
{
|
pictureOptionView.MouseUpEventHandler = (sender, e) =>
|
{
|
pictureOptionView.RemoveFromParent();
|
};
|
|
btnCancel.MouseUpEventHandler = (sender, e) => {
|
//optionView.Animate = Animate.UpToDown;
|
//btnCancel.Animate = Animate.UpToDown;
|
//new System.Threading.Thread(() =>
|
//{
|
//System.Threading.Thread.Sleep(500);
|
//Application.RunOnMainThread(() =>
|
//{
|
pictureOptionView.RemoveFromParent();
|
//});
|
//})
|
//{ IsBackground = true }.Start();
|
};
|
|
btnTakePicture.MouseUpEventHandler = (sender, e) => {
|
var pid = Guid.NewGuid();
|
Camera.TakePicture((obj) => {
|
if (obj == null)
|
return;
|
btnRoomBg.UnSelectedImagePath = pid.ToString();
|
},pid.ToString(),false);
|
if(pageTitleId == StringId.EditRoomInfo)
|
{
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
}
|
};
|
|
btnAlbum.MouseUpEventHandler = (sender, e) => {
|
var pid = Guid.NewGuid();
|
Camera.SelectPicture((obj) => {
|
if (obj == null)
|
return;
|
btnRoomBg.UnSelectedImagePath = pid.ToString();
|
}, pid.ToString(), false);
|
if (pageTitleId == StringId.EditRoomInfo)
|
{
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
}
|
};
|
|
|
}
|
}
|
}
|