本文整理汇总了C#中IResourceAccessor.GetResourceFilePaths方法的典型用法代码示例。如果您正苦于以下问题:C# IResourceAccessor.GetResourceFilePaths方法的具体用法?C# IResourceAccessor.GetResourceFilePaths怎么用?C# IResourceAccessor.GetResourceFilePaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResourceAccessor
的用法示例。
在下文中一共展示了IResourceAccessor.GetResourceFilePaths方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/// <summary>
/// Sets the font manager up with the specified <paramref name="resourcesCollection"/>.
/// This method will load the font defaults (family and size) and the font files from the
/// resource collection.
/// </summary>
public static void Load(IResourceAccessor resourcesCollection)
{
Unload();
string defaultFontFilePath = resourcesCollection.GetResourceFilePath(
SkinResources.FONTS_DIRECTORY + Path.DirectorySeparatorChar + DEFAULT_FONT_FILE);
XPathDocument doc = new XPathDocument(defaultFontFilePath);
XPathNavigator nav = doc.CreateNavigator();
nav.MoveToChild(XPathNodeType.Element);
_defaultFontFamily = nav.GetAttribute("FontFamily", string.Empty);
string defaultFontSize = nav.GetAttribute("FontSize", string.Empty);
_defaultFontSize = int.Parse(defaultFontSize);
// Iterate over font family descriptors
foreach (string descriptorFilePath in resourcesCollection.GetResourceFilePaths(
"^" + SkinResources.FONTS_DIRECTORY + "\\\\.*\\.desc$").Values)
{
doc = new XPathDocument(descriptorFilePath);
nav = doc.CreateNavigator();
nav.MoveToChild(XPathNodeType.Element);
string familyName = nav.GetAttribute("Name", string.Empty);
if (string.IsNullOrEmpty(familyName))
throw new ArgumentException("FontManager: Failed to parse family name for font descriptor file '{0}'", descriptorFilePath);
string ttfFile = nav.GetAttribute("Ttf", string.Empty);
if (string.IsNullOrEmpty(ttfFile))
throw new ArgumentException("FontManager: Failed to parse ttf name for font descriptor file '{0}'", descriptorFilePath);
string fontFilePath = resourcesCollection.GetResourceFilePath(
SkinResources.FONTS_DIRECTORY + Path.DirectorySeparatorChar + ttfFile);
FontFamily family = new FontFamily(familyName, fontFilePath);
_families[familyName] = family;
}
}