public System.Collections.IEnumerable GetSuggestions(string filter) { List <Hitomi.HTag> tags = HiyobiTags.Tags; if (tags == null) { HiyobiTags.LoadTags(); } return(tags.Select(x => x.full).StartsContains(filter.Split(' ').Last())); }
private void Init() { CheckUpdate.Auto(); HiyobiTags.LoadTags(); this.MinWidth = 300; Global.MainWindow = this; string[] args = Environment.GetCommandLineArgs(); bool relative = false; for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (arg == "/p" && args.Length - 1 > i) { if (relative) { path = Path.Combine(rootDir, args[i + 1]); } else { path = args[i + 1]; } } if (arg == "/r") { relative = true; } } if (path == string.Empty) { path = Path.Combine(rootDir, "hitomi_downloaded"); } else { if (relative) { path = Path.Combine(rootDir, path); } } if (!Directory.Exists(path)) { Console.WriteLine("Invaild Path"); path = Path.Combine(rootDir, "hitomi_downloaded"); } SearchMode1.SelectedIndex = 0; SetFolderSort(FolderSorts.Name); if (Global.Password == null) { Encrypt.Visibility = Visibility.Collapsed; Decrypt.Visibility = Visibility.Collapsed; } }
public System.Collections.IEnumerable GetSuggestions(string filter) { List <Hitomi.HTag> tags = HiyobiTags.Tags; if (tags == null) { HiyobiTags.LoadTags(); } if (filter.Split(' ').Length > 1) { string filterstring = string.Join(" ", filter.Split(' ').Take(filter.Split(' ').Length - 1)); return(tags.Select(x => x.full) .StartsContains(filter.Split(' ').Last()) .Select(x => filterstring + " " + x)); } else { return(tags.Select(x => x.full).StartsContains(filter.Split(' ').Last())); } //return tags.Select(x => x.name).Where(x => x.StartsWith(filter)); }
public void TagCache() { if (HiyobiTags.Tags == null) { HiyobiTags.LoadTags(); } try { List <Hitomi.HTag> tags = HiyobiTags.Tags; Dispatcher patcher = Global.dispatcher; ProgressBox progressBox = null; patcher.Invoke(() => { progressBox = new ProgressBox(); progressBox.Title = "태그 캐시 다운로드"; progressBox.Show(); progressBox.ProgressBar.Maximum = tags.Count; }); for (int i = 0; i < tags.Count; i++) { Hitomi.HTag tag = tags[i]; Thread th = new Thread(new ThreadStart(async() => { try { string dir = Path.Combine(rootDir, tag.type.ToString()); string file = Path.Combine(dir, tag.tag + ".json"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (File.Exists(file)) { //patcher.Invoke(() => progressBox.ProgressBar.Value++); return; } InternetP parser = new InternetP(); int[] ids = parser.ByteArrayToIntArrayBig(await parser.LoadNozomiTag(tag.type.ToString(), tag.tag, false, 0, 9999)); JArray arr = JArray.FromObject(ids); File.WriteAllText(file, arr.ToString()); Console.WriteLine("{0}/{1}: {2}", i, tags.Count, tag.full); } catch (IOException) { Console.WriteLine("Faild {0}/{1}: {2}", i, tags.Count, tag.full); } catch (Exception ex) { Console.WriteLine("Error {0} : {1}", tag.full, ex.Message); } finally { patcher.Invoke(() => { progressBox.ProgressBar.Value++; if (progressBox.ProgressBar.Value == progressBox.ProgressBar.Maximum) { progressBox.Close(); MessageBox.Show("캐시 다운로드가 끝났습니다."); } }); } })); th.Start(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }