wxr
2022-09-27 0ee75b88cfe03e46289de0de96e8ed4580c797d3
HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/AcControlPage.cs
@@ -90,27 +90,28 @@
            this.InitFrameWhiteContent1();
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(this.device);
            //this.RefreshNowDeviceStatuMemory(this.device);
            //刷新界面状态
            this.RefreshFormStatu();
            //读取状态
            new System.Threading.Thread(() =>
            {
                while (true)
                {
                    if(controlTime == DateTime.MinValue)
                    {
            Control.Ins.SendReadCommand(device);
            //new System.Threading.Thread(() =>
            //{
            //    while (true)
            //    {
            //        if(controlTime == DateTime.MinValue)
            //        {
                    }
                    else if (controlTime.AddSeconds(2)<DateTime.Now)
                    {
                        Control.Ins.SendReadCommand(device);
                        controlTime = DateTime.MinValue;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
            })
            { IsBackground = true }.Start();
            //        }
            //        else if (controlTime.AddSeconds(2)<DateTime.Now)
            //        {
            //            Control.Ins.SendReadCommand(device);
            //            controlTime = DateTime.MinValue;
            //        }
            //        System.Threading.Thread.Sleep(1000);
            //    }
            //})
            //{ IsBackground = true }.Start();
        }
        /// <summary>
@@ -118,7 +119,18 @@
        /// </summary>
        private void InitFrameWhiteContent1()
        {
            temp = (int)Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp));
            //获取温度值
            string setTempTemp = device.GetAttrState(FunctionAttributeKey.SetTemp);
            temp = (int) Convert.ToDouble(setTempTemp);
            if (temp <= 0)
            {
                //默认值改成16,2022年06月10日10:03:19 成甫要求的
                temp = 16;
                device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString());
            }
            arcBar = new DiyArcSeekBar()
            {
                Gravity = Gravity.CenterHorizontal,
@@ -147,7 +159,7 @@
            arcBar.IsOffline = device.GetAttrState(FunctionAttributeKey.OnOff) == "off";
            arcBar.MinValue = device.GetAttribute(FunctionAttributeKey.SetTemp).min;
            arcBar.MaxValue = device.GetAttribute(FunctionAttributeKey.SetTemp).max;
            arcBar.Progress = (int)Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp));
            arcBar.Progress = temp;
            btnTemp = new Button()
            {
@@ -158,10 +170,13 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = 50,
                IsBold = true,
                Text = Convert.ToDouble( device.GetAttrState(FunctionAttributeKey.SetTemp)).ToString(),
                Text = "111",
                TextAlignment = TextAlignment.Center,
            };
            btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5);
            btnTemp.Text = Convert.ToDouble(temp).ToString();
            FrameWhiteCentet1.AddChidren(btnTemp);
            btnTempUint = new Button()
            {
@@ -183,7 +198,7 @@
                Y = btnTemp.Bottom,
                Width = Application.GetRealWidth(120),
                Height = Application.GetRealHeight(20),
                Text = Language.StringByID(StringId.IndoorTemp) + "20°C",
                Text = Language.StringByID(StringId.Indoor) + " 20°C",
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
@@ -358,6 +373,15 @@
                };
                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.Mode, m);
                    btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(m);
@@ -485,6 +509,15 @@
                };
                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.Swing, m);
                    btnSwing.UnSelectedImagePath = acFunction.GetSwingIconPath(m);
