Exemple #1
0
        public ObservableCollection <CollectionVM> LoadCollections(ObservableCollection <LauncherVM> launchers)
        {
            //todo :make paths relative
            ObservableCollection <CollectionVM> collections = new ObservableCollection <CollectionVM>();

            string[] dirs = Directory.GetDirectories(RetroFE.GetAbsolutePath() + "/Collections");

            foreach (string dir in dirs)
            {
                string         settingsFile = Path.Combine(dir, "Settings.conf");
                string         menuFile     = Path.Combine(dir, "Menu.xml");
                CollectionVM   vm           = new CollectionVM();
                ConfFileParser ini          = new ConfFileParser(settingsFile);
                MenuParser     mp           = new MenuParser();
                string         launcher     = ini.GetSetting("launcher");
                vm.Name     = System.IO.Path.GetFileNameWithoutExtension(dir);
                vm.Launcher = launchers.FirstOrDefault(row => row.Name == launcher);
                vm.ListPath = ini.GetSetting("list.path");
                vm.Layout   = ini.GetSetting("layout");

                if (vm.Layout == "")
                {
                    vm.IsDefaultLayout = true;
                }
                vm.FileExtensions = ini.GetSetting("list.extensions");
                vm.MediaPathVideo = ini.GetSetting("media.video");
                vm.MediaPathTitle = ini.GetSetting("media.title");
                vm.MediaPathLogo  = ini.GetSetting("media.logo");
                vm.MediaPathTitle = ini.GetSetting("media.title");
                vm.MediaPathSnap  = ini.GetSetting("media.snap");
                vm.MediaPathBox   = ini.GetSetting("media.box");
                vm.MediaPathCart  = ini.GetSetting("media.cart");

                //todo: read submenus

                vm.Submenus = mp.ReadCollections(menuFile);
                collections.Add(vm);
            }

            return(collections);
        }