internal static void ClearMaximumSize(IArrangedElement element)
 {
     if (element.Properties.ContainsObject(_maximumSizeProperty))
     {
         element.Properties.RemoveObject(_maximumSizeProperty);
     }
 }
コード例 #2
0
 // Repositions a element in this list.
 internal void MoveElement(IArrangedElement element, int fromIndex, int toIndex) {
     int delta = toIndex - fromIndex;
 
     switch (delta) {
         case -1:
         case 1:
             // simple swap
             this.InnerList[fromIndex] = this.InnerList[toIndex];
             break;
 
         default:
             int start = 0;
             int dest = 0;
 
             // which direction are we moving?
             if (delta > 0) {
                 // shift down by the delta to open the new spot
                 start = fromIndex + 1;
                 dest = fromIndex;
             }
             else {
                 // shift up by the delta to open the new spot
                 start = toIndex;
                 dest = toIndex + 1;
 
                 // make it positive
                 delta = -delta;
             }
             Copy(this, start, this, dest, delta);
             break;
     }
     this.InnerList[toIndex] = element;
 }
        internal void MoveElement(IArrangedElement element, int fromIndex, int toIndex)
        {
            int length = toIndex - fromIndex;
            switch (length)
            {
                case -1:
                case 1:
                    this.InnerList[fromIndex] = this.InnerList[toIndex];
                    break;

                default:
                {
                    int sourceIndex = 0;
                    int destinationIndex = 0;
                    if (length > 0)
                    {
                        sourceIndex = fromIndex + 1;
                        destinationIndex = fromIndex;
                    }
                    else
                    {
                        sourceIndex = toIndex;
                        destinationIndex = toIndex + 1;
                        length = -length;
                    }
                    Copy(this, sourceIndex, this, destinationIndex, length);
                    break;
                }
            }
            this.InnerList[toIndex] = element;
        }
 public virtual void PerformLayout(IArrangedElement container, string propertyName)
 {
     if (this.suspendCount <= 0)
     {
         this.OnLayout(new LayoutEventArgs(container, propertyName));
     }
 }
コード例 #5
0
        internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) {
#if DEBUG        
            if (CompModSwitches.FlowLayout.TraceInfo) {            
                Debug.WriteLine("FlowLayout::GetPreferredSize("
                    + "container=" + container.ToString() + ", "
                    + "proposedConstraints=" + proposedConstraints.ToString() + ")");
                Debug.Indent();
            }
#endif
            Rectangle measureBounds = new Rectangle(new Point(0, 0), proposedConstraints);
            Size prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);

            if(prefSize.Width > proposedConstraints.Width || prefSize.Height> proposedConstraints.Height) {
                // Controls measured earlier than a control which couldn't be fit to constraints may
                // shift around with the new bounds.  We need to make a 2nd pass through the
                // controls using these bounds which are gauranteed to fit.
                measureBounds.Size = prefSize;
                prefSize = xLayout(container, measureBounds, /* measureOnly = */ true);
            }

#if DEBUG
            if (CompModSwitches.FlowLayout.TraceInfo) {
                Debug.Unindent();
                Debug.WriteLine("GetPreferredSize returned " + prefSize);
            }
#endif
            return prefSize;
        }
 internal void EnsureOwnership(IArrangedElement owner)
 {
     this._owner = owner;
     for (int i = 0; i < this.Count; i++)
     {
         this[i].Owner = owner;
     }
 }
 internal static AutoSizeMode GetAutoSizeMode(IArrangedElement element)
 {
     if (GetLayoutState(element)[_autoSizeModeSection] != 0)
     {
         return AutoSizeMode.GrowAndShrink;
     }
     return AutoSizeMode.GrowOnly;
 }
 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();
 }
コード例 #9
0
 public static void SetFlowDirection(IArrangedElement container, FlowDirection value)
 {
     if (!System.Windows.Forms.ClientUtils.IsEnumValid(value, (int) value, 0, 3))
     {
         throw new InvalidEnumArgumentException("value", (int) value, typeof(FlowDirection));
     }
     container.Properties.SetInteger(_flowDirectionProperty, (int) value);
     LayoutTransaction.DoLayout(container, container, PropertyNames.FlowDirection);
 }
 internal static Padding GetMargin(IArrangedElement element)
 {
     bool flag;
     Padding padding = element.Properties.GetPadding(_marginProperty, out flag);
     if (flag)
     {
         return padding;
     }
     return DefaultMargin;
 }
 internal static Size GetLayoutBounds(IArrangedElement element)
 {
     bool flag;
     Size size = element.Properties.GetSize(_layoutBoundsProperty, out flag);
     if (flag)
     {
         return size;
     }
     return Size.Empty;
 }
