private async Task LoadThumbnailAsync() { List <string> titles = new List <string>(); List <string> magics = new List <string>(); for (int i = 0, j = 0; i < 5 && j < HitomiData.Instance.metadata_collection.Count; j++) { if (HitomiData.Instance.metadata_collection[j].Artists != null && (HitomiData.Instance.metadata_collection[j].Language == HitomiSetting.Instance.GetModel().Language || HitomiSetting.Instance.GetModel().Language == "ALL") && HitomiData.Instance.metadata_collection[j].Artists.Contains(tbArtist.Text)) { string ttitle = HitomiData.Instance.metadata_collection[j].Name.Split('|')[0]; if (titles.Count > 0 && !titles.TrueForAll((title) => StringAlgorithms.get_diff(ttitle, title) > HitomiSetting.Instance.GetModel().TextMatchingAccuracy)) { continue; } titles.Add(ttitle); magics.Add(HitomiData.Instance.metadata_collection[j].ID.ToString()); i++; } } if (HitomiSetting.Instance.GetModel().DetailedLog) { LogEssential.Instance.PushLog(() => $"This images will be loaded. [RecommendControl]"); LogEssential.Instance.PushLog(magics); } for (int i = 0; i < magics.Count; i++) { _ = Task.Factory.StartNew(x => { int ix = (int)x; try { AddMetadataToPanel(ix, magics[ix]); } catch { } }, i); } }
private void textBox2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { e.Handled = true; e.SuppressKeyPress = true; textBox2.Text = textBox2.Text.Trim(); PushString("dc-koromo@hitomi-copy$ " + textBox2.Text); string cmd = textBox2.Text.Trim().Split(' ')[0]; if (cmd == "enum" || cmd == "enumi" || cmd == "enumx") { if (textBox2.Text.Trim().Split(' ').Length == 1) { foreach (var f in Application.OpenForms) { PushString(f.GetType().Name); } } else { try { string frm_name = textBox2.Text.Trim().Split(' ')[1]; if (cmd == "enum") { enum_recursion(Application.OpenForms[frm_name], textBox2.Text.Trim().Split(' '), 2, BindingFlags.Instance | BindingFlags.Public); } else if (cmd == "enumi") { enum_recursion(Application.OpenForms[frm_name], textBox2.Text.Trim().Split(' '), 2, default_bf); } else if (cmd == "enumx") { enum_recursion(Application.OpenForms[frm_name], textBox2.Text.Trim().Split(' '), 2); } } catch (Exception ex) { PushString(ex.Message); } } } else if (cmd == "get") { string[] split = textBox2.Text.Trim().Split(' '); if (split.Length >= 3) { string frm = split[1]; string var = split[2]; try { PushString(LogEssential.SerializeObject(get_recursion(Application.OpenForms[frm], split, 2))); } catch (Exception ex) { PushString(ex.Message); } } else if (split.Length >= 2 && split[1] == "hitomi_analysis") { PushString(string.Join("\r\n", HitomiAnalysis.Instance.Rank.Select(p => $"{p.Item1} ({p.Item2})"))); PushString($"Artist Counts : {HitomiAnalysis.Instance.Rank.Count}"); } else { PushString("using 'get (Form) (Variable1) [Variable2] ...'"); } } else if (cmd == "set") { string[] split = textBox2.Text.Trim().Split(' '); if (split.Length >= 4) { string frm = split[1]; string var = split[2]; string val = split[3]; try { set_recurion(Application.OpenForms[frm], split, 2); } catch (Exception ex) { PushString(ex.Message); } } else { PushString("using 'set (Form) (Variable1) [Variable2] ... [Value]'"); } } else if (cmd == "ra") { string[] split = textBox2.Text.Trim().Split(' '); if (split.Length > 1) { if (split[1] == "ulist") { PushString("User History"); HitomiAnalysisArtist user; user = new HitomiAnalysisArtist(HitomiLog.Instance.GetEnumerator()); foreach (var pair in user.GetDictionary()) { PushString($"{pair.Key} ({pair.Value})"); } } else if (split[1] == "list") { PushString("User Custom History"); if (HitomiAnalysis.Instance.CustomAnalysis != null) { HitomiAnalysis.Instance.CustomAnalysis.Sort((a, b) => a.Item2.CompareTo(b.Item2)); PushString(string.Join("\r\n", HitomiAnalysis.Instance.CustomAnalysis.Select(x => $"{x.Item1} ({x.Item2})"))); } } else if (split[1] == "clear") { HitomiAnalysis.Instance.CustomAnalysis.Clear(); } else if (split[1] == "update") { HitomiAnalysis.Instance.Update(); (Application.OpenForms[0] as frmMain).UpdateNewStatistics(); } else if (split[1] == "on") { HitomiAnalysis.Instance.UserDefined = true; } else if (split[1] == "off") { HitomiAnalysis.Instance.UserDefined = false; } else if (split[1] == "mion") { HitomiAnalysis.Instance.MustInclude = true; } else if (split[1] == "mioff") { HitomiAnalysis.Instance.MustInclude = false; } else if (split[1] == "rank") { PushString(string.Join("\r\n", HitomiAnalysis.Instance.Rank.ToArray().Reverse().Select(p => $"{p.Item1} ({p.Item2})"))); PushString($"Artist Counts : {HitomiAnalysis.Instance.Rank.Count}"); } else if (split[1] == "add") { if (split.Length >= 3) { string artist = Regex.Replace(split[2], "_", " "); bool found = false; found = HitomiData.Instance.tagdata_collection.artist.Any(x => x.Tag == artist); if (!found) { PushString($"'{artist}' is not found."); string similar = ""; int diff = int.MaxValue; HitomiData.Instance.tagdata_collection.artist.ForEach(x => { int diff_t = StringAlgorithms.get_diff(artist, x.Tag); if (diff_t < diff) { diff = diff_t; similar = x.Tag; } }); PushString($"Are you looking for '{similar}'?"); return; } (Application.OpenForms[0] as frmMain).AddRecommendArtist(artist); } else { PushString("using 'ra add (artist)'"); } } else if (split[1] == "+") { if (split.Length >= 4) { try { string tag = Regex.Replace(split[2], "_", " "); int val = Convert.ToInt32(split[3]); bool found = false; found = HitomiData.Instance.tagdata_collection.female.Any(x => x.Tag == tag); if (found == false) { found = HitomiData.Instance.tagdata_collection.male.Any(x => x.Tag == tag); } if (found == false) { found = HitomiData.Instance.tagdata_collection.tag.Any(x => x.Tag == tag); } if (!found) { PushString($"'{tag}' is not found."); string similar = ""; int diff = int.MaxValue; HitomiData.Instance.tagdata_collection.female.ForEach(x => { int diff_t = StringAlgorithms.get_diff(tag, x.Tag); if (diff_t < diff) { diff = diff_t; similar = x.Tag; } }); HitomiData.Instance.tagdata_collection.male.ForEach(x => { int diff_t = StringAlgorithms.get_diff(tag, x.Tag); if (diff_t < diff) { diff = diff_t; similar = x.Tag; } }); HitomiData.Instance.tagdata_collection.tag.ForEach(x => { int diff_t = StringAlgorithms.get_diff(tag, x.Tag); if (diff_t < diff) { diff = diff_t; similar = x.Tag; } }); PushString($"Are you looking for '{similar}'?"); return; } if (HitomiAnalysis.Instance.CustomAnalysis.Any(x => x.Item1 == tag)) { for (int i = 0; i < HitomiAnalysis.Instance.CustomAnalysis.Count; i++) { if (HitomiAnalysis.Instance.CustomAnalysis[i].Item1 == tag) { HitomiAnalysis.Instance.CustomAnalysis[i] = new Tuple <string, int>(tag, val); } } } else { HitomiAnalysis.Instance.CustomAnalysis.Add(new Tuple <string, int>(tag, val)); } } catch (Exception ex) { PushString(ex.Message); } } else if (split.Length == 3) { string tag = Regex.Replace(split[2], "_", " "); List <Tuple <string, int, int> > diff = new List <Tuple <string, int, int> >(); HitomiData.Instance.tagdata_collection.female.ForEach(x => diff.Add(new Tuple <string, int, int>(x.Tag, StringAlgorithms.get_diff(tag, x.Tag), x.Count))); HitomiData.Instance.tagdata_collection.male.ForEach(x => diff.Add(new Tuple <string, int, int>(x.Tag, StringAlgorithms.get_diff(tag, x.Tag), x.Count))); HitomiData.Instance.tagdata_collection.tag.ForEach(x => diff.Add(new Tuple <string, int, int>(x.Tag, StringAlgorithms.get_diff(tag, x.Tag), x.Count))); diff.Sort((a, b) => a.Item2.CompareTo(b.Item2)); for (int i = 5; i >= 0; i--) { PushString($"{diff[i].Item1} [{diff[i].Item3}]"); } return; } else { PushString("'+' command need 2 more parameters."); } } else if (split[1] == "+a") { if (split.Length >= 3) { try { string artist = Regex.Replace(split[2], "_", " "); bool found = false; found = HitomiData.Instance.tagdata_collection.artist.Any(x => x.Tag == artist); if (!found) { PushString($"'{artist}' is not found."); string similar = ""; int diff = int.MaxValue; HitomiData.Instance.tagdata_collection.artist.ForEach(x => { int diff_t = StringAlgorithms.get_diff(artist, x.Tag); if (diff_t < diff) { diff = diff_t; similar = x.Tag; } }); PushString($"Are you looking for '{similar}'?"); return; } foreach (var data in HitomiData.Instance.metadata_collection) { if (!HitomiSetting.Instance.GetModel().RecommendLanguageALL) { string lang = data.Language; if (data.Language == null) { lang = "N/A"; } if (HitomiSetting.Instance.GetModel().Language != "ALL" && HitomiSetting.Instance.GetModel().Language != lang) { continue; } } if (data.Artists != null && data.Tags != null && data.Artists.Contains(artist)) { foreach (var tag in data.Tags) { if (HitomiAnalysis.Instance.CustomAnalysis.Any(x => x.Item1 == tag)) { for (int i = 0; i < HitomiAnalysis.Instance.CustomAnalysis.Count; i++) { if (HitomiAnalysis.Instance.CustomAnalysis[i].Item1 == tag) { HitomiAnalysis.Instance.CustomAnalysis[i] = new Tuple <string, int>(tag, HitomiAnalysis.Instance.CustomAnalysis[i].Item2 + 1); } } } else { HitomiAnalysis.Instance.CustomAnalysis.Add(new Tuple <string, int>(tag, 1)); } } } } } catch (Exception ex) { PushString(ex.Message); } } else { PushString("'+a' command need 1 more parameters."); } } else if (split[1] == "-") { if (split.Length >= 3) { string tag = Regex.Replace(split[2], "_", " "); for (int i = 0; i < HitomiAnalysis.Instance.CustomAnalysis.Count; i++) { if (HitomiAnalysis.Instance.CustomAnalysis[i].Item1 == tag) { HitomiAnalysis.Instance.CustomAnalysis.RemoveAt(i--); } } } } else { PushString($"'{split[1]}' is not a valid command option."); } } else { PushString("using 'ra (option) [tag] [count] ...'"); PushString(" (option): ulist, list, clear, update, on, off, mion, mioff, rank, add, +, +a"); } } else if (cmd == "help") { PushString("Realtime Variable Update System"); PushString("Copyright (C) 2018. Hitomi Parser Developers"); PushString(""); PushString("enum [Form] [Variable1] [Variable2] ... : Enumerate form or class members."); PushString("enumi [Form] [Variable1] [Variable2] ... : Enumerate form or class members with private members."); PushString("enumx [Form] [Variable1] [Variable2] ... : Enumerate all class members without static."); PushString("get (Form|hitomi_analysis) (Variable1) [Variable2] ... : Get value."); PushString("set (Form) (Variable1) [Variable2] ... [Value] : Set value."); PushString("fucs : Frequently Used Command Snippet"); PushString("ra (option) [var1] [var2] ... : Recommend artists tools."); } else if (cmd == "fucs") { PushString("get frmMain latest_load_count"); PushString(" - get Recommend scroll status"); PushString("set frmMain latest_load_count 100"); PushString(" - set Recommend scroll status to 100"); } else { PushString("Command not found. Try 'help' command."); } cmd_stack.Insert(0, textBox2.Text + " "); textBox2.Text = ""; stack_pointer = 0; } else if (e.KeyCode == Keys.Up) { if (textBox2.Text == "") { stack_pointer = 0; } if (stack_pointer >= cmd_stack.Count) { stack_pointer = cmd_stack.Count - 1; } if (stack_pointer >= 0) { textBox2.Text = cmd_stack[stack_pointer]; Application.DoEvents(); textBox2.Focus(); textBox2.SelectionStart = Math.Max(0, textBox2.Text.Length * 10); textBox2.SelectionLength = 0; textBox2.Focus(); } stack_pointer++; } else if (e.KeyCode == Keys.Down) { textBox2.SelectionStart = Math.Max(0, textBox2.Text.Length - 1); textBox2.SelectionLength = 0; } }