wxr
2024-08-13 e76381c3393d284f3f8ab61930cb6b71f18b2d6b
HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs
@@ -6,7 +6,25 @@
namespace HDL_ON.UI
{
    public class VerticalScrolViewLayoutJinmao : VerticalScrolViewLayout
    {
        public VerticalScrolViewLayoutJinmao()
        {
#if __IOS__
            try
            {
                //自动偏移取消
                if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    (this.uiView as UIKit.UIScrollView).ContentInsetAdjustmentBehavior = UIKit.UIScrollViewContentInsetAdjustmentBehavior.Never;
                }
            }catch(Exception ex)
            {
                MainPage.Log("error", "金茂iOS 滚动容器偏移值设置异常:" + ex.Message);
            }
#endif
        }
    }
    /// <summary>
   /// 绿建科技系统
@@ -16,7 +34,7 @@
    {
        static AcstParentPage basePage;
        VerticalScrolViewLayout contentView;
        VerticalScrolViewLayoutJinmao contentView;
        string helloText = "上午好";
@@ -42,9 +60,7 @@
        /// </summary>
        Dictionary<string, AcstSubControlView> subViewList;
        Button btnWorkSceneControl;
        Button btnModeControl;
        Button btnPowerControl;
@@ -105,10 +121,14 @@
            this.function = FunctionList.List.GetAcstParentList()[0];
            this.BackgroundColor = CSS.CSS_Color.BackgroundColor;
            //this.AddChidren(new Button() { Height = Application.GetRealHeight(50), BackgroundColor = curColor });
            contentView = new VerticalScrolViewLayout() {
            contentView = new VerticalScrolViewLayoutJinmao()
            {
                Height = Application.GetRealHeight(667 - 56),
                VerticalScrollBarEnabled = false,
            };
            this.AddChidren(contentView);
            basePage.AddChidren(contentView);
            subViewList = new Dictionary<string, AcstSubControlView>();
        }
        /// <summary>
@@ -205,12 +225,12 @@
                    }
                    basePage.btnModeControl.IsSelected = basePage.btnWorkSceneControl.IsSelected = basePage.btnPowerControl.IsSelected = temp.GetAttrState("on_off") == "on";
                });
            }catch (Exception ex)
            }
            catch (Exception ex)
            {
                MainPage.Log("科技系统更新数据失败");
                MainPage.Log("科技系统更新数据失败:" + ex.Message);
            }
        }
        /// <summary>
        /// 更新子控信息
@@ -232,12 +252,21 @@
                        basePage.subViewList.TryGetValue(temp.sid, out view);
                        if (view != null)
                        {
                            if (temp.spk == SPK.AcstSub)
                            {
                            view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%";
                            view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "°";
                            view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on";
                        }
                            else if (temp.spk == SPK.WaterHeaterJinmao)
                            {
                                view.btnSubTempValues.Text = temp.GetAttrState(WaterHeaterJinmao_AttrEnum.temp.ToString()) + "°";
                                view.btnSubPower.IsSelected = temp.GetAttrState(WaterHeaterJinmao_AttrEnum.on_off.ToString()) == "on";
                    }
                    catch (Exception ex ) {
                        }
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log($"科技系统更新异常1:{ex.Message}");
                    }
                });
@@ -278,7 +307,8 @@
            Button btnBackClick = new Button();
            backView.AddChidren(btnBackClick);
            btnBackClick.MouseUpEventHandler = (sender, e) => {
            btnBackClick.MouseUpEventHandler = (sender, e) =>
            {
                this.RemoveFromParent();
            };
@@ -584,7 +614,8 @@
            };
            subTitleView.AddChidren(btnCollection);
            //收藏
            btnCollection.MouseUpEventHandler = (sender, e) => {
            btnCollection.MouseUpEventHandler = (sender, e) =>
            {
                function.collect = !function.collect;
                btnCollection.IsSelected = function.collect;
@@ -623,8 +654,9 @@
#if DEBUG
                    System.Threading.Thread.Sleep(200);
#endif
                    foreach (var sub in FunctionList.List.GetAcstSubList())
                    var showList = FunctionList.List.GetAcstSubList();
                    showList.AddRange(FunctionList.List.GetWaterHeaterJinmaoList());
                    foreach (var sub in showList)
                    {
                        if (subViewList.ContainsKey(sub.sid))
                        {
@@ -638,6 +670,7 @@
                                subFunctionListView = new HorizontalScrolViewLayout()
                                {
                                    Height = Application.GetRealHeight(93),
                                    ScrollEnabled = false,
                                };
                                contentView.AddChidren(subFunctionListView);
                                subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) });
@@ -660,7 +693,8 @@
                    }
                }
                catch { }
                finally{
                finally
                {
             
                }
            }).Start();
@@ -670,9 +704,12 @@
            #region 底部控制栏
            var bottomView = new FrameLayout()
            {
                Y = Application.GetRealHeight(667 - 56),
                Height = Application.GetRealHeight(56),
                Y = Application.GetRealHeight(667 - 66),
                Height = Application.GetRealHeight(66+16),
                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealHeight(16),
                BorderColor = 0x00FFFFFF,
                BorderWidth = 0,
            };
            this.AddChidren(bottomView);