コード例 #12
0
 internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints)
 {
     Rectangle displayRect = new Rectangle(new Point(0, 0), proposedConstraints);
     Size size = this.xLayout(container, displayRect, true);
     if ((size.Width <= proposedConstraints.Width) && (size.Height <= proposedConstraints.Height))
     {
         return size;
     }
     displayRect.Size = size;
     return this.xLayout(container, displayRect, true);
 }
 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 DoLayoutIf(bool condition, IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, string property)
 {
     if (!condition)
     {
         if (elementCausingLayout != null)
         {
             CommonProperties.xClearPreferredSizeCache(elementCausingLayout);
         }
     }
     else
     {
         DoLayout(elementToLayout, elementCausingLayout, property);
     }
 }
 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));
         }
     }
 }
コード例 #16
0
        private static ContainerProxy CreateContainerProxy(IArrangedElement container, FlowDirection flowDirection) {

            switch (flowDirection) {
                case FlowDirection.RightToLeft:
                    return new RightToLeftProxy(container);
                case FlowDirection.TopDown:
                    return new TopDownProxy(container);
                case FlowDirection.BottomUp:
                    return new BottomUpProxy(container);
                case FlowDirection.LeftToRight:
                default:
                    return new ContainerProxy(container);
            }
        
        }
コード例 #17
0
        // Entry point from LayoutEngine
        internal override bool LayoutCore(IArrangedElement container, LayoutEventArgs args) {
#if DEBUG        
            if (CompModSwitches.FlowLayout.TraceInfo) {
                Debug.WriteLine("FlowLayout::Layout("
                    + "container=" + container.ToString() + ", "
                    + "displayRect=" + container.DisplayRectangle.ToString() + ", "
                    + "args=" + args.ToString() + ")");
            }
            Debug.Indent();
#endif            

            // ScrollableControl will first try to get the layoutbounds from the derived control when 
            // trying to figure out if ScrollBars should be added.
            // VSWhidbey #392913            
            CommonProperties.SetLayoutBounds(container, xLayout(container, container.DisplayRectangle, /* measureOnly = */ false));
#if DEBUG
            Debug.Unindent();
#endif
            return CommonProperties.GetAutoSize(container);
        }
コード例 #18
0
        // Loop through the AutoSized controls and expand them if they are smaller than
        // their preferred size.  If expanding the controls causes overlap, bump the overlapped
        // control if it is AutoRelocatable.
        private static void LayoutAutoSizedControls(IArrangedElement container) {
            ArrangedElementCollection children = container.Children;
            for (int i = children.Count - 1; i >= 0; i--) {
                IArrangedElement element = children[i];
            
                if(CommonProperties.xGetAutoSizedAndAnchored(element)) {
                    Rectangle bounds = GetCachedBounds(element);  
                    
                    AnchorStyles anchor = GetAnchor(element);
                    Size proposedConstraints = LayoutUtils.MaxSize;

                    if ((anchor & (AnchorStyles.Left | AnchorStyles.Right)) == (AnchorStyles.Left | AnchorStyles.Right)) {
                        proposedConstraints.Width = bounds.Width;
                    }
                    if ((anchor & (AnchorStyles.Top | AnchorStyles.Bottom)) == (AnchorStyles.Top | AnchorStyles.Bottom)) {
                        proposedConstraints.Height = bounds.Height;
                    }
                    Size prefSize = element.GetPreferredSize(proposedConstraints);
            
                    Rectangle newBounds = bounds;
                
                    if (CommonProperties.GetAutoSizeMode(element) == AutoSizeMode.GrowAndShrink) {
                        // this is the case for simple things like radio button, checkbox, etc.
                        newBounds = GetGrowthBounds(element, prefSize);
                    }
                    else {
                        // we had whacked this check, but it turns out it causes undesirable 
                        // behavior in things like panel.  a panel with no elements sizes to 0,0.
                        if(bounds.Width < prefSize.Width || bounds.Height < prefSize.Height) {
                            Size newSize = LayoutUtils.UnionSizes(bounds.Size, prefSize);
                            newBounds = GetGrowthBounds(element, newSize);
                        }
                    }
                    if (newBounds != bounds) {
                         SetCachedBounds(element, newBounds);
                    }
                }             
            }
        }
