From 1dade03e0e71076af3a3de1bf10ba6cad61ac216 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 01 二月 2021 19:22:38 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into NewFilePath

---
 HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWeepRobotPage.cs |  341 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 288 insertions(+), 53 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWeepRobotPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWeepRobotPage.cs
old mode 100755
new mode 100644
index 4ebf58c..323e8fd
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWeepRobotPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWeepRobotPage.cs
@@ -17,13 +17,9 @@
         #region 鈻� 鍙橀噺澹版槑___________________________
 
         /// <summary>
-        /// 鐢垫睜鍥炬爣
+        /// 鐢垫睜鎺т欢
         /// </summary>
-        private IconViewControl btnBatteryIcon = null;
-        /// <summary>
-        /// 鐢垫睜鐧惧垎姣旀帶浠�
-        /// </summary>
-        private NormalViewControl btnBatteryView = null;
+        private BatteryPersentControl btnBattery = null;
         /// <summary>
         /// 鍚稿姏璋冭妭鍥炬爣
         /// </summary>
@@ -60,6 +56,14 @@
         /// 鎵湴鏈哄櫒浜烘暟鎹�
         /// </summary>
         private WeepRobotData weepRobotData = new WeepRobotData();
+        /// <summary>
+        /// 鏄惁鍦ㄦ帶鍒舵柟鍚戜腑
+        /// </summary>
+        private bool directionControling = false;
+        /// <summary>
+        /// 鏂瑰悜鎺у埗缁撴潫鏃堕棿
+        /// </summary>
+        private DateTime directionFinishTime = DateTime.Now.AddDays(-1);
 
         #endregion
 
