浏览代码

horizontalRuler.Text and verticalRuler.Text of the Scrolling scenario only need setted once, avoiding continuous redrawing.

BDisp 4 年之前
父节点
当前提交
06a001d5ea
共有 3 个文件被更改,包括 17 次插入5 次删除
  1. 7 2
      UICatalog/Scenarios/Dialogs.cs
  2. 7 2
      UICatalog/Scenarios/MessageBoxes.cs
  3. 3 1
      UICatalog/Scenarios/Scrolling.cs

+ 7 - 2
UICatalog/Scenarios/Dialogs.cs

@@ -93,8 +93,13 @@ namespace UICatalog {
 			};
 			frame.Add (numButtonsEdit);
 
-			Top.Loaded += () => frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
-				+ Dim.Height (numButtonsEdit) + 2;
+			void Top_Loaded ()
+			{
+				frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
+					+ Dim.Height (numButtonsEdit) + 2;
+				Top.Loaded -= Top_Loaded;
+			}
+			Top.Loaded += Top_Loaded;
 
 			label = new Label ("Button Pressed:") {
 				X = Pos.Center (),

+ 7 - 2
UICatalog/Scenarios/MessageBoxes.cs

@@ -124,8 +124,13 @@ namespace UICatalog {
 			};
 			frame.Add (styleRadioGroup);
 
-			Top.Loaded += () => frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit) + Dim.Height (messageEdit)
-				+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + 2;
+			void Top_Loaded ()
+			{
+				frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit) + Dim.Height (messageEdit)
+					+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + 2;
+				Top.Loaded -= Top_Loaded;
+			}
+			Top.Loaded += Top_Loaded;
 
 			label = new Label ("Button Pressed:") {
 				X = Pos.Center (),

+ 3 - 1
UICatalog/Scenarios/Scrolling.cs

@@ -143,11 +143,13 @@ namespace UICatalog {
 			};
 			scrollView.Add (verticalRuler);
 
-			Win.LayoutComplete += (a) => {
+			void Top_Loaded()  {
 				horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)] +
 				"\n" + "|         ".Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
 				verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height * 2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height * 2)];
+				Top.Loaded -= Top_Loaded;
 			};
+			Top.Loaded += Top_Loaded;
 
 			var pressMeButton = new Button ("Press me!") {
 				X = 3,