コード例 #19
0
 private static void ApplyCachedBounds(IArrangedElement container)
 {
     if (CommonProperties.GetAutoSize(container))
     {
         Rectangle displayRectangle = container.DisplayRectangle;
         if ((displayRectangle.Width == 0) || (displayRectangle.Height == 0))
         {
             ClearCachedBounds(container);
             return;
         }
     }
     IDictionary dictionary = (IDictionary) container.Properties.GetObject(_cachedBoundsProperty);
     if (dictionary != null)
     {
         foreach (DictionaryEntry entry in dictionary)
         {
             IArrangedElement key = (IArrangedElement) entry.Key;
             Rectangle bounds = (Rectangle) entry.Value;
             key.SetBounds(bounds, BoundsSpecified.None);
         }
         ClearCachedBounds(container);
     }
 }
コード例 #20
0
        // Gets the bounds of the element after growing to newSize (note that depending on
        // anchoring the element may grow to the left/updwards rather than to the
        // right/downwards. i.e., it may be translated.)
        private static Rectangle GetGrowthBounds(IArrangedElement element, Size newSize) {
            GrowthDirection direction = GetGrowthDirection(element);
            Rectangle oldBounds = GetCachedBounds(element);
            Point location = oldBounds.Location;

            Debug.Assert((CommonProperties.GetAutoSizeMode(element) == AutoSizeMode.GrowAndShrink || newSize.Height >= oldBounds.Height && newSize.Width >= oldBounds.Width),
                "newSize expected to be >= current size.");

            if((direction & GrowthDirection.Left) != GrowthDirection.None) {
                // We are growing towards the left, translate X
                location.X -= newSize.Width - oldBounds.Width;
            }
            
            if((direction & GrowthDirection.Upward) != GrowthDirection.None) {
                // We are growing towards the top, translate Y
                location.Y -= newSize.Height - oldBounds.Height;
            }

            Rectangle newBounds = new Rectangle(location, newSize);

            Debug.Assert((CommonProperties.GetAutoSizeMode(element) == AutoSizeMode.GrowAndShrink || newBounds.Contains(oldBounds)), "How did we resize in such a way we no longer contain our old bounds?");

            return newBounds;
        }
コード例 #21
0
        internal override Size GetPreferredSize(IArrangedElement container, Size proposedBounds) {
            Debug.Assert(!HasCachedBounds(container),
                "Do not call this method with an active cached bounds list.");
            
            Size prefSize;
            
            xLayout(container, /* measureOnly = */ true, out prefSize);
/*            container.Bounds = prefSize;
            xLayout(container, false, out prefSize);

            // make sure controls are big enough to fit on form if not - increase container size
            container.Bounds = newBounds;

            xLayout(container, true, out prefSize);*/
            
            return prefSize;
        }
コード例 #22
0
 private static bool HasCachedBounds(IArrangedElement container)
 {
     return((container != null) && (container.Properties.GetObject(_cachedBoundsProperty) != null));
 }
コード例 #23
0
 internal TableLayoutStyleCollection(IArrangedElement owner)
 {
     _owner = owner;
 }
コード例 #24
0
ファイル: LayoutUtils.cs プロジェクト: JianwenSun/cc
 public LayoutTransaction(Control controlToLayout, IArrangedElement controlCausingLayout, string property) :
     this(controlToLayout, controlCausingLayout, property, true) {
 }
コード例 #25
0
ファイル: LayoutUtils.cs プロジェクト: JianwenSun/cc
  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?");
 
  }