@@ -600,6 +633,15 @@
                };
                EventHandler<MouseEventArgs> eventHandler1 = (sender, e) =>
                {
                    //if (!device.online)
                    //{
                    //    new Tip()
                    //    {
                    //        CloseTime = 1,
                    //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                    //        Direction = AMPopTipDirection.None,
                    //    }.Show(MainPage.BaseView);
                    //}
                    btnFanIcon.IsSelected = btnFanText.IsSelected = true;
                    device.SetAttrState(FunctionAttributeKey.FanSpeed, m);
                    btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(m);
@@ -787,6 +829,15 @@
                btn.MouseUpEventHandler = (sender, e) =>
                {
                    //if (!device.online)
                    //{
                    //    new Tip()
                    //    {
                    //        CloseTime = 1,
                    //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                    //        Direction = AMPopTipDirection.None,
                    //    }.Show(MainPage.BaseView);
                    //}
                    Dictionary<string, string> d = new Dictionary<string, string>();
                    d.Add(attr.key, "");
                    Control.Ins.SendWriteCommand(device, d);
@@ -825,7 +876,7 @@
            if (this.device.sid != i_LocalDevice.sid) { return; }
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(i_LocalDevice);
            //this.RefreshNowDeviceStatuMemory(i_LocalDevice);
            //刷新界面状态
            this.RefreshFormStatu();
        }
@@ -841,11 +892,20 @@
        {
            btnMinus.MouseUpEventHandler = (sender, e) =>
            {
                //if (!device.online)
                //{
                //    new Tip()
                //    {
                //        CloseTime = 1,
                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                //        Direction = AMPopTipDirection.None,
                //    }.Show(MainPage.BaseView);
                //}
                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                {
                    return;
                }
                if (temp <= device.GetAttribute(FunctionAttributeKey.SetTemp).min)
                {
                    return;
@@ -855,6 +915,8 @@
                controlTime = DateTime.Now;
                arcBar.Progress = temp;
                btnTemp.Text = temp.ToString();
                //btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5);
                //btnTempUint.X = btnTemp.Right;
                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());
@@ -862,6 +924,15 @@
            };
            btnPlus.MouseUpEventHandler = (sender, e) =>
            {
                //if (!device.online)
                //{
                //    new Tip()
                //    {
                //        CloseTime = 1,
                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                //        Direction = AMPopTipDirection.None,
                //    }.Show(MainPage.BaseView);
                //}
                if (device.trait_on_off.curValue.ToString() == "off" || device.GetAttrState(FunctionAttributeKey.Mode) == "fan")
                {
                    return;
@@ -874,36 +945,42 @@
                controlTime = DateTime.Now;
                arcBar.Progress = temp;
                btnTemp.Text = temp.ToString();
                //btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5);
                //btnTempUint.X = btnTemp.Right;
                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(device, d);
            };
            arcBar.OnStopTrackingTouchEvent = (sender, e) =>
            //if (device.online)
            {
                temp = arcBar.Progress;
                device.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                btnTemp.Text = arcBar.Progress.ToString();
                controlTime = DateTime.Now;
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                Control.Ins.SendWriteCommand(device, d);
            };
            arcBar.OnProgressChangedEvent = (sender, e) =>
            {
                device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
                btnTemp.Text = e.ToString();
            };
            //arcBar.MouseDownEventHandler = (sender, e) => {
            //    Console.WriteLine("ddd");
            //    MainPage.BasePageView.ScrollEnabled =false;
            //};
            //arcBar.MouseUpEventHandler = (sender, e) => {
            //    Console.WriteLine("ddd2");
            //    MainPage.BasePageView.ScrollEnabled = true;
            //};
                arcBar.OnStopTrackingTouchEvent = (sender, e) =>
                {
                    temp = arcBar.Progress;
                    device.SetAttrState(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                    btnTemp.Text = arcBar.Progress.ToString();
                    controlTime = DateTime.Now;
                    Dictionary<string, string> d = new Dictionary<string, string>();
                    d.Add(FunctionAttributeKey.SetTemp, arcBar.Progress.ToString());
                    Control.Ins.SendWriteCommand(device, d);
                };
                arcBar.OnProgressChangedEvent = (sender, e) =>
                {
                    device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString());
                    btnTemp.Text = e.ToString();
                    //btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5);
                    //btnTempUint.X = btnTemp.Right;
                };
                //arcBar.MouseDownEventHandler = (sender, e) => {
                //    Console.WriteLine("ddd");
                //    MainPage.BasePageView.ScrollEnabled =false;
                //};
                //arcBar.MouseUpEventHandler = (sender, e) => {
                //    Console.WriteLine("ddd2");
                //    MainPage.BasePageView.ScrollEnabled = true;
                //};
            }
        }
        /// <summary>
        /// 控制模式事件
@@ -938,6 +1015,15 @@
            btnSwitch.MouseUpEventHandler = (sender, e) =>
            {
                //if (!device.online)
                //{
                //    new Tip()
                //    {
                //        CloseTime = 1,
                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
                //        Direction = AMPopTipDirection.None,
                //    }.Show(MainPage.BaseView);
                //}
                btnSwitch.IsSelected = !btnSwitch.IsSelected;
                device.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                if (device.trait_on_off.curValue.ToString() == "on")
@@ -976,18 +1062,22 @@
                }
                else
                {
                    btnIndoorTemp.Text = Language.StringByID(StringId.IndoorTemp) + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp))) + "°C";
                    //device = FunctionList.List.Functions.Find((obj) => obj.sid == device.sid);
                    btnIndoorTemp.Text = Language.StringByID(StringId.Indoor) + " " + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp).Replace(",", "."))) + "°C";
                    btnMode.SelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode));
                    btnSwing.SelectedImagePath = acFunction.GetSwingIconPath(device.GetAttrState(FunctionAttributeKey.Swing));
                    btnWindSpeed.SelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed));
                    btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode), false);
                    btnSwing.UnSelectedImagePath = acFunction.GetSwingIconPath(device.GetAttrState(FunctionAttributeKey.Swing), false);
                    btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed), false);
                    temp = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp)));
                    temp = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp).Replace(",", ".")));
                    arcBar.Progress = temp;
                    btnTemp.Text = temp.ToString() ;
                    btnTemp.Text = temp.ToString();
                    //btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5);
                    //btnTempUint.X = btnTemp.Right;
                    if (device.trait_on_off.curValue.ToString() == "on")
                    {
@@ -1026,15 +1116,5 @@
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 刷新当前设备的状态缓存
        /// </summary>
        private void RefreshNowDeviceStatuMemory(Function i_LocalDevice)
        {
        }
        #endregion
    }
}