当前位置: 首页>>代码示例>>C#>>正文


C# IArrangedElement.GetPreferredSize方法代码示例

本文整理汇总了C#中IArrangedElement.GetPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C# IArrangedElement.GetPreferredSize方法的具体用法?C# IArrangedElement.GetPreferredSize怎么用?C# IArrangedElement.GetPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IArrangedElement的用法示例。


在下文中一共展示了IArrangedElement.GetPreferredSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: xGetDockedSize

        //Unused
        //private static Size GetFillDockedSize(IArrangedElement element, Size remainingSize, bool measureOnly) {
        //    Size newSize = xGetDockedSize(element, remainingSize, /* constraints = */ remainingSize, measureOnly);
        //    newSize = LayoutUtils.UnionSizes(newSize, remainingSize);

        //    if (!measureOnly) {
        //        newSize = LayoutUtils.IntersectSizes(newSize, remainingSize);
        //    }

        //    Debug.Assert(newSize.Width >= remainingSize.Width && newSize.Height >= remainingSize.Height,
        //        "Error detected in GetFillDockedSize: Element did not stretch to remaning size.");
        //    Debug.Assert(measureOnly || (newSize.Width == remainingSize.Width && newSize.Height == remainingSize.Height),
        //        "Error detected in GetFillDockedSize: Dock size computed incorrectly during layout.");

        //    return newSize;
        //}

        private static Size xGetDockedSize(IArrangedElement element, Size remainingSize, Size constraints, bool measureOnly) {
            Size desiredSize;
            
            if (CommonProperties.GetAutoSize(element)) {
                // Ask control for its desired size using the provided constraints.
                // (e.g., a control docked to top will constrain width to remaining width
                // and minimize height.)
                desiredSize = element.GetPreferredSize(constraints);
            } else {
                desiredSize = element.Bounds.Size;
            }

            Debug.Assert((desiredSize.Width >= 0 && desiredSize.Height >= 0), "Error detected in xGetDockSize: Element size was negative.");
            return desiredSize;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:32,代码来源:DockAndAnchorLayout.cs

示例2: xLayoutDockedControl

        // Helper method that either sets the element bounds or does the preferredSize computation based on
        // the value of measureOnly.
        private static void xLayoutDockedControl(IArrangedElement element, Rectangle newElementBounds, bool measureOnly, ref Size preferredSize, ref Rectangle remainingBounds) {
            if (measureOnly) {
                Size neededSize = new Size(
                    Math.Max(0, newElementBounds.Width - remainingBounds.Width),
                    Math.Max(0, newElementBounds.Height - remainingBounds.Height));

                DockStyle dockStyle = GetDock(element);
                if ((dockStyle == DockStyle.Top) || (dockStyle == DockStyle.Bottom)) {
                    neededSize.Width = 0;
                }
                if ((dockStyle == DockStyle.Left) || (dockStyle == DockStyle.Right)) {
                    neededSize.Height = 0;
                }
                if (dockStyle != DockStyle.Fill) {
                    preferredSize += neededSize;
                    remainingBounds.Size += neededSize;
                }
                else if(dockStyle == DockStyle.Fill && CommonProperties.GetAutoSize(element)) {
                    Size elementPrefSize = element.GetPreferredSize(neededSize);
                    remainingBounds.Size += elementPrefSize;
                    preferredSize += elementPrefSize;
                }
            } else {
                element.SetBounds(newElementBounds, BoundsSpecified.None);

#if DEBUG
                Control control = element as Control;
                newElementBounds.Size = control.ApplySizeConstraints(newElementBounds.Size);
                // This usually happens when a Control overrides its SetBoundsCore or sets size during OnResize
                // to enforce constraints like AutoSize.  Generally you can just move this code to Control.GetAdjustedSize
                // and then PreferredSize will also pick up these constraints.  See ComboBox as an example.
                //
                if (CommonProperties.GetAutoSize(element) && !CommonProperties.GetSelfAutoSizeInDefaultLayout(element)) {
                    Debug.Assert(
                        (newElementBounds.Width < 0 || element.Bounds.Width == newElementBounds.Width) &&
                        (newElementBounds.Height < 0 || element.Bounds.Height == newElementBounds.Height),
                        "Element modified its bounds during docking -- PreferredSize will be wrong. See comment near this assert.");
                }
#endif
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:43,代码来源:DockAndAnchorLayout.cs

示例3: xLayoutDockedControl

 private static void xLayoutDockedControl(IArrangedElement element, Rectangle newElementBounds, bool measureOnly, ref Size preferredSize, ref Rectangle remainingBounds)
 {
     if (measureOnly)
     {
         Size proposedSize = new Size(Math.Max(0, newElementBounds.Width - remainingBounds.Width), Math.Max(0, newElementBounds.Height - remainingBounds.Height));
         DockStyle dock = GetDock(element);
         switch (dock)
         {
             case DockStyle.Top:
             case DockStyle.Bottom:
                 proposedSize.Width = 0;
                 break;
         }
         if ((dock == DockStyle.Left) || (dock == DockStyle.Right))
         {
             proposedSize.Height = 0;
         }
         if (dock != DockStyle.Fill)
         {
             preferredSize += proposedSize;
             remainingBounds.Size += proposedSize;
         }
         else if ((dock == DockStyle.Fill) && CommonProperties.GetAutoSize(element))
         {
             Size size2 = element.GetPreferredSize(proposedSize);
             remainingBounds.Size += size2;
             preferredSize += size2;
         }
     }
     else
     {
         element.SetBounds(newElementBounds, BoundsSpecified.None);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:DefaultLayout.cs

示例4: GetElementSize

 private Size GetElementSize(IArrangedElement element, Size proposedConstraints) {
     if(CommonProperties.GetAutoSize(element)) {
         return element.GetPreferredSize(proposedConstraints);
     } else {
         return CommonProperties.GetSpecifiedBounds(element).Size;
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:TableLayout.cs

示例5: xGetDockedSize

 private static Size xGetDockedSize(IArrangedElement element, Size remainingSize, Size constraints, bool measureOnly)
 {
     if (CommonProperties.GetAutoSize(element))
     {
         return element.GetPreferredSize(constraints);
     }
     return element.Bounds.Size;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:DefaultLayout.cs


注:本文中的IArrangedElement.GetPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。