本文整理汇总了C#中MediaPortal.GUI.Library.GUIFont.SetRange方法的典型用法代码示例。如果您正苦于以下问题:C# GUIFont.SetRange方法的具体用法?C# GUIFont.SetRange怎么用?C# GUIFont.SetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPortal.GUI.Library.GUIFont
的用法示例。
在下文中一共展示了GUIFont.SetRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFonts
/// <summary>
/// Loads the fonts from a file.
/// </summary>
/// <param name="strFilename">The filename from where the fonts are loaded.</param>
/// <returns>true if loaded else false</returns>
public static bool LoadFonts(string strFilename)
{
// Clear current set of fonts
Dispose();
lock (Renderlock)
{
int counter = 0;
Log.Info(" Load fonts from {0}", strFilename);
_listFonts.DisposeAndClear();
// Load the debug font
GUIFont fontDebug = new GUIFont("debug", "Arial", 12);
fontDebug.ID = counter++;
fontDebug.Load();
_listFonts.Add(fontDebug);
try
{
// Load the XML document
XmlDocument doc = new XmlDocument();
doc.Load(strFilename);
// Check the root element
if (doc.DocumentElement == null)
{
return false;
}
string strRoot = doc.DocumentElement.Name;
if (strRoot != "fonts")
{
return false;
}
// Select the list of fonts
XmlNodeList list = doc.DocumentElement.SelectNodes("/fonts/font");
foreach (XmlNode node in list)
{
XmlNode nodeStart = node.SelectSingleNodeFast("startchar");
XmlNode nodeEnd = node.SelectSingleNodeFast("endchar");
XmlNode nodeName = node.SelectSingleNodeFast("name");
XmlNode nodeFileName = node.SelectSingleNodeFast("filename");
XmlNode nodeHeight = node.SelectSingleNodeFast("height");
XmlNode nodeBold = node.SelectSingleNodeFast("bold");
XmlNode nodeItalics = node.SelectSingleNodeFast("italic");
if (nodeHeight != null && nodeName != null && nodeFileName != null)
{
bool bold = false;
bool italic = false;
if (nodeBold != null && nodeBold.InnerText != null && nodeBold.InnerText.Equals("yes"))
{
bold = true;
}
if (nodeItalics != null && nodeItalics.InnerText != null && nodeItalics.InnerText.Equals("yes"))
{
italic = true;
}
string strName = nodeName.InnerText;
string strFileName = nodeFileName.InnerText;
int iHeight = Int32.Parse(nodeHeight.InnerText);
// height is based on 720x576
float fPercent = (((float)GUIGraphicsContext.Height) * GUIGraphicsContext.ZoomVertical) / 576.0f;
fPercent *= iHeight;
iHeight = (int)fPercent;
FontStyle style = new FontStyle();
style = FontStyle.Regular;
if (bold)
{
style |= FontStyle.Bold;
}
if (italic)
{
style |= FontStyle.Italic;
}
GUIFont font = new GUIFont(strName, strFileName, iHeight, style);
font.ID = counter++;
// .NET's LocalisationProvider should give the correct amount of chars.
if (nodeStart != null && nodeStart.InnerText != "" && nodeEnd != null && nodeEnd.InnerText != "")
{
int start = Int32.Parse(nodeStart.InnerText);
int end = Int32.Parse(nodeEnd.InnerText);
font.SetRange(start, end);
}
else
{
font.SetRange(0, GUIGraphicsContext.CharsInCharacterSet);
}
font.Load();
_listFonts.Add(font);
}
}
// Select the list of aliases
XmlNodeList listAlias = doc.DocumentElement.SelectNodes("/fonts/alias");
foreach (XmlNode node in listAlias)
//.........这里部分代码省略.........
示例2: LoadFonts
/// <summary>
/// Loads the fonts from a file.
/// </summary>
/// <param name="strFilename">The filename from where the fonts are loaded.</param>
/// <returns>true if loaded else false</returns>
public static bool LoadFonts(string strFilename)
{
// Clear current set of fonts
Dispose();
lock (Renderlock)
{
int counter = 0;
Log.Info("Load fonts from: {0}", strFilename);
ListFonts.DisposeAndClear();
// Load the debug font
var fontDebug = new GUIFont("debug", "Arial", 12) {ID = counter++};
fontDebug.Load();
ListFonts.Add(fontDebug);
try
{
// Load the XML document
var doc = new XmlDocument();
doc.Load(strFilename);
// Check the root element
if (doc.DocumentElement == null)
{
return false;
}
string strRoot = doc.DocumentElement.Name;
if (strRoot != "fonts")
{
return false;
}
// Select the list of fonts
XmlNodeList list = doc.DocumentElement.SelectNodes("/fonts/font");
if (list != null)
{
foreach (XmlNode node in list)
{
XmlNode nodeStart = node.SelectSingleNodeFast("startchar");
XmlNode nodeEnd = node.SelectSingleNodeFast("endchar");
XmlNode nodeName = node.SelectSingleNodeFast("name");
XmlNode nodeFileName = node.SelectSingleNodeFast("filename");
XmlNode nodeHeight = node.SelectSingleNodeFast("height");
XmlNode nodeBold = node.SelectSingleNodeFast("bold");
XmlNode nodeItalics = node.SelectSingleNodeFast("italic");
if (nodeHeight != null && nodeName != null && nodeFileName != null)
{
bool bold = false;
bool italic = false;
if (nodeBold != null && nodeBold.InnerText.Equals("yes"))
{
bold = true;
}
if (nodeItalics != null && nodeItalics.InnerText.Equals("yes"))
{
italic = true;
}
string strName = nodeName.InnerText;
string strFileName = nodeFileName.InnerText;
int iHeight = Int32.Parse(nodeHeight.InnerText);
// font height is based on legacy hard coded resolution of 720x576
float baseSize = 576;
// adjust for different DPI settings (96dpi = 100%)
using (Graphics graphics = GUIGraphicsContext.form.CreateGraphics())
{
// With DPIAware setting baseSize need to be kept
if (Environment.OSVersion.Version.Major >= 6 && graphics.DpiY != 96.0)
{
baseSize *= graphics.DpiY/96;
}
}
float fPercent = (GUIGraphicsContext.Height * GUIGraphicsContext.ZoomVertical) / baseSize;
fPercent *= iHeight;
iHeight = (int)fPercent;
var style = FontStyle.Regular;
if (bold)
{
style |= FontStyle.Bold;
}
if (italic)
{
style |= FontStyle.Italic;
}
var font = new GUIFont(strName, strFileName, iHeight, style) {ID = counter++};
// .NET's LocalisationProvider should give the correct amount of chars.
if (nodeStart != null && nodeStart.InnerText != "" && nodeEnd != null && nodeEnd.InnerText != "")
{
int start = Int32.Parse(nodeStart.InnerText);
int end = Int32.Parse(nodeEnd.InnerText);
font.SetRange(start, end);
}
else
{
//.........这里部分代码省略.........