本文整理汇总了C#中Mapping.SetToEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# Mapping.SetToEmpty方法的具体用法?C# Mapping.SetToEmpty怎么用?C# Mapping.SetToEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping.SetToEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateMappings
private void UpdateMappings(ItemGroup group, IList items, ref int liveItemCount)
{
bool isLimitingGroups = InitialItemsLimit > 0;
int ilg = InitialItemsLimit;
int c = items.Count;
#if DEBUG_GIC
Debug.WriteLine("UpdateMappings is looking at " + group.Name +
" working with " + c +
" items and the incoming live count was " + liveItemCount);
#endif
Dictionary<Mapping, bool> previousItemsHash = new Dictionary<Mapping, bool>(group.Items.Count);
foreach (var item in group.Items)
{
#if DEBUG_GIC
Debug.WriteLine("A previous item is " + item.SpecializedString);
#endif
previousItemsHash[item] = true;
}
group.Items.Clear();
int insertionIndex = -1;
for (int i = 0; i < c; ++i)
{
insertionIndex++;
liveItemCount++;
var icsc = items[i] as ISpecializedComparisonString;
//Debug.Assert(icsc != null);
string s = icsc != null ? icsc.SpecializedComparisonString : items[i].ToString();
Mapping existing;
if (s == null)
{
continue;
}
bool needToCreate = true;
// If it already mapped somewhere?
if (_knownSpecializations.TryGetValue(s, out existing))
{
//Debug.WriteLine("A known specialization exists already for " + s);
if (existing.Group.Name == group.Name)
{
needToCreate = false;
//Debug.WriteLine("+ and it stayed in the same group.");
previousItemsHash.Remove(existing);
// TODO: REORDERING!
//int itemIndex = group.Panel.Children.IndexOf(existing.Presenter);
existing.Content = items[i];
if (existing.HasBeenShownYet)
{
existing.Presenter.Content = existing.Content;
}
// Needs to be in the new ordered list.
group.Items.Insert(insertionIndex, existing);
// Could see if they even really changed or not.
}
else
{
//Debug.WriteLine("- but it moved to this group from another!");
// Now present in this group, remove it from the old.
#if DEBUG_GIC
Debug.WriteLine("A previous item moved to the new group! " + s + existing.Content);
#endif
existing.Group.Panel.Children.Remove(existing.Presenter);
group.Items.Remove(existing);
_knownSpecializations.Remove(s);
// Decrement for a new insert!
// i--;
//insertionIndex--; // ? is this correct ?
}
}
if (needToCreate)
{
// Create a new mapping.
var map = new Mapping
{
Content = items[i],
Group = group,
};
map.SetToEmpty(MinimumItemHeight);
_knownSpecializations[s] = map;
map.OverallItemIndex = liveItemCount;
// Index of 0, not a count actually.
if (liveItemCount < _itemsInFirstScreen + 1)
//.........这里部分代码省略.........