From 2029e64ec0491f7e511dc15bffaf821bfbabe2de Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 20 七月 2020 14:10:22 +0800 Subject: [PATCH] 上传一个很特别的新版本 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 52 insertions(+), 2 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs index 304bd26..85c4f68 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelColorSelectForm.cs @@ -45,6 +45,8 @@ /// <param name="i_B">B</param> public void ShowForm(int i_R,int i_G,int i_B) { + this.ScrollEnabled = false; + //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSelectColor)); @@ -119,8 +121,16 @@ btnWhiteView.Radius = (uint)this.GetPictrueRealSize(30) / 2; framePic.AddChidren(btnWhiteView); + bool pointIsRight = false; + //鍦嗙殑鍗婂緞 + int circleR = framePic.Width / 2 - this.GetPictrueRealSize(35); colorPic.ColorChaged += (sender, eColor) => { + if (pointIsRight == false) + { + //鐐圭殑鍖哄煙涓嶆槸鍦嗙洏鍐� + return; + } listRGB = new List<int>(); listRGB.Add(Convert.ToInt32(Convert.ToString(eColor[0]))); listRGB.Add(Convert.ToInt32(Convert.ToString(eColor[1]))); @@ -138,13 +148,24 @@ }; colorPic.MouseDownEventHandler += (sender, e) => { + pointIsRight = this.CheckPoint(circleR, framePic.Width / 2, framePic.Height / 2, (int)e.X, (int)e.Y); + if (pointIsRight == false) + { + //鐐圭殑鍖哄煙涓嶆槸鍦嗙洏鍐� + return; + } //鏄剧ず鐧界偣 - btnWhiteView.X = (int)e.X; - btnWhiteView.Y = (int)e.Y; + btnWhiteView.X = (int)e.X - btnWhiteView.Width / 2; + btnWhiteView.Y = (int)e.Y - btnWhiteView.Height / 2; if (btnWhiteView.Visible == false) { btnWhiteView.Visible = true; } + }; + colorPic.MouseMoveEventHandler += (sender, e) => + { + //褰撻紶鏍囩偣涓嬩簨浠跺鐞� + colorPic.MouseDownEventHandler(sender, e); }; } @@ -229,6 +250,35 @@ #region 鈻� 涓�鑸柟娉昣__________________________ /// <summary> + /// 妫�娴嬬偣鍑荤偣 + /// </summary> + /// <param name="circleR">鍦嗙殑鍗婂緞</param> + /// <param name="circleX">鍦嗗績X杞�</param> + /// <param name="circleY">鍦嗗績Y杞�</param> + /// <param name="pointX">鐐瑰嚮鐐圭殑X杞�</param> + /// <param name="pointY">鐐瑰嚮鐐圭殑Y杞�</param> + /// <returns></returns> + private bool CheckPoint(int circleR, int circleX, int circleY, int pointX, int pointY) + { + int dwidth = circleX - pointX; + if (dwidth < 0) { dwidth *= -1; } + + int dHeight = circleY - pointY; + if (dHeight < 0) { dHeight *= -1; } + + //鏍规嵁涓夎鍑芥暟,姹備笁瑙掑舰鐨勬枩杈归暱 + int dlength = dwidth * dwidth + dHeight * dHeight; + //鍗婂緞闀垮害(涓嶅紑鏂�,鎵�浠ユ槸鎸夊钩鏂圭畻) + circleR *= circleR; + if (dlength < circleR) + { + //濡傛灉缁勬垚鐨勪笁瑙掑舰骞舵病鏈夐暱杩囧崐寰�,鍒欎唬琛ㄨ繕鍦ㄥ渾鍐�(涓嶅厑璁哥偣杈圭晫) + return true; + } + return false; + } + + /// <summary> /// 鍒濆鍖栧鐢ㄩ鑹茬殑榛樿鍊� /// </summary> /// <returns></returns> -- Gitblit v1.8.0