@@ -698,11 +735,13 @@
                var dialogView = new FrameLayout();
                dialog.AddChidren(dialogView);
                dialogView.MouseUpEventHandler = (sender, e) => {
                dialogView.MouseUpEventHandler = (sender, e) =>
                {
                    dialog.Close();
                };
                var dialogContentView = new VerticalScrolViewLayout() {
                var dialogContentView = new VerticalScrolViewLayout()
                {
                    X = Application.GetRealWidth(34),
                    Y = Application.GetRealHeight(291),
                    Width = Application.GetRealWidth(148),
@@ -711,7 +750,8 @@
                };
                dialogView.AddChidren(dialogContentView);
                var titleView = new FrameLayout() {
                var titleView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = Application.GetRealHeight(3),
                    Width = Application.GetRealWidth(144),
@@ -988,15 +1028,12 @@
            btnWorkSceneControl.MouseUpEventHandler = (sender2, e2) =>
            {
                //if (function.trait_on_off.state == "off")
                //{
                //    return;
                //}
                Dialog dialog = new Dialog();
                var dialogView = new FrameLayout();
                dialog.AddChidren(dialogView);
                dialogView.MouseUpEventHandler = (sender, e) => {
                dialogView.MouseUpEventHandler = (sender, e) =>
                {
                    dialog.Close();
                };
@@ -1286,11 +1323,33 @@
                Width = Application.GetRealWidth(35),
                TextColor = 0xFF1b3035,
                TextSize = 10,
                Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "°C",
                TextAlignment = TextAlignment.CenterLeft,
            };
            subFunctionView.AddChidren(btnSubTempValues);
            btnSubPower = new Button()
            {
                X = Application.GetRealWidth(121 + 7),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(28),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png",
                TextAlignment = TextAlignment.Center,
            };
            subFunctionView.AddChidren(btnSubPower);
            btnSubPower.MouseUpEventHandler = (sender, e) =>
            {
                btnSubPower.IsSelected = !btnSubPower.IsSelected;
                string onoff = btnSubPower.IsSelected ? "on" : "off";
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add(FunctionAttributeKey.OnOff, onoff);
                Control.Ins.SendWriteCommand(sub, d);
            };
            if (sub.spk == SPK.AcstSub)
            {
                btnSubTempValues.Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "°C";
            Button btnSubHumidityIcon = new Button()
            {
                X = btnSubTempValues.Right + Application.GetRealWidth(5),
@@ -1314,40 +1373,44 @@
            };
            subFunctionView.AddChidren(btnSubHumidityValues);
            btnSubPower = new Button()
                EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                X = Application.GetRealWidth(121 + 7),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(28),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png",
                TextAlignment = TextAlignment.Center,
            };
            subFunctionView.AddChidren(btnSubPower);
            btnSubPower.MouseUpEventHandler = (sender, e) => {
                btnSubPower.IsSelected = !btnSubPower.IsSelected;
                string onoff = btnSubPower.IsSelected ? "on" : "off";
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add(FunctionAttributeKey.OnOff, onoff);
                Control.Ins.SendWriteCommand(sub, d);
            };
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var page = new AcstSubPage(sub,imageFolder);
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage(()=> {
                    page.LoadPage(() =>
                    {
                    btnRoomInfo.Text = sub.name;
                });
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnRoomInfo.MouseUpEventHandler = eventHandler;
            btnSubHumidityIcon.MouseUpEventHandler = eventHandler;
            btnSubHumidityValues.MouseUpEventHandler = eventHandler;
            btnSubTempIcon.MouseUpEventHandler = eventHandler;
            btnSubTempValues.MouseUpEventHandler = eventHandler;
            subFunctionView.MouseUpEventHandler = eventHandler;
                btnSubHumidityIcon.MouseUpEventHandler = eventHandler;
                btnSubHumidityValues.MouseUpEventHandler = eventHandler;
            }
            else if (sub.spk == SPK.WaterHeaterJinmao)
            {
                btnSubTempValues.Text = sub.GetAttrState(WaterHeaterJinmao_AttrEnum.temp.ToString()) + "°C";
                EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
                {
                    var page = new WaterHeaterJinmaoPage(sub);
                    MainPage.BasePageView.AddChidren(page);
                    page.LoadPage(() =>
                    {
                        btnRoomInfo.Text = sub.name;
                    });
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                btnRoomInfo.MouseUpEventHandler = eventHandler;
                btnSubTempIcon.MouseUpEventHandler = eventHandler;
                btnSubTempValues.MouseUpEventHandler = eventHandler;
                subFunctionView.MouseUpEventHandler = eventHandler;
            }
        }
    }
@@ -1397,13 +1460,16 @@
        public void Click(Action action)
        {
            view.MouseUpEventHandler = (sender, e) => {
            view.MouseUpEventHandler = (sender, e) =>
            {
                action();
            };
            btnText.MouseUpEventHandler = (sender, e) => {
            btnText.MouseUpEventHandler = (sender, e) =>
            {
                action();
            };
            btnIcon.MouseUpEventHandler = (sender, e) => {
            btnIcon.MouseUpEventHandler = (sender, e) =>
            {
                action();
            };
        }