コード例 #26
0
        private static Rectangle GetAnchorDestination(IArrangedElement element, Rectangle displayRect, bool measureOnly)
        {
            AnchorInfo   anchorInfo = GetAnchorInfo(element);
            int          num        = anchorInfo.Left + displayRect.X;
            int          num2       = anchorInfo.Top + displayRect.Y;
            int          num3       = anchorInfo.Right + displayRect.X;
            int          num4       = anchorInfo.Bottom + displayRect.Y;
            AnchorStyles anchor     = GetAnchor(element);

            if (IsAnchored(anchor, AnchorStyles.Right))
            {
                num3 += displayRect.Width;
                if (!IsAnchored(anchor, AnchorStyles.Left))
                {
                    num += displayRect.Width;
                }
            }
            else if (!IsAnchored(anchor, AnchorStyles.Left))
            {
                num3 += displayRect.Width / 2;
                num  += displayRect.Width / 2;
            }
            if (IsAnchored(anchor, AnchorStyles.Bottom))
            {
                num4 += displayRect.Height;
                if (!IsAnchored(anchor, AnchorStyles.Top))
                {
                    num2 += displayRect.Height;
                }
            }
            else if (!IsAnchored(anchor, AnchorStyles.Top))
            {
                num4 += displayRect.Height / 2;
                num2 += displayRect.Height / 2;
            }
            if (!measureOnly)
            {
                if (num3 < num)
                {
                    num3 = num;
                }
                if (num4 < num2)
                {
                    num4 = num2;
                }
            }
            else
            {
                Rectangle cachedBounds = GetCachedBounds(element);
                if (((num3 < num) || (cachedBounds.Width != element.Bounds.Width)) || (cachedBounds.X != element.Bounds.X))
                {
                    if (cachedBounds != element.Bounds)
                    {
                        num = Math.Max(Math.Abs(num), Math.Abs(cachedBounds.Left));
                    }
                    num3 = (num + Math.Max(element.Bounds.Width, cachedBounds.Width)) + Math.Abs(num3);
                }
                else
                {
                    num  = (num > 0) ? num : element.Bounds.Left;
                    num3 = (num3 > 0) ? num3 : (element.Bounds.Right + Math.Abs(num3));
                }
                if (((num4 < num2) || (cachedBounds.Height != element.Bounds.Height)) || (cachedBounds.Y != element.Bounds.Y))
                {
                    if (cachedBounds != element.Bounds)
                    {
                        num2 = Math.Max(Math.Abs(num2), Math.Abs(cachedBounds.Top));
                    }
                    num4 = (num2 + Math.Max(element.Bounds.Height, cachedBounds.Height)) + Math.Abs(num4);
                }
                else
                {
                    num2 = (num2 > 0) ? num2 : element.Bounds.Top;
                    num4 = (num4 > 0) ? num4 : (element.Bounds.Bottom + Math.Abs(num4));
                }
            }
            return(new Rectangle(num, num2, num3 - num, num4 - num2));
        }
コード例 #27
0
 internal TableLayoutRowStyleCollection(IArrangedElement Owner) : base(Owner) {}
コード例 #28
0
 private static void SetAnchorInfo(IArrangedElement element, AnchorInfo value)
 {
     element.Properties.SetObject(_layoutInfoProperty, value);
 }
コード例 #29
0
 public static AnchorStyles GetAnchor(IArrangedElement element)
 {
     return(CommonProperties.xGetAnchor(element));
 }
コード例 #30
0
 private static void ClearCachedBounds(IArrangedElement container)
 {
     container.Properties.SetObject(_cachedBoundsProperty, null);
 }
コード例 #31
0
 private static AnchorInfo GetAnchorInfo(IArrangedElement element)
 {
     return((AnchorInfo)element.Properties.GetObject(_layoutInfoProperty));
 }
コード例 #32
0
 internal static Size GetPreferredSizeHorizontal(IArrangedElement container, Size proposedConstraints)
 {
     Size empty = Size.Empty;
     ToolStrip strip = container as ToolStrip;
     Size size2 = strip.DefaultSize - strip.Padding.Size;
     empty.Height = Math.Max(0, size2.Height);
     bool flag = false;
     bool flag2 = false;
     for (int i = 0; i < strip.Items.Count; i++)
     {
         ToolStripItem item = strip.Items[i];
         if (((IArrangedElement) item).ParticipatesInLayout)
         {
             flag2 = true;
             if (item.Overflow != ToolStripItemOverflow.Always)
             {
                 Padding margin = item.Margin;
                 Size preferredItemSize = GetPreferredItemSize(item);
                 empty.Width += margin.Horizontal + preferredItemSize.Width;
                 empty.Height = Math.Max(empty.Height, margin.Vertical + preferredItemSize.Height);
             }
             else
             {
                 flag = true;
             }
         }
     }
     if ((strip.Items.Count == 0) || !flag2)
     {
         empty = size2;
     }
     if (flag)
     {
         ToolStripOverflowButton overflowButton = strip.OverflowButton;
         Padding padding2 = overflowButton.Margin;
         empty.Width += padding2.Horizontal + overflowButton.Bounds.Width;
     }
     else
     {
         empty.Width += 2;
     }
     if (strip.GripStyle == ToolStripGripStyle.Visible)
     {
         Padding gripMargin = strip.GripMargin;
         empty.Width += gripMargin.Horizontal + strip.Grip.GripThickness;
     }
     return LayoutUtils.IntersectSizes(empty, proposedConstraints);
 }
