using System;
using HDL_ON.UI.UI2.Intelligence.Automation.LogicView;
using Shared;
using System.Collections.Generic;
using System.Text;
namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice
{
public class AddControl : FrameLayout
{
public AddControl()
{
Tag = "PirView";
}
public void Show(Control control)
{
#region 界面布局
this.BackgroundColor = CSS.CSS_Color.viewMiddle;
PirDevice.View.TopView topView = new View.TopView();
topView.topNameBtn.TextID = StringId.zhinengyaokongqi;
topView.topIconBtn.Visible = true;
topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png";
this.AddChidren(topView.FLayoutView());
topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
{
this.RemoveFromParent();
};
#region 添加按钮
FrameLayout addLayout = new FrameLayout
{
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(84),
Width = Application.GetRealWidth(TextSize.view375),
};
this.AddChidren(addLayout);
Button addBtn = new Button
{
Width = Application.GetRealWidth(344),
Height = Application.GetRealHeight(44),
Y = Application.GetRealHeight(24),
X = Application.GetRealWidth(16),
TextID = StringId.tianjiaanniu,
TextSize = TextSize.text16,
TextColor = CSS.CSS_Color.btnSaveBackgroundColor,
BorderColor = CSS.CSS_Color.btnSaveBackgroundColor,
BorderWidth = 1,
Radius = (uint)Application.GetRealHeight(22),
};
addLayout.AddChidren(addBtn);
#endregion
FrameLayout frameLayout = new FrameLayout
{
Y = Application.GetRealHeight(64 + 84),
Height = Application.GetRealHeight(667 - 64 - 84-104),
Width = Application.GetRealWidth(TextSize.view375),
};
this.AddChidren(frameLayout);
#region 保存
FrameLayout saveLayout = new FrameLayout
{
Y = Application.GetRealHeight(667 - 104),
Height = Application.GetRealHeight(104),
Width = Application.GetRealWidth(TextSize.view375),
BackgroundColor = CSS.CSS_Color.viewLine,
};
this.AddChidren(saveLayout);
saveLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
//暂时隐藏排序功能
Button paixuBtn = new Button
{
Width = Application.GetRealWidth(375 - 16 * 2),
Height = Application.GetRealHeight(20),
Y = Application.GetRealHeight(12),
X = Application.GetRealWidth(16),
TextID = StringId.paixu,
TextSize = TextSize.text14,
TextColor = CSS.CSS_Color.textTipColor,
};
//saveLayout.AddChidren(paixuBtn);
Button saveBtn = new Button
{
Width = Application.GetRealWidth(220),
Height = Application.GetRealHeight(44),
Y = paixuBtn.Bottom + Application.GetRealHeight(12),
X = Application.GetRealWidth(78),
TextID = StringId.save,
TextSize = TextSize.text16,
TextColor = CSS.CSS_Color.textWhiteColor,
TextAlignment = TextAlignment.Center,
BackgroundColor = CSS.CSS_Color.btnSaveBackgroundColor,
Radius = (uint)Application.GetRealHeight(22),
};
saveLayout.AddChidren(saveBtn);
#endregion
VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
frameLayout.AddChidren(vv);
RefreshView(vv, false, control);
#endregion
#region 界面点击事件
//删除点击事件
topView.clickSetBtn.MouseUpEventHandler += (sender, e) =>
{
topView.clickSetBtn.IsSelected = !topView.clickSetBtn.IsSelected;
if (topView.clickSetBtn.IsSelected)
{
topView.topIconBtn.UnSelectedImagePath = "";
topView.topIconBtn.Text = Language.StringByID(StringId.wancheng);
topView.topIconBtn.TextSize = TextSize.text14;
topView.topIconBtn.TextColor = CSS.CSS_Color.textColor;
RefreshView(vv, true, control);
}
else
{
topView.topIconBtn.UnSelectedImagePath = "PirIcon/del.png";
topView.topIconBtn.Text = "";
RefreshView(vv, false, control);
}
};
//添加按钮点击事件
addBtn.MouseUpEventHandler += (sender, e) =>
{
AddButton addButton = new AddButton();
MainPage.BasePageView.AddChidren(addButton);
addButton.Show(control);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
//保存点击事件
saveBtn.MouseUpEventHandler += (sender, e) =>
{
//移除当前界面
this.RemoveFromParent();
//可能之前已经存在该界面
PirMethod.RemoveView("AddControlComplete");
AddControlComplete addControlComplete = new AddControlComplete();
MainPage.BasePageView.AddChidren(addControlComplete);
addControlComplete.Show(control, false);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
#endregion
}
///
/// 加载按钮控件View的方法
///
/// 上下滑动控件
/// 表示是否显示删除图标
void RefreshView(VerticalScrolViewLayout vv, bool if_bool, Control control)
{
vv.RemoveAll();
View.Buttons buttons = new View.Buttons();
buttons.AddButton2(vv, control.status, (obj) =>
{
PirMethod.ThreadSend(control, (responsePackNew) =>
{
var buttonObj = control.status.Find((c) => c.value == obj.value);
if (buttonObj != null)
{
control.status.Remove(buttonObj);
}
RefreshView(vv, true, control);
}, "删除按键", "fram", this, null, obj);
}, if_bool);
}
}
}