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


C# nfloat.Sum方法代码示例

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


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

示例1: CalculateColumnWidths

        private nfloat[] CalculateColumnWidths(CGSize availableSpace)
        {
            var widthsByRow = new List<nfloat[]>();
            foreach (var row in rows)
            {
                for (var i = 0; i < widths.Length; i++)
                {
                    var width = widths[i];
                    var sizeRow = new nfloat[widths.Length];
                    switch (width.Style)
                    {
                        case TableWidthStyle.SizeToFit:
                            sizeRow[i] = (nfloat)row[i].SizeThatFits(new CGSize(nfloat.MaxValue, nfloat.MaxValue)).Width;
                            break;
                        case TableWidthStyle.Fixed:
                            sizeRow[i] = width.Value;
                            break;
                        case TableWidthStyle.Percentage:
                        case TableWidthStyle.Weight:
                            sizeRow[i] = 0;
                            break;
                    }
                    widthsByRow.Add(sizeRow);
                }
            }

            var calculatedWidths = new nfloat[widths.Length];
            for (var i = 0; i < widths.Length; i++)
            {
                calculatedWidths[i] = (nfloat)widthsByRow.Max(x => x[i]);
            }
            var bespokeWidth = calculatedWidths.Sum(x => x) + GetPaddingAndSpacingWidth();
            var remainingWidth = availableSpace.Width - bespokeWidth;
            var weightWidth = (nfloat)(remainingWidth - (nfloat)((nfloat)remainingWidth * widths.Where(x => x.Style == TableWidthStyle.Percentage).Sum(x => x.Value) / 100));
            var totalWeight = widths.Where(x => x.Style == TableWidthStyle.Weight).Sum(x => x.Value);
            var individualWeightWidth = weightWidth / totalWeight;
            var oddManOutWeightWidth = weightWidth - individualWeightWidth * totalWeight;

            var result = new nfloat[widths.Length];
            for (var i = 0; i < result.Length; i++)
            {
                var width = widths[i];
                switch (width.Style)
                {
                    case TableWidthStyle.Fixed:
                    case TableWidthStyle.SizeToFit:
                        result[i] = calculatedWidths[i];
                        break;
                    case TableWidthStyle.Percentage:
                        result[i] = (nfloat)((nfloat)width.Value / 100 * remainingWidth);
                        break;
                    case TableWidthStyle.Weight:
                        result[i] = individualWeightWidth * width.Value + oddManOutWeightWidth;
                        oddManOutWeightWidth = 0;
                        break;
                }
            }
            return result;
        }
开发者ID:kswoll,项目名称:iwt,代码行数:59,代码来源:TablePanel.cs


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