📄 skinfactory.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace gowk.utility.skin
{
public class SkinFactory
{
static SkinFactory m_instance=new SkinFactory();
Hashtable ht=new Hashtable();
protected SkinFactory(){}
public static SkinFactory Instance{get{return m_instance;}}
public Type this[Type t]
{
get{return (Type)ht[t];}
set
{
if(value==null)
throw(new ArgumentNullException());
else
ht[t]=value;
}
}
public SubClassBase GetSubClass(IntPtr hwnd)
{
Control c=Control.FromHandle(hwnd);
Type dstType=this.GetTypeToSkin(c.GetType());
if(dstType==null)
return null;
else
return (SubClassBase)dstType.GetConstructor(new Type[]{typeof(IntPtr)}).Invoke(new object[]{hwnd});
}
private Type GetTypeToSkin(Type t)
{
if(this.ht.ContainsKey(t))
{
return this[t];
}
else if(t==typeof(Control))
{
return null;
}
else
{
return this.GetTypeToSkin(t.BaseType);
}
}
public void Add(Type dstType,Type sknType)
{
this.ht.Add(dstType,sknType);
}
public void Remove(Type dstType)
{
this.ht.Remove(dstType);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -