wjc
2023-07-18 edfb48fa10b0518311ee46bef4aded0859069d16
2023年07月18日17:50:46

自动化输出RGB,RGBW设备增加rgb属性
1个文件已添加
6个文件已修改
435 ■■■■■ 已修改文件
HDL_ON/HDL_ON.projitems 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs 249 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/HDL_ON.projitems
@@ -551,6 +551,7 @@
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\VideoDoorLock\VideoDoorLockPage.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\VideoDoorLock\VideoDoorLockListPage.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\Light\GroupControlPage.cs" />
    <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\LogicView\RGBColorView.cs" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" />
HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -1405,7 +1405,7 @@
                string value = dic["value"];
                if (dictionaryA["key"] == key && dictionaryA["comparator"] == comparatorValue)
                {
                    if (this.checkSpk())
                    if (this.CheckSpk())
                    {
                        //有些设备需要增加这个判断
                        if (dictionaryA["value"] == value)
@@ -1429,7 +1429,7 @@
        /// 检查是否支持
        /// </summary>
        /// <returns></returns>
        private bool checkSpk()
        private bool CheckSpk()
        {
            if (this.function.spk == SPK.VideoDoorLock ||
               this.function.spk == SPK.doorgate
HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -1071,9 +1071,28 @@
                                                stateStr += "," +GetKeyValue("cct", dicList) + "k";
                                            }
                                        }
                                        if (device.spk == SPK.LightRGB)
                                        {
                                            string rgb = GetKeyValue("rgb", dicList);
                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
                                            {
                                                targetView.btnStateColor.Visible = true;
                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
                                            }
                                        }
                                        if (device.spk == SPK.LightRGBW)
                                        {
                                            string rgb = GetKeyValue("rgbw", dicList);
                                            if (!string.IsNullOrEmpty(rgb) && rgb.Length > 6)
                                            {
                                                targetView.btnStateColor.Visible = true;
                                                targetView.btnStateColor.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(rgb);
                                            }
                                        }
                                    }
                                    break;
                                case SPK.CurtainSwitch:
                                    {
                                        foreach (var dic in dicList)
@@ -1170,7 +1189,11 @@
                                        if (set_temp != "")
                                        {
                                            string unit = device.GetAttribute("temperature_type") == null ? "°" : device.GetAttribute("temperature_type").state;
                                            string unit = device.GetAttribute("temperature_type") == null ? "℃" : device.GetAttribute("temperature_type").state;
                                            if (string.IsNullOrEmpty(unit))
                                            {
                                                unit = "℃";
                                            }
                                            stateStr += set_temp + unit+",";
                                        }
@@ -1268,7 +1291,11 @@
                                        }
                                        if (set_temp != "")
                                        {
                                            string unit = device.GetAttribute("temperature_type") == null ? "°" : device.GetAttribute("temperature_type").state;
                                            string unit = device.GetAttribute("temperature_type") == null ? "℃" : device.GetAttribute("temperature_type").state;
                                            if (string.IsNullOrEmpty(unit))
                                            {
                                                unit = "℃";
                                            }
                                            stateStr += set_temp + unit + ",";
                                        }
                                        if (mode != "")
@@ -1614,6 +1641,22 @@
                                        button3.Text = value + "k";
                                    }
                                    break;
                                case "rgb":
                                case "rgbw":
                                    {
                                        if (button3 == null)
                                        {
                                            //怕调试软件乱上东西导致抛异常
                                            break;
                                        }
                                        if (!string.IsNullOrEmpty(value) && value.Length > 6)
                                        {
                                            button3.BackgroundColor = new LogicView.RGBColorView().GetBackgroundColor(value);
                                            button3.Tag = value;
                                        }
                                    }
                                    break;
                            }
                        }
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -187,7 +187,7 @@
            var list2 = this.GetVideoDeviceList();
            list.AddRange(list1);
            list.AddRange(list2);
            //GetTestDevice(ref list, true);
            GetTestDevice(ref list, true);
            return list;
        }
        /// <summary>
