using System;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
public class BaseFramLayout : FrameLayout
{
public BaseFramLayout()
{
}
///
/// 是否可以点击
///
private bool mIsClick = true;
///
/// 设置控制点击事件
///
/// false点击无效
public void SetClick(bool isClick)
{
this.mIsClick = isClick;
}
///
/// 设置控制点击事件
///
/// false点击无效
public bool GetClick()
{
return this.mIsClick;
}
///
/// 延时时间ms
///
public const int millisecondsTimeout = 100;
///
/// 选中颜色
///
public const uint seleBackgroundColor = 0xFFF2F3F7;
///
/// 不支持按键文本颜色
///
public const uint unBackgroundColor = 0xFFA3AAB7;
///
/// 不支持整个颜色
///
public const uint unParentBackgroundColor = 0xFFF2F3F7;
///
/// 调整真实高度
///
/// 底部高度(非真实值)
public void AdjustRealHeight(int bottomSpace = 0)
{
int bottomHeight = -1;
for (int i = 0; i < this.ChildrenCount; i++)
{
var child = this.GetChildren(i);
if (child.Bottom > bottomHeight)
{
bottomHeight = child.Bottom;
}
}
if (bottomHeight != -1)
{
this.Height = bottomHeight + Application.GetRealHeight(bottomSpace);
}
}
///
/// 获取坐标底部最下面的那个控件的底部坐标
///
///
public int GetLocationMostLastViewBottom()
{
int bottomHeight = -1;
for (int i = 0; i < this.ChildrenCount; i++)
{
var child = this.GetChildren(i);
if (child.Bottom > bottomHeight)
{
bottomHeight = child.Bottom;
}
}
return bottomHeight;
}
///
/// 设置高亮颜色(grb)
///
/// 选中颜色值
/// 未选中颜色值
/// 组件
public void SetHighlightColor(View view, uint seleColor =seleBackgroundColor, uint unColor = 0x00000000)
{
if (view == null)
{
return;
}
//按下去改变背景颜色
view.BackgroundColor = seleColor;
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(millisecondsTimeout);
Application.RunOnMainThread(() =>
{
//弹起来还原背景颜色
view.BackgroundColor = unColor;
});
})
{ IsBackground = true }.Start();
}
///
/// 设置Button专用
///
/// 组件
public void SetButtonIsSelected(Button button)
{
if (button == null)
{
return;
}
//按下去改变背景颜色
button.IsSelected = true;
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(millisecondsTimeout);
Application.RunOnMainThread(() =>
{
//弹起来还原背景颜色
button.IsSelected = false;
});
})
{ IsBackground = true }.Start();
}
///
/// 设置高亮背景图标
///
/// 选中图片路径
/// 未选中图片路径<
/// 组件
public void SetHighlightImagePath(FrameLayout frame, string seleImagePath, string unImagePath)
{
if (frame == null)
{
return;
}
//按下去改变背景颜色
frame.BackgroundImagePath = seleImagePath;
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(millisecondsTimeout);
Application.RunOnMainThread(() =>
{
//弹起来还原背景颜色
frame.BackgroundImagePath = unImagePath;
});
})
{ IsBackground = true }.Start();
}
}
}