@@ -90,25 +94,16 @@
         /// </summary>
         private void InitFrameWhiteContent1()
         {
-            //鐢垫睜鍥炬爣
-            this.btnBatteryIcon = new IconViewControl(24);
-            btnBatteryIcon.X = base.btnRoomName.Right + Application.GetRealWidth(24);
-            btnBatteryIcon.Y = base.btnRoomName.Y - (btnBatteryIcon.IconSize - base.btnRoomName.Height) / 2;
-            btnBatteryIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Battery.png";
-            FrameWhiteCentet1.AddChidren(btnBatteryIcon);
-            //鐢垫睜鐧惧垎姣�
-            this.btnBatteryView = new NormalViewControl(30, 16, true);
-            btnBatteryView.X = btnBatteryIcon.Right + Application.GetRealWidth(4);
-            btnBatteryView.Y = btnBatteryIcon.Y + (btnBatteryIcon.Height - Application.GetRealHeight(16)) / 2;
-            btnBatteryView.Text = this.weepRobotData.ElectricityLeft + "%";
-            btnBatteryView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
-            btnBatteryView.TextColor = CSS_Color.PromptingColor1;
-            FrameWhiteCentet1.AddChidren(btnBatteryView);
+            //鐢垫睜鎺т欢
+            this.btnBattery = new BatteryPersentControl();
+            btnBattery.X = base.btnRoomName.Right + Application.GetRealWidth(24);
+            FrameWhiteCentet1.AddChidren(btnBattery);
+            btnBattery.Y = base.btnRoomName.Y - (btnBattery.Height - base.btnRoomName.Height) / 2;
+            btnBattery.InitControl();
             //閰嶇疆鍙樻洿浜嬩欢
             base.SettionFinishEvent += () =>
             {
-                btnBatteryIcon.X = base.btnRoomName.Right + Application.GetRealWidth(24);
-                btnBatteryView.X = btnBatteryIcon.Right + Application.GetRealWidth(4);
+                btnBattery.X = base.btnRoomName.Right + Application.GetRealWidth(24);
             };
 
             //鍒濆鍖栦腑闂寸殑閭d釜鍥惧儚鎺у埗鎺т欢
@@ -122,10 +117,11 @@
             ImageControl.InitControl("FunctionIcon/Electrical/WeepRobot/ControlEnable.png", "FunctionIcon/Electrical/WeepRobot/ControlDisable.png",
                 "FunctionIcon/Electrical/WeepRobot/ControlUp.png", "FunctionIcon/Electrical/WeepRobot/ControlDown.png",
                 "FunctionIcon/Electrical/WeepRobot/ControlLeft.png", "FunctionIcon/Electrical/WeepRobot/ControlRight.png");
-            //鎺у埗浜嬩欢(涓嶆敮鎸丒nable鍜孌isable,閮藉綊涓篗id)
-            ImageControl.ControlEvent += (select) =>
+            //鎺у埗浜嬩欢(鍙湁enable,Mid,left,right,up,down銆� enable:鎵嬫寚鏉惧紑鏂瑰悜閿悗瑙﹀彂)
+            ImageControl.NotRecoverControlEvent += (select) =>
             {
-
+                //鍙戦�佹帶鍒舵柟鍚戝懡浠�
+                this.SendDirectionControlComand(select);
             };
 
             //鍚稿姏璋冭妭
@@ -137,6 +133,8 @@
             FrameWhiteCentet1.AddChidren(btnSuctionIcon);
             btnSuctionIcon.ButtonClickEvent += (sender, e) =>
             {
+                //鏄剧ず鍚稿姏璋冭妭閫夋嫨鐣岄潰
+                this.ShowSuctionSelectView();
             };
             this.btnSuctionView = new NormalViewControl(80, 54, true);
             btnSuctionView.Y = btnSuctionIcon.Bottom + Application.GetRealHeight(10);
@@ -149,13 +147,14 @@
 
             //鍏呯數鍥炬爣
             this.btnChargeIcon = new IconViewControl(28);
-            btnChargeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Charge.png";
-            btnChargeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/ChargeSelect.png";
+            btnChargeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/ChargeSelect.png";
             btnChargeIcon.Y = btnSuctionIcon.Y;
             btnChargeIcon.X = btnSuctionIcon.Right + Application.GetRealWidth(50);
             FrameWhiteCentet1.AddChidren(btnChargeIcon);
             btnChargeIcon.ButtonClickEvent += (sender, e) =>
             {
+                //鍙戦�佸厖鐢靛懡浠�
+                this.SendComand("mode", "chargego");
             };
             var btnChargeView = new NormalViewControl(80, 18, true);
             btnChargeView.Y = btnSuctionView.Y;
@@ -174,6 +173,8 @@
             FrameWhiteCentet1.AddChidren(btnVoiceIcon);
             btnVoiceIcon.ButtonClickEvent += (sender, e) =>
             {
+                //鍙戦�侀潤闊冲懡浠�
+                this.SendComand("voice_switch", this.weepRobotData.VoiceSwitch == true ? "false" : "true");
             };
             this.btnVoiceView = new NormalViewControl(80, 18, true);
             btnVoiceView.Y = btnSuctionView.Y;
@@ -191,6 +192,8 @@
             FrameWhiteCentet1.AddChidren(btnModeIcon);
             btnModeIcon.ButtonClickEvent += (sender, e) =>
             {
+                //鏄剧ず娓呮壂妯″紡閫夋嫨
+                this.ShowCleanModeSelectView();
             };
             this.btnModeView = new NormalViewControl(80, 54, true);
             btnModeView.Y = btnSuctionView.Y;
@@ -227,6 +230,8 @@
             rowManment.AddRightArrow();
             rowManment.ButtonClickEvent += (sender, e) =>
             {
+                var form = new TuyaWeepRobotConsumablesMagPage();
+                form.AddForm(this.device, this.weepRobotData);
             };
 
             //鍘嗗彶璁板綍
@@ -240,7 +245,130 @@
             rowHistory.AddRightArrow();
             rowHistory.ButtonClickEvent += (sender, e) =>
             {
+                var form = new TuyaWeepRobotHistoryPage();
+                form.AddForm(this.weepRobotData);
             };
+        }
+
+        #endregion
+
+        #region 鈻� 鍚稿姏璋冭妭閫夋嫨_______________________
+
+        /// <summary>
+        /// 鏄剧ず鍚稿姏璋冭妭閫夋嫨鐣岄潰
+        /// </summary>
+        private void ShowSuctionSelectView()
+        {
+            //鏁翠釜鐏拌壊鐣岄潰
+            var frameBack = new Dialog();
+
+            var dialogBody = new NormalFrameLayout();
+            frameBack.AddChidren(dialogBody);
+            dialogBody.ButtonClickEvent = (sender, e) =>
+            {
+                frameBack.Close();
+            };
+            frameBack.Show();
+
+            //鑿滃崟鎺т欢(鍚稿姏璋冭妭)
+            var menuContr = new DialogTitleMenuControl(3, Language.StringByID(StringId.SuctionAdjustment));
+            menuContr.X = Application.GetRealWidth(5);
+            menuContr.Y = Application.GetRealHeight(241);
+            menuContr.Width = Application.GetRealWidth(160);
+            menuContr.Height = Application.GetRealHeight(200);
+            dialogBody.AddChidren(menuContr);
+
+            //鍚稿姏1妗�
+            var iconPath = this.weepRobotData.Suction == "quiet" ? "FunctionIcon/Electrical/WeepRobot/SuctionSelect.png" : "FunctionIcon/Electrical/WeepRobot/Suction.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.SuctionOneGear), iconPath, this.weepRobotData.Suction == "strong", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佸惛鍔涘懡浠�
+                this.SendComand("suction", "quiet");
+            });
+
+            //鍚稿姏2妗�
+            iconPath = this.weepRobotData.Suction == "normal" ? "FunctionIcon/Electrical/WeepRobot/SuctionSelect.png" : "FunctionIcon/Electrical/WeepRobot/Suction.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.SuctionTwoGear), iconPath, this.weepRobotData.Suction == "normal", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佸惛鍔涘懡浠�
+                this.SendComand("suction", "normal");
+            });
+
+            //鍚稿姏3妗�
+            iconPath = this.weepRobotData.Suction == "strong" ? "FunctionIcon/Electrical/WeepRobot/SuctionSelect.png" : "FunctionIcon/Electrical/WeepRobot/Suction.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.SuctionThreeGear), iconPath, this.weepRobotData.Suction == "quiet", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佸惛鍔涘懡浠�
+                this.SendComand("suction", "strong");
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 娓呮壂妯″紡閫夋嫨_______________________
+
+        /// <summary>
+        /// 鏄剧ず娓呮壂妯″紡閫夋嫨鐣岄潰
+        /// </summary>
+        private void ShowCleanModeSelectView()
+        {
+            //鏁翠釜鐏拌壊鐣岄潰
+            var frameBack = new Dialog();
+
+            var dialogBody = new NormalFrameLayout();
+            frameBack.AddChidren(dialogBody);
+            dialogBody.ButtonClickEvent = (sender, e) =>
+            {
+                frameBack.Close();
+            };
+            frameBack.Show();
+
+            //鑿滃崟鎺т欢(娓呮壂妯″紡)
+            var menuContr = new DialogTitleMenuControl(4, Language.StringByID(StringId.CleanMode));
+            menuContr.X = Application.GetRealWidth(210);
+            menuContr.Y = Application.GetRealHeight(197);
+            menuContr.Width = Application.GetRealWidth(160);
+            menuContr.Height = Application.GetRealHeight(243);
+            dialogBody.AddChidren(menuContr);
+
+            //鑷姩娓呮壂
+            var iconPath = this.weepRobotData.Mode == "random" ? "FunctionIcon/Electrical/WeepRobot/AutoModeSelect.png" : "FunctionIcon/Electrical/WeepRobot/AutoMode.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.AutoClean), iconPath, this.weepRobotData.Mode == "random", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佹ā寮忓懡浠�
+                this.SendComand("mode", "random");
+            });
+
+            //瀹氱偣娓呮壂
+            iconPath = this.weepRobotData.Mode == "smart" ? "FunctionIcon/Electrical/WeepRobot/FixedPointModeSelect.png" : "FunctionIcon/Electrical/WeepRobot/FixedPointMode.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.FixedPointClean), iconPath, this.weepRobotData.Mode == "smart", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佹ā寮忓懡浠�
+                this.SendComand("mode", "smart");
+            });
+
+            //鍖哄煙娓呮壂
+            iconPath = this.weepRobotData.Mode == "spiral" ? "FunctionIcon/Electrical/WeepRobot/AreaModeSelect.png" : "FunctionIcon/Electrical/WeepRobot/AreaMode.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.AreaClean), iconPath, this.weepRobotData.Mode == "spiral", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佹ā寮忓懡浠�
+                this.SendComand("mode", "spiral");
+            });
+
+            //娌垮娓呮壂
+            iconPath = this.weepRobotData.Mode == "wall_follow" ? "FunctionIcon/Electrical/WeepRobot/WallModeSelect.png" : "FunctionIcon/Electrical/WeepRobot/WallMode.png";
+            menuContr.AddRowMenu(Language.StringByID(StringId.WallClean), iconPath, this.weepRobotData.Mode == "wall_follow", () =>
+            {
+                frameBack.Close();
+                //鍙戦�佹ā寮忓懡浠�
+                this.SendComand("mode", "wall_follow");
+            });
         }
 
         #endregion
