Exemplo n.º 1
0
        private void Refresh()
        {
            listView1.Items = null;

            label1.Text = Settings.Instance.DownloadDir;

            var apps = Array.Empty <string>();
            var dlcs = Array.Empty <string>();

            IEnumerable <string> files = Directory.GetFiles(Settings.Instance.DownloadDir, "*.pkg");

            var packageDir = Path.Combine(Settings.Instance.DownloadDir, "packages");

            if (Directory.Exists(packageDir))
            {
                files = files.Concat(Directory.GetFiles(packageDir, "*.pkg"));
            }

            var appDir = Path.Combine(Settings.Instance.DownloadDir, "app");

            if (Directory.Exists(appDir))
            {
                apps = Directory.GetDirectories(appDir);
            }

            var addContDir = Path.Combine(Settings.Instance.DownloadDir, "addcont");

            if (Directory.Exists(addContDir))
            {
                dlcs = Directory.GetDirectories(addContDir);
            }

            var imagesToLoad = new List <string>();

            var items = new List <LibraryItem>();

            foreach (var s in files)
            {
                var f = Path.GetFileNameWithoutExtension(s);

                var found = false;
                foreach (var itm in db)
                {
                    if (!f.Equals(itm.DownloadFileName))
                    {
                        continue;
                    }

                    var library = new LibraryItem
                    {
                        Text  = itm.TitleName + " (PKG)",
                        itm   = itm,
                        path  = s,
                        isPkg = true
                    };

                    items.Add(library);

                    foreach (var r in NPCache.I.renasceneCache)
                    {
                        if (!itm.Equals(r.itm))
                        {
                            continue;
                        }

                        imagesToLoad.Add(r.imgUrl);
                        // TODO: This
                        //lvi.ImageKey = r.imgUrl;
                        break;
                    }

                    found = true;
                    break;
                }

                if (!found)
                {
                    var library = new LibraryItem
                    {
                        Text  = f + " (UNKNOWN PKG)",
                        path  = s,
                        isPkg = true
                    };

                    items.Add(library);
                }
            }

            foreach (var s in apps)
            {
                var d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar)
                        .Last();

                var found = false;
                foreach (var itm in db)
                {
                    if (itm.IsDLC)
                    {
                        continue;
                    }

                    if (!itm.TitleId.Equals(d))
                    {
                        continue;
                    }

                    foreach (var r in NPCache.I.renasceneCache)
                    {
                        if (itm.Equals(r.itm))
                        {
                            imagesToLoad.Add(r.imgUrl);
                            // TODO: This
                            //lvi.ImageKey = r.imgUrl;
                            break;
                        }
                    }

                    var library = new LibraryItem
                    {
                        itm   = itm,
                        path  = s,
                        isPkg = false,
                        Text  = itm.TitleName
                    };

                    items.Add(library);

                    found = true;
                    break;
                }

                if (!found)
                {
                    var library = new LibraryItem
                    {
                        path  = s,
                        isPkg = false,
                        Text  = d + " UNKNOWN"
                    };

                    items.Add(library);
                }
            }


            //foreach (string s in dlcs)
            //{
            //    string d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();
            //    foreach (var itm in db)
            //    {
            //        if (itm.IsDLC && itm.TitleId.Equals(d))
            //        {
            //            ListViewItem lvi = new ListViewItem(itm.TitleName);

            //            listView1.Items.Add(lvi);

            //            foreach (var r in NPCache.I.renasceneCache)
            //                if (itm == r.itm)
            //                {
            //                    imagesToLoad.Add(r.imgUrl);
            //                    lvi.ImageKey = r.imgUrl;
            //    break;
            //                }
            //            LibraryItem library = new LibraryItem();
            //            library.itm = itm;
            //            library.patch = s;
            //            library.isPkg = false;
            //            lvi.Tag = library;
            //break;
            //        }
            //    }
            //}


            Task.Run(() =>
            {
                foreach (string url in imagesToLoad)
                {
                    WebClient wc = new WebClient();
                    wc.Proxy     = Settings.Instance.Proxy;
                    wc.Encoding  = Encoding.UTF8;
                    var img      = wc.DownloadData(url);
                    using (var ms = new MemoryStream(img))
                    {
                        Image image = Image.FromStream(ms);
                        image       = getThumb(image);
                        //Dispatcher.UIThread.Post((new Action(() => { imageList1.Images.Add(url, image); })));
                    }
                }
            });

            listView1.Items = items;
        }
