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


C# KeyValuePair.Last方法代码示例

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


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

示例1: IsValid

        private bool IsValid()
        {
            bool valid = true;

            var requiredFields = new KeyValuePair<MetroLabel, IMetroControl>[] {
                new KeyValuePair<MetroLabel, IMetroControl>(firstNameLabel, firstName),
                new KeyValuePair<MetroLabel, IMetroControl>(lastNameLabel, lastName),
                new KeyValuePair<MetroLabel, IMetroControl>(phoneLabel, phone),
                new KeyValuePair<MetroLabel, IMetroControl>(cardLabel, card)
                };

            if (CurrentClient != null)
                requiredFields = new KeyValuePair<MetroLabel, IMetroControl>[] { requiredFields.Last() };

            foreach (var field in requiredFields)
            {
                var label = field.Key;
                var textField = field.Value as MetroTextBox;

                label.UseCustomForeColor = false;

                if (textField.Text.ToString().IsNullOrWhiteSpace())
                {
                    valid = false;

                    label.UseCustomForeColor = true;
                    label.ForeColor = Color.Red;
                }
                label.Refresh();
            }

            return valid;
        }
开发者ID:MANACard,项目名称:MANA-API-Library,代码行数:33,代码来源:ClientRegistrationControl.cs

示例2: MeasureOverride

        protected override Size MeasureOverride(Size availableSize)
        {
            //横向瀑布流

            groupcount = (int)availableSize.Width / 256 >= 3 ? (int)availableSize.Width / 256 : 3;
            //三组流长度记录
            KeyValuePair<double, int>[] flowLength = new KeyValuePair<double, int>[groupcount];
            foreach (int index in Enumerable.Range(0, groupcount))
            {
                flowLength[index] = new KeyValuePair<double, int>(0.0, index);
            }

            //每组长度为总长度1/3
            double flowWidth = availableSize.Width / groupcount;

            //子控件宽为组宽,长无限制
            Size childMeasureSize = new Size(flowWidth, double.PositiveInfinity);

            //子控件遍历计算长度
            foreach (UIElement childElement in Children)
            {
                childElement.Measure(childMeasureSize);
                Size childSize = childElement.DesiredSize;
                //得到子控件长
                double childLength = childSize.Height;
                //暂存最短流长度
                var tempPair = flowLength[0];
                //最短流长度重新计算
                flowLength[0] = new KeyValuePair<double, int>(tempPair.Key + childLength, tempPair.Value);
                //重新按流长度排列键值对        这里以Key 的值作为排列依据,flowWidth[0]为Key最小的键值对,P可替换为任意字母
                flowLength = flowLength.OrderBy(P => P.Key).ToArray();
            }
            //返回 长:最长流的长;宽:传入的宽
            return new Size(availableSize.Width, flowLength.Last().Key);
        }
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:35,代码来源:AlbumFlowPage.xaml.cs


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