From 753e67c3705dddb8e913bd853db151f94f81d600 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 05 六月 2023 09:45:05 +0800
Subject: [PATCH] Merge branch 'Dev-Wxr'

---
 HDL_ON/UI/UI2/FuntionControlView/OrderFunctionPage.cs |  334 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 334 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/OrderFunctionPage.cs b/HDL_ON/UI/UI2/FuntionControlView/OrderFunctionPage.cs
new file mode 100644
index 0000000..a20397c
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/OrderFunctionPage.cs
@@ -0,0 +1,334 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using HDL_ON.DAL.Server;
+using HDL_ON.DriverLayer;
+using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
+using Shared;
+
+namespace HDL_ON.UI
+{
+    public class OrderFunctionPage : FrameLayout
+    {
+        #region 鎺т欢鍒楄〃
+        /// <summary>
+        /// 褰撳墠绐椾綋
+        /// </summary>
+        static FrameLayout bodyView;
+        /// <summary>
+        /// 鍔熻兘鍒楄〃闆嗗悎鏄剧ず鍖哄煙
+        /// </summary>
+        static VerticalScrolViewLayout functionListView;
+        /// <summary>
+        /// 瀹屾垚鎸夐挳
+        /// </summary>
+        Button btnConfrim;
+
+        #endregion
+        /// <summary>
+        /// 鍥炶皟鍒锋柊
+        /// </summary>
+        Action<Scene> backActon;
+
+        List<Function> orderList = new List<Function>();
+        List<int> orderNumber = new List<int>();
+
+        public OrderFunctionPage()
+        {
+            bodyView = this;
+        }
+
+        public void LoadPage(List<Function> functions,Action action)
+        {
+            List<int> orderNumberAlreay = new List<int>();
+            for (int i=0;i< functions.Count; i++)
+            {
+                if (functions[i].FunctionOrderNumber != 9999)
+                {
+                    orderNumberAlreay.Add(functions[i].FunctionOrderNumber);
+                }
+            }
+            for (int i = 1; i < functions.Count + 1; i++)
+            {
+                if (!orderNumberAlreay.Contains(i))
+                {
+                    orderNumber.Add(i);
+                }
+            }
+
+            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
+            new TopViewDiv(bodyView, Language.StringByID(StringId.Sort)).LoadTopView();
+
+            functionListView = new VerticalScrolViewLayout()
+            {
+                Y = Application.GetRealHeight(84),
+                Height = Application.GetRealHeight(640 - 100),
+            };
+            bodyView.AddChidren(functionListView);
+
+            LoadRow(functions);
+
+            #region 搴曢儴view
+            var bottomView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(591),
+                Height = Application.GetRealHeight(100),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+            };
+            this.AddChidren(bottomView);
+
+            btnConfrim = new Button()
+            {
+                Y = Application.GetRealHeight(12),
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(220),
+                Height = Application.GetRealHeight(44),
+                Radius = (uint)Application.GetRealHeight(22),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.MainBackgroundColor,
+                BackgroundColor = CSS_Color.BackgroundColor,
+                TextID = StringId.Confirm,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                SelectedTextColor = CSS_Color.MainBackgroundColor,
+                SelectedBackgroundColor = CSS_Color.MainColor,
+                IsSelected = true
+            };
+            bottomView.AddChidren(btnConfrim);
+            btnConfrim.MouseUpEventHandler = (sender, e) => {
+                foreach(var function in functions)
+                {
+                    function.SaveFunctionFile();
+                }
+                    action?.Invoke();
+                    this.RemoveFromParent();
+            };
+
+            #endregion
+
+        }
+
+        /// <summary>
+        /// 鏄剧ず鐨勮澶囩殑鎬绘暟
+        /// </summary>
+        int showCount = -1;
+
+        /// <summary>
+        /// 鍔犺浇鍔熻兘row
+        /// </summary>
+        /// <param name="lightList"></param>
+        void LoadRow(List<Function> functions, bool isAppend = false)
+        {
+            var waitPage = new Loading();
+            bodyView.AddChidren(waitPage);
+            waitPage.Start("");
+
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        if (!isAppend)
+                        {
+                            showCount = -1;
+                            functionListView.RemoveAll();
+                        }
+
+                        for(var i =0;i<100;i++)
+                        //foreach (var function in functions)
+                        {
+                            showCount++;
+                            if (showCount >= functions.Count)
+                            {
+                                break;
+                            }
+                            var function = functions[showCount];
+                            var functionDiv = new OrderFunctionRow()
+                            {
+                                Gravity = Gravity.CenterHorizontal,
+                                Width = Application.GetRealWidth(343),
+                                Height = Application.GetRealHeight(62),
+                                Radius = (uint)Application.GetMinRealAverage(12),
+                                BorderColor = 0x00FFFFFF,
+                                BorderWidth = 1,
+                                BackgroundColor = CSS_Color.MainBackgroundColor,
+                            };
+
+                            functionDiv.LoadDiv(function, orderNumber);
+
+
+                            functionListView.AddChidren(functionDiv);
+
+                            functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
+                        }
+
+                        if (functions.Count > showCount)
+                        {
+                            var btnAppend = new Button()
+                            {
+                                Height = Application.GetRealHeight(60),
+                                TextAlignment = TextAlignment.Center,
+                                TextSize = CSS_FontSize.SubheadingFontSize,
+                                TextColor = CSS_Color.FirstLevelTitleColor,
+                                TextID = StringId.LoadMore,
+                            };
+                            functionListView.AddChidren(btnAppend);
+                            btnAppend.MouseUpEventHandler = (sender, e) =>
+                            {
+                                btnAppend.RemoveFromParent();
+                                LoadRow(functions, true);
+                            };
+                        }
+                    });
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log("ShowFunctionRowError : " + ex.Message);
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        if (waitPage != null)
+                        {
+                            waitPage.RemoveFromParent();
+                            waitPage = null;
+                        }
+                    });
+                }
+            })
+            { IsBackground = true }.Start();
+
+        }
+
+
+
+    }
+
+
+
+    public class OrderFunctionRow : FrameLayout
+    {
+        #region 鍖哄煙鎺т欢
+        static FrameLayout bodyDiv;
+        /// <summary>
+        /// 鍔熻兘/鍦烘櫙icon
+        /// </summary>
+        Button btnIcon;
+        /// <summary>
+        /// 鍔熻兘鍚嶇О/鍦烘櫙鍚嶇О
+        /// </summary>
+        Button btnName;
+        /// <summary>
+        /// 妤煎眰淇℃伅鏄剧ず鎸夐挳
+        /// </summary>
+        Button btnFromFloor;
+        /// <summary>
+        /// 閫変腑鎸夐挳
+        /// </summary>
+        Button btnSelect;
+        #endregion
+
+        public OrderFunctionRow()
+        {
+            bodyDiv = this;
+        }
+
+
+        /// <summary>
+        /// 鍔犺浇鎺у埗鍗$墖鍖哄煙
+        /// </summary>
+        public void LoadDiv(Function function, List<int> orderNumber)
+        {
+            btnIcon = new Button()
+            {
+                X = Application.GetRealWidth(10),
+                Y = Application.GetRealHeight(15),
+                Width = Application.GetRealWidth(32),
+                Height = Application.GetRealWidth(32),
+                UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"
+            };
+            bodyDiv.AddChidren(btnIcon);
+
+            btnName = new Button()
+            {
+                X = Application.GetRealWidth(8 + 10 + 32),
+                Y = Application.GetRealHeight(10),
+                Width = Application.GetRealWidth(200),
+                Height = Application.GetRealHeight(24),
+                Text = function.name,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextSize = CSS_FontSize.TextFontSize,
+            };
+            bodyDiv.AddChidren(btnName);
+
+            btnFromFloor = new Button()
+            {
+                X = Application.GetRealWidth(8 + 10 + 32),
+                Y = Application.GetRealHeight(10 + 24),
+                Width = Application.GetRealWidth(200),
+                Height = Application.GetRealHeight(18),
+                Text = function.GetRoomListName(),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.PromptingColor1,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+            };
+            bodyDiv.AddChidren(btnFromFloor);
+
+            btnSelect = new Button()
+            {
+                X = Application.GetRealWidth(303),
+                Gravity = Gravity.CenterVertical,
+                Width = Application.GetRealWidth(32),
+                Height = Application.GetRealWidth(32),
+                Text = function.FunctionOrderNumber == 9999 ? "" : function.FunctionOrderNumber.ToString(),
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextAlignment = TextAlignment.Center,
+            };
+            bodyDiv.AddChidren(btnSelect);
+
+            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+                lock (orderNumber)
+                {
+                    if (function.FunctionOrderNumber == 9999)
+                    {
+                        function.FunctionOrderNumber = orderNumber[0];
+                        orderNumber.RemoveAt(0);
+                        btnSelect.Text = function.FunctionOrderNumber.ToString();
+                    }
+                    else
+                    {
+
+                        if (!orderNumber.Contains(function.FunctionOrderNumber))
+                        {
+                            for (var i = 0; i < orderNumber.Count; i++)
+                            {
+                                if (orderNumber[i] > function.FunctionOrderNumber)
+                                {
+                                    orderNumber.Insert(i, function.FunctionOrderNumber);
+                                    function.FunctionOrderNumber = 9999;
+                                    break;
+                                }
+                            }
+                        }
+                        if (function.FunctionOrderNumber != 9999)
+                        {
+                            orderNumber.Add(function.FunctionOrderNumber);
+                            function.FunctionOrderNumber = 9999;
+                        }
+                        btnSelect.Text = "";
+                    }
+                }   
+            };
+            btnName.MouseUpEventHandler = eventHandler;
+            btnSelect.MouseUpEventHandler = eventHandler;
+            bodyDiv.MouseUpEventHandler = eventHandler;
+
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.8.0