Exemple #1
0
        public static HitomiInfo Parse(HitomiInfoOrg org)
        {
            HitomiInfo info = new HitomiInfo();

            info.Title  = org.Title;
            info.Author = org.Author;
            info.Number = int.Parse(org.Number);
            {
                List <Tag> tags = new List <Tag>();
                string[]   arr  = org.Tags.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in arr)
                {
                    Tag tag = new Tag();
                    if (item.Contains(":"))
                    {
                        tag.types = (Tag.Types)Enum.Parse(typeof(Tag.Types), item.Split(':')[0]);
                        tag.name  = string.Join(":", item.Split(':').Skip(1));
                    }
                    else
                    {
                        tag.types = Tag.Types.tag;
                        tag.name  = item;
                    }

                    tags.Add(tag);
                }
                info.Tags = tags.ToArray();
            }
            return(info);
        }
Exemple #2
0
        private void Init()
        {
            thumbNail.Source       = h.thumb;
            thumbBrush.ImageSource = h.thumb;
            thumbNail.ToolTip      = GetToolTip(panel.Height);

            thumbNail.MouseDown += (object sender, MouseButtonEventArgs e) =>
            {
                Reader reader = new Reader(h);
                reader.Show();
            };

            nameLabel.Width   = panel.Width - border.Width;
            nameLabel.Content = System.IO.Path.GetFileName(h.dir);

            pageLabel.Content = h.page + "p";

            int           GB         = 1024 * 1024 * 1024;
            int           MB         = 1024 * 1024;
            int           KB         = 1024;
            DirectoryInfo info       = new DirectoryInfo(h.dir);
            double        FolderByte = info.EnumerateFiles().Sum(f => f.Length);

            sizeLabel.Content = Math.Round(FolderByte, 2) + "B";
            if (FolderByte > KB)
            {
                sizeLabel.Content = Math.Round(FolderByte / KB, 2) + "KB";
            }
            if (FolderByte > MB)
            {
                sizeLabel.Content = Math.Round(FolderByte / MB, 2) + "MB";
            }
            if (FolderByte > GB)
            {
                sizeLabel.Content = Math.Round(FolderByte / GB, 2) + "GB";
            }

            double SizePerPage = FolderByte / info.GetFiles().Length;

            sizeperpageLabel.Content = Math.Round(SizePerPage, 2) + "B";
            if (SizePerPage > KB)
            {
                sizeperpageLabel.Content = Math.Round(SizePerPage / KB, 2) + "KB";
            }
            if (SizePerPage > MB)
            {
                sizeperpageLabel.Content = Math.Round(SizePerPage / MB, 2) + "MB";
            }
            if (SizePerPage > GB)
            {
                sizeperpageLabel.Content = Math.Round(SizePerPage / GB, 2) + "GB";
            }

            ChangeColor(this);

            if (File.Exists(System.IO.Path.Combine(h.dir, "info.txt")))
            {
                HitomiInfoOrg hitomiInfoOrg = new HitomiInfoOrg();
                string[]      lines         = File.ReadAllLines(System.IO.Path.Combine(h.dir, "info.txt")).Where(x => x.Length > 0).ToArray();
                foreach (string line in lines)
                {
                    if (line.StartsWith("갤러리 넘버: "))
                    {
                    }
                    if (line.StartsWith("제목: "))
                    {
                    }
                    if (line.StartsWith("작가: "))
                    {
                    }
                    if (line.StartsWith("그룹: "))
                    {
                    }
                    if (line.StartsWith("타입: "))
                    {
                        hitomiInfoOrg.Types = line.Remove(0, "타입: ".Length);
                    }
                    if (line.StartsWith("시리즈: "))
                    {
                    }
                    if (line.StartsWith("캐릭터: "))
                    {
                    }
                    if (line.StartsWith("태그: "))
                    {
                        hitomiInfoOrg.Tags = line.Remove(0, "태그: ".Length);
                    }
                    if (line.StartsWith("언어: "))
                    {
                    }
                }
                HitomiInfo Hinfo = HitomiInfo.Parse(hitomiInfoOrg);
                foreach (HitomiInfo.Tag tag in Hinfo.Tags)
                {
                    tag tag1 = new tag
                    {
                        TagType = tag.types,
                        TagName = tag.name
                    };
                    switch (tag.types)
                    {
                    case HitomiViewer.Tag.Types.female:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(255, 94, 94));
                        break;

                    case HitomiViewer.Tag.Types.male:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(65, 149, 244));
                        break;

                    case HitomiViewer.Tag.Types.tag:
                    default:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(153, 153, 153));
                        break;
                    }
                    tagPanel.Children.Add(tag1);
                }
            }
        }