using Shared;
using HDL_ON.UI.CSS;
using System;
using System.Collections.Generic;
namespace HDL_ON.Stan
{
///
/// 做成一个RowLayout型的FrameLayout
///
public class FrameRowControl : FrameLayoutStatuControl
{
#region ■ 变量声明___________________________
///
/// 此控件的识别主键(自定义设置的)
///
public string MainKeys = string.Empty;
///
/// 左偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
///
public int LeftOffset = 0;
///
/// 右偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
///
public int RightOffset = 0;
///
/// 左边图标控件的大小
///
private int leftIconSize = 0;
///
/// 右边图标控件的大小
///
private int rightIconSize = 0;
///
/// 底线控件
///
private NormalViewControl btnBottomLine = null;
#endregion
#region ■ 初始化_____________________________
///
/// 做成一个RowLayout型的FrameLayout
///
/// 子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)
public FrameRowControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
{
this.Height = HdlControlResourse.ListViewRowHeight;
this.Width = Application.CurrentWidth;
}
#endregion
#region ■ 添加底线___________________________
///
/// 添加底线(如果左边有图标,则先添加图标,再添加底线)
/// 它的长度为:当前控件宽度-左右固定间距-左边图片宽度(如果有)-右边的偏移量
///
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(12);
XX = XX + leftIconSize + Application.GetRealWidth(12);
}
this.btnBottomLine = new NormalViewControl(lineWidth, HdlControlResourse.BottomLineHeight, false);
btnBottomLine.X = XX;
btnBottomLine.Y = this.Height - HdlControlResourse.BottomLineHeight;
btnBottomLine.BackgroundColor = CSS_Color.DividingLineColor;
base.AddChidren(btnBottomLine);
return btnBottomLine;
}
#endregion
#region ■ 添加左边Caption____________________
///
/// 添加左边Caption(如果有图标,则先添加图标,再添加Caption)
///
/// 内容
/// 宽度
/// 是否计算真实值
///
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;
}
///
/// 添加左边Caption,此方法不会主动添加到父控件中(如果有图标,则先添加图标,再添加Caption)
///
/// 内容
/// 宽度
/// 高度
/// 是否计算真实值
///
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(12);
}
var btnCaption = new NormalViewControl(i_width, i_height, real);
btnCaption.X = XX;
btnCaption.Text = i_caption;
return btnCaption;
}
#endregion
#region ■ 添加左边输入框_____________________
///
/// 添加左边输入框(如果有图标,则先添加图标,再添加输入框)
///
/// 初始内容
/// 宽度
/// 是否计算真实值
///
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(12);
}
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 ■ 添加左边图标_______________________
///
/// 添加左边图标
///
/// 图标大小
/// 图标地址
///
public IconViewControl AddLeftIcon(int i_Iconsize, 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 ■ 添加向右的图标_____________________
///
/// 添加向右的图标
///
public IconViewControl AddRightArrow()
{
var btnRight = new IconViewControl(20);
btnRight.Gravity = Gravity.CenterVertical;
btnRight.X =this.Width - btnRight.IconSize - HdlControlResourse.XXLeft + RightOffset;
btnRight.UnSelectedImagePath = "Public/Right.png";
this.AddChidren(btnRight, ChidrenBindMode.BindEvent);
if (chidrenYaxis != 0)
{
btnRight.Y += chidrenYaxis;
}
this.rightIconSize = btnRight.Width;
return btnRight;
}
///
/// 添加最右边的空白图片控件
///
/// 控件空度(非真实值)
/// 控件高度(非真实值)
///
public MostRightIconControl AddMostRightEmptyIcon(int i_width, int i_height)
{
//这是一个符合控件
var btnContr = new MostRightIconControl(i_width, i_height);
btnContr.Height = this.Height;
int XX = this.Width - this.GetPictrueRealSize(i_width) - HdlControlResourse.XXLeft;
btnContr.X = XX - (btnContr.Width - this.GetPictrueRealSize(i_width)) / 2;
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 ■ 添加右边的开关图标_________________
///
/// 添加右边的开关图标
///
///
public MostRightIconControl AddMostRightSwitchIcon()
{
var btnSwitch = this.AddMostRightEmptyIcon(36, 36);
this.ChangedChidrenBindMode(btnSwitch, ChidrenBindMode.NotBind);
btnSwitch.UnSelectedImagePath = "Public/Switch_2.png";
btnSwitch.SelectedImagePath = "Public/SwitchOn_2.png";
return btnSwitch;
}
#endregion
#region ■ 添加最右的显示文本_________________
///
/// 添加最右的显示文本(如果右边有图标的话,先添加图标后,再添加这个文本)
///
///
///
///
///
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;
}
///
/// 添加最右的显示文本,此方法不会主动添加到父控件中(如果右边有图标的话,先添加图标后,再添加这个文本)
///
/// 内容
/// 宽度
/// 高度
/// 是否计算真实值
///
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);
if (rightIconSize != 0)
{
//行的宽度减去最右边间距,再加上偏移量,再减去最右边的图片宽度,再减去图片与文字的间距,最后减去自身的宽度
btnContr.X = this.Width - HdlControlResourse.XXLeft + RightOffset - rightIconSize - Application.GetRealWidth(12) - i_width;
}
else
{
//行的宽度减去最右边间距,再加上偏移量,最后减去自身的宽度
btnContr.X = this.Width - HdlControlResourse.XXLeft + RightOffset - i_width;
}
btnContr.Height = i_height;
btnContr.TextAlignment = TextAlignment.CenterRight;
btnContr.TextColor = CSS_Color.PromptingColor1;
btnContr.Text = i_text;
btnContr.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
return btnContr;
}
#endregion
#region ■ 添加上部的显示文本_________________
///
/// 添加上部的显示文本(如果有图标,则先添加图标,再添加文本)
///
/// 内容
/// 宽度
/// 是否计算真实值
///
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(21), false);
contr.TextSize = CSS_FontSize.SubheadingFontSize;
//当指定实际坐标时,这里需要的偏移量为2倍
contr.Y = Application.GetRealHeight(4) + this.chidrenYaxis * 2;
this.AddChidren(contr, ChidrenBindMode.BindEvent);
return contr;
}
#endregion
#region ■ 添加下部的显示文本_________________
///
/// 添加下部的显示文本(如果有图标,则先添加图标,再添加文本)
///
/// 内容
/// 宽度
/// 是否计算真实值
///
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(17), false);
//当指定实际坐标时,这里需要的偏移量为2倍
contr.Y = Application.GetRealHeight(25) + this.chidrenYaxis * 2;
contr.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
contr.TextColor = CSS_Color.PromptingColor1;
this.AddChidren(contr, ChidrenBindMode.BindEvent);
return contr;
}
#endregion
}
}