wei
2021-01-11 b271bcceb1c4e718377ca86b6213816abcf7482a
HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
@@ -1,6 +1,7 @@
using System;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI
@@ -8,7 +9,7 @@
    public partial class FunctionControlZone : FrameLayout
    {
        #region 区域控件
        FrameLayout bodyDiv;
        static FrameLayout bodyDiv;
        /// <summary>
        /// 功能/场景icon
        /// </summary>
@@ -37,6 +38,7 @@
        public FunctionControlZone(Function func)
        {
            bodyDiv = this;
            bodyDiv.Tag = func.sid;
            function = func;
        }
@@ -58,33 +60,30 @@
            }
            LoadDiv();
            if (function.functionCategory == FunctionCategory.Curtain || function.functionCategory == FunctionCategory.Scene)//窗帘没有开关按钮
            if (function.Spk_Prefix == FunctionCategory.Curtain || function.Spk_Prefix == FunctionCategory.Music)//窗帘没有开关按钮
            {
                switch (function.functionCategory)
                switch (function.Spk_Prefix)
                {
                    case FunctionCategory.Curtain:
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
                        switch (function.spk)
                        {
                            case SPK.CurtainSwitch:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
                                break;
                            case SPK.CurtainTrietex:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/MotorCurtainIcon.png";
                                break;
                            case SPK.CurtainRoller:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/RollingShutterIcon.png";
                                break;
                        }
                        CurtainFragment();
                        break;
                    case FunctionCategory.Scene:
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
                        if ((function as Scene).sceneType == SceneType.MovieScene)
                        {
                            var movieIcon = new Button()
                            {
                                X = Application.GetRealWidth(52),
                                Y = Application.GetRealHeight(14),
                                Width = Application.GetRealWidth(16),
                                Height = Application.GetRealWidth(16),
                                UnSelectedImagePath = "FunctionIcon/Scene/MovieMark.png",
                            };
                            bodyDiv.AddChidren(movieIcon);
                            btnName.X = Application.GetRealWidth(52 + 16);
                        }
                        //加载场景控制事件
                        LoadEvent_ControlScene();
                    case FunctionCategory.Music:
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
                        MusicFragment();
                        break;
                }
            }
            else
@@ -94,7 +93,7 @@
                /// 开关按钮
                /// </summary>
                Button btnSwitch;
                if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer)
                if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
                {
                    btnSwitch = new Button()
                    {
@@ -104,10 +103,12 @@
                        Height = Application.GetMinRealAverage(32),
                        UnSelectedImagePath = "Public/PowerClose.png",
                        SelectedImagePath = "Public/PowerOpen.png",
                        IsSelected = function.on_off == "on",
                        Tag = function.functionType + "_Switch_" + function.sid,
                        IsSelected = function.trait_on_off.curValue.ToString() == "on",
                        Tag = function.sid + "_Switch",
                    };
                    bodyDiv.AddChidren(btnSwitch);
                    //加载开关按钮事件
                    LoadEvent_SwitchFunction(btnSwitch, function.attributes.Find((obj) => obj.key == FunctionAttributeKey.FadeTime));
                }
                else
                {
@@ -119,24 +120,29 @@
                        Height = Application.GetMinRealAverage(32),
                        UnSelectedImagePath = "Public/PowerClose.png",
                        SelectedImagePath = "Public/PowerOpen.png",
                        IsSelected = function.on_off == "on",
                        Tag = function.functionType + "_Switch_" + function.sid,
                        IsSelected = function.trait_on_off.curValue.ToString() == "on",
                        Tag = function.sid + "_Switch",
                    };
                    bodyDiv.AddChidren(btnSwitch);
                    //加载开关按钮事件
                    LoadEvent_SwitchFunction(btnSwitch);
                }
                //加载开关按钮事件
                LoadEvent_SwitchFunction(btnSwitch);
                switch (function.functionCategory)
                switch (function.Spk_Prefix)
                {
                    case FunctionCategory.Thermostat:
                        switch (function.functionType)
                    case FunctionCategory.AC:
                        switch (function.spk)
                        {
                            case FunctionType.AC:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon.png";
                            case SPK.AcStandard:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
                                LoadLastStatesButton();
                                break;
                            case FunctionType.FloorHeating:
                        }
                        break;
                    case FunctionCategory.FloorHeat:
                        switch (function.spk)
                        {
                            case SPK.FloorHeatStandard:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
                                LoadLastStatesButton();
                                break;
@@ -144,18 +150,29 @@
                        break;
                    case FunctionCategory.Light:
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
                        btnSwitch.IsSelected = function.on_off == "on";
                        btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on";
                        LoadLightControl();
                        break;
                    case FunctionCategory.Electric:
                        switch (function.spk)
                        {
                            case SPK.ElectricSocket:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
                                break;
                            case SPK.ElectricFan:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
                                break;
                            case SPK.ElectricTV:
                                btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
                                break;
                        }
                        btnSwitch.IsSelected = function.trait_on_off.curValue.ToString() == "on";
                        break;
                }
                #endregion
            }
            if (function.functionCategory != FunctionCategory.Scene)
            {
                LoadEvent_DivSkipEvent();
            }
            LoadEvent_DivSkipEvent();
            LoadEvent_FunctionCollection();
        }
