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


C# Size.Inflate方法代码示例

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


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

示例1: MeasureCore

        /// <summary>
        ///     Implements basic measure-pass layout system behavior.
        /// </summary>
        /// <remarks>
        ///     In WPF this method is definded on UIElement as protected virtual and returns an empty Size.
        ///     FrameworkElement (which derrives from UIElement) then creates a sealed implementation similar to the below.
        ///     In XPF UIElement and FrameworkElement have been collapsed into a single class.
        /// </remarks>
        /// <param name = "availableSize">The available size that the parent element can give to the child elements.</param>
        /// <returns>The desired size of this element in layout.</returns>
        private Size MeasureCore(Size availableSize)
        {
            this.ResolveDeferredBindings(this.GetNearestDataContext());
            this.OnApplyTemplate();

            Thickness margin = this.Margin;
            Size availableSizeWithoutMargins = availableSize.Deflate(margin);

            var minMax = new MinMax(this);

            availableSizeWithoutMargins.Width = availableSizeWithoutMargins.Width.Coerce(
                minMax.MinWidth, minMax.MaxWidth);
            availableSizeWithoutMargins.Height = availableSizeWithoutMargins.Height.Coerce(
                minMax.MinHeight, minMax.MaxHeight);

            Size size = this.MeasureOverride(availableSizeWithoutMargins);

            size = new Size(Math.Max(size.Width, minMax.MinWidth), Math.Max(size.Height, minMax.MinHeight));
            Size unclippedSize = size;

            bool isClippingRequired = false;
            if (size.Width > minMax.MaxWidth)
            {
                size.Width = minMax.MaxWidth;
                isClippingRequired = true;
            }

            if (size.Height > minMax.MaxHeight)
            {
                size.Height = minMax.MaxHeight;
                isClippingRequired = true;
            }

            Size desiredSizeWithMargins = size.Inflate(margin);

            if (desiredSizeWithMargins.Width > availableSize.Width)
            {
                desiredSizeWithMargins.Width = availableSize.Width;
                isClippingRequired = true;
            }

            if (desiredSizeWithMargins.Height > availableSize.Height)
            {
                desiredSizeWithMargins.Height = availableSize.Height;
                isClippingRequired = true;
            }

            this.unclippedSize = isClippingRequired ? unclippedSize : Size.Empty;

            return desiredSizeWithMargins;
        }
开发者ID:redbadger,项目名称:XPF,代码行数:61,代码来源:UIElement.cs


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