+ 增加了一个类

This commit is contained in:
Sunny 2020-08-17 21:50:48 +08:00
parent 1bc5fed028
commit b298ad6192
7 changed files with 104 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -937,7 +937,6 @@
this.uiToolTip1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiToolTip1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(239)))), ((int)(((byte)(239)))), ((int)(((byte)(239)))));
this.uiToolTip1.OwnerDraw = true;
this.uiToolTip1.ToolTipTitle = "ToolTip title";
//
// uiSymbolButton1
//

View File

@ -402,6 +402,7 @@
<Compile Include="Controls\UIToolTip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Units\UConcurrentDoubleKeyDictionary.cs" />
<Compile Include="Units\USnowflakeID.cs" />
<Compile Include="Units\UThunder.cs" />
<Compile Include="Controls\UILine.cs">

View File

@ -0,0 +1,103 @@
/******************************************************************************
* SunnyUI
* CopyRight (C) 2012-2020 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@qq.com
*
* Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI
*
* SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note.
* 使
******************************************************************************
* : ULogFile.cs
* : 线
* : V2.2
* : 2020-08-17
*
* 2020-08-17: V2.2.7
******************************************************************************/
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace Sunny.UI
{
public class ConcurrentDoubleKeyDictionary<TKey1, TKey2>
{
private readonly ConcurrentDictionary<TKey1, TKey2> Key1 = new ConcurrentDictionary<TKey1, TKey2>();
private readonly ConcurrentDictionary<TKey2, TKey1> Key2 = new ConcurrentDictionary<TKey2, TKey1>();
public void TryAdd(TKey1 key1, TKey2 key2)
{
Key1.AddOrUpdate(key1, key2);
Key2.AddOrUpdate(key2, key1);
}
public TKey2 this[TKey1 key1]
{
get => GetKey2(key1);
set => TryAdd(key1, value);
}
public int Count => Key1.Count;
public void RemoveByKey1(TKey1 key1)
{
if (ContainsKey1(key1))
{
TKey2 key2 = GetKey2(key1);
Key1.TryRemove(key1, out _);
if (ContainsKey2(key2)) Key2.TryRemove(key2, out _);
}
}
public void RemoveByKey2(TKey2 key2)
{
if (ContainsKey2(key2))
{
TKey1 key1 = GetKey1(key2);
Key2.TryRemove(key2, out _);
if (ContainsKey1(key1)) Key1.TryRemove(key1, out _);
}
}
public TKey2 GetKey2(TKey1 key1)
{
return Key1.ContainsKey(key1) ? Key1[key1] : default(TKey2);
}
public TKey1 GetKey1(TKey2 key2)
{
return Key2.ContainsKey(key2) ? Key2[key2] : default(TKey1);
}
public bool ContainsKey1(TKey1 key1)
{
return Key1.ContainsKey(key1);
}
public bool ContainsKey2(TKey2 key2)
{
return Key2.ContainsKey(key2);
}
public IList<TKey1> Key1List()
{
return Key1.Keys.ToList();
}
public IList<TKey2> Key2List()
{
return Key2.Keys.ToList();
}
public void Clear()
{
Key1.Clear();
Key2.Clear();
}
}
}