コード例 #33
0
        private static Size GetAnchorPreferredSize(IArrangedElement container) {
            Size prefSize = Size.Empty;
                     
            ArrangedElementCollection children = container.Children;
            for (int i = children.Count - 1; i >= 0; i--) {                    
                IArrangedElement element = container.Children[i];
                if(!CommonProperties.GetNeedsDockLayout(element) && element.ParticipatesInLayout) {
                    AnchorStyles anchor = GetAnchor(element);
                    Padding margin = CommonProperties.GetMargin(element);
                    Rectangle elementSpace = LayoutUtils.InflateRect(GetCachedBounds(element), margin);

                    if (IsAnchored(anchor, AnchorStyles.Left) && !IsAnchored(anchor, AnchorStyles.Right)) {
                        // If we are anchored to the left we make sure the container is large enough not to clip us
                        // (unless we are right anchored, in which case growing the container will just resize us.)
                        prefSize.Width = Math.Max(prefSize.Width, elementSpace.Right);
                    }
                    
                    if (/*IsAnchored(anchor, AnchorStyles.Top) &&*/ !IsAnchored(anchor, AnchorStyles.Bottom)) {
                        // If we are anchored to the top we make sure the container is large enough not to clip us
                        // (unless we are bottom anchored, in which case growing the container will just resize us.)
                        prefSize.Height = Math.Max(prefSize.Height, elementSpace.Bottom);
                    
                    }

                    if (IsAnchored(anchor, AnchorStyles.Right)) {
                        // If we are right anchored, see what the anchor distance between our right edge and
                        // the container is, and make sure our container is large enough to accomodate us.                            
                        Rectangle anchorDest = GetAnchorDestination(element, Rectangle.Empty, /*measureOnly=*/true);
                        if (anchorDest.Width < 0) {
                            prefSize.Width = Math.Max(prefSize.Width, elementSpace.Right + anchorDest.Width);
                        }
                        else {
                            prefSize.Width = Math.Max(prefSize.Width, anchorDest.Right);
                        }
                    }
                    
                    if (IsAnchored(anchor, AnchorStyles.Bottom)) { 
                        // If we are right anchored, see what the anchor distance between our right edge and
                        // the container is, and make sure our container is large enough to accomodate us.                            
                        Rectangle anchorDest = GetAnchorDestination(element, Rectangle.Empty, /*measureOnly=*/true);
                        if (anchorDest.Height < 0) {
                            prefSize.Height = Math.Max(prefSize.Height, elementSpace.Bottom + anchorDest.Height);
                        }
                        else {
                            prefSize.Height = Math.Max(prefSize.Height, anchorDest.Bottom);
                        }
                    }


                }
            }     
            return prefSize;
        }
コード例 #34
0
        private static bool xLayout(IArrangedElement container, bool measureOnly, out Size preferredSize)
        {
            ArrangedElementCollection children = container.Children;

            preferredSize = new Size(-7103, -7105);
            if (measureOnly || (children.Count != 0))
            {
                bool flag  = false;
                bool flag2 = false;
                bool flag3 = false;
                for (int i = children.Count - 1; i >= 0; i--)
                {
                    IArrangedElement element = children[i];
                    if (CommonProperties.GetNeedsDockAndAnchorLayout(element))
                    {
                        if (!flag && CommonProperties.GetNeedsDockLayout(element))
                        {
                            flag = true;
                        }
                        if (!flag2 && CommonProperties.GetNeedsAnchorLayout(element))
                        {
                            flag2 = true;
                        }
                        if (!flag3 && CommonProperties.xGetAutoSizedAndAnchored(element))
                        {
                            flag3 = true;
                        }
                    }
                }
                Size empty = Size.Empty;
                Size b     = Size.Empty;
                if (flag)
                {
                    empty = LayoutDockedControls(container, measureOnly);
                }
                if (flag2 && !measureOnly)
                {
                    LayoutAnchoredControls(container);
                }
                if (flag3)
                {
                    LayoutAutoSizedControls(container);
                }
                if (!measureOnly)
                {
                    ApplyCachedBounds(container);
                }
                else
                {
                    b = GetAnchorPreferredSize(container);
                    Padding padding = Padding.Empty;
                    Control control = container as Control;
                    if (control != null)
                    {
                        padding = control.Padding;
                    }
                    else
                    {
                        padding = CommonProperties.GetPadding(container, Padding.Empty);
                    }
                    b.Width  -= padding.Left;
                    b.Height -= padding.Top;
                    ClearCachedBounds(container);
                    preferredSize = LayoutUtils.UnionSizes(empty, b);
                }
            }
            return(CommonProperties.GetAutoSize(container));
        }