Exemplo n.º 2
0
        void UpdateRemoteDirectory()
        {
            if (string.IsNullOrEmpty(comboBox1.Text))
            {
                return;
            }
            listView2.Items.Clear();
            remoteLib.Clear();
            string        appDir   = Path.Combine(comboBox1.Text, "app");
            string        dlcDir   = Path.Combine(comboBox1.Text, "addcont");
            string        patchDir = Path.Combine(comboBox1.Text, "patch");
            DirectoryInfo di       = new DirectoryInfo(appDir);

            if (!di.Exists)
            {
                return;
            }
            List <string> imagesToLoad = new List <string>();

            foreach (DirectoryInfo directoryInfo in di.GetDirectories())
            {
                string folder = directoryInfo.Name;
                foreach (Item itm in db)
                {
                    if (itm.IsDLC)
                    {
                        continue;
                    }
                    if (itm.TitleId == folder)
                    {
                        DirectoryInfo dlcDi   = new DirectoryInfo(Path.Combine(dlcDir, itm.TitleId));
                        DirectoryInfo patchDi = new DirectoryInfo(Path.Combine(patchDir, itm.TitleId));
                        ListViewItem  lvi     = new ListViewItem($"({itm.Region}) {itm.TitleName}");
                        listView2.Items.Add(lvi);

                        foreach (var r in NPCache.I.renasceneCache)
                        {
                            if (itm.Equals(r.itm))
                            {
                                imagesToLoad.Add(r.imgUrl);
                                lvi.ImageKey = r.imgUrl;
                                break;
                            }
                        }
                        LibraryItem library = new LibraryItem();
                        library.itm  = itm;
                        library.path = directoryInfo.FullName;
                        if (dlcDi.Exists)
                        {
                            library.dlcPath = dlcDi.FullName;
                        }

                        if (patchDi.Exists)
                        {
                            library.patchPath = patchDi.FullName;
                        }
                        library.isPkg = false;
                        lvi.Tag       = library;
                        remoteLib.Add(library);
                        break;
                    }
                }
            }
            Task.Run(() =>
            {
                foreach (string url in imagesToLoad)
                {
                    WebClient wc = new WebClient();
                    wc.Proxy     = Settings.Instance.proxy;
                    wc.Encoding  = Encoding.UTF8;
                    var img      = wc.DownloadData(url);
                    using (var ms = new MemoryStream(img))
                    {
                        Image image = Image.FromStream(ms);
                        image       = getThumb(image);
                        Invoke(new Action(() =>
                        {
                            imageList1.Images.Add(url, image);
                        }));
                    }
                }
            });
        }
