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);
         }
     }
 }
示例#3
0
 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?");
 }
示例#4
0
 // 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);
     }
 }
示例#5
0
        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));
         }
     }
 }
示例#7
0
        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));
                }
            }
        }