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