add new tabcontrol style and radiobutton style
This commit is contained in:
1 parent
fb202f0e0a
commit
4eb8b828b4
27 files changed
+620
-40
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Controls;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 该类可以为可视化元素提供单开的功能
|
||||
/// </summary>
|
||||
public class SingleOpenHelper
|
||||
{
|
||||
private static readonly Dictionary<string, ISingleOpen> OpenDic = new Dictionary<string, ISingleOpen>();
|
||||
|
||||
/// <summary>
|
||||
/// 根据指定的类型创建实例
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static T CreateControl<T>() where T : Visual, ISingleOpen, new()
|
||||
{
|
||||
var typeStr = typeof(T).FullName;
|
||||
|
||||
if (string.IsNullOrEmpty(typeStr)) return default(T);
|
||||
|
||||
var temp = new T();
|
||||
if (!OpenDic.Keys.Contains(typeStr))
|
||||
{
|
||||
OpenDic.Add(typeStr, temp);
|
||||
return temp;
|
||||
}
|
||||
var currentCtl = OpenDic[typeStr];
|
||||
if (currentCtl.CanDispose)
|
||||
{
|
||||
currentCtl.Dispose();
|
||||
OpenDic[typeStr] = temp;
|
||||
return temp;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user