瀏覽代碼

Force AutoSize false instead of throw Exception when setting Width/Height

tznind 1 年之前
父節點
當前提交
7d4d77ca64
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      Terminal.Gui/View/Layout/ViewLayout.cs

+ 8 - 4
Terminal.Gui/View/Layout/ViewLayout.cs

@@ -228,7 +228,8 @@ public partial class View
 
             if (AutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Height)}.");
+                Debug.WriteLine (@$"Must set AutoSize to false before setting {nameof (Height)}.");
+                AutoSize = false;
             }
 
             //if (ValidatePosDim) {
@@ -236,9 +237,10 @@ public partial class View
 
             if (IsAdded && AutoSize && !isValidNewAutoSize)
             {
-                throw new InvalidOperationException (
+                Debug.WriteLine (
                                                      @$"Must set AutoSize to false before setting the {nameof (Height)}."
                                                     );
+                AutoSize = false;
             }
 
             //}
@@ -275,14 +277,16 @@ public partial class View
 
             if (AutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Width)}.");
+                Debug.WriteLine($@"Must set AutoSize to false before setting {nameof(Width)}.");
+                AutoSize = false;
             }
 
             bool isValidNewAutoSize = AutoSize && IsValidAutoSizeWidth (_width);
 
             if (IsAdded && AutoSize && !isValidNewAutoSize)
             {
-                throw new InvalidOperationException (@$"Must set AutoSize to false before setting {nameof (Width)}.");
+                Debug.WriteLine($@"Must set AutoSize to false before setting {nameof(Width)}.");
+                AutoSize = false;
             }
 
             OnResizeNeeded ();