From bfb3d0d4879dca8c59ff287c92f5113162f3a33a Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期二, 27 八月 2024 15:22:48 +0800
Subject: [PATCH] 代码备份

---
 OnPro/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs |  352 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 352 insertions(+), 0 deletions(-)

diff --git a/OnPro/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs b/OnPro/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs
new file mode 100644
index 0000000..a8dc5e0
--- /dev/null
+++ b/OnPro/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicSeriesSettingPage.cs
@@ -0,0 +1,352 @@
+锘縰sing System;
+using System.Collections.Generic;
+using HDL_ON.Entity;
+using HDL_ON.UI.CSS;
+using Shared;
+namespace HDL_ON.UI.UI2.Intelligence.Automation
+{
+    public class LogicSeriesSettingPage :FrameLayout
+    {
+        FrameLayout bodyView;
+
+        public LogicSeriesSettingPage()
+        {
+            bodyView = this;
+        }
+
+        public void LoadPage(List<Function> list)
+        {
+            new TopViewDiv(bodyView, Language.StringByID(StringId.HorseRaceLamp)).LoadTopView();
+            bodyView.BackgroundColor = CSS.CSS_Color.BackgroundColor;
+
+            VerticalScrolViewLayout contentView = new VerticalScrolViewLayout()
+            {
+                Y = Application.GetRealHeight(64),
+                Height = Application.GetRealHeight(603 - 50),
+            };
+            bodyView.AddChidren(contentView);
+
+            #region 鎵惧嚭鎵�鏈夊簭鍒楃殑oid
+            List<string> oidList = new List<string>();
+
+            foreach (var rgb in list)
+            {
+                var oid = rgb.sid.Substring(0, 16);
+                if (!oidList.Contains(oid))
+                {
+                    oidList.Add(oid);
+                }
+            }
+
+            var seriesList = FunctionList.List.GetSeries();
+
+            foreach(var temp in seriesList)
+            {
+                var oid = temp.sid.Substring(0, 16);
+                if (!oidList.Contains(oid))
+                {
+                    oidList.Add(oid);
+                }
+            }
+            #endregion
+
+
+            //Dictionary<string, List<string>> deviceList = new Dictionary<string, List<string>>();
+            //foreach(var oid in oidList)
+            //{
+            //    var sidList = FunctionList.List.
+
+            //    if (!deviceList.ContainsKey(oid))
+            //    {
+            //        deviceList.Add(oid)
+            //    }
+            //}
+
+            foreach(var oid in oidList)
+            {
+                Function rgb = null;
+                rgb = list.Find((obj) => obj.sid.Substring(0, 16) == oid);
+                if(rgb == null)
+                {
+                    rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightRGB && obj.sid.Substring(0, 16) == oid);
+                    if (rgb == null)
+                    {
+                        rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightCCT && obj.sid.Substring(0, 16) == oid);
+                        if (rgb == null)
+                        {
+                            rgb = FunctionList.List.GetLightList().Find((obj) => obj.spk == SPK.LightDimming && obj.sid.Substring(0, 16) == oid);
+                        }
+                    }
+                }
+                var titleView = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(44),
+                    BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                };
+                contentView.AddChidren(titleView);
+                titleView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor, Gravity = Gravity.BottomCenter });
+
+                var btnViewTitle = new Button()
+                {
+                    X = Application.GetRealWidth(16),
+                    TextSize = CSS.CSS_FontSize.SubheadingFontSize,
+                    IsBold = true,
+                    Text = rgb.name,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = CSS.CSS_Color.MainColor,
+                };
+                titleView.AddChidren(btnViewTitle);
+
+                if (rgb.GetAttribute(FunctionAttributeKey.Colorful) != null)
+                {
+                    var autoColorfulView = new FrameLayout()
+                    {
+                        Height = Application.GetRealHeight(44),
+                        BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                    };
+                    contentView.AddChidren(autoColorfulView);
+                    autoColorfulView.AddChidren(new Button() { Width = Application.GetRealWidth(343), Gravity = Gravity.BottomCenter, Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor, Y = Application.GetRealHeight(44) - 1 });
+
+                    Button btnAutoColorfulRight = new Button()
+                    {
+                        X = Application.GetRealWidth(339),
+                        Gravity = Gravity.CenterVertical,
+                        Width = Application.GetMinRealAverage(16),
+                        Height = Application.GetMinRealAverage(16),
+                        UnSelectedImagePath = "Public/Right.png",
+                    };
+                    autoColorfulView.AddChidren(btnAutoColorfulRight);
+
+                    var btnAutoColorfulTitle = new Button()
+                    {
+                        X = Application.GetRealWidth(16),
+                        TextAlignment = TextAlignment.CenterLeft,
+                        TextSize = CSS.CSS_FontSize.TextFontSize,
+                        TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                        TextID = StringId.Auto,
+                    };
+                    autoColorfulView.AddChidren(btnAutoColorfulTitle);
+                    btnAutoColorfulTitle.MouseUpEventHandler = (sender, e) =>
+                    {
+                        LoadEditDialog_OnOff(rgb.sid, true);
+                    };
+                }
+
+                var rgbSeriesList = seriesList.FindAll((obj) => obj.sid.Substring(0, 16) == rgb.sid.Substring(0, 16));
+                foreach(var rgbSeries in rgbSeriesList)
+                {
+                    var colorfulView = new FrameLayout()
+                    {
+                        Height = Application.GetRealHeight(44),
+                        BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
+                    };
+                    contentView.AddChidren(colorfulView);
+                    colorfulView.AddChidren(new Button() { Width = Application.GetRealWidth(343), Gravity = Gravity.BottomCenter, Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor, Y = Application.GetRealHeight(44) - 1 });
+
+                    Button btnColorfulRight = new Button()
+                    {
+                        X = Application.GetRealWidth(339),
+                        Gravity = Gravity.CenterVertical,
+                        Width = Application.GetMinRealAverage(16),
+                        Height = Application.GetMinRealAverage(16),
+                        UnSelectedImagePath = "Public/Right.png",
+                    };
+                    colorfulView.AddChidren(btnColorfulRight);
+
+                    var btnColorfulTitle = new Button()
+                    {
+                        X = Application.GetRealWidth(16),
+                        TextAlignment = TextAlignment.CenterLeft,
+                        TextSize = CSS.CSS_FontSize.TextFontSize,
+                        TextColor = CSS.CSS_Color.FirstLevelTitleColor,
+                        Text = rgbSeries.name,
+                    };
+                    colorfulView.AddChidren(btnColorfulTitle);
+                    btnColorfulTitle.MouseUpEventHandler = (sender, e) =>
+                    {
+                        LoadEditDialog_OnOff(rgbSeries.sid);
+                    };
+
+                }
+
+
+                contentView.AddChidren(new Button {
+                    Height = Application.GetRealHeight(8),
+                    BackgroundColor = CSS_Color.BackgroundColor,
+                });
+
+            }
+
+        }
+
+
+        /// <summary>
+        /// 鍔犺浇寮�鍏抽�夋嫨寮圭獥
+        /// </summary>
+        /// <param name="function"></param>
+        /// <param name="btn"></param>
+        void LoadEditDialog_OnOff(string sid, bool isRgb = false)
+        {
+            Dialog dialog = new Dialog();
+
+            var pView = new FrameLayout()
+            {
+                BackgroundColor = CSS_Color.DialogTransparentColor1,
+            };
+            dialog.AddChidren(pView);
+
+            var optionBaseView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(500),
+                Height = Application.GetRealHeight(160),
+                AnimateSpeed = 0.3f,
+                Animate = Animate.DownToUp,
+            };
+            pView.AddChidren(optionBaseView);
+
+            var optionView = new VerticalScrolViewLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(100),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+                ScrollEnabled = false,
+            };
+            optionBaseView.AddChidren(optionView);
+
+            var btnOn = new Button()
+            {
+                Height = Application.GetRealHeight(50),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.On,
+            };
+            optionView.AddChidren(btnOn);
+
+            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
+
+            var btnOff = new Button()
+            {
+                Height = Application.GetRealHeight(50),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.TextualColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.OFF,
+            };
+            optionView.AddChidren(btnOff);
+
+            var btnCancel = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(8) + optionView.Bottom,
+                Width = Application.GetRealWidth(343),
+                Height = Application.GetRealHeight(50),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(12),
+                TextID = StringId.Cancel,
+                TextColor = CSS_Color.WarningColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+            };
+            optionBaseView.AddChidren(btnCancel);
+
+            dialog.Show();
+
+            pView.MouseUpEventHandler = (sender, e) => {
+                dialog.Close();
+            };
+
+            btnCancel.MouseUpEventHandler = (sender, e) => {
+                dialog.Close();
+            };
+            btnOn.MouseUpEventHandler = (sender, e) => {
+                dialog.Close();
+                Output outputDevice = new Output();
+                outputDevice.target_type = "1";
+                outputDevice.sid = sid;
+                outputDevice.delay = "0";
+
+                List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>();
+
+                Dictionary<string, string> diction = new Dictionary<string, string>();
+                if (isRgb)
+                {
+                    diction.Add("key", FunctionAttributeKey.Colorful);
+                }
+                else
+                {
+                    diction.Add("key", "on_off");
+                }
+                diction.Add("value", "on");
+                dicSateteList.Add(diction);
+
+                outputDevice.status = dicSateteList;
+
+                var oldTemp = Logic.currlogic.output.Find((obj) => obj.sid.Substring(0, 16) == sid.Substring(0, 16));
+                if (oldTemp != null)
+                {
+                    Logic.currlogic.output.Remove(oldTemp);
+                }
+                Logic.currlogic.output.Add(outputDevice);
+
+                this.RemoveFromParent();
+                LogicMethod.Current.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+            };
+            btnOff.MouseUpEventHandler = (sender, e) => {
+                dialog.Close();
+
+
+                Output outputDevice = new Output();
+                outputDevice.target_type = "1";
+                outputDevice.sid = sid;
+                outputDevice.delay = "0";
+
+                List<Dictionary<string, string>> dicSateteList = new List<Dictionary<string, string>>();
+
+                Dictionary<string, string> diction = new Dictionary<string, string>();
+                if (isRgb)
+                {
+                    diction.Add("key", FunctionAttributeKey.Colorful);
+                }
+                else
+                {
+                    diction.Add("key", "on_off");
+                }
+                diction.Add("value", "off");
+                dicSateteList.Add(diction);
+
+                outputDevice.status = dicSateteList;
+
+                try
+                {
+                    var oldTemp = Logic.currlogic.output.Find((obj) => obj.sid != null && obj.sid.Length > 16 && obj.sid.Substring(0, 16) == sid.Substring(0, 16));
+                    if (oldTemp != null)
+                    {
+                        Logic.currlogic.output.Remove(oldTemp);
+                    }
+                }catch(Exception ex)
+                {
+                    MainPage.Log($"鑷姩鍖栦繚瀛樿窇椹伅鏁版嵁寮傚父:{ex.Message}");
+                }
+                Logic.currlogic.output.Add(outputDevice);
+
+
+                this.RemoveFromParent();
+
+                LogicMethod.Current.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+
+        }
+
+    }
+}

--
Gitblit v1.8.0