📄 commands.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -