Merge branch 'master' of https://gitee.com/TAOQIJH/SunnyUI
This commit is contained in:
commit
03f8d890d8
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
@ -158,9 +158,27 @@ namespace Sunny.UI
|
|||||||
foreColor = uiColor.UnSelectedForeColor;
|
foreColor = uiColor.UnSelectedForeColor;
|
||||||
backColor = uiColor.BackColor;
|
backColor = uiColor.BackColor;
|
||||||
menuHoverColor = uiColor.HoverColor;
|
menuHoverColor = uiColor.HoverColor;
|
||||||
|
menuSelectedColor = uiColor.SelectedColor;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color menuSelectedColor = Color.FromArgb(36, 36, 36);
|
||||||
|
|
||||||
|
[DefaultValue(typeof(Color), "36, 36, 36")]
|
||||||
|
[Description("菜单栏选中背景颜色"), Category("SunnyUI")]
|
||||||
|
public Color MenuSelectedColor
|
||||||
|
{
|
||||||
|
get => menuSelectedColor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
menuSelectedColor = value;
|
||||||
|
_menuStyle = UIMenuStyle.Custom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Description("选中使用菜单栏选中背景颜色MenuSelectedColor,不选用则使用背景色BackColor"), Category("SunnyUI"), DefaultValue(false)]
|
||||||
|
public bool MenuSelectedColorUsed { get; set; }
|
||||||
|
|
||||||
private Color menuHoverColor = Color.FromArgb(76, 76, 76);
|
private Color menuHoverColor = Color.FromArgb(76, 76, 76);
|
||||||
|
|
||||||
[DefaultValue(typeof(Color), "76, 76, 76")]
|
[DefaultValue(typeof(Color), "76, 76, 76")]
|
||||||
@ -344,6 +362,11 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
if (i == SelectedIndex)
|
if (i == SelectedIndex)
|
||||||
{
|
{
|
||||||
|
if (MenuSelectedColorUsed)
|
||||||
|
{
|
||||||
|
e.Graphics.FillRectangle(MenuSelectedColor, rect.X, Height - NodeSize.Height, rect.Width, NodeSize.Height);
|
||||||
|
}
|
||||||
|
|
||||||
if (!NavBarMenu.Visible)
|
if (!NavBarMenu.Visible)
|
||||||
{
|
{
|
||||||
e.Graphics.FillRectangle(SelectedHighColor, rect.X, Height - 4, rect.Width, 4);
|
e.Graphics.FillRectangle(SelectedHighColor, rect.X, Height - 4, rect.Width, 4);
|
||||||
|
@ -27,143 +27,155 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
public class ConcurrentGroupDictionary<TGroup, TKey, TValue>
|
public class ConcurrentGroupDictionary<TGroup, TKey, TValue>
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<TGroup, ConcurrentDictionary<TKey, TValue>> GroupDictionary
|
private readonly ConcurrentDictionary<TGroup, ConcurrentDictionary<TKey, TValue>> Dictionary
|
||||||
= new ConcurrentDictionary<TGroup, ConcurrentDictionary<TKey, TValue>>();
|
= new ConcurrentDictionary<TGroup, ConcurrentDictionary<TKey, TValue>>();
|
||||||
private readonly ConcurrentDictionary<TKey, TValue> ObjectDictionary
|
|
||||||
= new ConcurrentDictionary<TKey, TValue>();
|
|
||||||
|
|
||||||
public ConcurrentDictionary<TKey, TValue> this[TGroup group]
|
public ConcurrentDictionary<TKey, TValue> this[TGroup group]
|
||||||
{
|
{
|
||||||
get => ContainsGroup(group) ? GroupDictionary[group] : new ConcurrentDictionary<TKey, TValue>();
|
get => ContainsGroup(group) ? Dictionary[group] : new ConcurrentDictionary<TKey, TValue>();
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!ContainsGroup(group)) TryAdd(group);
|
if (!ContainsGroup(group)) TryAdd(group);
|
||||||
GroupDictionary[group] = value;
|
Dictionary[group] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsGroup(TGroup group)
|
public bool ContainsGroup(TGroup group)
|
||||||
{
|
{
|
||||||
return GroupDictionary.ContainsKey(group);
|
return Dictionary.ContainsKey(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsKey(TKey key)
|
public bool ContainsKey(TKey key)
|
||||||
{
|
{
|
||||||
return ObjectDictionary.ContainsKey(key);
|
return Groups.Any(group => ContainsKey(group, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsKey(TGroup group, TKey key)
|
public bool ContainsKey(TGroup group, TKey key)
|
||||||
{
|
{
|
||||||
return ContainsGroup(group) && GroupDictionary[group].ContainsKey(key);
|
return ContainsGroup(group) && Dictionary[group].ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryAdd(TGroup group)
|
public void TryAdd(TGroup group)
|
||||||
{
|
{
|
||||||
if (!GroupDictionary.ContainsKey(group))
|
if (!Dictionary.ContainsKey(group))
|
||||||
GroupDictionary.TryAdd(group, new ConcurrentDictionary<TKey, TValue>());
|
Dictionary.TryAdd(group, new ConcurrentDictionary<TKey, TValue>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryAdd(TGroup group, TKey key, TValue value)
|
public void TryAdd(TGroup group, TKey key, TValue value)
|
||||||
{
|
{
|
||||||
TryAdd(group);
|
TryAdd(group);
|
||||||
|
|
||||||
if (GroupDictionary[group].ContainsKey(key))
|
if (ContainsKey(group, key))
|
||||||
GroupDictionary[group][key] = value;
|
Dictionary[group][key] = value;
|
||||||
else
|
else
|
||||||
GroupDictionary[group].TryAdd(key, value);
|
Dictionary[group].TryAdd(key, value);
|
||||||
|
|
||||||
if (ObjectDictionary.ContainsKey(key))
|
|
||||||
ObjectDictionary[key] = value;
|
|
||||||
else
|
|
||||||
ObjectDictionary.TryAdd(key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryRemove(TGroup group, TKey key, TValue value)
|
public bool TryUpdate(TGroup group, TKey key, TValue value)
|
||||||
{
|
{
|
||||||
if (GroupDictionary.ContainsKey(group))
|
if (!ContainsGroup(group)) return false;
|
||||||
{
|
TryAdd(group, key, value);
|
||||||
if (GroupDictionary[group].ContainsKey(key)) GroupDictionary[group].TryRemove(key, out _);
|
return true;
|
||||||
if (GroupDictionary[group].Count == 0) GroupDictionary.TryRemove(group, out _);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ObjectDictionary.ContainsKey(key))
|
public void TryRemove(TGroup group, TKey key)
|
||||||
|
{
|
||||||
|
if (ContainsGroup(group))
|
||||||
{
|
{
|
||||||
ObjectDictionary.TryRemove(key, out _);
|
if (ContainsKey(group, key)) Dictionary[group].TryRemove(key, out _);
|
||||||
|
if (GroupItemsCount(group) == 0) Dictionary.TryRemove(group, out _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAll()
|
public void TryRemove(TGroup group)
|
||||||
{
|
{
|
||||||
List<TGroup> groups = GroupDictionary.Keys.ToList();
|
ClearGroup(group);
|
||||||
foreach (var group in groups)
|
Dictionary.TryRemove(group, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
ClearGroup(group);
|
ClearGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupDictionary.Clear();
|
Dictionary.Clear();
|
||||||
ObjectDictionary.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearGroup(TGroup group)
|
public void ClearGroup(TGroup group)
|
||||||
{
|
{
|
||||||
if (GroupDictionary.ContainsKey(group))
|
if (ContainsGroup(group))
|
||||||
{
|
{
|
||||||
List<TKey> keys = GroupDictionary[group].Keys.ToList();
|
Dictionary[group].Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TValue> Values(TGroup group)
|
||||||
|
{
|
||||||
|
return ContainsGroup(group) ? Dictionary[group].Values.ToList() : new List<TValue>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TGroup> Groups
|
||||||
|
{
|
||||||
|
get => Dictionary.Keys.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TGroup> SortedGroups
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<TGroup> groups = Groups;
|
||||||
|
groups.Sort();
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TKey> Keys(TGroup group)
|
||||||
|
{
|
||||||
|
return ContainsGroup(group) ? Dictionary[group].Keys.ToList() : new List<TKey>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TKey> SortedKeys(TGroup group)
|
||||||
|
{
|
||||||
|
List<TKey> keys = Keys(group);
|
||||||
|
keys.Sort();
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TValue> SortedValues(TGroup group)
|
||||||
|
{
|
||||||
|
List<TValue> values = new List<TValue>();
|
||||||
|
if (ContainsGroup(group))
|
||||||
|
{
|
||||||
|
var keys = SortedKeys(group);
|
||||||
foreach (var key in keys)
|
foreach (var key in keys)
|
||||||
{
|
{
|
||||||
if (ObjectDictionary.ContainsKey(key))
|
values.Add(Dictionary[group][key]);
|
||||||
ObjectDictionary.TryRemove(key, out _);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupDictionary[group].Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TValue> GetValues(TGroup group)
|
|
||||||
{
|
|
||||||
if (!this.GroupDictionary.ContainsKey(group))
|
|
||||||
{
|
|
||||||
return new List<TValue>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GroupDictionary[group].Values.ToList();
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TGroup> Groups()
|
public TValue GetValue(TGroup group, TKey key)
|
||||||
{
|
{
|
||||||
return GroupDictionary.Keys.ToList();
|
return ContainsKey(group, key) ? Dictionary[group][key] : default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TValue> AllValues()
|
public int AllCount
|
||||||
{
|
{
|
||||||
return ObjectDictionary.Values.ToList();
|
get => Groups.Sum(GroupItemsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TKey> AllKeys()
|
public int GroupCount
|
||||||
{
|
{
|
||||||
return ObjectDictionary.Keys.ToList();
|
get => Dictionary.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TKey> GroupKeys(TGroup group)
|
public int GroupItemsCount(TGroup group)
|
||||||
{
|
{
|
||||||
return ContainsGroup(group) ? GroupDictionary[group].Keys.ToList() : new List<TKey>();
|
return ContainsGroup(group) ? Dictionary[group].Count : 0;
|
||||||
}
|
|
||||||
|
|
||||||
public List<TValue> GroupValues(TGroup group)
|
|
||||||
{
|
|
||||||
return ContainsGroup(group) ? GroupDictionary[group].Values.ToList() : new List<TValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TValue GetValue(TKey key)
|
|
||||||
{
|
|
||||||
return ObjectDictionary.ContainsKey(key) ? ObjectDictionary[key] : default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count() => ObjectDictionary.Count;
|
|
||||||
|
|
||||||
public int Count(TGroup group)
|
|
||||||
{
|
|
||||||
return ContainsGroup(group) ? GroupDictionary[group].Count : 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user