陈嘉乐
2021-01-27 122dc4312c72b2d2aaa50a2adf84165f5600b99a
HDL_ON/UI/UI2/3-Intelligence/Automation/EmptyClass.cs
@@ -8,9 +8,27 @@
{
    public class EmptyClass : FrameLayout
    {
        public void Show()
        /// <summary>
        ///
        /// </summary>
        /// <param name="list">表示该列表元素A-Z字母筛选显示出来</param>
        /// <param name="list6">表示该列表元素显示在list前面(该列表元素不做A-Z字母筛选),没有可以为list6=null</param>
        /// <param name="action">返回选中文本</param>
        public void Show(List<string> list, List<string> list6, Action<string> action)
        {
            //string text = "30";
            //byte[] bytes = new byte[text.Length / 2];
            //for (int i = 0, j = 0; i < bytes.Length; j += 2, i++)
            //{
            //    //把16进度转换成byte
            //    bytes[i] = Convert.ToByte(text.Substring(j, 2), 16);
            //}
            ////把byte数组转换成文字
            //string str = System.Text.Encoding.UTF8.GetString(bytes);
            var frameLayout = new FrameLayout
            {
                BackgroundColor = CSS.CSS_Color.viewTop,
@@ -41,23 +59,25 @@
                UnSelectedImagePath = "LogicIcon/back.png",
            };
            frameLayout.AddChidren(backBtn);
            backBtn.MouseUpEventHandler += (sen,e) => {
            backBtn.MouseUpEventHandler += (sen, e) =>
            {
                this.RemoveFromParent();
            };
            var editText = new EditText {
            var editText = new EditText
            {
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealWidth(28),
                X = Application.GetRealWidth(TextSize.left16),
                Y = Application.GetRealHeight(76),
                BackgroundColor = CSS.CSS_Color.view,
                TextColor= CSS.CSS_Color.textColor,
                TextAlignment=TextAlignment.Center,
                TextColor = CSS.CSS_Color.textColor,
                TextAlignment = TextAlignment.Center,
            };
            frameLayout.AddChidren(editText);
                var fram = new FrameLayout
            var fram = new FrameLayout
            {
                Y = Application.GetRealHeight(112),
                Height = Application.GetRealHeight(667 - 112),
@@ -65,25 +85,38 @@
                BackgroundColor = CSS.CSS_Color.view,
            };
            this.AddChidren(fram);
            var list11 = new List<string> {
               "爱你", "哎呦","埃及","哈弗换壳哈弗", "爱德华多v","俺几个疯了",
                "拜了", "巴士", "百夫",  "百合地理课你打算", "不度老骥伏枥", "比到九点",
                "车站","测试","此地", "才看见好得快","吃软饭","从看见二十多",
               "等待机会吧","的客户", "多喝点", "登记哦然后", "打电话",
                 "恩肤霜看就看了", "饿死os","恶魔城","儿科联动", "恩六颗子弹拉拉裤洗澡了","发大学生发发",
                "真厉害i发多少", "知道你付款了发", "尬酒回复",  "改进的话", "天天速度回答", "太好了开车",
                "减肥的看过","桡出口处那","如果觉得", "很舒服的","吃软饭","从看见二十多",
               "龙卷风亏大发","去好看", "多喝点", "好浪费好", "打电话"};
            var list1 = GetDateList(list11);
            //var list11 = new List<string> {
            //   "爱你", "哎呦","埃及","哈弗换壳哈弗", "爱德华多v","俺几个疯了",
            //    "拜了", "巴士", "百夫",  "百合地理课你打算", "不度老骥伏枥", "比到九点",
            //    "车站","测试","此地", "才看见好得快","吃软饭","从看见二十多",
            //   "等待机会吧","的客户", "多喝点", "登记哦然后", "打电话",
            //     "恩肤霜看就看了", "饿死os","恶魔城","儿科联动", "恩六颗子弹拉拉裤洗澡了","发大学生发发",
            //    "真厉害i发多少", "知道你付款了发", "尬酒回复",  "改进的话", "天天速度回答", "太好了开车",
            //    "减肥的看过","桡出口处那","如果觉得", "很舒服的","吃软饭","从看见二十多",
            //   "龙卷风亏大发","去好看", "多喝点", "好浪费好", "打电话"};
            if (list == null)
            {
                list = new List<string>();
            }
            if (list6 == null)
            {
                list6 = new List<string>();
            }
            var list1 = GetDateList(list);
            list1.Add("1");
            list1.InsertRange(0, list6);
            var vv = new VerticalScrolViewLayout();
            fram.AddChidren(vv);
            var listStr = new List<string>();
            listStr.AddRange(list1);
            editText.TextChangeEventHandler += (view, strView) =>
            {
                var listStr = new List<string>();
                listStr.Clear();
                for (int i = 0; i < list1.Count; i++)
                {
                    var s = list1[i];
@@ -92,7 +125,7 @@
                        listStr.Add(s);
                    }
                }
                RefreshLayout(vv, listStr);
                RefreshLayout(vv, listStr, action);
            };
@@ -102,50 +135,55 @@
            var a_zFra = new FrameLayout
            {
                Y = Application.GetRealHeight(46),
                X = Application.GetRealWidth(362-6),
                X = Application.GetRealWidth(362 - 6),
                Height = Application.GetRealHeight(351),
                Width = Application.GetRealWidth(10+6),
                Width = Application.GetRealWidth(10 + 6),
            };
            fram.AddChidren(a_zFra);
            var list = GetList();
            for (int i = 0; i < list.Count; i++)
            var list2 = GetList();
            for (int i = 0; i < list2.Count; i++)
            {
                var a_zBtn = new Button
                {
                    Padding= new Padding(0,6,0,0),
                    Padding = new Padding(0, 6, 0, 0),
                    Y = Application.GetRealHeight(i * 13),
                    Width = Application.GetRealWidth(16),
                    Height = Application.GetRealHeight(10),
                    Text = list[i],
                    Text = list2[i],
                    TextSize = TextSize.text10,
                    TextColor = CSS.CSS_Color.textConfirmColor,
                    Tag= list[i],
                    Tag = list2[i],
                };
                a_zFra.AddChidren(a_zBtn);
                a_zBtn.MouseUpEventHandler += (sender, e) =>
                {
                    //找到索引值
                    var index = list1.IndexOf(a_zBtn.Tag.ToString());
                    if (index != -1)
                    try
                    {
                        vv.ScrollToViewIndex(index);
                    }
                    else
                    {
                        if (a_zBtn.Tag.ToString() == "#")
                        //找到索引值
                        var index = listStr.IndexOf(a_zBtn.Tag.ToString());
                        if (index != -1)
                        {
                            vv.ScrollToViewIndex(0);
                            vv.ScrollToViewIndex(index);
                        }
                        else
                        {
                            if (a_zBtn.Tag.ToString() == "#")
                            {
                                vv.ScrollToViewIndex(0);
                            }
                        }
                    }
                    catch { }
                };
            }
            #endregion
            RefreshLayout(vv, list1);
            RefreshLayout(vv, list1,action);
@@ -157,7 +195,7 @@
        /// </summary>
        /// <param name="vv">父控件</param>
        /// <param name="list">显示列表</param>
        private void RefreshLayout(VerticalScrolViewLayout vv, List<string> list)
        private void RefreshLayout(VerticalScrolViewLayout vv, List<string> list,Action<string> action)
        {
            vv.RemoveAll();
            foreach (var str in list)
@@ -174,9 +212,10 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = str,
                };
                var clickBtn = new Button {
                var clickBtn = new Button
                {
                    Tag = str,
                    Width=Application.GetRealWidth(350),
                    Width = Application.GetRealWidth(350),
                };
                if (Exist(str))
@@ -194,7 +233,7 @@
                    rowLayout.AddChidren(clickBtn);
                }
                vv.AddChidren(rowLayout);
                clickBtn.MouseUpEventHandler += (se, e) =>
                clickBtn.MouseUpEventHandler += (sen, e) =>
                {
                    //找到索引值
                    var index = list.IndexOf(clickBtn.Tag.ToString());
@@ -213,7 +252,7 @@
        private bool Exist(string str)
        {
            if (GetList().Contains(str)|| "主流品牌"== str)
            if (GetList().Contains(str) || "主流品牌" == str)
            {
                return true;
            }
@@ -230,64 +269,47 @@
        private List<string> GetDateList(List<string> mList)
        {
            var list = new List<string>();
            for (int i = 0; i < mList.Count; i++)
            //获取A-Z字母列表
            var a_zList = GetList(false);
            //遍历A-Z字母列表
            for (int i = 0; i < a_zList.Count; i++)
            {
                //提取字符串第一位
                string str = mList[i].Substring(0, 1);
                var s = GetCharSpellCode(str);
                if (!list.Contains(s))
                var zimu = a_zList[i];
                //遍历字符串列表
                for (int a = 0; a < mList.Count; a++)
                {
                    foreach (var value in GetList(false))
                    {
                        if (!list.Contains(s))
                        {
                            //重新排序A-Z
                            list.Add(s);
                        }
                    }
                }
            }
            return RelationshipList(list, mList);
        }
        /// <summary>
        /// 重新排序字母与数据关系
        /// </summary>
        /// <param name="mList1">字母表</param>
        /// <param name="mList2">显示数据表</param>
        /// <returns></returns>
        private List<string> RelationshipList(List<string> mList1, List<string> mList2)
        {
            var list = new List<string>();
            for (int i = 0; i < mList1.Count; i++)
            {
                var zimo = mList1[i];
                ///添加字母
                list.Add(zimo);
                for (int j = 0; j < mList2.Count; j++)
                {
                    var str = mList[a];
                    //提取字符串第一位
                    string str = mList2[j].Substring(0, 1);
                    var s = GetCharSpellCode(str);
                    //判断返回字母与当前字母是否相等
                    if (zimo == s)
                    string s = str.Substring(0, 1);
                    //返回字符串第一位首字母(大写)
                    var a_z = GetCharSpellCode(s);
                    //判断是否同字母
                    if (zimu == a_z)
                    {
                        ///添加数据
                        list.Add(mList2[j]);
                        //判断列表是否存在字母
                        if (!list.Contains(zimu))
                        {
                            //添加字母
                            list.Add(zimu);
                        }
                        //添加首字同一个字母的数据
                        list.Add(str);
                    }
                }
            }
            return list;
        }
        /// <summary>
        /// 获取A-Z字母列表
        /// </summary>
        /// <returns></returns>
        private List<string> GetList(bool value=true) {
        private List<string> GetList(bool value = true)
        {
            var list = new List<string>();
            if (value) {
            if (value)
            {
                list.Add("#");
            }
            for (int j = 65; j <= 90; j++)