private void buttonTagList_Click(object sender, EventArgs e) { ArrayList taglist = new ArrayList(); FileInfo[] files = { }; ImageInfo ii = new ImageInfo(); try { DirectoryInfo dir = new DirectoryInfo(sf.FolderPath); string lookfor = "*.jpg;*.jpeg;*.gif;*.png;*.tif;*.tiff;*.bmp"; string[] extensions = lookfor.Split(new char[] { ';' }); ArrayList myfileinfos = new ArrayList(); foreach (string ext in extensions) { myfileinfos.AddRange(dir.GetFiles(ext)); } files = (FileInfo[])myfileinfos.ToArray(typeof(FileInfo)); } catch (Exception ex) { FlickrSync.Error("Error accessing path: " + sf.FolderPath, ex, FlickrSync.ErrorType.Normal); } this.Cursor = Cursors.WaitCursor; foreach (FileInfo fi in files) { try { ii.Load(fi.FullName, ImageInfo.FileTypes.FileTypeUnknown); } catch (Exception ex) { this.Cursor = Cursors.Default; FlickrSync.Error("Error loading image information: " + fi.FullName, ex, FlickrSync.ErrorType.Normal); return; } foreach (string tag in ii.GetTagsArray()) { bool exists = false; foreach (string tagexist in taglist) { if (tag == tagexist) { exists = true; break; } } if (!exists) { taglist.Add(tag); } } } this.Cursor = Cursors.Default; SelectFromList listForm = new SelectFromList(taglist); listForm.ShowDialog(); if (textBoxTags.Text == "") { textBoxTags.Text = listForm.Selected; } else { textBoxTags.Text += "; " + listForm.Selected; } }
private bool ShouldExcludePhoto(SyncFolder sf, FileInfo fi, out ImageInfo ii) { ii = new ImageInfo(); string[] ftags = sf.FilterTags.Split(';'); for (int i = 0; i < ftags.GetLength(0); i++) { ftags[i] = ftags[i].Trim(); } bool include = true; if (sf.FilterType == SyncFolder.FilterTypes.FilterIncludeTags || sf.FilterType == SyncFolder.FilterTypes.FilterStarRating || sf.SyncMethod == SyncFolder.Methods.SyncDateTaken || sf.SyncMethod == SyncFolder.Methods.SyncTitleOrFilename) { ii.Load(fi.FullName, ImageInfo.FileTypes.FileTypeUnknown); } if (sf.FilterType == SyncFolder.FilterTypes.FilterIncludeTags) { include = false; foreach (string tag in ii.GetTagsArray()) { foreach (string tag2 in ftags) { if (string.Equals(tag, tag2, StringComparison.OrdinalIgnoreCase)) { include = true; break; } } if (include) { break; } } } if (sf.FilterType == SyncFolder.FilterTypes.FilterStarRating) { if (sf.FilterStarRating > ii.GetStarRating()) { include = false; } } /*if (fi.Length > max_size) include = false;*/ return !include; }
private void buttonTagList_Click(object sender, EventArgs e) { ArrayList taglist = new ArrayList(); FileInfo[] files ={ }; ImageInfo ii = new ImageInfo(); try { DirectoryInfo dir = new DirectoryInfo(sf.FolderPath); string lookfor = "*.jpg;*.jpeg;*.gif;*.png;*.tif;*.tiff;*.bmp"; string[] extensions = lookfor.Split(new char[] { ';' }); ArrayList myfileinfos = new ArrayList(); foreach (string ext in extensions) myfileinfos.AddRange(dir.GetFiles(ext)); files = (FileInfo[]) myfileinfos.ToArray(typeof(FileInfo)); } catch (Exception ex) { FlickrSync.Error("Error accessing path: " + sf.FolderPath, ex, FlickrSync.ErrorType.Normal); } this.Cursor = Cursors.WaitCursor; foreach (FileInfo fi in files) { try { ii.Load(fi.FullName, ImageInfo.FileTypes.FileTypeUnknown); } catch (Exception ex) { this.Cursor = Cursors.Default; FlickrSync.Error("Error loading image information: " + fi.FullName, ex, FlickrSync.ErrorType.Normal); return; } foreach (string tag in ii.GetTagsArray()) { bool exists = false; foreach (string tagexist in taglist) if (tag == tagexist) { exists = true; break; } if (!exists) taglist.Add(tag); } } this.Cursor = Cursors.Default; SelectFromList listForm = new SelectFromList(taglist); listForm.ShowDialog(); if (textBoxTags.Text == "") textBoxTags.Text = listForm.Selected; else textBoxTags.Text += "; " + listForm.Selected; }