mac
2023-09-26 841e7972869b6e967d06da0d91186cd69f1d4eb5
HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs
@@ -1,11 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
    public class PublicInterface
    {
        /// <summary>
        /// 单选择
        /// </summary>
        /// <param name="frame">显示在哪个界面的父控件</param>
        /// <param name="list">显示数据源</param>
        /// <param name="titleText"></param>
        /// <param name="stateText">之前状态文本</param>
        /// <param name="action">返回值</param>
        /// <param name="textSize">显示文本字体大小</param>
        public void SingleSelectionShow(FrameLayout frame, List<FuntionControlView.Aks.Entity.RemoteControlEntity> list, string titleText, string stateText, Action<int> action, int textSize = LogicView.TextSize.text14)
        {
            if (list == null)
            {
                return;
            }
            FrameLayout frameLayout = new FrameLayout
            {
                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
            };
            frame.AddChidren(frameLayout);
            LogicView.DateView view = new LogicView.DateView();
            view.btnTitle.Text = titleText;
            view.FLayoutView(frameLayout, list.Count);
            view.btnCancel.MouseUpEventHandler += (sender, e) =>
            {
                //移除fLayout界面
                frameLayout.RemoveFromParent();
            };
            ///定义一个Btn记录选中状态
            Button checkBtn = new Button
            {
                Tag = "unknown",
            };
            for (int i = 0; i < list.Count; i++)
            {
                FuntionControlView.Aks.Entity.RemoteControlEntity remoteControl = list[i];
                LogicView.CheckView checkView = new LogicView.CheckView();
                checkView.frameLayout.Y = Application.GetRealHeight(56 + 50 * i);
                checkView.btnText.TextSize = textSize;
                view.frameLayout.AddChidren(checkView.FLayoutView());
                checkView.btnText.Text = remoteControl.name;
                checkView.btnClick.Tag = i;//标记
                if (stateText == remoteControl.name)
                {
                    //显示之前的选中状态
                    checkBtn.IsSelected = false;
                    checkView.btnCheckIcon.IsSelected = true;
                    checkBtn = checkView.btnCheckIcon;
                    checkBtn.Tag = checkView.btnClick.Tag.ToString();
                }
                //点击事件
                checkView.btnClick.MouseUpEventHandler += (sender1, e1) =>
                {
                    checkBtn.IsSelected = false;
                    checkView.btnCheckIcon.IsSelected = true;
                    checkBtn = checkView.btnCheckIcon;
                    checkBtn.Tag = checkView.btnClick.Tag.ToString();
                };
            }
            view.btnConfirm.MouseUpEventHandler += (sender1, e1) =>
            {
                if (checkBtn.Tag.ToString() == "unknown")
                {
                    return;
                }
                var index = int.Parse(checkBtn.Tag.ToString());
                if (index > list.Count)
                {
                    index = 0;
                }
                action(index);
                //移除fLayout界面
                frameLayout.RemoveFromParent();
            };
        }
        /// <summary>
        /// 单选择
        /// </summary>