public void Load(TagQueryCriteria tagQueryCriteria = null, bool newAdditionsOnly = false) { FileNames.Clear(); currentQuery = tagQueryCriteria ?? new TagQueryCriteria(); var sourcePath = PersistanceUtil.RetreiveSetting(Setting.SourceDirectory); if (!Directory.Exists(sourcePath)) { sourcePath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); PersistanceUtil.RecordSetting(Setting.SourceDirectory, sourcePath); } if (newAdditionsOnly) { FileNames.Add(NewFiles); } else { FileNames.Add(ImageFileUtil.GetImageFilenames(sourcePath, currentQuery)); } if (currentQuery.orderDirection == OrderDirection.RANDOM) { FileNames.Shuffle(); } watcher.Path = sourcePath; watcher.EnableRaisingEvents = true; FilesLoaded(null, new EventArgs()); }
/* * public static string FixTag( string tagText, TagCasing casingFormat, out List<char> rejectedChars) * { * var result = FilterChars(tagText, out rejectedChars); * result = ChangeToSnakeCasing(result); * return result; * } */ public static void FixAllTagsInFiles(ImageFiles imageFiles)//, TagCasing casingFormat = TagCasing.SnakeCase) { var cancel = false; var cancelContext = new CancelDialogDataContext(); var cancelDialog = new CancelDialog(); cancelContext.CurrentValue = 0; cancelContext.MaxValue = imageFiles.Count; cancelContext.PerformAction = () => { foreach (var filePath in imageFiles) { if (cancel) { break; } var cleaned = ImageFileUtil.GetImageTags(filePath); ImageFileUtil.ApplyTagsToImage(filePath, cleaned); cancelContext.CurrentValue++; } }; cancelContext.OnCancel = (s, e) => { cancel = true; cancelDialog.Close(); }; cancelContext.OnClosed = (s, e) => { cancel = true; cancelDialog.Close(); }; cancelDialog.SetContext(cancelContext); cancelDialog.ShowDialog(); }
private void SetSource_MenuItem_Click(object sender, RoutedEventArgs e) { var result = ""; var success = ImageFileUtil.GetDirectoryFromDialog(out result, PersistanceUtil.RetreiveSetting(Setting.SourceDirectory)); if (success) { PersistanceUtil.RecordSetting(Setting.SourceDirectory, result); main.ImageFiles.Load(main.ImageFiles.currentQuery); } }
public void AddToAll(ImageTag tag) { if (!tag.IsEmpty() && !selectedImageTags.Contains(tag)) { selectedImageTags.Add(tag); foreach (var selected in main.imageGrid.SelectedItems.Cast <ImageInfo>()) { var current = ImageFileUtil.GetImageTags(selected.ImgPath); current.Add(tag); ImageFileUtil.ApplyTagsToImage(selected, current); } } }
private void ChangeSelectedImageTags() { HashSet <ImageTag> tags = null; foreach (var selected in main.imageGrid.SelectedItems.Cast <ImageInfo>()) { var newTags = ImageFileUtil.GetImageTags(selected.ImgPath); if (tags == null) { tags = newTags; } else { tags.IntersectWith(newTags); } } selectedImageTags.Clear(); selectedImageTags.Add(tags); }
private void BatchTag_MenuItem_Click(object sender, RoutedEventArgs e) { var files = ImageFiles.GetAll(); if (files.Count > ImageAnalysisAPI.ImageAnalysis.maxItemsPerBatchRequest) { if (MessageBoxResult.No == MessageBox.Show(files.Count + " files are queued for process, do you want to continue?", "Warning:", MessageBoxButton.YesNo)) { return; } } Task.Run(async() => { var asyncEnumerable = ImageAnalysisAPI.ImageAnalysis.RequestBatchAnalysis(files); await asyncEnumerable.ForEachAsync(toCombine => { ImageFileUtil.BatchApplyTagsToImages(toCombine.ToDictionary(v => v.Key, v => v.Value.Cast <ImageTag>())); }); }); }