using Shared.Phone.UserCenter;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace Shared.Phone.MainPage.Controls
|
{
|
/// <summary>
|
/// 左滑的房间列表界面里面的房间卡片控件
|
/// </summary>
|
public class ListRoomCardControl : FrameLayoutControl
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 房间ID
|
/// </summary>
|
private string roomId = string.Empty;
|
/// <summary>
|
/// 房间图片控件
|
/// </summary>
|
private ImageView picRoom = null;
|
/// <summary>
|
/// 房间名称控件
|
/// </summary>
|
private NormalViewControl btnRoomName = null;
|
/// <summary>
|
/// 房间名字的背景
|
/// </summary>
|
private NormalViewControl btnRoomNameBackGroud = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 左滑的房间列表界面里面的房间卡片控件
|
/// </summary>
|
public ListRoomCardControl()
|
{
|
this.Width = Application.GetRealWidth(495);
|
this.Height = Application.GetRealHeight(354);
|
}
|
|
/// <summary>
|
/// 初始化房间卡片控件
|
/// </summary>
|
/// <param name="room"></param>
|
public void InitControl(Common.Room room)
|
{
|
this.roomId = room.Id;
|
|
//房间底部阴影效果
|
var btnRoomShadow = new NormalViewControl(this.Width, this.Height, false);
|
btnRoomShadow.UnSelectedImagePath = "Room/RoomCardView.png";
|
this.AddChidren(btnRoomShadow, ChidrenBindMode.NotBind);
|
|
//房间图片
|
this.picRoom = new ImageView();
|
picRoom.Gravity = Gravity.CenterHorizontal;
|
picRoom.Width = Application.GetRealWidth(467);
|
picRoom.Height = Application.GetRealHeight(311);
|
picRoom.Radius = (uint)Application.GetRealHeight(29);
|
this.AddChidren(picRoom, ChidrenBindMode.NotBind);
|
|
//遮罩
|
var frameBack = new NormalViewControl(picRoom.Width, picRoom.Height, false);
|
frameBack.Gravity = picRoom.Gravity;
|
frameBack.Radius = picRoom.Radius;
|
frameBack.BackgroundColor = 0x33000000;
|
this.AddChidren(picRoom, ChidrenBindMode.BindEventOnly);
|
|
////房间名字的背景
|
//var btnRoomNameBackGroud = new NormalViewControl(Application.GetRealWidth(141), Application.GetRealHeight(84), false);
|
//btnRoomNameBackGroud.X = Application.GetRealWidth(14);
|
//btnRoomNameBackGroud.UnSelectedImagePath = "Room/RoomCardView_Name.png";
|
//this.AddChidren(btnRoomNameBackGroud, ChidrenBindMode.BindEventOnly);
|
|
////房间名字
|
//this.btnRoomName = new NormalViewControl(btnRoomNameBackGroud.Width, btnRoomNameBackGroud.Height, false);
|
//btnRoomName.X = Application.GetRealWidth(14);
|
//btnRoomName.TextSize = 12;
|
//btnRoomName.IsBold = true;
|
//btnRoomName.TextAlignment = TextAlignment.Center;
|
//btnRoomName.TextColor = UserCenterColor.Current.White;
|
//this.AddChidren(btnRoomName, ChidrenBindMode.BindEventOnly);
|
|
//房间名字的背景
|
this.btnRoomNameBackGroud = new NormalViewControl(Application.GetRealWidth(141), Application.GetRealHeight(84), false);
|
btnRoomNameBackGroud.X = Application.GetRealWidth(14);
|
btnRoomNameBackGroud.BackgroundColor = 0x80000000;
|
this.AddChidren(btnRoomNameBackGroud, ChidrenBindMode.BindEventOnly);
|
|
//房间名字
|
this.btnRoomName = new NormalViewControl(50, Application.GetRealHeight(84), false);
|
btnRoomName.X = Application.GetRealWidth(14);
|
btnRoomName.TextSize = 12;
|
btnRoomName.IsBold = true;
|
btnRoomName.TextAlignment = TextAlignment.Center;
|
btnRoomName.TextColor = UserCenterColor.Current.White;
|
this.AddChidren(btnRoomName, ChidrenBindMode.BindEventOnly);
|
|
//刷新控件信息
|
this.RefreshControl();
|
}
|
|
#endregion
|
|
#region ■ 刷新控件___________________________
|
|
/// <summary>
|
/// 刷新控件信息
|
/// </summary>
|
public void RefreshControl()
|
{
|
var room = HdlRoomLogic.Current.GetRoomById(this.roomId);
|
if (room != null)
|
{
|
//刷新名字
|
btnRoomName.Text = room.Name;
|
int realWidth = btnRoomName.GetRealWidthByText() + Application.GetRealWidth(70);
|
if (realWidth < Application.GetRealWidth(141))
|
{
|
realWidth = Application.GetRealWidth(141);
|
}
|
else if (realWidth > Application.GetRealWidth(420))
|
{
|
realWidth = Application.GetRealWidth(420);
|
}
|
btnRoomName.Width = realWidth;
|
btnRoomNameBackGroud.Width = realWidth;
|
btnRoomNameBackGroud.SetCornerWithSameRadius(picRoom.Radius, HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomRight);
|
|
//刷新图片
|
if (room.BackgroundImageType == 0)
|
{
|
picRoom.ImagePath = room.BackgroundImage;
|
}
|
else
|
{
|
picRoom.ImagePath = System.IO.Path.Combine(Common.Config.Instance.FullPath, room.BackgroundImage);
|
}
|
}
|
}
|
|
#endregion
|
}
|
}
|