@@ -207,10 +224,14 @@
                Height = Application.GetMinRealAverage(40),
                SelectedImagePath = "Collection/CollectionIcon.png",
                UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
                IsSelected = function.collection
                IsSelected = function.collect
            };
            bodyDiv.AddChidren(btnCollectionIcon);
            //bodyDiv.AddChidren(btnCollectionIcon);
            //2020-12-16 如果是成员隐藏收藏功能
            if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare)
            {
                bodyDiv.AddChidren(btnCollectionIcon);
            }
        }
        /// <summary>
@@ -218,16 +239,16 @@
        /// </summary>
        void LoadLightControl()
        {
            switch (function.functionType)
            switch (function.spk)
            {
                case FunctionType.Dimmer:
                case FunctionType.RGB:
                case SPK.LightDimming:
                case SPK.LightRGB:
                    #region Dimmer
                    var btnDimmerMinValues = new Button()
                    {
                        X = Application.GetRealWidth(14),
                        Y = Application.GetRealHeight(85),
                        Width = Application.GetRealWidth(22),
                        Width = Application.GetRealWidth(30),
                        Height = Application.GetRealHeight(21),
                        Text = "0%",
                        TextAlignment = TextAlignment.CenterLeft,
@@ -238,19 +259,20 @@
                    var dimmerControlBar = new DiyImageSeekBar()
                    {
                        X = Application.GetRealWidth(14+ 22),
                        X = Application.GetRealWidth(14 + 22),
                        Y = Application.GetRealHeight(68),//91,设计数据
                        Width = Application.GetRealWidth(180),
                        Height = Application.GetRealHeight(54),
                        SeekBarViewHeight = Application.GetRealHeight(8),
                        ThumbImagePath = "Public/ThumbImage.png",
                        ThumbImageHeight = Application.GetRealHeight(54),
                        ProgressBarColor = (function as Light).on_off == "on" ? CSS_Color.AuxiliaryColor1 : CSS_Color.PromptingColor2,
                        ProgressBarColor = function.trait_on_off.curValue.ToString() == "on" ? CSS_Color.AuxiliaryColor1 : CSS_Color.PromptingColor2,
                        ProgressTextColor = CSS_Color.FirstLevelTitleColor,
                        ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        ProgressTextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                        MaxValue = 100,
                        Progress = (function as Light).brightness,
                        Tag = function.functionType + "_DimmerBar_" + function.sid
                        Tag = function.sid + "_DimmerBar",
                        SeekBarPadding = Application.GetRealWidth(20),
                    };
                    bodyDiv.AddChidren(dimmerControlBar);
@@ -258,7 +280,7 @@
                    {
                        X = Application.GetRealWidth(14 + 22+180),
                        Y = Application.GetRealHeight(85),
                        Width = Application.GetRealWidth(35),
                        Width = Application.GetRealWidth(45),
                        Height = Application.GetRealHeight(21),
                        Text = "100%",
                        TextAlignment = TextAlignment.CenterLeft,
@@ -287,7 +309,8 @@
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png",
                SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png",
                Tag = function.functionType + "_off_" + function.sid
                IsSelected = function.trait_on_off.curValue.ToString() == "off",
                Tag = function.sid + "_off"
            };
            bodyDiv.AddChidren(btnCurtainClose);
@@ -299,6 +322,8 @@
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "FunctionIcon/Curtain/CurtainStopIcon.png",
                SelectedImagePath = "FunctionIcon/Curtain/CurtainStopOnIcon.png",
                Tag = function.sid + "_stop",
                IsSelected = function.trait_on_off.curValue.ToString() == "stop"
            };
            bodyDiv.AddChidren(btnCurtainStop);
@@ -310,17 +335,68 @@
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png",
                SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png",
                Tag = function.functionType + "_on_" + function.sid
                Tag = function.sid + "_on",
                IsSelected = function.trait_on_off.curValue.ToString() == "on"
            };
            bodyDiv.AddChidren(btnCurtainOpen);
            LoadEvent_ControlCurtain(btnCurtainStop, btnCurtainOpen, btnCurtainClose, function as Curtain);
            #endregion
        }
        /// <summary>
        /// 加载音乐功能控制卡片
        /// </summary>
        void MusicFragment()
        {
            #region Music
            var btnPrev = new Button()
            {
                X = Application.GetRealWidth(163),
                Y = Application.GetRealHeight(58),
                Width = Application.GetMinRealAverage(32),
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "MusicIcon/prev.png",
                SelectedImagePath = "MusicIcon/prevSeletced.png",
            };
            bodyDiv.AddChidren(btnPrev);
            var btnPlay = new Button()
            {
                X = Application.GetRealWidth(233),
                Y = Application.GetRealHeight(58),
                Width = Application.GetMinRealAverage(32),
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "MusicIcon/pause.png",
                SelectedImagePath = "MusicIcon/play.png",
                IsSelected = (function as A31MusicModel).A31PlayStatus.status == "play" ,
                Tag = function.spk + "_State_" + function.sid
            };
            bodyDiv.AddChidren(btnPlay);
            var btnNext = new Button()
            {
                X = Application.GetRealWidth(303),
                Y = Application.GetRealHeight(58),
                Width = Application.GetMinRealAverage(32),
                Height = Application.GetMinRealAverage(32),
                UnSelectedImagePath = "MusicIcon/next.png",
                SelectedImagePath = "MusicIcon/nextSelected.png",
            };
            bodyDiv.AddChidren(btnNext);
            LoadEvent_ControlMusic(btnPlay, btnNext, btnPrev, function as A31MusicModel);
            #endregion
        }
        /// <summary>
        /// 加载功能状态信息按钮
        /// </summary>
        void LoadLastStatesButton()
        {
            if(function.spk == SPK.LightSwitch)
            {
                return;
            }
            var btnLastStates = new Button()
            {
                X = Application.GetRealWidth(10 + 32 + 8),
@@ -332,11 +408,10 @@
                SelectedTextColor = CSS_Color.PromptingColor1,
                TextColor = 0x00000000,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                Tag = function.functionType + "_laststates_" + function.sid,
                IsSelected = function.on_off == "on"
                Tag = function.spk + "_laststates_" + function.sid,
                IsSelected = function.trait_on_off.curValue.ToString() == "on"
            };
            bodyDiv.AddChidren(btnLastStates);
        }
    }
}
}