Пример #1
0
        public void LoadHitomi(string[] files)
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => label.Visibility = Visibility.Hidden));
            if (files.Length <= 0)
            {
                Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => label.Visibility = Visibility.Hidden));
                return;
            }
            string[] Folders      = FolderSort(files);
            int      i            = 0;
            int      SelectedPage = 1;

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
            {
                this.Background = new SolidColorBrush(Global.background);
                MainPanel.Children.Clear();
                if (SearchMode2.SelectedIndex == 1)
                {
                    Folders = Folders.Reverse().ToArray();
                }
                SelectedPage = Page_Index.SelectedIndex + 1;
                this.Title   = string.Format("MainWindow - {0}페이지", SelectedPage);
            }));
            foreach (string folder in Folders.Where(x => Array.IndexOf(Folders, x) + 1 <= Page_itemCount * SelectedPage && Array.IndexOf(Folders, x) + 1 > (SelectedPage - 1) * Page_itemCount))
            {
                i++;
                Console.WriteLine("{0}: {1}", i, folder);
                var      allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".lock" };
                string[] innerFiles        = Directory.GetFiles(folder).Where(file => allowedExtensions.Any(file.ToLower().EndsWith)).ToArray().ESort();
                Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                {
                    Hitomi h = new Hitomi
                    {
                        name        = folder.Split(Path.DirectorySeparatorChar).Last(),
                        dir         = folder,
                        page        = innerFiles.Length,
                        files       = innerFiles,
                        type        = Hitomi.Type.Folder,
                        FolderByte  = File2.GetFolderByte(folder),
                        SizePerPage = File2.GetSizePerPage(folder)
                    };
                    if (innerFiles.Length <= 0)
                    {
                        h.thumb     = ImageProcessor.FromResource("NoImage.jpg");
                        h.thumbpath = "";
                    }
                    else
                    {
                        h.thumb     = ImageProcessor.ProcessEncrypt(innerFiles.First());
                        h.thumbpath = innerFiles.First();
                    }
                    if (h.thumb == null)
                    {
                        return;
                    }
                    label.FontSize = 100;
                    label.Content  = i + "/" + Page_itemCount;
                    MainPanel.Children.Add(new HitomiPanel(h, this, true));
                    Console.WriteLine("Completed: {0}", folder);
                }));
            }
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => label.Visibility = Visibility.Hidden));
        }
Пример #2
0
        public async Task <List <Hitomi> > LoadCompre(List <string> items)
        {
            List <Hitomi> res = new List <Hitomi>();

            start(items.Count);
            foreach (string item in items)
            {
                if (item.isUrl())
                {
                    Uri uri = new Uri(item);
                    if (uri.Host == "hiyobi.me")
                    {
                        string id = Path.GetFileNameWithoutExtension(uri.AbsolutePath);
                        Hitomi h  = await new HiyobiLoader(text: id).Parser();
                        res.Add(h);
                        update(h, items.IndexOf(item), items.Count);
                    }
                    if (uri.Host == "hitomi.la")
                    {
                        string id = Path.GetFileNameWithoutExtension(uri.AbsolutePath);
                        this.url   = $"https://ltn.hitomi.la/galleryblock/{id}.html";
                        this.index = int.Parse(id);
                        Hitomi h = await HitomiData();

                        this.url = $"https://ltn.hitomi.la/galleries/{id}.js";
                        JObject info = await HitomiGalleryInfo();

                        h.type  = Hitomi.Type.Hitomi;
                        h.tags  = HitomiTags(info);
                        h.files = HitomiFiles(info).ToArray();
                        h.page  = h.files.Length;
                        h.thumb = await ImageProcessor.LoadWebImageAsync("https:" + h.thumbpath);

                        update(h, items.IndexOf(item), items.Count);
                    }
                }
                else
                {
                    var      allowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".lock" };
                    string[] innerFiles        = Directory.GetFiles(item).Where(file => allowedExtensions.Any(file.ToLower().EndsWith)).ToArray().ESort();
                    if (innerFiles.Length <= 0)
                    {
                        continue;
                    }
                    Hitomi h = new Hitomi
                    {
                        name        = item.Split(Path.DirectorySeparatorChar).Last(),
                        dir         = item,
                        page        = innerFiles.Length,
                        files       = innerFiles,
                        thumb       = await ImageProcessor.ProcessEncryptAsync(innerFiles.First()),
                        type        = Hitomi.Type.Folder,
                        FolderByte  = File2.GetFolderByte(item),
                        SizePerPage = File2.GetSizePerPage(item)
                    };
                    update(h, items.IndexOf(item), items.Count);
                }
            }
            end();
            return(res);
        }