@@ -1197,7 +1197,9 @@
                      // new Entity.Function { sid = "1234567899", name = "门磁传感器", spk = Entity.SPK.SensorDoorWindow },
                      //  new Entity.Function { sid = "12345678991234", name = "HDL机械手", spk = Entity.SPK.MechanicalArm },
                      //    new Entity.Function { sid = "123456789912345", name = "海曼机械手", spk = Entity.SPK.MechanicalArm },
                      //        new Entity.Function { sid = "12345678991234566", name = "海曼机械手", spk = Entity.SPK.MechanicalArm },
                              new Entity.Function { sid = "123456789912345668", name = "AC", spk = Entity.SPK.AcIr },
                                 new Entity.Function { sid = "12345678991234567", name = "RGB", spk = Entity.SPK.LightRGB },
                                  new Entity.Function { sid = "123456789912345678", name = "RGBW", spk = Entity.SPK.LightRGBW },
            };
                foreach (var function in functions)
                {
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/AddOutputInputView.cs
@@ -62,6 +62,17 @@
            X = Application.GetRealWidth(165-10),
            TextAlignment = TextAlignment.CenterRight,
        };
        /// <summary>
        /// (条件或者目标)色盘专用
        /// </summary>
        public Button btnStateColor = new Button
        {
            Width = Application.GetRealWidth(10),
            Height = Application.GetRealWidth(10),
            Radius = (uint)Application.GetRealHeight(5),
            X = Application.GetRealWidth(315 - 10),
            Visible=false,
        };
        /// <summary>
        /// (条件或者目标)图标