@@ -267,23 +395,60 @@
         #region 鈻� 鍙戦�佸悇绉嶅懡浠______________________
 
         /// <summary>
-        /// 鍙戦�佸紑鍏冲懡浠�
+        /// 鍙戦�佹帶鍒舵柟鍚戝懡浠�
         /// </summary>
-        private void SendSwitchComand()
+        /// <param name="direction">鍙湁enable,Mid,left,right,up,down銆� enable:鎵嬫寚鏉惧紑鏂瑰悜閿悗瑙﹀彂</param>
+        private void SendDirectionControlComand(DirectionEnum direction)
         {
-            //this.btnSwitch.CanClick = false;
+            if (direction == DirectionEnum.Mid)
+            {
+                //鍙戦�佸紑鍏冲懡浠�
+                this.SendComand(FunctionAttributeKey.OnOff, this.weepRobotData.Cleaning == true ? "off" : "on");
+            }
+            else if (direction == DirectionEnum.Enable)
+            {
+                //鍋�
+                this.directionControling = false;
+                this.directionFinishTime = DateTime.Now;
+                this.SendComand("direction_control", "stop");
+            }
+            else if (direction == DirectionEnum.Left)
+            {
+                //宸�
+                this.directionControling = true;
+                this.SendComand("direction_control", "turn_left");
+            }
+            else if (direction == DirectionEnum.Right)
+            {
+                //鍙�
+                this.directionControling = true;
+                this.SendComand("direction_control", "turn_right");
+            }
+            else if (direction == DirectionEnum.Up)
+            {
+                //涓�
+                this.directionControling = true;
+                this.SendComand("direction_control", "forward");
+            }
+            else if (direction == DirectionEnum.Down)
+            {
+                //涓�
+                this.directionControling = true;
+                this.SendComand("direction_control", "backward");
+            }
+        }
 
