private void PicDetailElement_Load(object sender, EventArgs e)
        {
            lTitle.Text     = ha.Title;
            lArtist.Text    = string.Join(",", ha.Artists ?? Enumerable.Empty <string>());
            lSeries.Text    = string.Join(",", ha.Series ?? Enumerable.Empty <string>());
            lGroup.Text     = string.Join(",", ha.Groups ?? Enumerable.Empty <string>());
            lCharacter.Text = string.Join(",", ha.Characters ?? Enumerable.Empty <string>());
            lDate.Text      = HitomiDate.estimate_datetime(Convert.ToInt32(ha.Magic)).ToString();
            if (ha.Tags != null)
            {
                ha.Tags.ToList().ForEach((a) =>
                {
                    a = HitomiCommon.LegalizeTag(a);
                    if (a.StartsWith("female:"))
                    {
                        AddTagToPanel(a.Substring("female:".Length), 1);
                    }
                    else if (a.StartsWith("male:"))
                    {
                        AddTagToPanel(a.Substring("male:".Length), 2);
                    }
                    else
                    {
                        AddTagToPanel(a, 0);
                    }
                });
            }
            if (HitomiSetting.Instance.GetModel().UsingExHentaiBaseOpener)
            {
                metroButton4.Text = "익헨에서 열기";
            }
            lLang.Text = ha.Language;
            if (HitomiSetting.Instance.GetModel().Language != "ALL")
            {
                label9.Dispose();
                lLang.Dispose();
            }

            for (int i = 0; i < Controls.Count; i++)
            {
                if (Controls[i] is Label && Controls[i] != lPage)
                {
                    ConvertToVUILabel(Controls[i--] as Label);
                }
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(this).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
        public SearchElements(IArticle article)
        {
            InitializeComponent();

            Article = article;

            HitomiArticle ha = article as HitomiArticle;

            if (HitomiLog.Instance.Contains(ha.Magic))
            {
                Downloaded.Visibility = Visibility.Visible;
            }
            Title.Text = $"제목 : {ha.Title}";
            if (ha.Artists != null)
            {
                InfoPanel.Children.Add(new TextBlock
                {
                    Text                = $"작가 : " + string.Join(", ", ha.Artists),
                    FontSize            = 17,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(10, 0, 0, 0)
                });
            }
            if (ha.Groups != null)
            {
                InfoPanel.Children.Add(new TextBlock
                {
                    Text                = $"그룹 : " + string.Join(", ", ha.Groups),
                    FontSize            = 17,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(10, 0, 0, 0)
                });
            }
            if (ha.Series != null)
            {
                InfoPanel.Children.Add(new TextBlock
                {
                    Text                = $"시리즈 : " + string.Join(", ", ha.Series),
                    FontSize            = 17,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(10, 0, 0, 0)
                });
            }
            if (ha.Characters != null)
            {
                InfoPanel.Children.Add(new TextBlock
                {
                    Text                = $"캐릭터 : " + string.Join(", ", ha.Characters),
                    FontSize            = 17,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(10, 0, 0, 0)
                });
            }
            if (ha.Tags != null)
            {
                foreach (var tag in ha.Tags)
                {
                    var e = new Button();

                    string text        = tag;
                    var    stack_panel = new StackPanel {
                        Orientation = Orientation.Horizontal
                    };

                    if (tag.StartsWith("female:"))
                    {
                        e.Background  = new SolidColorBrush(Color.FromRgb(0xE8, 0x60, 0xA0));
                        e.BorderBrush = e.Background;
                        text          = tag.Substring("female:".Length);
                        stack_panel.Children.Add(new PackIcon
                        {
                            Kind              = PackIconKind.GenderFemale,
                            Opacity           = 0.8,
                            VerticalAlignment = VerticalAlignment.Center,
                        });
                    }
                    else if (tag.StartsWith("male:"))
                    {
                        e.Background  = new SolidColorBrush(Color.FromRgb(0x00, 0xB1, 0xCF));
                        e.BorderBrush = e.Background;
                        text          = tag.Substring("male:".Length);
                        stack_panel.Children.Add(new PackIcon
                        {
                            Kind              = PackIconKind.GenderMale,
                            Opacity           = 0.8,
                            VerticalAlignment = VerticalAlignment.Center,
                        });
                    }
                    else
                    {
                        e.Background  = Brushes.LightGray;
                        e.BorderBrush = e.Background;
                    }

                    stack_panel.Children.Add(new TextBlock
                    {
                        FontSize          = 11,
                        Margin            = new Thickness(2, 0, 3, 0),
                        VerticalAlignment = VerticalAlignment.Center,
                        Text = text
                    });

                    e.Content  = stack_panel;
                    e.Height   = 20;
                    e.FontSize = 10;
                    e.Margin   = new Thickness(1, 1, 1, 1);
                    e.Click   += E_Click;
                    e.Tag      = tag;

                    Tags.Children.Add(e);
                }
            }
            Date.Text = HitomiDate.estimate_datetime(Convert.ToInt32(ha.Magic)).ToString();

            Loaded += SearchElements_Loaded;
        }
Beispiel #3
0
        private void frmGalleryInfo_LoadAsync(object sender, EventArgs e)
        {
            lDate.Text = HitomiDate.estimate_datetime(Convert.ToInt32(id)).ToString();
            if (pic != null)
            {
                pbImage.Image   = pic.Image;
                lTitle.Text     = pic.Article.Title;
                lArtist.Text    = string.Join(",", pic.Article.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", pic.Article.Series ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", pic.Article.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", pic.Article.Characters ?? Enumerable.Empty <string>());
                textBox1.Text   = string.Join(",", pic.Article.Tags ?? Enumerable.Empty <string>());

                if (pic.Article.Tags != null)
                {
                    pic.Article.Tags.ToList().ForEach((a) =>
                    {
                        a = HitomiCommon.LegalizeTag(a);
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }
            }
            else
            {
                lTitle.Text     = metadata.Name;
                lArtist.Text    = string.Join(",", metadata.Artists ?? Enumerable.Empty <string>());
                lSeries.Text    = string.Join(",", metadata.Parodies ?? Enumerable.Empty <string>());
                lGroup.Text     = string.Join(",", metadata.Groups ?? Enumerable.Empty <string>());
                lCharacter.Text = string.Join(",", metadata.Characters ?? Enumerable.Empty <string>());

                if (metadata.Tags != null)
                {
                    metadata.Tags.ToList().ForEach((a) =>
                    {
                        if (a.StartsWith("female:"))
                        {
                            AddTagToPanel(a.Substring("female:".Length), 1);
                        }
                        else if (a.StartsWith("male:"))
                        {
                            AddTagToPanel(a.Substring("male:".Length), 2);
                        }
                        else
                        {
                            AddTagToPanel(a, 0);
                        }
                    });
                }

                Task.Run(() => download_image());
            }

            if (HitomiSetting.Instance.GetModel().ShowPageCount)
            {
                Task.Run(() => {
                    string ppp = HitomiCore.GetPageCount(id).ToString() + "p";
                    this.Send(() => lPage.Text = ppp);
                });
            }
            else
            {
                lPage.Dispose();
            }
        }
        public async void SearchAsync(string content)
        {
            try
            {
                List <HitomiMetadata> result;
                Stopwatch             sw = Stopwatch.StartNew();
                var end = sw.ElapsedMilliseconds;

                int start_element = 0;
                int count_element = 0;

                if (content.Contains('/'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("/")).ElementAt(0);
                    start_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (content.Contains('?'))
                {
                    var elem = content.Split(' ').Where(x => x.StartsWith("?")).ElementAt(0);
                    count_element = Convert.ToInt32(elem.Substring(1));
                    content       = content.Replace(elem, " ");
                }

                if (!Settings.Instance.Hitomi.UsingAdvancedSearch || content.Contains("recent:"))
                {
                    result = await HitomiDataParser.SearchAsync(content.Trim());

                    end = sw.ElapsedMilliseconds - end;
                    sw.Stop();
                    if (content.Contains("recent:"))
                    {
                        var elem         = content.Split(' ').Where(x => x.StartsWith("recent:")).ElementAt(0);
                        int recent_count = 0;
                        int recent_start = 0;
                        if (elem.Substring("recent:".Length).Contains("-"))
                        {
                            recent_start = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[0]);
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length).Split('-')[1]);
                        }
                        else
                        {
                            recent_count = Convert.ToInt32(elem.Substring("recent:".Length));
                        }
                        SearchText.Text = "recent:" + (recent_start + recent_count) + "-" + recent_count;
                    }
                }
                else
                {
                    result = await HitomiDataSearchAdvanced.Search(content.Trim());

                    end = sw.ElapsedMilliseconds - end;
                    sw.Stop();
                }

                if (start_element != 0 && start_element <= result.Count)
                {
                    result.RemoveRange(0, start_element);
                }
                if (count_element != 0 && count_element < result.Count)
                {
                    result.RemoveRange(count_element, result.Count - count_element);
                }

                var vm = DataContext as Domain.FinderDataGridViewModel;
                result.Sort((a, b) => b.ID.CompareTo(a.ID));
                vm.Items.Clear();
                foreach (var article in result)
                {
                    vm.Items.Add(new Domain.FinderDataGridItemViewModel
                    {
                        아이디    = article.ID.ToString(),
                        제목     = article.Name,
                        타입     = article.Type,
                        작가     = string.Join(",", article.Artists ?? Enumerable.Empty <string>()),
                        그룹     = string.Join(",", article.Groups ?? Enumerable.Empty <string>()),
                        시리즈    = string.Join(",", article.Parodies ?? Enumerable.Empty <string>()),
                        캐릭터    = string.Join(",", article.Characters ?? Enumerable.Empty <string>()),
                        업로드_시간 = HitomiDate.estimate_datetime(article.ID).ToString(),
                        태그     = string.Join(",", article.Tags ?? Enumerable.Empty <string>()),
                        다운     = HitomiLog.Instance.Contains(article.ID.ToString()) ? "★" : ""
                    });
                }

                ResultText.Text = $"{result.Count.ToString("#,#")}개 ({end / 1000.0} 초)";
            }
            catch
            {
            }
        }
Beispiel #5
0
        /// <summary>
        /// Article의 디렉토리 경로를 만듭니다.
        /// </summary>
        /// <param name="article"></param>
        /// <param name="search_text"></param>
        /// <returns></returns>
        public static string MakeDownloadDirectory(HitomiArticle article, string search_text = "")
        {
            string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
            string title   = article.Title ?? "";
            string artists = "";
            string type    = article.Type ?? "";
            string series  = "";
            string search  = search_text;

            if (article.Artists != null)
            {
                //if (HitomiSetting.Instance.GetModel().ReplaceArtistsWithTitle == false)
                artists = article.Artists[0];
                //else
                //{
                //    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                //    artists = textInfo.ToTitleCase(article.Artists[0]);
                //}
            }
            if (article.Series != null)
            {
                series = article.Series[0];
            }
            if (title != null)
            {
                title = title.Replace('|', 'ㅣ');
                foreach (char c in invalid)
                {
                    title = title.Replace(c.ToString(), "");
                }
            }
            if (artists != null)
            {
                foreach (char c in invalid)
                {
                    artists = artists.Replace(c.ToString(), "");
                }
            }
            if (series != null)
            {
                foreach (char c in invalid)
                {
                    series = series.Replace(c.ToString(), "");
                }
            }
            if (search != null)
            {
                foreach (char c in invalid)
                {
                    search = search.Replace(c.ToString(), "");
                }
            }

            string path = Settings.Instance.Hitomi.Path;

            path = Regex.Replace(path, "{Title}", title, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Artists}", artists, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Id}", article.Magic, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Type}", type, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Date}", DateTime.Now.ToString("yyyy-MM-dd"), RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Series}", series, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Search}", search, RegexOptions.IgnoreCase);
            path = Regex.Replace(path, "{Upload}", HitomiDate.estimate_datetime(article.Magic.ToInt32()).ToString("yyyy-MM-dd"), RegexOptions.IgnoreCase);
            return(path);
        }
        /// <summary>
        /// 히토미 콘솔 리다이렉트
        /// </summary>
        static bool Redirect(string[] arguments, string contents)
        {
            HitomiConsoleOption option = CommandLineParser <HitomiConsoleOption> .Parse(arguments);

            if (option.Error)
            {
                Console.Instance.WriteLine(option.ErrorMessage);
                if (option.HelpMessage != null)
                {
                    Console.Instance.WriteLine(option.HelpMessage);
                }
                return(false);
            }
            else if (option.Help)
            {
                PrintHelp();
            }
            else if (option.Article != null)
            {
                ProcessArticle(option.Article);
            }
            else if (option.ImageLink != null)
            {
                ProcessImage(option.ImageLink, option.Type);
            }
            //
            //  다운로드 관련
            //
            else if (option.DownloadMetadata)
            {
                Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore.");
                return(true);
                //ProcessDownloadMetadata();
            }
            else if (option.LoadMetadata)
            {
                ProcessLoadMetadata();
            }
            else if (option.DownloadHidden)
            {
                Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore.");
                return(true);
                //ProcessDownloadHidden();
            }
            else if (option.LoadHidden)
            {
                ProcessLoadHidden();
            }
            //
            //  로드 및 동기화
            //
            else if (option.Sync)
            {
                Console.Instance.WriteErrorLine("Disabled. You cannot use this command anymore.");
                return(true);
                //ProcessSync();
            }
            else if (option.Load)
            {
                ProcessLoad();
            }
            //
            //  검색
            //
            else if (option.Search != null)
            {
                ProcessSearch(option.Search, option.ShowAllSearchList);
            }
            else if (option.SetSearchToken != null)
            {
                Instance.setter = option.SetSearchToken[0];
            }
            //
            //  Date 동기화
            //
            else if (option.SyncDate)
            {
                HitomiDate.print_datetime_data();
            }
            else if (option.Latest)
            {
                ProcessLatest();
            }
            //
            //  작가 추천
            //
            else if (option.Rank)
            {
                ProcessRank();
            }
            else if (option.TagList)
            {
                ProcessTagList();
            }
            //
            //  단순 통계
            //
            else if (option.Ranking)
            {
                ProcessRanking();
            }
            //
            //  Forbidden 데이터
            //
            else if (option.Forbidden != null)
            {
                ProcessForbidden(option.Forbidden);
            }
            //
            //  로그 복구
            //
            else if (option.LogRecover != null)
            {
                ProcessRecoverLog(option.LogRecover);
            }
            //
            //  테스트
            //
            else if (option.Test != null)
            {
                ProcessTest(option.Test);
            }

            return(true);
        }