Exemplo n.º 1
0
        /// <summary>
        /// Loads all cover which are defined in the cover config file.
        /// </summary>
        private static void LoadCover(string coverThemeName)
        {
            SCoverTheme coverTheme = new SCoverTheme();

            coverTheme = CoverTheme(coverThemeName);

            if (coverTheme.Name != String.Empty)
            {
                bool           loaded    = false;
                XPathDocument  xPathDoc  = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc  = new XPathDocument(Path.Combine(CSettings.sFolderCover, coverTheme.File));
                    navigator = xPathDoc.CreateNavigator();
                    loaded    = true;
                }
                catch (Exception)
                {
                    loaded = false;
                    if (navigator != null)
                    {
                        navigator = null;
                    }

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

                if (loaded)
                {
                    lock (_MutexCover)
                    {
                        _Cover.Clear();
                        List <string> cover = CHelper.GetValuesFromXML("Cover", navigator);
                        for (int i = 0; i < cover.Count; i++)
                        {
                            SCover sk    = new SCover();
                            string name  = String.Empty;
                            string value = String.Empty;
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Name", navigator, ref name, String.Empty);
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Path", navigator, ref value, String.Empty);
                            sk.Name  = name;
                            sk.Value = Path.Combine(coverTheme.Folder, value);
                            if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))))
                            {
                                sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)));
                            }
                            else
                            {
                                sk.Texture = _NoCover;
                            }

                            _Cover.Add(sk);

                            if (sk.Name == "NoCover")
                            {
                                _NoCover = sk.Texture;
                            }
                        }
                    }
                }

                CHelper       Helper = new CHelper();
                List <string> files  = new List <string>();

                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.png", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpeg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.bmp", true, true));


                foreach (string file in files)
                {
                    string name = Path.GetFileNameWithoutExtension(file);

                    if (!CoverExists(name))
                    {
                        SCover sk = new SCover();

                        string value = String.Empty;

                        sk.Name  = name;
                        sk.Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file));

                        sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, sk.Value));

                        _Cover.Add(sk);
                    }
                }
            }
        }
Exemplo n.º 2
0
		/// <summary>
		/// Loads all cover which are defined in the cover config file.
		/// </summary>
        private static void LoadCover(string coverThemeName)
        {
            SCoverTheme coverTheme = new SCoverTheme();

            coverTheme = CoverTheme(coverThemeName);

            if (coverTheme.Name != String.Empty)
            {

                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(CSettings.sFolderCover, coverTheme.File));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception)
                {
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

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

                if (loaded)
                {
                    lock (_MutexCover)
                    {
                        _Cover.Clear();
                        List<string> cover = CHelper.GetValuesFromXML("Cover", navigator);
                        for (int i = 0; i < cover.Count; i++)
                        {
                            SCover sk = new SCover();
                            string name = String.Empty;
                            string value = String.Empty;
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Name", navigator, ref name, String.Empty);
                            CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Path", navigator, ref value, String.Empty);
                            sk.Name = name;
                            sk.Value = Path.Combine(coverTheme.Folder,value);
                            if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value))))
                            {
                                sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)));
                            }
                            else
                            {
                                sk.Texture = _NoCover;
                            }

                            _Cover.Add(sk);

                            if (sk.Name == "NoCover")
                            {
                                _NoCover = sk.Texture;
                            }
                        }
                    }
                }

                CHelper Helper = new CHelper();
                List<string> files = new List<string>();

                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.png", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.jpeg", true, true));
                files.AddRange(Helper.ListFiles(Path.Combine(CSettings.sFolderCover, coverTheme.Folder), "*.bmp", true, true));


                foreach (string file in files)
                {
                    string name = Path.GetFileNameWithoutExtension(file);

                    if (!CoverExists(name))
                    {
                        SCover sk = new SCover();

                        string value = String.Empty;

                        sk.Name = name;
                        sk.Value = Path.Combine(coverTheme.Folder,Path.GetFileName(file));

                        sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.sFolderCover, sk.Value));

                        _Cover.Add(sk);
                    }
                }
            }
        }