-            //string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
-            //HdlThreadLogic.Current.RunThread(() =>
-            //{
-            //    var dic = new Dictionary<string, string>();
-            //    dic.Add(FunctionAttributeKey.OnOff, statu);
-            //    Control.Ins.SendWriteCommand(this.device, dic, true);
-            //    HdlThreadLogic.Current.RunMain(() =>
-            //    {
-            //        this.btnSwitch.CanClick = true;
-            //    });
-            //});
+        /// <summary>
+        /// 鍙戦�佸懡浠�
+        /// </summary>
+        private void SendComand(string key, string i_value)
+        {
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                var dic = new Dictionary<string, string>();
+                dic.Add(key, i_value);
+                Control.Ins.SendWriteCommand(this.device, dic, true);
+            }, ShowErrorMode.NO);
         }
 
         #endregion
@@ -299,21 +464,91 @@
             if (this.weepRobotData.VoiceSwitch == true)
             {
                 //闇�瑕佸垏鎹㈠浘鏍�
-                if (this.btnVoiceIcon.UnSelectedImagePath != "FunctionIcon/Electrical/WeepRobot/Mute.png")
-                {
-                    this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Mute.png";
-                    this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/MuteSelect.png";
-                }
+                this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Mute.png";
+                this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/MuteSelect.png";
             }
             else
             {
                 //闇�瑕佸垏鎹㈠浘鏍�
-                if (this.btnVoiceIcon.UnSelectedImagePath != "FunctionIcon/Electrical/WeepRobot/Voice.png")
+                this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Voice.png";
+                this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/VoiceSelect.png";
+            }
+            //濡傛灉鏄竻鎵姸鎬�
+            if (this.weepRobotData.Cleaning == true)
+            {
+                //鍚稿姏璋冭妭涓嶅彲鐢�
+                this.btnSuctionIcon.IsSelected = false;
+                this.btnSuctionIcon.CanClick = false;
+                //澹伴煶涓嶅彲鐢�
+                this.btnVoiceIcon.IsSelected = false;
+                this.btnVoiceIcon.CanClick = false;
+                //娓呮壂妯″紡涓嶅彲鐢�
+                this.btnModeIcon.IsSelected = false;
+                this.btnModeIcon.CanClick = false;
+                //鏂瑰悜鎸夐敭涓嶅彲鐢�
+                if (this.directionControling == false && (DateTime.Now - this.directionFinishTime).TotalSeconds >= 2)
                 {
-                    this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Voice.png";
-                    this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/VoiceSelect.png";
+                    //鍦ㄦ墜鍔ㄦ帶鍒舵柟鍚戠殑杩囩▼涓�,涓嶅厑璁稿彉鏇村浘鐗�,骞朵笖缁撴潫涔嬪悗,2绉掑唴涓嶆帴鍙椾换浣曞弽棣�
+                    this.ImageControl.SetDirectionImage(DirectionEnum.Disable);
                 }
             }
