Beispiel #1
0
        /// <summary>
        /// Loads theme fonts from skin file
        /// </summary>
        public static void LoadThemeFonts(string ThemeName, string FontFolder, XPathNavigator navigator)
        {
            string value = string.Empty;
            int i = 1;
            while (CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Folder", navigator, ref value, value))
            {
                SFont sf = new SFont();
                sf.Folder = value;

                sf.IsThemeFont = true;
                sf.ThemeName = ThemeName;

                bool ok = true;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                sf.FileNormal = value;
                value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                CFont f = new CFont(value);
                sf.Normal = f;
                
                string name = String.Empty;
                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Name", navigator, ref name, value);
                sf.Name = name;
                
                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                sf.FileItalic = value;
                value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f = new CFont(value);
                sf.Italic = f;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                sf.FileBold = value;
                value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f = new CFont(value);
                sf.Bold = f;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                sf.FileBoldItalic = value;
                value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f = new CFont(value);
                sf.BoldItalic = f;

                sf.Outline = 0f;
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                if (ok)
                    _Fonts.Add(sf);
                else
                {
                    CLog.LogError("Error loading theme fonts for theme \"" + ThemeName + "\": Error in Font" + i.ToString());
                }
                i++;
            }

            CLog.StartBenchmark(1, "BuildGlyphs");
            BuildGlyphs();
            CLog.StopBenchmark(1, "BuildGlyphs");
        }
Beispiel #2
0
        /// <summary>
        /// Loads theme fonts from skin file
        /// </summary>
        public static void LoadThemeFonts(string ThemeName, string FontFolder, XPathNavigator navigator)
        {
            string value = string.Empty;
            int    i     = 1;

            while (CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Folder", navigator, ref value, value))
            {
                SFont sf = new SFont();
                sf.Folder = value;

                sf.IsThemeFont = true;
                sf.ThemeName   = ThemeName;

                bool ok = true;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                sf.FileNormal = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                CFont f = new CFont(value);
                sf.Normal = f;

                string name = String.Empty;
                ok     &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Name", navigator, ref name, value);
                sf.Name = name;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                sf.FileItalic = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.Italic     = f;

                ok         &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                sf.FileBold = value;
                value       = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f           = new CFont(value);
                sf.Bold     = f;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                sf.FileBoldItalic = value;
                value             = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.BoldItalic = f;

                sf.Outline = 0f;
                ok        &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                if (ok)
                {
                    _Fonts.Add(sf);
                }
                else
                {
                    CLog.LogError("Error loading theme fonts for theme \"" + ThemeName + "\": Error in Font" + i.ToString());
                }
                i++;
            }

            CLog.StartBenchmark(1, "BuildGlyphs");
            BuildGlyphs();
            CLog.StopBenchmark(1, "BuildGlyphs");
        }
Beispiel #3
0
        /// <summary>
        /// Load default fonts
        /// </summary>
        /// <returns></returns>
        private static bool LoadFontList()
        {
            bool loaded = false;
            XPathDocument xPathDoc = null;
            XPathNavigator navigator = null;

            try
            {
                xPathDoc = new XPathDocument(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
                navigator = xPathDoc.CreateNavigator();
                loaded = true;
            }
            catch (Exception e)
            {
                CLog.LogError("Error loading default fonts: " + e.Message);
                loaded = false;
                if (navigator != null)
                    navigator = null;

                if (xPathDoc != null)
                    xPathDoc = null;
            }
            _Fonts.Clear();

            if (loaded)
            {
                string value = string.Empty;
                int i = 1;
                while (CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Folder", navigator, ref value, value))
                {
                    string Folder = value;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                        Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    CFont f = new CFont(value);
                    SFont sf = new SFont();
                    sf.Normal = f;

                    string name = String.Empty;
                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Name", navigator, ref name, value);
                    sf.Name = name;
                    sf.IsThemeFont = false;
                    sf.ThemeName = String.Empty;
                    
                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                        Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f = new CFont(value);
                    sf.Italic = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                        Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f = new CFont(value);
                    sf.Bold = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                        Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f = new CFont(value);
                    sf.BoldItalic = f;

                    sf.Outline = 0f;
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                    sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                    _Fonts.Add(sf);
                    i++;
                }
            }
            return loaded;
        }
Beispiel #4
0
        /// <summary>
        /// Load default fonts
        /// </summary>
        /// <returns></returns>
        private static bool LoadFontList()
        {
            bool           loaded    = false;
            XPathDocument  xPathDoc  = null;
            XPathNavigator navigator = null;

            try
            {
                xPathDoc  = new XPathDocument(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
                navigator = xPathDoc.CreateNavigator();
                loaded    = true;
            }
            catch (Exception e)
            {
                CLog.LogError("Error loading default fonts: " + e.Message);
                loaded = false;
                if (navigator != null)
                {
                    navigator = null;
                }

                if (xPathDoc != null)
                {
                    xPathDoc = null;
                }
            }
            _Fonts.Clear();

            if (loaded)
            {
                string value = string.Empty;
                int    i     = 1;
                while (CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Folder", navigator, ref value, value))
                {
                    string Folder = value;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    CFont f  = new CFont(value);
                    SFont sf = new SFont();
                    sf.Normal = f;

                    string name = String.Empty;
                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Name", navigator, ref name, value);
                    sf.Name        = name;
                    sf.IsThemeFont = false;
                    sf.ThemeName   = String.Empty;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f         = new CFont(value);
                    sf.Italic = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f       = new CFont(value);
                    sf.Bold = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f             = new CFont(value);
                    sf.BoldItalic = f;

                    sf.Outline = 0f;
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                    sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                    _Fonts.Add(sf);
                    i++;
                }
            }
            return(loaded);
        }