wxr
2021-03-15 6e580804d74d7a6fb118b6ba381e88aa81f267c7
HDL_ON/UI/UI2/FuntionControlView/AC/AcControlPage.cs
@@ -44,7 +44,9 @@
        /// </summary>
        Button btnSwitch;
        AC acDevice;
        AC acFunction = new AC();
        #endregion
@@ -55,7 +57,6 @@
        /// </summary>
        public override void InitFrameWhiteContent()
        {
            acDevice = device as AC;
            base.ShowColltionButton = false;
            base.SetTitleText(Language.StringByID(StringId.Electric));
@@ -85,16 +86,10 @@
            {
                Gravity = Gravity.CenterHorizontal,
                OpenAngle = 160,
                ThumbImagePath = device.GetAttrState(FunctionAttributeKey.OnOff)  == "on" ? "FunctionIcon/AC/DiyThumbIconOn.png" : "FunctionIcon/AC/DiyThumbIcon.png",
                ThumbImageHeight = Application.GetRealWidth(50),
                ProgressBarColor = CSS_Color.MainColor,
                OfflineProgressBarColor = CSS_Color.PromptingColor2,
                IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off",
                MinValue = device.GetAttribute(FunctionAttributeKey.OnOff).min,
                MaxValue = device.GetAttribute(FunctionAttributeKey.OnOff).max,
                //IsClickable = acDevice.trait_on_off.curValue.ToString() == "on",
                ArcColor = CSS_Color.BackgroundColor,
                Progress = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp)),
#if __IOS__
                Y = Application.GetRealHeight(120 + 25),
                Width = Application.GetRealWidth(260 - 40),
@@ -109,6 +104,13 @@
            };
            FrameWhiteCentet1.AddChidren(arcBar);
            arcBar.ThumbImagePath = device.GetAttrState(FunctionAttributeKey.OnOff) == "on" ? "FunctionIcon/AC/DiyThumbIconOn.png" : "FunctionIcon/AC/DiyThumbIcon.png";
            arcBar.IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off";
            arcBar.MinValue = device.GetAttribute(FunctionAttributeKey.SetTemp).min;
            arcBar.MaxValue = device.GetAttribute(FunctionAttributeKey.SetTemp).max;
            arcBar.Progress = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
            btnTemp = new Button()
            {
@@ -176,7 +178,7 @@
                Y = Application.GetRealHeight(334),
                Width = Application.GetRealWidth(30),
                Height = Application.GetRealWidth(30),
                UnSelectedImagePath = acDevice.GetModeIconPath(),
                UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)),
            };
            FrameWhiteCentet1.AddChidren(btnMode);
@@ -186,7 +188,7 @@
                Y = Application.GetRealHeight(337),
                Width = Application.GetRealWidth(30),
                Height = Application.GetRealWidth(30),
                UnSelectedImagePath = acDevice.GetFanIconPath(),
                UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)),
            };
            FrameWhiteCentet1.AddChidren(btnWindSpeed);
@@ -204,6 +206,8 @@
            LoadEvent_TempChange();
            LoadEvent_AcStatesChange();
            LoadDiv_IrView();
        }
        /// <summary>
@@ -281,9 +285,9 @@
                };
                modeChangeView.AddChidren(btnModeText);
                btnModeIcon.UnSelectedImagePath = acDevice.GetModeIconPath(false);
                btnModeIcon.SelectedImagePath = acDevice.GetModeIconPath();
                btnModeText.Text = acDevice.GetModeAttrText( m);
                btnModeIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m, false);
                btnModeIcon.SelectedImagePath = acFunction.GetModeIconPath(m);
                btnModeText.Text = acFunction.GetModeAttrText( m);
                if (modeList.IndexOf(m) < modeList.Count - 1)
                {
@@ -303,14 +307,14 @@
                EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                {
                    btnModeIcon.IsSelected = btnModeText.IsSelected = true;
                    acDevice.SetAttrState(FunctionAttributeKey.Mode, m);
                    btnMode.UnSelectedImagePath = acDevice.GetModeIconPath();
                    device.SetAttrState(FunctionAttributeKey.Mode, m);
                    btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(m);
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    btnMode.UnSelectedImagePath = btnModeIcon.UnSelectedImagePath;
                    d.Add(FunctionAttributeKey.Mode, m);
                    Control.Ins.SendWriteCommand(acDevice, d);
                    Control.Ins.SendWriteCommand(device, d);
                    dialog.Close();
                    if (acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                    if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                    {
                        arcBar.IsClickable = false;
                    }
@@ -404,9 +408,9 @@
                    TextSize = CSS_FontSize.TextFontSize,
                };
                modeChangeView.AddChidren(btnFanText);
                btnFanIcon.UnSelectedImagePath = acDevice.GetModeIconPath(false);
                btnFanIcon.SelectedImagePath = acDevice.GetModeIconPath();
                btnFanText.Text = acDevice.GetModeAttrText(m);
                btnFanIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m,false);
                btnFanIcon.SelectedImagePath = acFunction.GetModeIconPath(m);
                btnFanText.Text = acFunction.GetModeAttrText(m);
                if (modeList.IndexOf(m) < modeList.Count - 1)
                {
@@ -427,11 +431,11 @@
                EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                {
                    btnFanIcon.IsSelected = btnFanText.IsSelected = true;
                    acDevice.SetAttrState(FunctionAttributeKey.FanSpeed, m);
                    btnWindSpeed.UnSelectedImagePath = acDevice.GetFanIconPath();
                    device.SetAttrState(FunctionAttributeKey.FanSpeed, m);
                    btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(m);
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add(FunctionAttributeKey.FanSpeed, m);
                    Control.Ins.SendWriteCommand(acDevice, d);
                    Control.Ins.SendWriteCommand(device, d);
                    btnWindSpeed.UnSelectedImagePath = btnFanIcon.UnSelectedImagePath;
                    dialog.Close();
                };
@@ -442,6 +446,146 @@
            dialog.Show();
        }
        /// <summary>
        /// 加载红外遥控器,额外按钮
        /// </summary>
        void LoadDiv_IrView()
        {
            if (device.spk == SPK.AcIr)
            {
                var btnMore = new Button()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight(334),
                    Width = Application.GetRealWidth(30),
                    Height = Application.GetRealWidth(30),
                    UnSelectedImagePath = "FunctionIcon/AC/More.png",
                };
                FrameWhiteCentet1.AddChidren(btnMore);
                btnMore.MouseUpEventHandler = (sender, e) => {
                    LoadDialog_IrMoreView();
                };
            }
        }
        /// <summary>
        /// 加载额外对红外按钮界面
        /// </summary>
        void LoadDialog_IrMoreView()
        {
            Dialog dialog = new Dialog();
            var div = new FrameLayout();
            dialog.AddChidren(div);
            div.MouseUpEventHandler = (sender, e) => {
                dialog.Close();
            };
            var bodyView = new FrameLayout()
            {
                Y = Application.GetRealHeight(463),
                Height = Application.GetRealHeight(375),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            div.AddChidren(bodyView);
            var contentView = new FrameLayout()
            {
                Y = Application.GetRealHeight(16),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(296),
            };
            bodyView.AddChidren(contentView);
                var row = new FrameLayout()
                {
                    Height = Application.GetRealHeight(60),
                };
                contentView.AddChidren(row);
                int index = 0;
            foreach (var attr in device.attributes)
            {
                if (attr.key == FunctionAttributeKey.Mode
                    || attr.key == FunctionAttributeKey.OnOff
                    || attr.key == FunctionAttributeKey.SetTemp
                    || attr.key == FunctionAttributeKey.SetTempStep
                    || attr.key == FunctionAttributeKey.FanSpeed
                    || attr.key == FunctionAttributeKey.FanManual
                    || attr.key == FunctionAttributeKey.FanAuto
                    )
                {
                    continue;
                }
                if (index != 0 && index % 3 == 0)
                {
                    row = new FrameLayout()
                    {
                        Width = Application.GetRealWidth(200),
                        Height = Application.GetRealHeight(56),
                    };
                    contentView.AddChidren(row);
                }
                var btn = new Button()
                {
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth(88),
                    Height = Application.GetRealHeight(40),
                    Radius = (uint)Application.GetRealHeight(18),
                    BorderColor = CSS_Color.PromptingColor1,
                    BorderWidth = (uint)Application.GetRealWidth(2),
                    TextAlignment = TextAlignment.Center,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    SelectedTextColor = CSS_Color.MainBackgroundColor,
                    SelectedBackgroundColor = CSS_Color.MainColor,
                };
                if (attr.value.Count > 0)
                {
                    btn.Text = attr.value[0];
                }
                if (index % 3 == 1)
                {
                    btn.Gravity = Gravity.Center;
                }
                else if (index % 3 == 2)
                {
                    btn.X = Application.GetRealWidth(208);
                }
                row.AddChidren(btn);
                btn.MouseUpEventHandler = (sender, e) =>
                {
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add(FunctionAttributeKey.Key, attr.key);
                    Control.Ins.SendWriteCommand(device, d);
                    new System.Threading.Thread(() =>
                    {
                        System.Threading.Thread.Sleep(2000);
                        Application.RunOnMainThread(() =>
                        {
                            btn.IsSelected = false;
                        });
                    })
                    { IsBackground = true }.Start();
                };
                index++;
            }
            dialog.Show();
        }
        #endregion
@@ -473,53 +617,53 @@
        {
            btnMinus.MouseUpEventHandler = (sender, e) =>
            {
                if (acDevice.trait_on_off.curValue.ToString() == "off" || acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                {
                    return;
                }
                var temp = Convert.ToInt32(acDevice.GetAttrState(FunctionAttributeKey.SetTemp));
                if (temp <= acDevice.GetAttribute(FunctionAttributeKey.Mode).min)
                var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
                if (temp <= device.GetAttribute(FunctionAttributeKey.Mode).min)
                {
                    return;
                }
                temp--;
                arcBar.Progress = temp;
                btnTemp.Text = temp.ToString();
                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.SetTemp, temp.ToString());
                Control.Ins.SendWriteCommand(acDevice, d);
                Control.Ins.SendWriteCommand(device, d);
            };
            btnPlus.MouseUpEventHandler = (sender, e) =>
            {
                if (acDevice.trait_on_off.curValue.ToString() == "off" || acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                {
                    return;
                }
                var temp = Convert.ToInt32(acDevice.GetAttrState(FunctionAttributeKey.SetTemp));
                if (temp >= acDevice.GetAttribute(FunctionAttributeKey.SetTemp).max)
                var temp = Convert.ToInt32(device.GetAttrState(FunctionAttributeKey.SetTemp));
                if (temp >= device.GetAttribute(FunctionAttributeKey.SetTemp).max)
                {
                    return;
                }
                temp++;
                arcBar.Progress = temp;
                btnTemp.Text = temp.ToString();
                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.SetTemp, temp.ToString());
                Control.Ins.SendWriteCommand(acDevice, d);
                Control.Ins.SendWriteCommand(device, d);
            };
            arcBar.OnStopTrackingTouchEvent = (sender, e) =>
            {
                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                device.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                btnTemp.Text = arcBar.Progress.ToString();
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                Control.Ins.SendWriteCommand(acDevice, d);
                Control.Ins.SendWriteCommand(device, d);
            };
            arcBar.OnProgressChangedEvent = (sender, e) =>
            {
                acDevice.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
                device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
                btnTemp.Text = e.ToString();
            };
        }
@@ -530,7 +674,7 @@
        {
            btnMode.MouseUpEventHandler = (sender, e) =>
            {
                if (acDevice.trait_on_off.curValue.ToString() == "off")
                if (device.trait_on_off.curValue.ToString() == "off")
                {
                    return;
                }
@@ -538,7 +682,7 @@
            };
            btnWindSpeed.MouseUpEventHandler = (sender, e) =>
            {
                if (acDevice.trait_on_off.curValue.ToString() == "off")
                if (device.trait_on_off.curValue.ToString() == "off")
                {
                    return;
                }
@@ -548,8 +692,8 @@
            btnSwitch.MouseUpEventHandler = (sender, e) =>
            {
                btnSwitch.IsSelected = !btnSwitch.IsSelected;
                acDevice.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                if (acDevice.trait_on_off.curValue.ToString() == "on")
                device.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                if (device.trait_on_off.curValue.ToString() == "on")
                {
                    arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png";
                    btnSwitch.IsSelected = true;
@@ -562,8 +706,8 @@
                    arcBar.IsOffline = true;
                }
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.OnOff, acDevice.trait_on_off.curValue.ToString());
                Control.Ins.SendWriteCommand(acDevice, d);
                d.Add(FunctionAttributeKey.OnOff, device.trait_on_off.curValue.ToString());
                Control.Ins.SendWriteCommand(device, d);
            };
        }
@@ -579,16 +723,16 @@
            Application.RunOnMainThread(() =>
            {
                btnTemp.Text = device.GetAttrState(FunctionAttributeKey.SetTemp);
                btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(acDevice.GetAttrState(FunctionAttributeKey.IndoorTemp))) + "°C";
                btnMode.UnSelectedImagePath = acDevice.GetModeIconPath();
                btnWindSpeed.UnSelectedImagePath = acDevice.GetFanIconPath();
                arcBar.Progress = Convert.ToInt32(Convert.ToDouble(acDevice.GetAttrState(FunctionAttributeKey.SetTemp)));
                if (acDevice.trait_on_off.curValue.ToString() == "on")
                btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.IndoorTemp))) + "°C";
                btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode));
                btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed));
                arcBar.Progress = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp)));
                if (device.trait_on_off.curValue.ToString() == "on")
                {
                    arcBar.IsOffline = false;
                    btnSwitch.IsSelected = true;
                    arcBar.ThumbImagePath = "FunctionIcon/AC/DiyThumbIconOn.png";
                    if (acDevice.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                    if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                    {
                        arcBar.IsClickable = false;
                    }