@@ -122,12 +133,14 @@
            verticalScrolView.AddChidren(frameLayout);
            frameLayout.AddChidren(rowLayout);
            btnIcon.Gravity = Gravity.CenterVertical;
            btnStateColor.Gravity = Gravity.CenterVertical;
            btnText.Gravity = Gravity.CenterVertical;
            btnText.TextAlignment = TextAlignment.CenterLeft;
            btnNextIcon.Gravity = Gravity.CenterVertical;
            rowLayout.AddChidren(btnIcon);
            rowLayout.AddChidren(btnText);
            rowLayout.AddChidren(btnState);
            rowLayout.AddChidren(btnStateColor);
            rowLayout.AddChidren(btnNextIcon);
            rowLayout.AddRightView(btnDelay);
            rowLayout.AddRightView(btnDel);
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/RGBColorView.cs
New file
@@ -0,0 +1,249 @@
using System;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI.UI2.Intelligence.Automation.LogicView
{
    public class RGBColorView
    {
        public RGBColorView()
        {
        }
        /// <summary>
                /// 加载rgb选择弹窗
                /// </summary>
                /// <param name="function"></param>
                /// <param name="btn"></param>
        public void LoadRGBDialog(string stateRGBValue, Action<string> action)
        {
            string rgbString = "";
            Light tempLight = new Light();
            if (string.IsNullOrEmpty(stateRGBValue))
            {
                stateRGBValue = "255,255,255";
            }
            Dialog dialog = new Dialog()
            {
                Height = Application.GetRealHeight(647),
            };
            var bodyView = new FrameLayout();
            dialog.AddChidren(bodyView);
            var contentView = new FrameLayout()
            {
                Gravity = Gravity.BottomCenter,
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(300),
                Radius = (uint)Application.GetRealWidth(12),
            };
            bodyView.AddChidren(contentView);
            #region 标题区
            var titleView = new FrameLayout()
            {
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(52),
            };
            contentView.AddChidren(titleView);
            var btnTitle = new Button()
            {
                Height = Application.GetRealHeight(52),
                Gravity = Gravity.Center,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextColor = CSS_Color.MainColor,
                Text = "RGB",
                TextAlignment = TextAlignment.Center,
            };
            titleView.AddChidren(btnTitle);
            titleView.AddChidren(new Button() { Height = 1, BackgroundColor = CSS_Color.DividingLineColor, Y = Application.GetRealHeight(51) });
            #endregion
            int attrViewHight = Application.GetRealHeight(245);
            //属性设置区域
            var attrView = new FrameLayout()
            {
                Y = Application.GetRealHeight(52),
                Width = Application.GetRealWidth(343),
                Height = attrViewHight
            };
            contentView.AddChidren(attrView);
            attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
            #region RGB
            var rgbView = new FrameLayout()
            {
                Height = Application.GetRealHeight(248)
            };
            attrView.AddChidren(rgbView);
            var btnCurColor = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(10),
                Width = Application.GetMinRealAverage(24),
                Height = Application.GetMinRealAverage(24),
                Radius = (uint)Application.GetMinRealAverage(8),
                BorderColor = CSS_Color.PromptingColor2,
                BorderWidth = 1,
                BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(stateRGBValue))
            };
            rgbView.AddChidren(btnCurColor);
            //色盘的桌布控件(限制那个白色滑动球使用)
            var framePickerBack = new FrameLayout();
            framePickerBack.Gravity = Gravity.CenterHorizontal;
            framePickerBack.Y = Application.GetRealHeight(20);
            framePickerBack.Width = Application.GetMinRealAverage(198);
            framePickerBack.Height = Application.GetMinRealAverage(198);
            rgbView.AddChidren(framePickerBack);
            var colorPicker = new ColorPicker()
            {
                ColorImagePath = "FunctionIcon/Light/ColorWheel.png",
            };
            framePickerBack.AddChidren(colorPicker);
            //白点控件
            var btnWhiteRound = new Button();
            btnWhiteRound.Width = Application.GetRealWidth(24);
            btnWhiteRound.Height = Application.GetRealWidth(24);
            btnWhiteRound.UnSelectedImagePath = "FunctionIcon/Light/ColorWheelTip.png";
            btnWhiteRound.Visible = false;
            framePickerBack.AddChidren(btnWhiteRound);
            //当前点击的【点】是否正确
            bool pointIsRight = false;
            //圆的半径(考虑边界,需要设置它的半径比较小一点)
            int circleR = colorPicker.Width / 2 - Application.GetRealWidth(12);
            colorPicker.ColorChaged += (sender2, e2) =>
            {
                rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
                //trait.value = rgbString;
                btnCurColor.BackgroundColor = (uint)(0xFF000000 + tempLight.GetRGBcolor(rgbString));
            };
            colorPicker.MouseDownEventHandler += (sender, e) =>
            {
                pointIsRight = this.CheckPoint(circleR, colorPicker.Width / 2, colorPicker.Height / 2, (int)e.X, (int)e.Y);
                if (pointIsRight == false)
                {
                    //点的区域不是圆盘内
                    return;
                }
                //显示白点
                btnWhiteRound.X = (int)e.X - btnWhiteRound.Width / 2;
                btnWhiteRound.Y = (int)e.Y - btnWhiteRound.Height / 2;
                if (btnWhiteRound.Visible == false)
                {
                    btnWhiteRound.Visible = true;
                }
            };
            colorPicker.MouseMoveEventHandler += (sender, e) =>
            {
                //当鼠标点下事件处理
                colorPicker.MouseDownEventHandler(sender, e);
            };
            #endregion
            #region 
            var btnCancel = new Button()
            {
                X = Application.GetRealWidth(20),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(44),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.TextualColor,
                TextID = StringId.Cancel,
            };
            titleView.AddChidren(btnCancel);
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            var btnComplete = new Button()
            {
                X = Application.GetRealWidth(223),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(46),
                TextColor = CSS_Color.MainColor,
                TextAlignment = TextAlignment.CenterRight,
                TextSize = CSS_FontSize.TextFontSize,
                TextID = StringId.Complete
            };
            titleView.AddChidren(btnComplete);
            //例:右下圆角 大小为50
            int mRectCornerID = HDLUtils.RectCornerBottomRight;
            btnComplete.SetCornerWithSameRadius((uint)Application.GetRealWidth(14), mRectCornerID);
            btnComplete.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
                action?.Invoke(rgbString);
                //trait.value = rgbString;
            };
            #endregion
            dialog.Show();
        }
        /// <summary>
        /// 检测点击点
        /// </summary>
        /// <param name="circleR">圆的半径</param>
        /// <param name="circleX">圆心X轴</param>
        /// <param name="circleY">圆心Y轴</param>
        /// <param name="pointX">点击点的X轴</param>
        /// <param name="pointY">点击点的Y轴</param>
        /// <returns></returns>
        private bool CheckPoint(int circleR, int circleX, int circleY, int pointX, int pointY)
        {
            int dwidth = circleX - pointX;
            if (dwidth < 0) { dwidth *= -1; }
            int dHeight = circleY - pointY;
            if (dHeight < 0) { dHeight *= -1; }
            //根据三角函数,求三角形的斜边长
            int dlength = dwidth * dwidth + dHeight * dHeight;
            //半径长度(不开方,所以是按平方算)
            circleR *= circleR;
            if (dlength < circleR)
            {
                //如果组成的三角形并没有长过半径,则代表还在圆内(不允许点边界)
                return true;
            }
            return false;
        }
        /// <summary>
        /// 获取控件背景值
        /// button.BackgroundColor =(uint)(0xFF000000 + new Light().GetRGBcolor(rgbValueStr))
        /// </summary>
        /// <param name="rgbString">rgb值</param>
        /// <returns></returns>
        public uint GetBackgroundColor(string rgbString)
        {
            return (uint)(0xFF000000 + new Light().GetRGBcolor(rgbString));
        }
    }
}
HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -2,6 +2,7 @@
using Shared;
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
@@ -113,8 +114,8 @@
                    break;
                //灯光开关 亮度
                case SPK.LightDimming:
                case SPK.LightRGB:
                case SPK.LightRGBW:
                //case SPK.LightRGB:
                //case SPK.LightRGBW:
                    {
                        #region 界面
                        ///开关
@@ -146,6 +147,60 @@
                        {
                            //显示编辑之前的设备状态
                            GetEditDeviceState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null);
                        }
                        #endregion
                    }
                    break;
                case SPK.LightRGB:
                case SPK.LightRGBW:
                    {
                        #region 界面
                        ///开关
                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
                        lightSwitchView.btnText.TextID = StringId.switchLogic;
                        fLayout.AddChidren(lightSwitchView.FLayoutView());
                        ///亮度
                        LogicView.FunTypeView brightnessView = new LogicView.FunTypeView();
                        brightnessView.frameLayout.Y = lightSwitchView.frameLayout.Bottom;
                        brightnessView.btnText.TextID = StringId.brightnesLogic;
                        fLayout.AddChidren(brightnessView.FLayoutView());
                        brightnessView.btnState.Text = "5%";//产品经理晓辉要求改的 2021-11-06
                        ///RGB色盘
                        LogicView.FunTypeView rgbView = new LogicView.FunTypeView();
                        rgbView.frameLayout.Y = brightnessView.frameLayout.Bottom;
                        //rgbView.btnText.TextID = StringId.brightnesLogic;
                        rgbView.btnText.Text= "RGB色盘";
                        rgbView.btnState.Tag = "";
                        rgbView.btnState.Width = Application.GetRealWidth(16);
                        rgbView.btnState.Height = Application.GetRealWidth(16);
                        rgbView.btnState.Radius = (uint)Application.GetRealWidth(8);
                        rgbView.btnState.X = Application.GetRealWidth(375 - 48 - 16);
                        fLayout.AddChidren(rgbView.FLayoutView());
                        ///设备延时iewv
                        DelayView(fLayout, rgbView.frameLayout.Bottom);
                        #endregion
                        #region 点击事件
                        ///开关点击事件
                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            SwitchViewMethod(device, lightSwitchView.btnState, 2);
                        };
                        ///亮度点击事件
                        brightnessView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            BrightnessMethod(device, brightnessView.btnState, brightnessView.btnText.Text);
                        };
                        ///RGB色盘点击事件
                        rgbView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
                            RgbColorDiskMethod(device, rgbView.btnState, rgbView.btnText.Text);
                        };
                        if (edit)
                        {
                            //显示编辑之前的设备状态
                            GetEditDeviceState(device, index, lightSwitchView.btnState, brightnessView.btnState, rgbView.btnState, null);
                        }
                        #endregion
                    }
