📄 customemotiondictionary.cs
字号:
namespace Imps.Client.Core.CustomEmotion
{
using Imps.Utils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
public class CustomEmotionDictionary : IDictionary<string, Imps.Client.Core.CustomEmotion.CustomEmotion>, ICollection<KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion>>, IEnumerable<KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion>>, IEnumerable
{
private Dictionary<string, Imps.Client.Core.CustomEmotion.CustomEmotion> _dicEmotionsById = new Dictionary<string, Imps.Client.Core.CustomEmotion.CustomEmotion>();
private Dictionary<string, Imps.Client.Core.CustomEmotion.CustomEmotion> _dicEmotionsByShortCut = new Dictionary<string, Imps.Client.Core.CustomEmotion.CustomEmotion>();
private List<Imps.Client.Core.CustomEmotion.CustomEmotion> _lstEmoitons = new List<Imps.Client.Core.CustomEmotion.CustomEmotion>();
private IComparer<string> _shortCutCompare;
private string[] _sortedShortCuts = new string[0];
private object syncObject = new object();
public void Add(KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion> item)
{
throw new Exception("The method or operation is not implemented.");
}
public void Add(string key, Imps.Client.Core.CustomEmotion.CustomEmotion value)
{
this._dicEmotionsById.Add(key, value);
this._lstEmoitons.Add(value);
if (!string.IsNullOrEmpty(value.ShortCut))
{
string shortCutDictionaryKey = CustomEmotionManager.GetShortCutDictionaryKey(value.ShortCut);
if (!this._dicEmotionsByShortCut.ContainsKey(shortCutDictionaryKey))
{
this._dicEmotionsByShortCut.Add(shortCutDictionaryKey, value);
}
}
}
public void Clear()
{
this._dicEmotionsById.Clear();
this._dicEmotionsByShortCut.Clear();
this._lstEmoitons.Clear();
}
public bool Contains(KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion> item)
{
throw new Exception("The method or operation is not implemented.");
}
public bool ContainsKey(string key)
{
return this._dicEmotionsById.ContainsKey(key);
}
public void CopyTo(KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion>[] array, int arrayIndex)
{
throw new Exception("The method or operation is not implemented.");
}
public Imps.Client.Core.CustomEmotion.CustomEmotion GetEmotionByShortCut(string shortCut)
{
if (this._dicEmotionsByShortCut.ContainsKey(CustomEmotionManager.GetShortCutDictionaryKey(shortCut)))
{
return this._dicEmotionsByShortCut.get_Item(CustomEmotionManager.GetShortCutDictionaryKey(shortCut));
}
return null;
}
public List<Imps.Client.Core.CustomEmotion.CustomEmotion> GetEmotions(int start, int end)
{
if (((start < 0) || (start > this.LstEmoitons.get_Count())) || ((end < start) || (end > this.LstEmoitons.get_Count())))
{
throw new ArgumentOutOfRangeException("参数无效,,请在指定的范围内取值");
}
List<Imps.Client.Core.CustomEmotion.CustomEmotion> list = new List<Imps.Client.Core.CustomEmotion.CustomEmotion>();
for (int i = start; i <= end; i++)
{
list.Add(this.LstEmoitons.get_Item(i));
}
return list;
}
public IEnumerator<KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion>> GetEnumerator()
{
return this._dicEmotionsById.GetEnumerator();
}
public bool Remove(KeyValuePair<string, Imps.Client.Core.CustomEmotion.CustomEmotion> item)
{
throw new Exception("The method or operation is not implemented.");
}
public bool Remove(string key)
{
if (!this.ContainsKey(key))
{
return false;
}
Imps.Client.Core.CustomEmotion.CustomEmotion emotion = this[key];
if (this._lstEmoitons.Contains(emotion))
{
this._lstEmoitons.Remove(emotion);
}
if (!string.IsNullOrEmpty(emotion.ShortCut))
{
string shortCutDictionaryKey = CustomEmotionManager.GetShortCutDictionaryKey(emotion.ShortCut);
if (this._dicEmotionsByShortCut.ContainsKey(shortCutDictionaryKey))
{
this._dicEmotionsByShortCut.Remove(shortCutDictionaryKey);
}
}
return this._dicEmotionsById.Remove(key);
}
internal void Sort()
{
this._lstEmoitons.Sort();
}
internal void SortShortCuts()
{
this._sortedShortCuts = new string[this._dicEmotionsByShortCut.get_Count()];
this._dicEmotionsByShortCut.get_Keys().CopyTo(this._sortedShortCuts, 0);
Array.Sort<string>(this._sortedShortCuts, new Comparison<string>(null, (IntPtr) StringHelper.ComparsionByCharValue));
}
IEnumerator IEnumerable.GetEnumerator()
{
return this._dicEmotionsById.GetEnumerator();
}
public bool TryGetValue(string key, out Imps.Client.Core.CustomEmotion.CustomEmotion value)
{
return this._dicEmotionsById.TryGetValue(key, ref value);
}
internal void UpdateEmotionsByShortCut(Imps.Client.Core.CustomEmotion.CustomEmotion emotion, string shortCut)
{
string shortCutDictionaryKey = CustomEmotionManager.GetShortCutDictionaryKey(emotion.ShortCut);
if (this._dicEmotionsByShortCut.ContainsKey(shortCutDictionaryKey))
{
this._dicEmotionsByShortCut.Remove(shortCutDictionaryKey);
}
if (!string.IsNullOrEmpty(shortCut))
{
string text2 = CustomEmotionManager.GetShortCutDictionaryKey(shortCut);
if (!this._dicEmotionsByShortCut.ContainsKey(text2))
{
this._dicEmotionsByShortCut.Add(text2, emotion);
}
}
}
public int Count
{
get
{
return this._dicEmotionsById.get_Count();
}
}
public bool IsReadOnly
{
get
{
throw new Exception("The method or operation is not implemented.");
}
}
public Imps.Client.Core.CustomEmotion.CustomEmotion this[string key]
{
get
{
return this._dicEmotionsById.get_Item(key);
}
set
{
this._dicEmotionsById.set_Item(key, value);
}
}
public ICollection<string> Keys
{
get
{
return this._dicEmotionsById.get_Keys();
}
}
public List<Imps.Client.Core.CustomEmotion.CustomEmotion> LstEmoitons
{
get
{
return this._lstEmoitons;
}
set
{
this._lstEmoitons = value;
}
}
internal string[] SortedShortCuts
{
get
{
return this._sortedShortCuts;
}
}
public ICollection<Imps.Client.Core.CustomEmotion.CustomEmotion> Values
{
get
{
return this._dicEmotionsById.get_Values();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -