wjc
2022-06-30 0b5b6ec781a8cb3400ad34693792bad07e97a00c
HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/FhControlPage.cs
@@ -36,6 +36,11 @@
        /// </summary>
        Button btnMode;
        /// <summary>
        /// 工作模式按钮
        /// </summary>
        Button btnWrokMode;
        /// <summary>
        /// 开关按钮
        /// </summary>
        Button btnSwitch;
@@ -172,6 +177,25 @@
            };
            FrameWhiteCentet1.AddChidren(btnPlus);
            if (device.GetAttribute("mode_work") != null)
            {
                btnWrokMode = new Button()
                {
                    X = Application.GetRealWidth(60),
                    Y = Application.GetRealHeight(334),
                    Width = Application.GetRealWidth(30),
                    Height = Application.GetRealWidth(30),
                    UnSelectedImagePath = fhTemp.GetWrokModeIconPath(device.GetAttrState("mode_work")),
                };
                FrameWhiteCentet1.AddChidren(btnWrokMode);
                if (device.GetAttribute("mode_work").value.Count > 1)
                {
                    btnMode.MouseUpEventHandler = (sender, e) =>
                    {
                        LoadDiv_ChangeModeView();
                    };
                }
            }
            if (device.GetAttribute(FunctionAttributeKey.Mode) != null)
            {
                btnMode = new Button()
@@ -208,6 +232,135 @@
            LoadEvent_AcStatesChange();
        }
        /// <summary>
        /// 加载修改模式区域
        /// </summary>
        void LoadDiv_ChangeWorkModeView()
        {
            Dialog dialog = new Dialog();
            FrameLayout dialogView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.DialogTransparentColor1,
            };
            dialog.AddChidren(dialogView);
            FrameLayout modeChangeView;
            modeChangeView = new FrameLayout()
            {
                X = Application.GetRealWidth(30),
                Y = Application.GetRealHeight(128),
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealHeight(287),
                BackgroundImagePath = "FunctionIcon/AC/DivBg1.png",
            };
            dialogView.AddChidren(modeChangeView);
            Button btnTitle;
            btnTitle = new Button()
            {
                X = Application.GetRealWidth(8 + 16),
                Y = Application.GetRealHeight(8),
                Width = Application.GetRealWidth(112),
                Height = Application.GetRealHeight(44),
                TextID = StringId.ChooseMode,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
            };
            modeChangeView.AddChidren(btnTitle);
            Button btnLine = new Button()
            {
                X = btnTitle.X,
                Y = btnTitle.Bottom,
                Width = Application.GetRealWidth(112),
                Height = Application.GetRealHeight(1),
                BackgroundColor = CSS_Color.BackgroundColor,
            };
            modeChangeView.AddChidren(btnLine);
            var modeList = device.GetAttribute(FunctionAttributeKey.WorkMode).value;
            foreach (var m in modeList)
            {
                Button btnModeIcon = new Button()
                {
                    X = btnTitle.X,
                    Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8),
                    Width = Application.GetRealWidth(24),
                    Height = Application.GetRealWidth(24),
                    IsSelected = device.GetAttrState(FunctionAttributeKey.WorkMode) == m,
                };
                modeChangeView.AddChidren(btnModeIcon);
                Button btnModeText = new Button()
                {
                    X = Application.GetRealWidth(12) + btnModeIcon.Right,
                    Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8),
                    Height = Application.GetRealHeight(44),
                    Width = Application.GetRealWidth(90),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    SelectedTextColor = CSS_Color.MainColor,
                    IsSelected = device.GetAttrState(FunctionAttributeKey.Mode) == m,
                    TextSize = CSS_FontSize.TextFontSize,
                };
                modeChangeView.AddChidren(btnModeText);
                btnModeIcon.UnSelectedImagePath = fhTemp.GetModeIconPath(m, false);
                btnModeIcon.SelectedImagePath = fhTemp.GetModeIconPath(m);
                btnModeText.Text = fhTemp.GetModeAttrText(m);
                if (modeList.IndexOf(m) < modeList.Count - 1)
                {
                    modeChangeView.AddChidren(new Button()
                    {
                        X = btnTitle.X,
                        Y = btnModeText.Bottom,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(1),
                        BackgroundColor = CSS_Color.BackgroundColor,
                    });
                }
                EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
                {
                    dialog.Close();
                };
                EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                {
                    //if (!device.online)
                    //{
                    //    new Tip()
                    //    {
                    //        CloseTime = 1,
                    //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                    //        Direction = AMPopTipDirection.None,
                    //    }.Show(MainPage.BaseView);
                    //}
                    btnModeIcon.IsSelected = btnModeText.IsSelected = true;
                    device.SetAttrState(FunctionAttributeKey.WorkMode, m);
                    btnMode.UnSelectedImagePath = fhTemp.GetWrokModeIconPath(m);
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    btnMode.UnSelectedImagePath = btnModeIcon.UnSelectedImagePath;
                    d.Add(FunctionAttributeKey.WorkMode, m);
                    Control.Ins.SendWriteCommand(device, d);
                    dialog.Close();
                };
                btnModeIcon.MouseUpEventHandler = eventHandler1;
                btnModeText.MouseUpEventHandler = eventHandler1;
                dialogView.MouseUpEventHandler = eventHandler;
            }
            dialogView.MouseUpEventHandler = (sender, e) => {
                dialog.Close();
            };
            dialog.Show();
        }
        /// <summary>
        /// 加载修改模式区域
@@ -525,6 +678,15 @@
                    arcBar.IsClickable = false;
                    arcBar.IsOffline = true;
                }
                if(btnWrokMode!=null){
                    var dd = device.GetAttrState("mode_work");
                    if (dd != "0")
                    {
                        btnWrokMode.UnSelectedImagePath = fhTemp.GetWrokModeIconPath(dd);
                    }
                }
            });
        }