黄学彪
2019-10-12 c6b35c3138b944830b5336bf610f918154dd47c7
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
134
135
136
137
138
139
140
141
142
143
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个简单场景选择的行控件
    /// </summary>
    public class SceneSimpleSelectControl : FrameRowControl
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 场景ID
        /// </summary>
        private int SceneId = 0;
        /// <summary>
        /// 场景对象
        /// </summary>
        public Common.SceneUI Scene
        {
            get { return Common.Room.CurrentRoom.GetSceneUIBySceneId(SceneId); }
        }
        /// <summary>
        /// 选择控件
        /// </summary>
        private MostRightIconControl btnSelect = null;
 
        /// <summary>
        /// 选择的状态是否能够取消
        /// </summary>
        public bool SelectCancel = true;
        /// <summary>
        /// 状态
        /// </summary>
        private StatuMode Statu = StatuMode.UN_SELECT;
        /// <summary>
        /// 是否处于选择状态
        /// </summary>
        public bool IsSelected
        {
            get { return Statu == StatuMode.SELECT; }
            set
            {
                if (value == false)
                {
                    if (SelectCancel == true)
                    {
                        this.SetUnselectStatu();
                    }
                }
                else
                {
                    this.SetSelectStatu();
                }
            }
        }
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 做成一个简单场景选择的行控件
        /// </summary>
        /// <param name="i_Scene">场景对象</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param>
        public SceneSimpleSelectControl(Common.SceneUI i_Scene, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
        {
            this.SceneId = i_Scene.Id;
            this.ButtonClickEvent += (sender, e) =>
            {
                this.IsSelected = Statu == StatuMode.SELECT ? false : true;
            };
        }
 
        /// <summary>
        /// 初始化内部控件
        /// </summary>
        public void InitControl()
        {
            var SceneTemp = this.Scene;
 
            //图标
            var btnIcon = this.AddLeftIcon();
            btnIcon.UnSelectedImagePath = "Item/Scene.png";
 
            //场景
            var btnScene = this.AddLeftCaption(SceneTemp.Name, 850, 60);
            btnScene.TextSize = 15;
            //这个坐标有点特殊
            btnScene.Y = Application.GetRealHeight(12) + this.chidrenYaxis;
            this.AddChidren(btnScene, ChidrenBindMode.BindEventOnly);
 
            //房间
            string roomName = Common.Room.CurrentRoom.GetRoomNameBySceneId(SceneId);
            var btnRoom = this.AddLeftCaption(roomName, 850, 50, true);
            //这个坐标有点特殊
            btnRoom.Y = Application.GetRealHeight(72) + this.chidrenYaxis;
            btnRoom.TextSize = 12;
            btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
            this.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly);
 
            btnSelect = this.AddMostRightEmptyIcon(58, 58);
            btnSelect.Visible = false;
            btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
        }
 
        #endregion
 
        #region ■ 选择状态___________________________
 
        /// <summary>
        /// 设定选择状态
        /// </summary>
        private void SetSelectStatu()
        {
            if (Statu == StatuMode.SELECT)
            {
                return;
            }
            btnSelect.Visible = true;
            //状态变更
            Statu = StatuMode.SELECT;
        }
 
        /// <summary>
        /// 设置非选择状态
        /// </summary>
        private void SetUnselectStatu()
        {
            if (Statu == StatuMode.UN_SELECT)
            {
                return;
            }
            btnSelect.Visible = false;
            //状态变更
            Statu = StatuMode.UN_SELECT;
        }
        #endregion
    }
}