using System;
|
using System.Collections.Generic;
|
|
namespace Shared.Phone
|
{
|
/// <summary>
|
/// 做成一个RowLayout型的FrameLayout
|
/// </summary>
|
public class FrameRowControl : FrameLayoutStatuControl
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 此控件的识别主键(自定义设置的)
|
/// </summary>
|
public string MainKeys = string.Empty;
|
/// <summary>
|
/// 左偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
|
/// </summary>
|
public int LeftOffset = 0;
|
/// <summary>
|
/// 右偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
|
/// </summary>
|
public int RightOffset = 0;
|
/// <summary>
|
/// 左边图标控件的大小
|
/// </summary>
|
private int leftIconSize = 0;
|
/// <summary>
|
/// 右边图标控件的大小
|
/// </summary>
|
private int rightIconSize = 0;
|
/// <summary>
|
/// 底线控件
|
/// </summary>
|
private NormalViewControl btnBottomLine = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 做成一个RowLayout型的FrameLayout
|
/// </summary>
|
/// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
public FrameRowControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
{
|
this.Height = HdlControlResourse.ListViewRowHeight;
|
this.Width = Application.CurrentWidth;
|
}
|
|
#endregion
|
|
#region ■ 添加底线___________________________
|
|
/// <summary>
|
/// <para>添加底线(如果左边有图标,则先添加图标,再添加底线)</para>
|
/// <para>它的长度为:当前控件宽度-左右固定间距-左边图片宽度(如果有)-右边的偏移量</para>
|
/// </summary>
|
public virtual NormalViewControl AddBottomLine()
|
{
|
if (this.btnBottomLine != null)
|
{
|
//已经添加了底线
|
return btnBottomLine;
|
}
|
int lineWidth = this.Width - HdlControlResourse.XXLeft * 2 - LeftOffset - RightOffset;
|
int XX = HdlControlResourse.XXLeft + LeftOffset;
|
if (leftIconSize > 0)
|
{
|
lineWidth = lineWidth - leftIconSize - Application.GetRealWidth(35);
|
XX = XX + leftIconSize + Application.GetRealWidth(35);
|
}
|
this.btnBottomLine = new NormalViewControl(lineWidth, HdlControlResourse.BottomLineHeight, false);
|
btnBottomLine.X = XX;
|
btnBottomLine.Y = this.Height - HdlControlResourse.BottomLineHeight;
|
btnBottomLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
base.AddChidren(btnBottomLine);
|
|
return btnBottomLine;
|
}
|
|
#endregion
|
|
#region ■ 添加左边Caption____________________
|
|
/// <summary>
|
/// 添加左边Caption(如果有图标,则先添加图标,再添加Caption)
|
/// </summary>
|
/// <param name="i_caption">内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public NormalViewControl AddLeftCaption(string i_caption, int i_width, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
}
|
var contr = this.AddLeftCaption(i_caption, i_width, this.Height, false);
|
this.AddChidren(contr, ChidrenBindMode.BindEvent);
|
if (chidrenYaxis != 0)
|
{
|
contr.Y += chidrenYaxis;
|
}
|
|
return contr;
|
}
|
|
/// <summary>
|
/// 添加左边Caption,此方法不会主动添加到父控件中(如果有图标,则先添加图标,再添加Caption)
|
/// </summary>
|
/// <param name="i_caption">内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="i_height">高度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public NormalViewControl AddLeftCaption(string i_caption, int i_width, int i_height, bool real = true)
|
{
|
int XX = HdlControlResourse.XXLeft + LeftOffset;
|
if (this.leftIconSize > 0)
|
{
|
XX += this.leftIconSize + Application.GetRealWidth(35);
|
}
|
var btnCaption = new NormalViewControl(i_width, i_height, real);
|
btnCaption.X = XX;
|
|
btnCaption.Text = i_caption;
|
|
return btnCaption;
|
}
|
|
#endregion
|
|
#region ■ 添加左边输入框_____________________
|
|
/// <summary>
|
/// 添加左边输入框(如果有图标,则先添加图标,再添加输入框)
|
/// </summary>
|
/// <param name="i_txtValue">初始内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public TextInputControl AddLeftInput(string i_txtValue, int i_width, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
}
|
int XX = HdlControlResourse.XXLeft + LeftOffset;
|
if (this.leftIconSize > 0)
|
{
|
XX += this.leftIconSize + Application.GetRealWidth(35);
|
}
|
var contr = new TextInputControl(i_width, this.Height, false);
|
contr.Text = i_txtValue;
|
contr.X = XX;
|
|
this.AddChidren(contr, ChidrenBindMode.NotBind);
|
if (chidrenYaxis != 0)
|
{
|
contr.Y += chidrenYaxis;
|
}
|
|
return contr;
|
}
|
|
#endregion
|
|
#region ■ 添加左边图标_______________________
|
|
/// <summary>
|
/// 添加左边图标
|
/// </summary>
|
/// <param name="i_Iconsize">图标大小</param>
|
/// <param name="i_IconPath">图标地址</param>
|
/// <returns></returns>
|
public IconViewControl AddLeftIcon(int i_Iconsize = 81, string i_IconPath = null)
|
{
|
var btnIcon = new IconViewControl(i_Iconsize);
|
btnIcon.X = HdlControlResourse.XXLeft + LeftOffset;
|
btnIcon.Gravity = Gravity.CenterVertical;
|
if (i_IconPath != null)
|
{
|
btnIcon.UnSelectedImagePath = i_IconPath;
|
}
|
this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
|
if (chidrenYaxis != 0)
|
{
|
btnIcon.Y += chidrenYaxis;
|
}
|
|
this.leftIconSize = btnIcon.IconSize;
|
return btnIcon;
|
}
|
|
#endregion
|
|
#region ■ 添加向右的图标_____________________
|
|
/// <summary>
|
/// 添加向右的图标
|
/// </summary>
|
public IconViewControl AddRightArrow()
|
{
|
var btnRight = new IconViewControl(58);
|
btnRight.Gravity = Gravity.CenterVertical;
|
btnRight.X =this.Width - btnRight.IconSize - HdlControlResourse.XXLeft + RightOffset;
|
btnRight.UnSelectedImagePath = "Item/RightNext.png";
|
this.AddChidren(btnRight, ChidrenBindMode.BindEvent);
|
|
if (chidrenYaxis != 0)
|
{
|
btnRight.Y += chidrenYaxis;
|
}
|
|
this.rightIconSize = btnRight.Width;
|
|
return btnRight;
|
}
|
|
/// <summary>
|
/// 添加最右边的空白图片控件
|
/// </summary>
|
/// <param name="i_width">控件空度(非真实值)</param>
|
/// <param name="i_height">控件高度(非真实值)</param>
|
/// <returns></returns>
|
public MostRightIconControl AddMostRightEmptyIcon(int i_width, int i_height)
|
{
|
var btnContr = new MostRightIconControl(i_width, i_height);
|
btnContr.UseClickStatu = false;
|
this.AddChidren(btnContr, ChidrenBindMode.NotBind);
|
btnContr.InitControl();
|
//复合控件需要特殊处理
|
this.ChangedChidrenBindMode(btnContr, ChidrenBindMode.BindEvent);
|
if (RightOffset != 0)
|
{
|
btnContr.X += RightOffset;
|
}
|
|
this.rightIconSize = this.GetPictrueRealSize(i_width);
|
if (chidrenYaxis != 0)
|
{
|
btnContr.btnIcon.Y += chidrenYaxis;
|
}
|
|
return btnContr;
|
}
|
|
#endregion
|
|
#region ■ 添加右边的开关图标_________________
|
|
/// <summary>
|
/// 添加右边的开关图标
|
/// </summary>
|
/// <returns></returns>
|
public MostRightIconControl AddMostRightSwitchIcon()
|
{
|
var btnSwitch = this.AddMostRightEmptyIcon(104, 63);
|
this.ChangedChidrenBindMode(btnSwitch, ChidrenBindMode.NotBind);
|
btnSwitch.UnSelectedImagePath = "Item/Switch2.png";
|
btnSwitch.SelectedImagePath = "Item/Switch2Selected.png";
|
|
return btnSwitch;
|
}
|
|
#endregion
|
|
#region ■ 添加最右的显示文本_________________
|
|
/// <summary>
|
/// 添加最右的显示文本(如果右边有图标的话,先添加图标后,再添加这个文本)
|
/// </summary>
|
/// <param name="i_text"></param>
|
/// <param name="i_width"></param>
|
/// <param name="real"></param>
|
/// <returns></returns>
|
public NormalViewControl AddMostRightView(string i_text, int i_width, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
}
|
var btnContr = AddMostRightView(i_text, i_width, this.Height, false);
|
this.AddChidren(btnContr, ChidrenBindMode.BindEvent);
|
if (chidrenYaxis != 0)
|
{
|
btnContr.Y += chidrenYaxis;
|
}
|
|
return btnContr;
|
}
|
|
/// <summary>
|
/// 添加最右的显示文本,此方法不会主动添加到父控件中(如果右边有图标的话,先添加图标后,再添加这个文本)
|
/// </summary>
|
/// <param name="i_caption">内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="i_height">高度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public NormalViewControl AddMostRightView(string i_text, int i_width, int i_height, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
i_height = Application.GetRealHeight(i_height);
|
}
|
var btnContr = new NormalViewControl(i_width, i_height, false);
|
btnContr.X = this.Width - HdlControlResourse.XXLeft - i_width - rightIconSize + RightOffset;
|
btnContr.Height = i_height;
|
btnContr.TextAlignment = TextAlignment.CenterRight;
|
btnContr.TextColor = UserCenterColor.Current.TextGrayColor1;
|
btnContr.Text = i_text;
|
|
return btnContr;
|
}
|
|
#endregion
|
|
#region ■ 添加上部的显示文本_________________
|
|
/// <summary>
|
/// 添加上部的显示文本(如果有图标,则先添加图标,再添加文本)
|
/// </summary>
|
/// <param name="i_caption">内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public NormalViewControl AddTopView(string i_caption, int i_width, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
}
|
var contr = this.AddLeftCaption(i_caption, i_width, Application.GetRealHeight(60), false);
|
contr.TextSize = 15;
|
//当指定实际坐标时,这里需要的偏移量为2倍
|
contr.Y = Application.GetRealHeight(12) + this.chidrenYaxis * 2;
|
this.AddChidren(contr, ChidrenBindMode.BindEvent);
|
|
return contr;
|
}
|
|
#endregion
|
|
#region ■ 添加下部的显示文本_________________
|
|
/// <summary>
|
/// 添加下部的显示文本(如果有图标,则先添加图标,再添加文本)
|
/// </summary>
|
/// <param name="i_caption">内容</param>
|
/// <param name="i_width">宽度</param>
|
/// <param name="real">是否计算真实值</param>
|
/// <returns></returns>
|
public NormalViewControl AddBottomView(string i_caption, int i_width, bool real = true)
|
{
|
if (real == true)
|
{
|
i_width = Application.GetRealWidth(i_width);
|
}
|
var contr = this.AddLeftCaption(i_caption, i_width, Application.GetRealHeight(50), false);
|
//当指定实际坐标时,这里需要的偏移量为2倍
|
contr.Y = Application.GetRealHeight(72) + this.chidrenYaxis * 2;
|
contr.TextSize = 12;
|
contr.TextColor = UserCenterColor.Current.TextGrayColor1;
|
this.AddChidren(contr, ChidrenBindMode.BindEvent);
|
|
return contr;
|
}
|
|
#endregion
|
}
|
}
|