@@ -333,7 +388,12 @@
                        };
                        int min = device.GetAttribute("set_temp") == null ? 16 : device.GetAttribute("set_temp").min;
                        int max = device.GetAttribute("set_temp") == null ? 32 : device.GetAttribute("set_temp").max;
                        string unit = device.GetAttribute("temperature_type") == null ? "°" : device.GetAttribute("temperature_type").state;
                        string unit = device.GetAttribute("temperature_type") == null ? "℃" : device.GetAttribute("temperature_type").state;
                        if (string.IsNullOrEmpty(unit))
                        {
                            //调试软件有空能上传为空
                            unit = "℃";
                        }
                        ///温度点击事件
                        temperatureView.btnClick.MouseUpEventHandler += (sender, e) =>
                        {
@@ -439,7 +499,11 @@
                        {
                            int min = device.GetAttribute("set_temp") == null ? 16 : device.GetAttribute("set_temp").min;
                            int max = device.GetAttribute("set_temp") == null ? 32 : device.GetAttribute("set_temp").max;
                            string unit = device.GetAttribute("temperature_type") == null ? "°" : device.GetAttribute("temperature_type").state;
                            string unit = device.GetAttribute("temperature_type") == null ? "℃" : device.GetAttribute("temperature_type").state;
                            if (string.IsNullOrEmpty(unit)) {
                                //调试软件有空能上传为空
                                unit = "℃";
                            }
                            string tempValue = temperatureView.btnState.Text;
                            LogicView.TemperatureView tempView = new LogicView.TemperatureView();
                            tempView.FLayoutView(this, tempValue, (stateStr) =>
@@ -951,6 +1015,47 @@
            #endregion
        }
        /// <summary>
        /// RGB色盘专用
        /// </summary>
        /// <param name="device">设备</param>
        /// <param name="button">状态控件</param>
        /// <param name="titleName">标题</param>
        private void RgbColorDiskMethod(Entity.Function device, Button button, string titleName)
        {
            LogicView.RGBColorView rgbColorView = new LogicView.RGBColorView();
            rgbColorView.LoadRGBDialog(button.Tag.ToString(), (rgbValueStr) =>
            {
                button.BackgroundColor = rgbColorView.GetBackgroundColor(rgbValueStr);
                //界面显示选中值
                button.Tag = rgbValueStr;
                //button.Text = rgbValueStr;
                selectedState = device.spk + rgbValueStr.ToString();
                //设备属性值,云雀上定义好的;
                string keyVlaue = "";
                switch (device.spk)
                {
                    case SPK.LightRGB:
                        {
                            keyVlaue = "rgb";
                        }
                        break;
                    case SPK.LightRGBW:
                        {
                            keyVlaue = "rgbw";
                        }
                        break;
                }
                //数据封装
                AddDictionary(keyVlaue, rgbValueStr);
            });
        }
        /// <summary>
        /// 显示编辑之前的设备状态
        /// </summary>
@@ -1054,5 +1159,7 @@
        }
    }
}