Exemplo n.º 1
0
        public static void ListSkins()
        {
            CHelper Helper     = new CHelper();
            int     themeIndex = GetThemeIndex();

            _Skins.Clear();

            if (themeIndex < 0)
            {
                CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme);
                return;
            }

            Theme theme = _Themes[themeIndex];

            string        path  = Path.Combine(theme.Path, theme.SkinFolder);
            List <string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool           loaded    = false;
                XPathDocument  xPathDoc  = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc  = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded    = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                    {
                        navigator = null;
                    }

                    if (xPathDoc != null)
                    {
                        xPathDoc = null;
                    }
                }

                if (loaded)
                {
                    Skin skin = new Skin();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/SkinSystemVersion", navigator, ref version);

                    if (version == SkinSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref skin.Name, String.Empty);
                        if (skin.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref skin.Author, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMajor", navigator, ref skin.SkinVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMinor", navigator, ref skin.SkinVersionMinor);


                            skin.Path     = path;
                            skin.FileName = file;

                            skin.SkinList = new Dictionary <string, SkinElement>();
                            List <string> names = CHelper.GetValuesFromXML("Skins", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name            = str;
                                sk.Value           = String.Empty;
                                skin.SkinList[str] = sk;
                            }

                            skin.VideoList = new List <SkinElement>();
                            names          = CHelper.GetValuesFromXML("Videos", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name  = str;
                                sk.Value = String.Empty;
                                skin.VideoList.Add(sk);
                            }
                            _Skins.Add(skin);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Skin \"" + file + "\", ";
                        if (version < SkinSystemVersion)
                        {
                            msg += "the file ist outdated! ";
                        }
                        else
                        {
                            msg += "the file is for newer program versions! ";
                        }

                        msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void ListThemes()
        {
            CHelper Helper = new CHelper();
            _Themes.Clear();

            string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderThemes);
            List<string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading theme " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    Theme theme = new Theme();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/ThemeSystemVersion", navigator, ref version);

                    if (version == ThemeSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref theme.Name, String.Empty);
                        if (theme.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref theme.Author, String.Empty);
                            CHelper.GetValueFromXML("//root/Info/SkinFolder", navigator, ref theme.SkinFolder, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMajor", navigator, ref theme.ThemeVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMinor", navigator, ref theme.ThemeVersionMinor);
                            theme.Path = path;
                            theme.FileName = file;

                            _Themes.Add(theme);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Theme \"" + file + "\", ";
                        if (version < ThemeSystemVersion)
                            msg += "the file ist outdated! ";
                        else
                            msg += "the file is for newer program versions! ";

                        msg += "Current ThemeSystemVersion is " + ThemeSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void ListThemes()
        {
            CHelper Helper = new CHelper();

            _Themes.Clear();

            string        path  = Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderThemes);
            List <string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool           loaded    = false;
                XPathDocument  xPathDoc  = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc  = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded    = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading theme " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                    {
                        navigator = null;
                    }

                    if (xPathDoc != null)
                    {
                        xPathDoc = null;
                    }
                }

                if (loaded)
                {
                    Theme theme = new Theme();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/ThemeSystemVersion", navigator, ref version);

                    if (version == ThemeSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref theme.Name, String.Empty);
                        if (theme.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref theme.Author, String.Empty);
                            CHelper.GetValueFromXML("//root/Info/SkinFolder", navigator, ref theme.SkinFolder, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMajor", navigator, ref theme.ThemeVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/ThemeVersionMinor", navigator, ref theme.ThemeVersionMinor);
                            theme.Path     = path;
                            theme.FileName = file;

                            _Themes.Add(theme);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Theme \"" + file + "\", ";
                        if (version < ThemeSystemVersion)
                        {
                            msg += "the file ist outdated! ";
                        }
                        else
                        {
                            msg += "the file is for newer program versions! ";
                        }

                        msg += "Current ThemeSystemVersion is " + ThemeSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }