本文整理汇总了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;
}
示例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);
}