黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.MainPage.Controls
{
    /// <summary>
    /// 左滑的房间列表界面里面的房间卡片控件
    /// </summary>
    public class ListRoomCardControl : FrameLayoutStatuControl
    {
        #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 = HdlControlLogic.Current.GetPictrueRealSize(495);
            this.Height = HdlControlLogic.Current.GetPictrueRealSize(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 = HdlControlLogic.Current.GetPictrueRealSize(467);
            picRoom.Height = HdlControlLogic.Current.GetPictrueRealSize(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.BindEvent);
 
            //房间名字的背景
            this.btnRoomNameBackGroud = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(141), Application.GetRealHeight(84), false);
            btnRoomNameBackGroud.X = HdlControlLogic.Current.GetPictrueRealSize(14);
            btnRoomNameBackGroud.BackgroundColor = 0x80000000;
            this.AddChidren(btnRoomNameBackGroud, ChidrenBindMode.BindEvent);
 
            //房间名字
            this.btnRoomName = new NormalViewControl(50, Application.GetRealHeight(84), false);
            btnRoomName.X = HdlControlLogic.Current.GetPictrueRealSize(14);
            btnRoomName.TextSize = 12;
            btnRoomName.IsBold = true;
            btnRoomName.TextAlignment = TextAlignment.Center;
            btnRoomName.TextColor = UserCenterColor.Current.White;
            this.AddChidren(btnRoomName, ChidrenBindMode.BindEvent);
 
            //刷新控件信息
            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() + HdlControlLogic.Current.GetPictrueRealSize(70);
                if (realWidth < HdlControlLogic.Current.GetPictrueRealSize(141))
                {
                    realWidth = HdlControlLogic.Current.GetPictrueRealSize(141);
                }
                else if (realWidth > HdlControlLogic.Current.GetPictrueRealSize(420))
                {
                    realWidth = HdlControlLogic.Current.GetPictrueRealSize(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
    }
}