added samples
[windows-sources.git] / sdk / samples / WPFSamples / DialogBoxSample / csharp / fontpropertylists.cs
blob16df2513b8e3ba8ffe28f9ea53d26aa3f9faabc2
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Collections.ObjectModel;
5 using System.Reflection;
6 using System.Windows;
7 using System.Windows.Media;
9 namespace SDKSample
11 public class FontPropertyLists
13 static Collection<FontFamily> fontFaces;
14 static Collection<FontStyle> fontStyles;
15 static Collection<FontWeight> fontWeights;
16 static Collection<double> fontSizes;
18 /// <summary>
19 /// Return a collection of avaliable font styles
20 /// </summary>
21 public static ICollection<FontFamily> FontFaces
23 get
25 if (fontFaces == null) fontFaces = new Collection<FontFamily>();
26 foreach (FontFamily fontFamily in Fonts.SystemFontFamilies)
28 fontFaces.Add(fontFamily);
30 return fontFaces;
34 /// <summary>
35 /// Return a collection of avaliable font styles
36 /// </summary>
37 public static ICollection FontStyles
39 get
41 if (fontStyles == null)
43 fontStyles = new Collection<FontStyle>();
44 fontStyles.Add(System.Windows.FontStyles.Normal);
45 fontStyles.Add(System.Windows.FontStyles.Oblique);
46 fontStyles.Add(System.Windows.FontStyles.Italic);
48 return fontStyles;
52 /// <summary>
53 /// Return a collection of avaliable FontWeight
54 /// </summary>
55 public static ICollection FontWeights
57 get
59 if (fontWeights == null)
61 fontWeights = new Collection<FontWeight>();
62 fontWeights.Add(System.Windows.FontWeights.Thin);
63 fontWeights.Add(System.Windows.FontWeights.Light);
64 fontWeights.Add(System.Windows.FontWeights.Regular);
65 fontWeights.Add(System.Windows.FontWeights.Normal);
66 fontWeights.Add(System.Windows.FontWeights.Medium);
67 fontWeights.Add(System.Windows.FontWeights.Heavy);
68 fontWeights.Add(System.Windows.FontWeights.SemiBold);
69 fontWeights.Add(System.Windows.FontWeights.DemiBold);
70 fontWeights.Add(System.Windows.FontWeights.Bold);
71 fontWeights.Add(System.Windows.FontWeights.Black);
72 fontWeights.Add(System.Windows.FontWeights.ExtraLight);
73 fontWeights.Add(System.Windows.FontWeights.ExtraBold);
74 fontWeights.Add(System.Windows.FontWeights.ExtraBlack);
75 fontWeights.Add(System.Windows.FontWeights.UltraLight);
76 fontWeights.Add(System.Windows.FontWeights.UltraBold);
77 fontWeights.Add(System.Windows.FontWeights.UltraBlack);
79 return fontWeights;
83 /// <summary>
84 /// Return a collection of font sizes.
85 /// </summary>
86 public static Collection<double> FontSizes
88 get
90 if (fontSizes == null)
92 fontSizes = new Collection<double>();
93 for (double i = 8; i <= 40; i++) fontSizes.Add(i);
95 return fontSizes;
99 public static bool CanParseFontStyle(string fontStyleName)
103 FontStyleConverter converter = new FontStyleConverter();
104 converter.ConvertFromString(fontStyleName);
105 return true;
107 catch
109 return false;
112 public static FontStyle ParseFontStyle(string fontStyleName)
114 FontStyleConverter converter = new FontStyleConverter();
115 return (FontStyle)converter.ConvertFromString(fontStyleName);
117 public static bool CanParseFontWeight(string fontWeightName)
121 FontWeightConverter converter = new FontWeightConverter();
122 converter.ConvertFromString(fontWeightName);
123 return true;
125 catch
127 return false;
130 public static FontWeight ParseFontWeight(string fontWeightName)
132 FontWeightConverter converter = new FontWeightConverter();
133 return (FontWeight)converter.ConvertFromString(fontWeightName);