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)
|
{
|
if (string.IsNullOrEmpty(room.name))
|
{
|
new Tip()
|
{
|
CloseTime = 3,
|
Text = Language.StringByID(StringId.RoomNameCannotBeEmpty),
|
Direction = AMPopTipDirection.None,
|
}.Show(bodyView);
|
return;
|
}
|
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);
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
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) =>
|
{
|
//房间名称不能为空
|
if (string.IsNullOrEmpty(str))
|
{
|
new Tip()
|
{
|
CloseTime = 3,
|
Text = Language.StringByID(StringId.RoomNameCannotBeEmpty),
|
Direction = AMPopTipDirection.None,
|
}.Show(bodyView);
|
return;
|
}
|
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);
|
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) =>
|
{
|
pictureOptionView.RemoveFromParent();
|
};
|
btnTakePicture.MouseDownEventHandler = (sender, e) => {
|
btnTakePicture.IsSelected = true;
|
};
|
btnTakePicture.MouseUpEventHandler = (sender, e) =>
|
{
|
btnTakePicture.IsSelected = false;
|
var pid = Guid.NewGuid();
|
CropImage.TakePicture((imagePath) =>
|
{
|
if (imagePath != null)
|
{
|
btnRoomBg.UnSelectedImagePath = imagePath.ToString();
|
room.backgroundImage = btnRoomBg.UnSelectedImagePath;
|
MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
|
}
|
}, pid.ToString(), 16, 9);
|
if (pageTitleId == StringId.EditRoomInfo)
|
{
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
}
|
pictureOptionView.RemoveFromParent();
|
};
|
btnAlbum.MouseDownEventHandler = (sender, e) => {
|
btnAlbum.IsSelected = true;
|
};
|
|
btnAlbum.MouseUpEventHandler = (sender, e) =>
|
{
|
btnAlbum.IsSelected = false;
|
var pid = Guid.NewGuid();
|
CropImage.SelectPicture((imagePath) =>
|
{
|
if (imagePath != null)
|
{
|
btnRoomBg.UnSelectedImagePath = imagePath.ToString();
|
room.backgroundImage = btnRoomBg.UnSelectedImagePath;
|
MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath);
|
#if DEBUG
|
new Tip() { CloseTime = 5, Text = imagePath }.Show(MainPage.BasePageView);
|
#endif
|
}
|
}, pid.ToString(), 16, 9);
|
if (pageTitleId == StringId.EditRoomInfo)
|
{
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
}
|
pictureOptionView.RemoveFromParent();
|
};
|
}
|
}
|
}
|