public static IDisposable CreateTransactionIf(bool condition, Control controlToLayout, IArrangedElement elementCausingLayout, string property) { if (condition) { return(new LayoutTransaction(controlToLayout, elementCausingLayout, property)); } CommonProperties.xClearPreferredSizeCache(elementCausingLayout); return(new NullLayoutTransaction()); }
public static void DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, string property) { if (elementCausingLayout != null) { CommonProperties.xClearPreferredSizeCache(elementCausingLayout); if (elementToLayout != null) { CommonProperties.xClearPreferredSizeCache(elementToLayout); elementToLayout.PerformLayout(elementCausingLayout, property); } } }
public static void DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, string property) { if (elementCausingLayout != null) { CommonProperties.xClearPreferredSizeCache(elementCausingLayout); if (elementToLayout != null) { CommonProperties.xClearPreferredSizeCache(elementToLayout); elementToLayout.PerformLayout(elementCausingLayout, property); } } Debug.Assert(elementCausingLayout != null, "LayoutTransaction.DoLayout - elementCausingLayout is null, no layout performed - did you mix up your parameters?"); }
// This overload should be used when a property has changed that affects preferred size, // but you only want to layout if a certain condition exists (say you want to layout your // parent because your preferred size has changed). public static void DoLayoutIf(bool condition, IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, string property) { if (!condition) { if (elementCausingLayout != null) { CommonProperties.xClearPreferredSizeCache(elementCausingLayout); } } else { LayoutTransaction.DoLayout(elementToLayout, elementCausingLayout, property); } }
internal static void xClearAllPreferredSizeCaches(IArrangedElement start) { CommonProperties.xClearPreferredSizeCache(start); ArrangedElementCollection controlsCollection = start.Children; // This may have changed the sizes of our children. // PERFNOTE: This is more efficient than using Foreach. Foreach // forces the creation of an array subset enum each time we // enumerate for (int i = 0; i < controlsCollection.Count; i++) { xClearAllPreferredSizeCaches(controlsCollection[i]); } }
public LayoutTransaction(Control controlToLayout, IArrangedElement controlCausingLayout, string property, bool resumeLayout) { CommonProperties.xClearPreferredSizeCache(controlCausingLayout); this._controlToLayout = controlToLayout; this._resumeLayout = resumeLayout; if (this._controlToLayout != null) { this._controlToLayout.SuspendLayout(); CommonProperties.xClearPreferredSizeCache(this._controlToLayout); if (resumeLayout) { this._controlToLayout.PerformLayout(new LayoutEventArgs(controlCausingLayout, property)); } } }
public LayoutTransaction(Control controlToLayout, IArrangedElement controlCausingLayout, string property, bool resumeLayout) { CommonProperties.xClearPreferredSizeCache(controlCausingLayout); _controlToLayout = controlToLayout; _resumeLayout = resumeLayout; if (_controlToLayout != null) { #if DEBUG _layoutSuspendCount = _controlToLayout.LayoutSuspendCount; #endif _controlToLayout.SuspendLayout(); CommonProperties.xClearPreferredSizeCache(_controlToLayout); // Same effect as calling performLayout on Dispose but then we would have to keep // controlCausingLayout and property around as state. if (resumeLayout) { _controlToLayout.PerformLayout(new LayoutEventArgs(controlCausingLayout, property)); } } }