Exemplo n.º 3
0
        private void Library_Load(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            listView2.Items.Clear();
            localLib.Clear();

            label1.Text = Settings.Instance.downloadDir;

            string[] apps  = new string[0];
            string[] dlcs  = new string[0];
            string[] files = Directory.GetFiles(Settings.Instance.downloadDir, "*.pkg");

            if (Directory.Exists(Settings.Instance.downloadDir + "\\packages"))
            {
                var lst = files.ToList();
                lst.AddRange(Directory.GetFiles(Settings.Instance.downloadDir + "\\packages", "*.pkg"));
                files = lst.ToArray();
            }

            if (Directory.Exists(Settings.Instance.downloadDir + "\\app"))
            {
                apps = Directory.GetDirectories(Settings.Instance.downloadDir + "\\app");
            }
            if (Directory.Exists(Settings.Instance.downloadDir + "\\addcont"))
            {
                dlcs = Directory.GetDirectories(Settings.Instance.downloadDir + "\\addcont");
            }

            List <string> imagesToLoad = new List <string>();

            foreach (string s in files)
            {
                var f = Path.GetFileNameWithoutExtension(s);

                bool found = false;
                foreach (var itm in db)
                {
                    if (f.Equals(itm.DownloadFileName))
                    {
                        ListViewItem lvi = new ListViewItem(itm.TitleName + " (PKG)" + " [" + itm.TitleId + "]");

                        listView1.Items.Add(lvi);

                        foreach (var r in NPCache.I.renasceneCache)
                        {
                            if (itm.Equals(r.itm))
                            {
                                imagesToLoad.Add(r.imgUrl);
                                lvi.ImageKey = r.imgUrl;
                                break;
                            }
                        }
                        LibraryItem library = new LibraryItem();
                        library.itm   = itm;
                        library.path  = s;
                        library.isPkg = true;
                        lvi.Tag       = library;
                        found         = true;
                        break;
                    }
                }

                if (!found)
                {
                    ListViewItem lvi = new ListViewItem(f + " (UNKNOWN PKG)");

                    listView1.Items.Add(lvi);

                    LibraryItem library = new LibraryItem();
                    library.path  = s;
                    library.isPkg = true;
                    lvi.Tag       = library;
                }
            }

            foreach (string s in apps)
            {
                string d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();

                bool found = false;
                foreach (var itm in db)
                {
                    if (!itm.IsDLC)
                    {
                        if (itm.TitleId.Equals(d))
                        {
                            ListViewItem lvi = new ListViewItem($"({itm.Region}) {itm.TitleName}");

                            listView1.Items.Add(lvi);

                            foreach (var r in NPCache.I.renasceneCache)
                            {
                                if (itm.Equals(r.itm))
                                {
                                    imagesToLoad.Add(r.imgUrl);
                                    lvi.ImageKey = r.imgUrl;
                                    break;
                                }
                            }
                            LibraryItem library = new LibraryItem();
                            library.itm  = itm;
                            library.path = s;
                            if (Directory.Exists(Path.Combine(Settings.Instance.downloadDir, "addcont", itm.TitleId)))
                            {
                                library.dlcPath = Path.Combine(Settings.Instance.downloadDir, "addcont", itm.TitleId);
                            }
                            if (Directory.Exists(Path.Combine(Settings.Instance.downloadDir, "patch", itm.TitleId)))
                            {
                                library.patchPath = Path.Combine(Settings.Instance.downloadDir, "patch", itm.TitleId);
                            }
                            library.isPkg = false;
                            lvi.Tag       = library;
                            found         = true;
                            localLib.Add(library);
                            break;
                        }
                    }
                }

                if (!found)
                {
                    ListViewItem lvi = new ListViewItem(d + " UNKNOWN");

                    listView1.Items.Add(lvi);

                    LibraryItem library = new LibraryItem();
                    library.path  = s;
                    library.isPkg = false;
                    lvi.Tag       = library;
                }
            }



            //foreach (string s in dlcs)
            //{
            //    string d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();
            //    foreach (var itm in db)
            //    {
            //        if (itm.IsDLC && itm.TitleId.Equals(d))
            //        {
            //            ListViewItem lvi = new ListViewItem(itm.TitleName);

            //            listView1.Items.Add(lvi);

            //            foreach (var r in NPCache.I.renasceneCache)
            //                if (itm == r.itm)
            //                {
            //                    imagesToLoad.Add(r.imgUrl);
            //                    lvi.ImageKey = r.imgUrl;
            //    break;
            //                }
            //            LibraryItem library = new LibraryItem();
            //            library.itm = itm;
            //            library.patch = s;
            //            library.isPkg = false;
            //            lvi.Tag = library;
            //break;
            //        }
            //    }
            //}


            Task.Run(() =>
            {
                foreach (string url in imagesToLoad)
                {
                    WebClient wc = new WebClient();
                    wc.Proxy     = Settings.Instance.proxy;
                    wc.Encoding  = Encoding.UTF8;
                    var img      = wc.DownloadData(url);
                    using (var ms = new MemoryStream(img))
                    {
                        Image image = Image.FromStream(ms);
                        image       = getThumb(image);
                        Invoke(new Action(() =>
                        {
                            imageList1.Images.Add(url, image);
                        }));
                    }
                }
            });
            SetupRemoteDirectory();
            UpdateRemoteDirectory();
        }