コード例 #35
0
        // Examines an elements anchoring to figure out which direction it should grow.
        private static GrowthDirection GetGrowthDirection(IArrangedElement element) {
            AnchorStyles anchor = GetAnchor(element);
            GrowthDirection growthDirection = GrowthDirection.None;
            
            if((anchor & AnchorStyles.Right) != AnchorStyles.None
                && (anchor & AnchorStyles.Left) == AnchorStyles.None) {
                // element is anchored to the right, but not the left.
                growthDirection |= GrowthDirection.Left;
            } else {
                // otherwise we grow towards the right (common case)
                growthDirection |= GrowthDirection.Right;
            }
        
            if((anchor & AnchorStyles.Bottom) != AnchorStyles.None
                && (anchor & AnchorStyles.Top) == AnchorStyles.None) {
                // element is anchored to the bottom, but not the top.
                growthDirection |= GrowthDirection.Upward;
            } else {
                // otherwise we grow towards the bottom. (common case)
                growthDirection |= GrowthDirection.Downward;
            }

            Debug.Assert((growthDirection & GrowthDirection.Left) == GrowthDirection.None
                || (growthDirection & GrowthDirection.Right) == GrowthDirection.None,
                "We shouldn't allow growth to both the left and right.");
            Debug.Assert((growthDirection & GrowthDirection.Upward) == GrowthDirection.None
                || (growthDirection & GrowthDirection.Downward) == GrowthDirection.None,
                "We shouldn't allow both upward and downward growth.");
            return growthDirection;
        }
コード例 #36
0
 internal LayoutSettings(IArrangedElement owner)
 {
     Owner = owner;
 }
コード例 #37
0
ファイル: LayoutUtils.cs プロジェクト: JianwenSun/cc
 //returns anchorStyles, transforms from DockStyle if necessary
 internal static AnchorStyles GetUnifiedAnchor(IArrangedElement element) {
     DockStyle dockStyle = DefaultLayout.GetDock(element);
     if (dockStyle != DockStyle.None) {
         return dockingToAnchor[(int)dockStyle];
     }
     return DefaultLayout.GetAnchor(element);
 }
コード例 #38
0
 void IArrangedElement.PerformLayout(IArrangedElement affectedElement, string affectedProperty)
 {
 }
コード例 #39
0
ファイル: LayoutUtils.cs プロジェクト: JianwenSun/cc
        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));    
                }
            }
        }
コード例 #40
0
 internal TableLayoutRowStyleCollection(IArrangedElement Owner) : base(Owner)
 {
 }
コード例 #41
0
        internal override bool LayoutCore(IArrangedElement container, LayoutEventArgs args)
        {
            Size size;

            return(xLayout(container, false, out size));
        }
コード例 #42
0
 public static DockStyle GetDock(IArrangedElement element)
 {
     return(CommonProperties.xGetDock(element));
 }
