|
using System;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
/// <summary>
|
/// 功能分配房间界面
|
/// </summary>
|
public partial class GroupChooseRoomPage : FrameLayout
|
{
|
#region 控件列表
|
FrameLayout bodyView;
|
/// <summary>
|
/// 内容加载区域
|
/// </summary>
|
VerticalScrolViewLayout contentView;
|
|
Button btnAllRoomText;
|
Button btnChooseAll;
|
|
#endregion
|
|
#region 局部变量
|
|
GroupControl function
|
;
|
/// <summary>
|
/// 回调事件
|
/// </summary>
|
Action backAction;
|
#endregion
|
|
public GroupChooseRoomPage(GroupControl groupControl, Action action)
|
{
|
bodyView = this;
|
this.function = groupControl;
|
backAction = action;
|
}
|
|
public override void RemoveFromParent()
|
{
|
new System.Threading.Thread(() =>
|
{
|
Application.RunOnMainThread(() =>
|
{
|
backAction?.Invoke();
|
});
|
})
|
{ IsBackground = true }.Start();
|
base.RemoveFromParent();
|
}
|
|
/// <summary>
|
/// 加载页面
|
/// </summary>
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView();
|
|
|
|
var contentView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(667 - 64),
|
};
|
bodyView.AddChidren(contentView);
|
|
var allRoomView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(allRoomView);
|
|
btnChooseAll = new Button()
|
{
|
X = Application.GetRealWidth(331),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "Public/ChooseIcon.png",
|
SelectedImagePath = "Public/ChooseOnIcon.png",
|
IsSelected = true
|
};
|
allRoomView.AddChidren(btnChooseAll);
|
|
btnAllRoomText = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextID = StringId.All,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
allRoomView.AddChidren(btnAllRoomText);
|
|
|
foreach (var room in SpatialInfo.CurrentSpatial.RoomList)
|
{
|
var roomView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Tag = "row"
|
};
|
contentView.AddChidren(roomView);
|
|
var btnLine = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Height = Application.GetMinReal(1),
|
Width = Application.GetRealWidth(343),
|
BackgroundColor = CSS_Color.DividingLineColor,
|
};
|
roomView.AddChidren(btnLine);
|
|
Button btnChoose = new Button()
|
{
|
X = Application.GetRealWidth(331),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "Public/ChooseIcon.png",
|
SelectedImagePath = "Public/ChooseOnIcon.png",
|
IsSelected = function.roomIds.Contains(room.roomId),
|
Tag = "ChooseIcon"
|
};
|
roomView.AddChidren(btnChoose);
|
|
Button btnRoomText = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
//Width = Application.GetRealWidth(280),
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = room.floorName + room.roomName,
|
};
|
roomView.AddChidren(btnRoomText);
|
btnRoomText.MouseUpEventHandler = (sender, e) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
LoadEvent_RoomSelected(room, btnChoose.IsSelected);
|
};
|
|
if (!function.roomIds.Contains(room.roomId) && btnChooseAll.IsSelected)
|
{
|
btnChooseAll.IsSelected = false;
|
}
|
|
}
|
|
LoadEventLoad();
|
}
|
}
|
/// <summary>
|
/// 功能分配房间BLL
|
/// </summary>
|
public partial class GroupChooseRoomPage
|
{
|
/// <summary>
|
/// 加载事件列表
|
/// </summary>
|
void LoadEventLoad()
|
{
|
LoadMethod_AllElection();
|
}
|
|
/// <summary>
|
/// 全选按钮事件
|
/// </summary>
|
void LoadMethod_AllElection()
|
{
|
btnAllRoomText.MouseUpEventHandler += (sender, e) =>
|
{
|
btnChooseAll.IsSelected = !btnChooseAll.IsSelected;
|
|
for (int i = 0; i < contentView.ChildrenCount; i++)
|
{
|
var view = contentView.GetChildren(i);
|
if (view.GetType() == typeof(FrameLayout))
|
{
|
if (view.Tag != null && view.Tag.ToString() == "row")
|
{
|
for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++)
|
{
|
var btn = (view as FrameLayout).GetChildren(j);
|
if (btn.GetType() == typeof(Button))
|
{
|
if (btn.Tag != null && btn.Tag.ToString() == "ChooseIcon")
|
{
|
(btn as Button).IsSelected = btnChooseAll.IsSelected;
|
}
|
}
|
}
|
}
|
}
|
}
|
function.roomIds.Clear();
|
if (btnChooseAll.IsSelected)
|
{
|
foreach (var room in Entity.SpatialInfo.CurrentSpatial.RoomList)
|
{
|
if (btnChooseAll.IsSelected)
|
{
|
function.roomIds.Add(room.roomId);
|
}
|
}
|
}
|
};
|
}
|
|
/// <summary>
|
/// 房间选中事件
|
/// </summary>
|
void LoadEvent_RoomSelected(Entity.Room room, bool isAdd)
|
{
|
if (isAdd)
|
{
|
function.roomIds.Add(room.roomId);
|
}
|
else
|
{
|
function.roomIds.Remove(room.roomId);
|
}
|
|
|
if (function.roomIds.Count == SpatialInfo.CurrentSpatial.RoomList.Count)
|
{
|
btnChooseAll.IsSelected = true;
|
}
|
else
|
{
|
btnChooseAll.IsSelected = false;
|
}
|
}
|
|
}
|
}
|