+            else
+            {
+                //鍚稿姏璋冭妭鍙敤
+                this.btnSuctionIcon.IsSelected = true;
+                this.btnSuctionIcon.CanClick = true;
+                //澹伴煶鍙敤
+                this.btnVoiceIcon.IsSelected = true;
+                this.btnVoiceIcon.CanClick = true;
+                //娓呮壂妯″紡鍙敤
+                this.btnModeIcon.IsSelected = true;
+                this.btnModeIcon.CanClick = true;
+                //鍙樻洿鎺у埗鎺т欢鐨勫浘鐗�
+                if (this.directionControling == false && (DateTime.Now - this.directionFinishTime).TotalSeconds >= 2)
+                {
+                    //鍦ㄦ墜鍔ㄦ帶鍒舵柟鍚戠殑杩囩▼涓�,涓嶅厑璁稿彉鏇村浘鐗�,骞朵笖缁撴潫涔嬪悗,2绉掑唴涓嶆帴鍙椾换浣曞弽棣�
+                    this.ImageControl.SetDirectionImage(DirectionEnum.Enable);
+                }
+            }
+
+            //娓呮壂妯″紡
+            if (this.weepRobotData.Mode == "random")
+            {
+                //鑷姩娓呮壂
+                this.btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/AutoMode.png";
+                this.btnModeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/AutoModeSelect.png";
+                this.btnModeView.TextID = StringId.AutoClean;
+            }
+            else if (this.weepRobotData.Mode == "smart")
+            {
+                //瀹氱偣娓呮壂
+                this.btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/FixedPointMode.png";
+                this.btnModeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/FixedPointModeSelect.png";
+                this.btnModeView.TextID = StringId.FixedPointClean;
+            }
+            else if (this.weepRobotData.Mode == "wall_follow")
+            {
+                //娌垮娓呮壂
+                this.btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/WallMode.png";
+                this.btnModeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/WallModeSelect.png";
+                this.btnModeView.TextID = StringId.WallClean;
+            }
+            else if (this.weepRobotData.Mode == "spiral")
+            {
+                //鍖哄煙娓呮壂
+                this.btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/AreaMode.png";
+                this.btnModeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/AreaModeSelect.png";
+                this.btnModeView.TextID = StringId.AreaClean;
+            }
+            else
+            {
+                //娓呮壂妯″紡
+                this.btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Clean.png";
+                this.btnModeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/CleanSelect.png";
+                this.btnModeView.TextID = StringId.CleanMode;
+            }
+            //鐢垫睜鐢甸噺
+            this.btnBattery.SetValue(this.weepRobotData.ElectricityLeft);
         }
 
         #endregion
@@ -328,7 +563,7 @@
             foreach (var data in i_LocalDevice.attributes)
             {
                 //寮�鍏�
-                if (data.key == "on_off") { this.weepRobotData.Open = data.realValue.ToLower() == "on"; }
+                if (data.key == "on_off") { this.weepRobotData.Cleaning = data.realValue.ToLower() == "on"; }
                 //瀵绘壘鏈哄櫒
                 else if (data.key == "seek") { this.weepRobotData.SearchRobot = data.realValue.ToLower() == "true"; }
                 //杈瑰埛閲嶇疆
@@ -411,12 +646,12 @@
         /// <summary>
         /// 鎵湴鏈哄櫒浜虹殑鏁版嵁
         /// </summary>
-        private class WeepRobotData
+        public class WeepRobotData
         {
             /// <summary>
-            /// 鏄惁鎵撳紑
+            /// 鏄惁澶勪簬娓呮壂涓�
             /// </summary>
-            public bool Open = true;
+            public bool Cleaning = true;
             /// <summary>
             /// 瀵绘壘鏈哄櫒
             /// </summary>

--
Gitblit v1.8.0