commands.cs
来自「微软的行业应用解决方案示例」· CS 代码 · 共 55 行
CS
55 行
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Mobile.Data
{
/// <summary>
///
/// </summary>
internal class Commands : Dictionary<string, CommandItem>
{
/// <summary>
///
/// </summary>
public int MaxItems
{
get;
set;
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="command"></param>
public new void Add(string key, CommandItem command)
{
int minItemUse = int.MaxValue;
string removeKey = string.Empty;
// Enforce not adding more than the maximum items
if (this.Count >= MaxItems)
{
// remove an item first
foreach (KeyValuePair<string, CommandItem> currentItem in this)
{
if (currentItem.Value.Count < minItemUse)
{
minItemUse = currentItem.Value.Count;
removeKey = currentItem.Key;
}
}
if (!string.IsNullOrEmpty(removeKey))
{
this[removeKey].Command.Dispose();
this.Remove(removeKey);
}
}
base.Add(key, command);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?