From 5ea6aa8ea047d4d7b6137fa86c03109aeb1b67ff Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 18 十二月 2020 18:03:18 +0800
Subject: [PATCH] Merge branch 'CJL' into NewFilePath

---
 HDL_ON/UI/UI0-Public/Widget/TextButton.cs |   91 ++++++++++++++++++++++++++++-----------------
 1 files changed, 57 insertions(+), 34 deletions(-)

diff --git a/HDL_ON/UI/UI0-Public/Widget/TextButton.cs b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
index 4148731..cebc715 100755
--- a/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
+++ b/HDL_ON/UI/UI0-Public/Widget/TextButton.cs
@@ -4,6 +4,8 @@
 #if __IOS__
 using UIKit;
 using Foundation;
+#else
+using Android.Graphics;
 #endif
 
 namespace HDL_ON.UI
@@ -11,7 +13,7 @@
     /// <summary>
     /// TextButton
     /// 瑙e喅iOS 鏂囨湰鍒拌竟妗嗘湁杈硅窛闂
-    /// 
+    /// 鏀寔鏍规嵁鏂囨湰鍔ㄦ�佽绠楅珮搴�
     /// </summary>
     public class TextButton : Button
     {
@@ -22,6 +24,45 @@
             (this.uiView as MyButton).ContentEdgeInsets = new UIEdgeInsets(0, 0, 0, 0);
 #endif
 
+        }
+
+        /// <summary>
+        /// 璁剧疆闇�瑕侀檺鍒剁殑鏈�澶ц鏁�
+        /// 浣嗘槸瓒呰繃琛屾暟鐨勮瘽浼氱己灏戠渷鐣ュ彿...锛屾殏鏃舵棤娉曡В鍐�
+        /// </summary>
+        public int MaxLine = 0;
+        /// <summary>
+        /// 鍔ㄦ�佽绠楅珮搴�
+        /// 璧嬪�兼枃鏈悗鍜屾寚瀹氬搴﹀悗锛岄�氳繃璁$畻鐪熷疄鐨勯渶瑕佸搴﹀拰鎸囧畾瀹藉害绠楀嚭澶氳闇�瑕佺殑鐪熷疄楂樺害
+        /// 璇ユ柟娉曟湁璇樊涓嶈兘100%鍑嗙‘
+        /// 鏈�姝g‘鏂规硶鏄牴鎹� 鍗曡鍗曚釜瀛椾綋鐨勯珮搴﹀姞涓婅璺濇潵璁$畻
+        /// </summary>
+        /// <returns></returns>
+        public int GetMoreLineNeedHeight()
+        {
+            //璁$畻闇�瑕佺殑鐪熷疄瀹藉害
+            int needWidth = this.GetTextWidth();
+            //璁$畻鍦ㄦ寚瀹氬搴︽儏鍐典笅锛岄渶瑕佺殑鐪熷疄琛屾暟
+            int line = (needWidth / this.Width);
+            //姹備綑
+            int modValue = (needWidth % this.Width);
+            //浣欏ぇ浜�0锛屽垯澶氬姞涓�琛�
+            if (modValue > 0)
+            {
+                line = line + 1;
+            }
+            if (line > 0)
+            {
+                if(MaxLine != 0)
+                {
+                    line = Math.Min(line, MaxLine);
+                }
+                return line * this.Height;
+            }
+            else
+            {
+                return this.Height;
+            }
         }
 
         int _lineSpacing;
@@ -60,42 +101,13 @@
         /// 鏄剧ず褰撳墠鏂囧瓧闇�瑕佸嚑琛�
         /// </summary>
         /// <returns></returns>
-        int GetNeedLinesWithWidth()
+        public int GetNeedLinesWithWidth()
         {
-            return 0;
+            return (this.GetTextWidth() / this.Width) * this.Height;
+            //return 0;
         }
-        /**
- 
 
-// @param width 缁欏畾涓�涓搴�
-// @return 杩斿洖琛屾暟
-// */
-//- (NSInteger) needLinesWithWidth:(CGFloat) width
-//        {
-//            //鍒涘缓涓�涓猯abe
-//            UILabel * label = [[UILabel alloc]
-//            init];
-//            //font鍜屽綋鍓峫abel淇濇寔涓�鑷�
-//            label.font = self.font;
-//            NSString* text = self.text;
-//            NSInteger sum = 0;
-//            //鎬昏鏁板彈鎹㈣绗﹀奖鍝嶏紝鎵�浠ヨ繖閲岃绠楁�昏鏁帮紝闇�瑕佺敤鎹㈣绗﹀垎闅旇繖娈垫枃瀛楋紝鐒跺悗璁$畻姣忔鏂囧瓧鐨勮鏁帮紝鐩稿姞鍗虫槸鎬昏鏁般��
-//            NSArray* splitText = [text componentsSeparatedByString: @"\n"];
-//    for (NSString* sText in splitText)
-//            {
-//                label.text = sText;
-//                //鑾峰彇杩欐鏂囧瓧涓�琛岄渶瑕佺殑size
-//                CGSize textSize = [label systemLayoutSizeFittingSize: CGSizeZero];
-//                //size.width/鎵�闇�瑕佺殑width 鍚戜笂鍙栨暣灏辨槸杩欐鏂囧瓧鍗犵殑琛屾暟
-//                NSInteger lines = ceilf(textSize.width / width);
-//                //褰撴槸0鐨勬椂鍊欙紝璇存槑杩欐槸鎹㈣锛岄渶瑕佹寜涓�琛岀畻銆�
-//                lines = lines == 0 ? 1 : lines;
-//                sum += lines;
-//            }
-//            return sum;
-//            }
 
-            //#elif __Android__
 #else
 
         /// <summary>
@@ -107,8 +119,19 @@
            (this.AndroidView as Android.Widget.Button).SetLineSpacing(spacing, 1);
         }
 
-#endif
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        int GetTextHeight()
+        {
+            string text = "Text";
+            Rect rect = new Rect();
+            (this.AndroidView as Android.Widget.Button).Paint.GetTextBounds(text, 0, text.Length, rect);
+            return rect.Height();
         }
+#endif
+    }
 
 
 

--
Gitblit v1.8.0