Exemplo n.º 1
0
        public static HitomiInfoOrg parseTXT(string s)
        {
            HitomiInfoOrg hitomiInfoOrg = new HitomiInfoOrg();

            string[] lines = s.Split(new char[] { '\n', '\r' }).Where(x => x.Length > 0).ToArray();
            foreach (string line in lines)
            {
                if (line.StartsWith("태그: "))
                {
                    hitomiInfoOrg.Tags = line.Remove(0, "태그: ".Length);
                }
                if (line.StartsWith("작가: "))
                {
                    hitomiInfoOrg.Author = line.Remove(0, "작가: ".Length);
                }
                if (line.StartsWith("갤러리 넘버: "))
                {
                    hitomiInfoOrg.Number = line.Remove(0, "갤러리 넘버: ".Length);
                }
            }
            return(hitomiInfoOrg);
        }
Exemplo n.º 2
0
        private void Init()
        {
            if (h.thumb == null)
            {
                h.thumb = ImageProcessor.FromResource("NoImage.jpg");
            }
            thumbNail.Source       = h.thumb;
            thumbBrush.ImageSource = h.thumb;
            thumbNail.ToolTip      = GetToolTip(panel.Height);

            authorsPanel.Children.Clear();
            authorsPanel.Children.Add(new Label {
                Content = "작가 :"
            });
            tagPanel.Children.Clear();
#pragma warning disable CS0618 // 형식 또는 멤버는 사용되지 않습니다.
            if (blur)
            {
                thumbNail.BitmapEffect = new BlurBitmapEffect {
                    Radius = 5, KernelType = KernelType.Gaussian
                }
            }
            ;
            Config config = new Config();
            config.Load();
            if (config.ArrayValue <string>(Settings.except_tags).Any(x => h.tags.Select(y => y.name).Contains(x)))
            {
                if (config.BoolValue(Settings.block_tags) ?? false)
                {
                    MainWindow.MainPanel.Children.Remove(this);
                    return;
                }
                else
                {
                    thumbNail.BitmapEffect = new BlurBitmapEffect {
                        Radius = 5, KernelType = KernelType.Gaussian
                    }
                };
            }
#pragma warning restore CS0618 // 형식 또는 멤버는 사용되지 않습니다.

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

            int    GB         = 1024 * 1024 * 1024;
            int    MB         = 1024 * 1024;
            int    KB         = 1024;
            double FolderByte = h.FolderByte;
            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 = h.SizePerPage;
            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);
            HitomiInfo hInfo = null;
            Uri        uriResult;
            bool       result = Uri.TryCreate(h.dir, UriKind.Absolute, out uriResult) &&
                                ((uriResult.Scheme == Uri.UriSchemeHttp) || (uriResult.Scheme == Uri.UriSchemeHttps));
            if (h.tags.Count > 0)
            {
                foreach (Tag tag in h.tags)
                {
                    tag tag1 = new tag
                    {
                        TagType = tag.types,
                        TagName = tag.name
                    };
                    switch (tag.types)
                    {
                    case Structs.Tag.Types.female:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(255, 94, 94));
                        break;

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

                    case Structs.Tag.Types.tag:
                    default:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(153, 153, 153));
                        break;
                    }
                    tagPanel.Children.Add(tag1);
                }
            }
            else if (result)
            {
            }
            else if (File.Exists(System.IO.Path.Combine(h.dir, "info.json")))
            {
                JObject jobject = JObject.Parse(File.ReadAllText(System.IO.Path.Combine(h.dir, "info.json")));

                h.id   = jobject.StringValue("id");
                h.name = jobject.StringValue("name");
                HitomiInfoOrg hInfoOrg = new HitomiInfoOrg();
                foreach (JToken tags in jobject["tags"])
                {
                    tag tag = new tag();
                    tag.TagType = (Tag.Types) int.Parse(tags["types"].ToString());
                    tag.TagName = tags["name"].ToString();
                    switch (tag.TagType)
                    {
                    case Structs.Tag.Types.female:
                        tag.TagColor = new SolidColorBrush(Color.FromRgb(255, 94, 94));
                        break;

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

                    case Structs.Tag.Types.tag:
                    default:
                        tag.TagColor = new SolidColorBrush(Color.FromRgb(153, 153, 153));
                        break;
                    }
                    tagPanel.Children.Add(tag);
                }
                ftype = (Hitomi.Type) int.Parse(jobject["type"].ToString());
                if (jobject.ContainsKey("authors"))
                {
                    h.authors = jobject["authors"].Select(x => x.ToString()).ToArray();
                }
                else if (jobject.ContainsKey("author"))
                {
                    h.authors = jobject["author"].ToString().Split(new string[] { ", " }, StringSplitOptions.None);
                }
                else
                {
                    h.authors = new string[0];
                }
            }
            else 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("태그: "))
                    {
                        hitomiInfoOrg.Tags = line.Remove(0, "태그: ".Length);
                    }
                    if (line.StartsWith("작가: "))
                    {
                        hitomiInfoOrg.Author = line.Remove(0, "작가: ".Length);
                    }
                    if (line.StartsWith("갤러리 넘버: "))
                    {
                        hitomiInfoOrg.Number = line.Remove(0, "갤러리 넘버: ".Length);
                    }
                    if (line.StartsWith("제목: "))
                    {
                        hitomiInfoOrg.Title = line.Remove(0, "제목: ".Length);
                    }
                }
                hInfo     = HitomiInfo.Parse(hitomiInfoOrg);
                h.name    = hInfo.Title;
                h.id      = hInfo.Number.ToString();
                h.author  = hInfo.Author;
                h.authors = hInfo.Author.Split(new string[] { ", " }, StringSplitOptions.None);
                foreach (Tag tag in hInfo.Tags)
                {
                    tag tag1 = new tag
                    {
                        TagType = tag.types,
                        TagName = tag.name
                    };
                    switch (tag.types)
                    {
                    case Structs.Tag.Types.female:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(255, 94, 94));
                        break;

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

                    case Structs.Tag.Types.tag:
                    default:
                        tag1.TagColor = new SolidColorBrush(Color.FromRgb(153, 153, 153));
                        break;
                    }
                    tagPanel.Children.Add(tag1);
                }
            }
            else
            {
                h.authors = new string[0];
            }

            if (large)
            {
                panel.Height = 150;
                authorsStackPanel.Visibility = Visibility.Visible;
                foreach (string artist in h.authors)
                {
                    if (h.authors.ToList().IndexOf(artist) != 0)
                    {
                        Label dot = new Label();
                        dot.Content = ", ";
                        dot.Padding = new Thickness(0, 5, 2.5, 5);
                        authorsPanel.Children.Add(dot);
                    }
                    Label lb = new Label();
                    lb.Content    = artist;
                    lb.Foreground = new SolidColorBrush(Colors.Blue);
                    lb.Cursor     = Cursors.Hand;
                    lb.MouseDown += authorLabel_MouseDown;
                    lb.Padding    = new Thickness(0, 5, 0, 5);
                    authorsPanel.Children.Add(lb);
                }
            }

            nameLabel.Width   = panel.Width - border.Width;
            nameLabel.Content = h.name;
            ContextSetup();
        }