コード例 #43
0
 internal static Size GetPreferredSizeVertical(IArrangedElement container, Size proposedConstraints)
 {
     Size empty = Size.Empty;
     bool flag = false;
     ToolStrip element = container as ToolStrip;
     bool flag2 = false;
     for (int i = 0; i < element.Items.Count; i++)
     {
         ToolStripItem item = element.Items[i];
         if (((IArrangedElement) item).ParticipatesInLayout)
         {
             flag2 = true;
             if (item.Overflow != ToolStripItemOverflow.Always)
             {
                 Size preferredItemSize = GetPreferredItemSize(item);
                 Padding margin = item.Margin;
                 empty.Height += margin.Vertical + preferredItemSize.Height;
                 empty.Width = Math.Max(empty.Width, margin.Horizontal + preferredItemSize.Width);
             }
             else
             {
                 flag = true;
             }
         }
     }
     if ((element.Items.Count == 0) || !flag2)
     {
         empty = LayoutUtils.FlipSize(element.DefaultSize);
     }
     if (flag)
     {
         ToolStripOverflowButton overflowButton = element.OverflowButton;
         Padding padding2 = overflowButton.Margin;
         empty.Height += padding2.Vertical + overflowButton.Bounds.Height;
     }
     else
     {
         empty.Height += 2;
     }
     if (element.GripStyle == ToolStripGripStyle.Visible)
     {
         Padding gripMargin = element.GripMargin;
         empty.Height += gripMargin.Vertical + element.Grip.GripThickness;
     }
     if (element.Size != empty)
     {
         CommonProperties.xClearPreferredSizeCache(element);
     }
     return empty;
 }
コード例 #44
0
        private static Size LayoutDockedControls(IArrangedElement container, bool measureOnly)
        {
            Rectangle                 remainingBounds = measureOnly ? Rectangle.Empty : container.DisplayRectangle;
            Size                      empty           = Size.Empty;
            IArrangedElement          element         = null;
            ArrangedElementCollection children        = container.Children;

            for (int i = children.Count - 1; i >= 0; i--)
            {
                Size             size6;
                IArrangedElement element2 = children[i];
                if (CommonProperties.GetNeedsDockLayout(element2))
                {
                    switch (GetDock(element2))
                    {
                    case DockStyle.Top:
                    {
                        Size      size2      = GetVerticalDockedSize(element2, remainingBounds.Size, measureOnly);
                        Rectangle rectangle2 = new Rectangle(remainingBounds.X, remainingBounds.Y, size2.Width, size2.Height);
                        xLayoutDockedControl(element2, rectangle2, measureOnly, ref empty, ref remainingBounds);
                        remainingBounds.Y      += element2.Bounds.Height;
                        remainingBounds.Height -= element2.Bounds.Height;
                        break;
                    }

                    case DockStyle.Bottom:
                    {
                        Size      size3      = GetVerticalDockedSize(element2, remainingBounds.Size, measureOnly);
                        Rectangle rectangle3 = new Rectangle(remainingBounds.X, remainingBounds.Bottom - size3.Height, size3.Width, size3.Height);
                        xLayoutDockedControl(element2, rectangle3, measureOnly, ref empty, ref remainingBounds);
                        remainingBounds.Height -= element2.Bounds.Height;
                        break;
                    }

                    case DockStyle.Left:
                    {
                        Size      size4      = GetHorizontalDockedSize(element2, remainingBounds.Size, measureOnly);
                        Rectangle rectangle4 = new Rectangle(remainingBounds.X, remainingBounds.Y, size4.Width, size4.Height);
                        xLayoutDockedControl(element2, rectangle4, measureOnly, ref empty, ref remainingBounds);
                        remainingBounds.X     += element2.Bounds.Width;
                        remainingBounds.Width -= element2.Bounds.Width;
                        break;
                    }

                    case DockStyle.Right:
                    {
                        Size      size5      = GetHorizontalDockedSize(element2, remainingBounds.Size, measureOnly);
                        Rectangle rectangle5 = new Rectangle(remainingBounds.Right - size5.Width, remainingBounds.Y, size5.Width, size5.Height);
                        xLayoutDockedControl(element2, rectangle5, measureOnly, ref empty, ref remainingBounds);
                        remainingBounds.Width -= element2.Bounds.Width;
                        break;
                    }

                    case DockStyle.Fill:
                        if (!(element2 is MdiClient))
                        {
                            goto Label_025B;
                        }
                        element = element2;
                        break;
                    }
                }
                goto Label_0295;
Label_025B:
                size6 = remainingBounds.Size;
                Rectangle newElementBounds = new Rectangle(remainingBounds.X, remainingBounds.Y, size6.Width, size6.Height);
                xLayoutDockedControl(element2, newElementBounds, measureOnly, ref empty, ref remainingBounds);
Label_0295:
                if (element != null)
                {
                    SetCachedBounds(element, remainingBounds);
                }
            }
            return(empty);
        }