Exemplo n.º 4
0
        private void Library_Load(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            listView2.Items.Clear();

            label1.Text = Settings.Instance.downloadDir;
            label3.Text = "";

            if (Directory.Exists(Settings.Instance.downloadDir))
            {
                string[] apps   = new string[0];
                string[] appsSD = new string[0];
                string[] dlcs   = new string[0];
                string[] files  = Directory.GetFiles(Settings.Instance.downloadDir, "*.pkg");

                string SourcePath      = Settings.Instance.downloadDir + "\\app";
                string DestinationPath = textBox2.Text + ":\\app";

                string SourcePathDLC      = Settings.Instance.downloadDir + "\\addcont";
                string DestinationPathDLC = textBox2.Text + ":\\addcont";


                if (Directory.Exists(Settings.Instance.downloadDir + "\\packages"))
                {
                    var lst = files.ToList();
                    lst.AddRange(Directory.GetFiles(Settings.Instance.downloadDir + "\\packages", "*.pkg"));
                    files = lst.ToArray();
                }

                if (Directory.Exists(Settings.Instance.downloadDir + "\\app"))
                {
                    apps = Directory.GetDirectories(Settings.Instance.downloadDir + "\\app");
                }
                if (Directory.Exists(textBox2.Text + ":\\app"))
                {
                    appsSD = Directory.GetDirectories(textBox2.Text + ":\\app");
                }
                if (Directory.Exists(Settings.Instance.downloadDir + "\\addcont"))
                {
                    dlcs = Directory.GetDirectories(Settings.Instance.downloadDir + "\\addcont");
                }



                List <string> imagesToLoad = new List <string>();

                foreach (string s in files)
                {
                    var f = Path.GetFileNameWithoutExtension(s);

                    bool found = false;
                    foreach (var itm in db)
                    {
                        if (f.Equals(itm.DownloadFileName))
                        {
                            ListViewItem lvi = new ListViewItem(itm.TitleName + " (PKG)");

                            listView1.Items.Add(lvi);

                            foreach (var r in NPCache.I.renasceneCache)
                            {
                                if (itm.Equals(r.itm))
                                {
                                    imagesToLoad.Add(r.imgUrl);
                                    lvi.ImageKey = r.imgUrl;
                                    break;
                                }
                            }
                            LibraryItem library = new LibraryItem();
                            library.itm   = itm;
                            library.path  = s;
                            library.isPkg = true;
                            lvi.Tag       = library;
                            found         = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        ListViewItem lvi = new ListViewItem(f + " (UNKNOWN PKG)");

                        listView1.Items.Add(lvi);

                        LibraryItem library = new LibraryItem();
                        library.path  = s;
                        library.isPkg = true;
                        lvi.Tag       = library;
                    }
                }

                foreach (string s in apps)
                {
                    string d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();

                    bool found = false;
                    foreach (var itm in db)
                    {
                        if (!itm.IsDLC)
                        {
                            if (itm.TitleId.Equals(d))
                            {
                                bool   SD    = false;
                                string Nname = itm.TitleName + "\n\r" + itm.TitleId + "\n\r" + itm.Tsize + " MB";
                                if (itm.DLCs > 0)
                                {
                                    if (Directory.Exists(SourcePathDLC + "\\" + itm.TitleId))
                                    {
                                        Nname += "\n\r" + Directory.GetDirectories(SourcePathDLC + "\\" + itm.TitleId).Length + "/" + itm.DLCs + " DLC";
                                    }
                                    else
                                    {
                                        Nname += "\n\r" + "0/" + itm.DLCs + " DLC";
                                    }
                                }
                                if (appsSD.Length > 0)
                                {
                                    if (appsSD.Contains(s.Replace(SourcePath, DestinationPath)))
                                    {
                                        Nname = Nname + "\n\rSD - GAME";
                                        SD    = true;
                                    }
                                    if (itm.DLCs > 0)
                                    {
                                        if (Directory.Exists(DestinationPathDLC + "\\" + itm.TitleId))
                                        {
                                            //if (Directory.GetDirectories(SourcePathDLC + itm.TitleId).Length == itm.DLCs)
                                            int i = Directory.GetDirectories(DestinationPathDLC + "\\" + itm.TitleId).Length;
                                            if (Directory.GetDirectories(DestinationPathDLC + "\\" + itm.TitleId).Contains(DestinationPathDLC + "\\" + itm.TitleId + "\\sce_pfs"))
                                            {
                                                i -= 1;
                                            }
                                            if (Directory.GetDirectories(DestinationPathDLC + "\\" + itm.TitleId).Contains(DestinationPathDLC + "\\" + itm.TitleId + "\\sce_sys"))
                                            {
                                                i -= 1;
                                            }
                                            Nname += " / " + i + " DLC";
                                        }
                                    }
                                }

                                ListViewItem lvi = new ListViewItem(Nname);
                                if (SD)
                                {
                                    lvi.BackColor = Color.Yellow;
                                }


                                listView1.Items.Add(lvi);

                                foreach (var r in NPCache.I.renasceneCache)
                                {
                                    if (itm.Equals(r.itm))
                                    {
                                        imagesToLoad.Add(r.imgUrl);
                                        lvi.ImageKey = r.imgUrl;
                                        break;
                                    }
                                }
                                LibraryItem library = new LibraryItem();
                                library.itm   = itm;
                                library.path  = s;
                                library.isPkg = false;
                                lvi.Tag       = library;
                                found         = true;
                                break;
                            }
                        }
                    }

                    if (!found)
                    {
                        ListViewItem lvi = new ListViewItem(d + " UNKNOWN");

                        listView1.Items.Add(lvi);

                        LibraryItem library = new LibraryItem();
                        library.path  = s;
                        library.isPkg = false;
                        lvi.Tag       = library;
                    }
                }



                //foreach (string s in dlcs)
                //{
                //    string d = Path.GetFullPath(s).TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();
                //    foreach (var itm in db)
                //    {
                //        if (itm.IsDLC && itm.TitleId.Equals(d))
                //        {
                //            ListViewItem lvi = new ListViewItem(itm.TitleName);
                //            listView1.Items.Add(lvi);
                //            foreach (var r in NPCache.I.renasceneCache)
                //                if (itm == r.itm)
                //                {
                //                    imagesToLoad.Add(r.imgUrl);
                //                    lvi.ImageKey = r.imgUrl;
                //    break;
                //                }
                //            LibraryItem library = new LibraryItem();
                //            library.itm = itm;
                //            library.patch = s;
                //            library.isPkg = false;
                //            lvi.Tag = library;
                //break;
                //        }
                //    }
                //}


                Task.Run(() =>
                {
                    try
                    {
                        foreach (string url in imagesToLoad)
                        {
                            WebClient wc = new WebClient();
                            wc.Proxy     = Settings.Instance.proxy;
                            wc.Encoding  = Encoding.UTF8;
                            var img      = wc.DownloadData(url);
                            using (var ms = new MemoryStream(img))
                            {
                                Image image = Image.FromStream(ms);
                                image       = getThumb(image);
                                Invoke(new Action(() =>
                                {
                                    imageList1.Images.Add(url, image);
                                }));
                            }
                        }
                    }
                    catch (Exception)
                    {
                        //MessageBox.Show(err.Message);
                    }
                });
            }
            else
            {
                MessageBox.Show("Diretório da bliblioteca não encontrado.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            label4.Text = listView1.Items.Count + " Jogos";
        }