Sfoglia il codice sorgente

fix null reference error

HOME 1 anno fa
parent
commit
8421cccd6f
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      BsWidget/GdiPlusExt.cs

+ 2 - 0
BsWidget/GdiPlusExt.cs

@@ -25,6 +25,8 @@ namespace BsWidget
 
         public static SizeF DrawStringWithOutline(this Graphics g, string text, Font font, float x, float y, Color outlineColor, Color fillColor, float outlineWidth = 1)
         {
+            if (text == null) return SizeF.Empty;
+
             // assuming g is the Graphics object on which you want to draw the text
             using var p = new GraphicsPath();
             p.AddString(