C#及WPF獲取本機所有字體和顏色的方法
更新時間:2015年09月23日 15:27:57 作者:我心依舊
這篇文章主要介紹了C#及WPF獲取本機所有字體和顏色的方法,實例分析了C#及WPF獲取本機字體及顏色的相關(guān)技巧,非常簡單實用,需要的朋友可以參考下
本文實例講述了C#及WPF獲取本機所有字體和顏色的方法。分享給大家供大家參考。具體如下:
WPF 獲取所有的字體:
System.Drawing.Text.InstalledFontCollection font = new System.Drawing.Text.InstalledFontCollection();
System.Drawing.FontFamily[] array= font.Families;
foreach (var v in array)
{
MessageBox.Show(v.Name);
}
WPF 獲取所有的顏色:
Type type = typeof(System.Windows.Media.Brushes);
System.Reflection.PropertyInfo[] info = type.GetProperties();
foreach (System.Reflection.PropertyInfo pi in info)
{
string colorName=pi.Name;
}
C#獲取所有的字體:
InstalledFontCollection MyFont=new InstalledFontCollection();
FontFamily[] MyFontFamilies=MyFont.Families;
ArrayList list = new ArrayList();
int Count=MyFontFamilies.Length;
for(int i=0;i <Count;i++)
{
string FontName=MyFontFamilies[i].Name;
list.add(FontName);
}
C#獲取所有的顏色:
Array colors = System.Enum.GetValues( typeof(KnownColor) );
foreach( object colorName in colors ){
ListItem tmp = new ListItem( colorName.ToString() , colorName.ToString());
this.styleColor.Items.Add( tmp );
}
希望本文所述對大家的C#程序設(shè)計有所幫助。
您可能感興趣的文章:
相關(guān)文章
Unity打開淘寶app并跳轉(zhuǎn)到商品頁面功能的實現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于如何利用Unity打開淘寶app并跳轉(zhuǎn)到商品頁面功能的相關(guān)資料,這個功能目前在網(wǎng)上找不到相關(guān)的解決方法,所以自己寫了出來,需要的朋友可以參考下2021-07-07
Unity?UGUI的MaskableGraphic可遮罩圖形組件介紹使用
這篇文章主要為大家介紹了Unity?UGUI的MaskableGraphic可遮罩圖形組件介紹使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-07-07

