From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期三, 22 六月 2022 11:22:18 +0800
Subject: [PATCH] 修改引用路径

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs |  182 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 165 insertions(+), 17 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs
index 85c4f68..71725b2 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs
@@ -32,6 +32,14 @@
         /// 鍦嗙洏閫夋嫨鐨勯鑹叉樉绀烘帶浠�(鍐呮)
         /// </summary>
         private IconViewControl wheelSelectIcon2 = null;
+        /// <summary>
+        /// 鏄惁鏄鑹查�夋嫨
+        /// </summary>
+        private bool isColorSelect = false;
+        /// <summary>
+        /// 棰滆壊鍊艰緭鍏ユ帶浠�
+        /// </summary>
+        private TextInputControl txtColorInput = null;
 
         #endregion
 
@@ -43,7 +51,7 @@
         /// <param name="i_R">R</param>
         /// <param name="i_G">G</param>
         /// <param name="i_B">B</param>
-        public void ShowForm(int i_R,int i_G,int i_B)
+        public void ShowForm(int i_R, int i_G, int i_B)
         {
             this.ScrollEnabled = false;
 
@@ -97,17 +105,15 @@
         /// </summary>
         private void InitColorPictrueControl()
         {
-            //鍦嗙洏鎺т欢鐨凢rameLayout
-            var frameBack = new FrameLayout();
-            frameBack.Y = Application.GetRealHeight(66);
-            frameBack.Height = Application.GetRealHeight(1204);
-            bodyFrameLayout.AddChidren(frameBack);
+            //鍒濆鍖栭鑹茶緭鍏ユ帶浠�
+            this.txtColorInput = this.InitColorInputControl();
 
             var framePic = new FrameLayout();
             framePic.Width = this.GetPictrueRealSize(588);
             framePic.Height = this.GetPictrueRealSize(588);
-            framePic.Gravity = Gravity.Center;
-            frameBack.AddChidren(framePic);
+            framePic.Gravity = Gravity.CenterHorizontal;
+            framePic.Y = Application.GetRealHeight(192);
+            bodyFrameLayout.AddChidren(framePic);
 
             //鍦嗙洏鎺т欢
             var colorPic = new ColorPicker();
@@ -137,14 +143,11 @@
                 listRGB.Add(Convert.ToInt32(Convert.ToString(eColor[2])));
 
                 //鏄剧ず閫夋嫨棰滆壊鐨勬帶浠�
-                if (nowSelectIcon1 != null)
-                {
-                    nowSelectIcon1.BorderColor = UserCenterColor.Current.White;
-                }
-                wheelSelectIcon2.BackgroundColor = this.GetColorByRGB(eColor[0], eColor[1], eColor[2]);
-                wheelSelectIcon1.BorderColor = 0xffcccccc;
-                wheelSelectIcon1.Name = listRGB[0] + "-" + listRGB[1] + "-" + listRGB[2];
-                nowSelectIcon1 = wheelSelectIcon1;
+                this.ShowNowSelectColorControl(eColor);
+
+                //鑾峰彇棰滆壊鐨勭炕璇戞枃鏈�
+                isColorSelect = true;
+                this.txtColorInput.Text = this.GetColorTextTranslate(listRGB[0], listRGB[1], listRGB[2]);
             };
             colorPic.MouseDownEventHandler += (sender, e) =>
             {
@@ -167,6 +170,99 @@
                 //褰撻紶鏍囩偣涓嬩簨浠跺鐞�
                 colorPic.MouseDownEventHandler(sender, e);
             };
+
+            //鎵嬪姩杈撳叆鍊兼敼鍙樹簨浠�
+            this.txtColorInput.TextChangeEventHandler += (sender, value) =>
+            {
+                if (isColorSelect == true)
+                {
+                    //杩欓噷鏄敱鐐瑰嚮鑹茬洏杩涜璧嬪�艰Е鍙�
+                    isColorSelect = false;
+                    return;
+                }
+                //妫�娴嬭緭鍏ョ殑棰滆壊鍊�
+                var byteColor = this.CheckInputColorValue(value);
+                if (byteColor == null)
+                {
+                    return;
+                }
+                if (btnWhiteView.Visible == true)
+                {
+                    //鐧界偣闅愯棌
+                    btnWhiteView.Visible = false;
+                }
+
+                //璁板綍缂撳瓨
+                listRGB = new List<int>();
+                listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[0])));
+                listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[1])));
+                listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[2])));
+
+                //鏄剧ず閫夋嫨棰滆壊鐨勬帶浠�
+                this.ShowNowSelectColorControl(byteColor);
+            };
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栭鑹茶緭鍏ユ帶浠�
+        /// </summary>
+        /// <returns></returns>
+        private TextInputControl InitColorInputControl()
+        {
+            //鑷畾涔夎壊鍊肩殑澶栨
+            var frameInput = new NormalFrameLayout();
+            frameInput.Width = Application.GetRealWidth(458);
+            frameInput.Height = Application.GetRealHeight(104);
+            frameInput.Y = Application.GetRealHeight(1103);
+            frameInput.Gravity = Gravity.CenterHorizontal;
+            frameInput.BorderColor = 0xffcccccc;
+            frameInput.Radius = (uint)Application.GetRealWidth(17);
+            frameInput.BorderWidth = Application.GetRealWidth(3) == 0 ? 1 : (uint)Application.GetRealWidth(3);
+            bodyFrameLayout.AddChidren(frameInput);
+            var btnMark = new NormalViewControl(100, 58, true);
+            btnMark.X = Application.GetRealWidth(35);
+            btnMark.Gravity = Gravity.CenterVertical;
+            btnMark.IsBold = true;
+            btnMark.Text = "# ";
+            btnMark.Width = btnMark.GetRealWidthByText();
+            btnMark.TextColor = UserCenterColor.Current.TextGrayColor2;
+            frameInput.AddChidren(btnMark);
+            //鑷畾涔夎壊鍊艰緭鍏ユ
+            var txtInput = new TextInputControl(400, 58, true);
+            txtInput.X = btnMark.Right;
+            txtInput.Gravity = Gravity.CenterVertical;
+            txtInput.TextSize = 16;
+            txtInput.FrameBorder = frameInput;
+            frameInput.AddChidren(txtInput);
+            //鑹插�煎彿涓�6浣嶏紙鐢变换鎰忔暟瀛�+瀛楁瘝缁勫悎锛�
+            var btnTipView = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(55), false);
+            btnTipView.Y = frameInput.Bottom + Application.GetRealHeight(20);
+            btnTipView.IsBold = true;
+            btnTipView.TextAlignment = TextAlignment.Center;
+            btnTipView.TextColor = UserCenterColor.Current.TextGrayColor2;
+            btnTipView.TextSize = 12;
+            btnTipView.TextID = R.MyInternationalizationString.uColorLengthMsg;
+            bodyFrameLayout.AddChidren(btnTipView);
+
+            return txtInput;
+        }
+
+        /// <summary>
+        /// 鏄剧ず閫夋嫨棰滆壊鐨勬帶浠�
+        /// </summary>
+        /// <param name="eColor"></param>
+        private void ShowNowSelectColorControl(byte[] eColor)
+        {
+            //鏄剧ず閫夋嫨棰滆壊鐨勬帶浠�
+            if (nowSelectIcon1 != null)
+            {
+                nowSelectIcon1.BorderColor = UserCenterColor.Current.White;
+            }
+            var uintColor = this.GetColorByRGB(eColor[0], eColor[1], eColor[2]);
+            wheelSelectIcon2.BackgroundColor = uintColor;
+            wheelSelectIcon1.BorderColor = 0xffcccccc;
+            wheelSelectIcon1.Name = listRGB[0] + "-" + listRGB[1] + "-" + listRGB[2];
+            nowSelectIcon1 = wheelSelectIcon1;
         }
 
         #endregion
@@ -194,7 +290,7 @@
                 btnFrame.Width = this.GetPictrueRealSize(80);
                 btnFrame.Radius = (uint)this.GetPictrueRealSize(80) / 2;
                 btnFrame.X = Xdefult + i * this.GetPictrueRealSize(80 + 24);
-                btnFrame.Y = Application.GetRealHeight(1054);
+                btnFrame.Y = Application.GetRealHeight(880);
                 btnFrame.BackgroundColor = UserCenterColor.Current.White;
                 btnFrame.BorderWidth = 1;
                 btnFrame.BorderColor = UserCenterColor.Current.White;
@@ -221,6 +317,10 @@
                     wheelSelectIcon1 = btnFrame;
                     wheelSelectIcon2 = btnIcon;
                     nowSelectIcon1 = btnFrame;
+
+                    //鑾峰彇棰滆壊鐨勭炕璇戞枃鏈�
+                    isColorSelect = true;
+                    this.txtColorInput.Text = this.GetColorTextTranslate(i_R, i_G, i_B);
                 }
 
                 btnFrame.ButtonClickEvent += (sender, e) =>
@@ -241,6 +341,9 @@
                         listRGB.Add(Convert.ToInt32(Convert.ToString(Arry[1])));
                         listRGB.Add(Convert.ToInt32(Convert.ToString(Arry[2])));
                     }
+                    //鑾峰彇棰滆壊鐨勭炕璇戞枃鏈�
+                    isColorSelect = true;
+                    this.txtColorInput.Text = this.GetColorTextTranslate(listRGB[0], listRGB[1], listRGB[2]);
                 };
             }
         }
@@ -296,6 +399,51 @@
         }
 
         /// <summary>
+        /// 妫�娴嬭緭鍏ョ殑棰滆壊鍊�
+        /// </summary>
+        /// <param name="colorText"></param>
+        /// <returns></returns>
+        private byte[] CheckInputColorValue(string colorText)
+        {
+            //鍙湁闀垮害涓�6鎵嶅鐞�
+            if (colorText.Length != 6) { return null; }
+
+            colorText = colorText.ToUpper();
+            foreach (var c in colorText)
+            {
+                if (char.IsNumber(c) == true)
+                {
+                    //鏁板瓧鐨勮瘽,OK
+                    continue;
+                }
+                if ('A' <= c && c <= 'F')
+                {
+                    //A-F鐨勮瘽,OK
+                    continue;
+                }
+                return null;
+            }
+            int R = Convert.ToInt32(colorText.Substring(0, 2), 16);
+            int G = Convert.ToInt32(colorText.Substring(2, 2), 16);
+            int B = Convert.ToInt32(colorText.Substring(4, 2), 16);
+            return new byte[] { (byte)R, (byte)G, (byte)B };
+        }
+
+        /// <summary>
+        /// 鑾峰彇棰滆壊鐨勭炕璇戞枃鏈�
+        /// </summary>
+        /// <param name="i_R"></param>
+        /// <param name="i_G"></param>
+        /// <param name="i_B"></param>
+        /// <returns></returns>
+        private string GetColorTextTranslate(int i_R, int i_G, int i_B)
+        {
+            return Convert.ToString(i_R, 16).ToUpper().PadLeft(2, '0')
+                + Convert.ToString(i_G, 16).ToUpper().PadLeft(2, '0')
+                + Convert.ToString(i_B, 16).ToUpper().PadLeft(2, '0');
+        }
+
+        /// <summary>
         /// 灏哛GB杞崲涓洪鑹�
         /// </summary>
         /// <param name="R"></param>

--
Gitblit v1.8.0