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;
|
}
|
};
|
}
|
}
|
}
|