当前位置: 首页>>代码示例>>C#>>正文


C# GUIFont.Load方法代码示例

本文整理汇总了C#中MediaPortal.GUI.Library.GUIFont.Load方法的典型用法代码示例。如果您正苦于以下问题:C# GUIFont.Load方法的具体用法?C# GUIFont.Load怎么用?C# GUIFont.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaPortal.GUI.Library.GUIFont的用法示例。


在下文中一共展示了GUIFont.Load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
        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
                {
//.........这里部分代码省略.........
开发者ID:MediaPortal,项目名称:MediaPortal-1,代码行数:101,代码来源:GUIFontManager.cs

示例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
        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)
//.........这里部分代码省略.........
开发者ID:disaster123,项目名称:MediaPortal-1,代码行数:101,代码来源:GUIFontManager.cs

示例3: LoadSettings

    public void LoadSettings()
    {
      using (Settings xmlreader = new MPSettings())
      {
        string strTmp = "";
        _fontName = xmlreader.GetValueAsString("subtitles", "fontface", "Arial");
        m_iFontSize = xmlreader.GetValueAsInt("subtitles", "fontsize", 18);
        m_bBold = xmlreader.GetValueAsBool("subtitles", "bold", true);
        strTmp = xmlreader.GetValueAsString("subtitles", "color", "ffffff");
        m_iColor = Convert.ToInt64(strTmp, 16);

        m_iShadow = xmlreader.GetValueAsInt("subtitles", "shadow", 5);

        FontStyle style = FontStyle.Regular;
        if (m_bBold)
        {
          style = FontStyle.Bold;
        }
        m_font = new GUIFont("subFont", _fontName, m_iFontSize, style);
        m_font.Load();
        m_font.InitializeDeviceObjects();
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:23,代码来源:SubTitles.cs


注:本文中的MediaPortal.GUI.Library.GUIFont.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。