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); }
private async void ExportNumber_Click(object sender, RoutedEventArgs e) { JArray export = new JArray(); foreach (string item in Directory.GetDirectories(path)) { if (File.Exists($"{item}/info.json")) { JObject j = JObject.Parse(File.ReadAllText($"{item}/info.json")); JObject obj = new JObject(); obj["id"] = j["id"]; obj["type"] = int.Parse(j["type"].ToString()); export.Add(obj); } else if (File.Exists($"{item}/info.txt")) { JObject obj = new JObject(); HitomiInfoOrg info = InfoLoader.parseTXT(File.ReadAllText($"{item}/info.txt")); obj["id"] = info.Number; bool result = await new InternetP(index: int.Parse(info.Number)).isHiyobi(); if (result) { obj["type"] = (int)Hitomi.Type.Hiyobi; } else { obj["type"] = (int)Hitomi.Type.Hitomi; } export.Add(obj); } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "번호 파일|*.json"; if (!sfd.ShowDialog() ?? false) { return; } File.WriteAllText(sfd.FileName, export.ToString()); }
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); } } }