xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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 System;
using System.Collections.Generic;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个点击能够显示选中状态背景色的RowLayout
    /// </summary>
    public class StatuRowLayout : RowLayout
    {
        /// <summary>
        /// Mouse up event.
        /// </summary>
        public delegate void _MouseUpEvent(object sender, MouseEventArgs e);
        /// <summary>
        /// 单击弹起事件
        /// </summary>
        public _MouseUpEvent MouseUpEvent;
        /// <summary>
        /// 桌布控件
        /// </summary>
        private StatuFrameLayout frameLayout = null;
        /// <summary>
        /// 原来的背景色
        /// </summary>
        private uint oldBackColor = 0;
 
        /// <summary>
        /// 做成一个点击能够显示选中状态背景色的RowLayout
        /// </summary>
        /// <param name="listView">列表控件</param>
        public StatuRowLayout(VerticalScrolViewLayout listView = null)
        {
            this.Height = ControlCommonResourse.ListViewRowHeight;
 
            if (listView != null)
            {
                listView.AddChidren(this);
            }
        }
 
        /// <summary>
        /// 添加子控件
        /// </summary>
        /// <param name="view">子控件</param>
        /// <param name="chidrenBindMode">绑定模式</param>
        public void AddChidren(View view, ChidrenBindMode chidrenBindMode = ChidrenBindMode.BindAll)
        {
            //初始化桌布控件
            this.InitframeLayout();
 
            this.frameLayout.AddChidren(view, chidrenBindMode);
        }
 
        /// <summary>
        /// 变更子控件的绑定模式
        /// </summary>
        /// <param name="view">子控件</param>
        /// <param name="chidrenBindMode">变更的绑定模式</param>
        public void ChangedChidrenBindMode(View view, ChidrenBindMode chidrenBindMode)
        {
            if (view is Button)
            {
                this.frameLayout.ChangedChidrenBindMode(view, chidrenBindMode);
            }
        }
 
        /// <summary>
        /// 强制实施控件选中状态
        /// </summary>
        /// <param name="waiTime"></param>
        public void StartSelectStatuThread(int waiTime)
        {
            //设置选择状态
            this.frameLayout.StartSelectStatuThread(waiTime);
        }
 
        /// <summary>
        /// 移除底层控件自身的单击事件
        /// </summary>
        public void RemoveBaseClickEvent()
        {
            this.frameLayout.RemoveBaseClickEvent();
        }
 
        /// <summary>
        /// 添加向右的图标
        /// </summary>
        public RowRightIconView AddRightIconControl()
        {
            var btnRight = new RowRightIconView();
            this.frameLayout.AddChidren(btnRight);
 
            return btnRight;
        }
 
        /// <summary>
        /// 初始化桌布控件
        /// </summary>
        private void InitframeLayout()
        {
            if (this.frameLayout != null)
            {
                return;
            }
            this.frameLayout = new StatuFrameLayout(this.Height, false);
            base.AddChidren(frameLayout);
            this.oldBackColor = this.BackgroundColor;
 
            //单击事件
            this.frameLayout.MouseUpEvent += (sender, e) =>
            {
                if (this.MouseUpEvent != null)
                {
                    this.MouseUpEvent(sender, e);
                }
            };
 
            //设置背景色
            this.frameLayout.SelectStatuEventBefore += (select) =>
            {
                if (select == true)
                {
                    this.frameLayout.BackgroundColor = UserCenterColor.Current.RowSelectBackColor;
                }
                else
                {
                    this.frameLayout.BackgroundColor = this.oldBackColor;
                }
            };
        }
    }
}