using System;
|
using Shared;
|
namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView
|
{
|
public class SwitchView
|
{
|
|
/// <summary>
|
/// 主控件
|
/// </summary>
|
public FrameLayout frameLayout = new FrameLayout
|
{
|
BackgroundColor = CSS.CSS_Color.view,
|
Y = Application.GetRealHeight(515),
|
X = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(44 * 44),
|
Width = Application.GetRealWidth(343),
|
Radius = (uint)Application.GetRealHeight(12)
|
};
|
/// <summary>
|
/// 取消
|
/// </summary>
|
public Button btnCancel = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextSize = TextSize.text16,
|
TextColor = CSS.CSS_Color.textRedColor,
|
TextID = StringId.cancelSelected,
|
Y = Application.GetRealHeight(611),
|
X = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(343),
|
BackgroundColor = CSS.CSS_Color.view,
|
Radius = (uint)Application.GetRealHeight(12)
|
};
|
/// <summary>
|
/// 开
|
/// </summary>
|
public Button btnOn = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextSize = LogicView.TextSize.text16,
|
TextColor = CSS.CSS_Color.textCancelColor,
|
TextID = StringId.onLogic,
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(343),
|
|
};
|
/// <summary>
|
/// 线
|
/// </summary>
|
public Button btnLine = new Button
|
{
|
Height = 1,
|
BackgroundColor = CSS.CSS_Color.viewLine,
|
Y = Application.GetRealHeight(43),
|
};
|
/// <summary>
|
/// 关
|
/// </summary>
|
public Button btnOff = new Button
|
{
|
Y = Application.GetRealHeight(44),
|
TextAlignment = TextAlignment.Center,
|
TextSize = LogicView.TextSize.text16,
|
TextColor = CSS.CSS_Color.textCancelColor,
|
TextID = StringId.offLogic,
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(343),
|
};
|
/// <summary>
|
/// 线1
|
/// </summary>
|
public Button btnLine1 = new Button
|
{
|
Height = 1,
|
BackgroundColor = CSS.CSS_Color.viewLine,
|
Y = Application.GetRealHeight(43 + 44),
|
};
|
/// <summary>
|
/// 暂停
|
/// </summary>
|
public Button btnStop = new Button
|
{
|
Y = Application.GetRealHeight(44 + 44),
|
TextAlignment = TextAlignment.Center,
|
TextSize = LogicView.TextSize.text16,
|
TextColor = CSS.CSS_Color.textCancelColor,
|
TextID = StringId.stop,
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(343),
|
};
|
|
|
|
/// <summary>
|
/// View的方法
|
/// </summary>
|
/// <param name="frame">父控件</param>
|
/// <param name="i">显示选择View数量</param>
|
///<param name="stateVuale">之前的状态值</param>
|
/// <param name="action">返回回调</param>
|
/// <returns></returns>
|
public void FLayoutView(FrameLayout frame, int i,string stateVuale,Action<string>action)
|
{
|
frameLayout.Y = Application.GetRealHeight(603 - (44 * i));
|
frameLayout.Height = Application.GetRealHeight(44 * i);
|
frame.AddChidren(frameLayout);
|
frame.AddChidren(btnCancel);
|
frameLayout.AddChidren(btnOn);
|
frameLayout.AddChidren(btnLine);
|
frameLayout.AddChidren(btnOff);
|
if (i > 2)
|
{
|
/// 判断是否要是显示"暂停"按钮
|
frameLayout.AddChidren(btnLine1);
|
frameLayout.AddChidren(btnStop);
|
}
|
//取消点击事件
|
btnCancel.MouseUpEventHandler += (sender1, e1) =>
|
{
|
frame.RemoveFromParent();
|
};
|
|
|
///显示之前状态
|
if (stateVuale != "")
|
{
|
if (stateVuale ==btnOn.Text)
|
{
|
btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
|
}
|
else if (stateVuale == btnOff.Text)
|
{
|
btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
|
}
|
else if (stateVuale == btnStop.Text)
|
{
|
btnStop.TextColor = CSS.CSS_Color.textConfirmColor;
|
}
|
}
|
|
//开-点击事件
|
btnOn.MouseUpEventHandler += (sender2, e2) =>
|
{
|
action("on");
|
frame.RemoveFromParent();
|
};
|
//关-点击事件
|
btnOff.MouseUpEventHandler += (sender3, e3) =>
|
{
|
action("off");
|
frame.RemoveFromParent();
|
};
|
//暂停-点击事件
|
btnStop.MouseUpEventHandler += (sender3, e3) =>
|
{
|
action("stop");
|
frame.RemoveFromParent();
|
};
|
|
}
|
|
|
/// <summary>
|
/// View的方法
|
/// </summary>
|
/// <param name="frame">父控件</param>
|
/// <param name="text1">父控件</param>
|
/// <param name="text2">显示选择View数量</param>
|
///<param name="stateVuale">之前的状态值</param>
|
/// <param name="action">返回回调</param>
|
/// <returns></returns>
|
public void FLayoutView(FrameLayout frame, int text1, int text2, string stateVuale, Action<int> action,bool tag=true)
|
{
|
int i = 2;
|
frameLayout.Y = Application.GetRealHeight(603 - (44 * i));
|
frameLayout.Height = Application.GetRealHeight(44 * i);
|
frame.AddChidren(frameLayout);
|
frame.AddChidren(btnCancel);
|
btnOn.TextID = text1;
|
btnOff.TextID = text2;
|
frameLayout.AddChidren(btnOn);
|
frameLayout.AddChidren(btnLine);
|
frameLayout.AddChidren(btnOff);
|
//取消点击事件
|
btnCancel.MouseUpEventHandler += (sender1, e1) =>
|
{
|
frame.RemoveFromParent();
|
};
|
|
///显示之前状态
|
if (stateVuale != "")
|
{
|
if (stateVuale == btnOn.Text)
|
{
|
btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
|
}
|
else if (stateVuale == btnOff.Text)
|
{
|
btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
|
}
|
|
}
|
|
//点击事件
|
btnOn.MouseUpEventHandler += (sender2, e2) =>
|
{
|
action(btnOn.TextID);
|
if (tag)
|
{
|
frame.RemoveFromParent();
|
}
|
};
|
//点击事件
|
btnOff.MouseUpEventHandler += (sender3, e3) =>
|
{
|
action(btnOff.TextID);
|
if (tag)
|
{
|
frame.RemoveFromParent();
|
}
|
};
|
|
|
}
|
|
|
///// <summary>
|
///// View的方法
|
///// </summary>
|
///// <param name="frame">父控件</param>
|
///// <param name="i">显示选择View数量</param>
|
///// <returns></returns>
|
//public void FLayoutView(FrameLayout frame, int i)
|
//{
|
// frameLayout.Y = Application.GetRealHeight(603 - (44 * i));
|
// frameLayout.Height = Application.GetRealHeight(44 * i);
|
// frame.AddChidren(frameLayout);
|
// frame.AddChidren(btnCancel);
|
// frameLayout.AddChidren(btnOn);
|
// frameLayout.AddChidren(btnLine);
|
// frameLayout.AddChidren(btnOff);
|
// if (i > 2)
|
// {
|
// /// 判断是否要是显示"暂停"按钮
|
// frameLayout.AddChidren(btnLine1);
|
// frameLayout.AddChidren(btnStop);
|
// }
|
// btnCancel.MouseUpEventHandler += (sender1, e1) =>
|
// {
|
// frame.RemoveFromParent();
|
// };
|
//}
|
}
|
}
|