private SyncItem CreateSyncItem(SyncFolder sf, FileInfo fi, ImageInfo ii, SyncItem.Actions action, string name, long max_size) { var si = new SyncItem(); si.Action = action; if (fi.Length > max_size) { si.Action = SyncItem.Actions.ActionNone; } si.Filename = fi.FullName; si.SetId = sf.SetId; si.SetTitle = sf.SetTitle; si.SetDescription = sf.SetDescription; si.NoDeleteTags = sf.NoDeleteTags; if (!string.IsNullOrEmpty(ii.GetTitle()) && sf.SyncMethod != SyncFolder.Methods.SyncFilename) { si.Title = ii.GetTitle(); } else { si.Title = name; } si.Description = ii.GetDescription(); si.Tags = ii.GetTagsArray(); if (!string.IsNullOrEmpty(ii.GetCity())) { si.Tags.Add(ii.GetCity()); } if (!string.IsNullOrEmpty(ii.GetCountry())) { si.Tags.Add(ii.GetCountry()); } si.GeoLat = ii.GetGeo(true); si.GeoLong = ii.GetGeo(false); si.FolderPath = sf.FolderPath; si.Permission = sf.Permission; return si; }
private bool IsPhotoMatch(SyncFolder sf, PhotoInfo pi, ImageInfo ii, string name) { if (sf.SyncMethod == SyncFolder.Methods.SyncFilename && pi.Title == name) { return true; } if (sf.SyncMethod == SyncFolder.Methods.SyncDateTaken && pi.DateTaken == ii.GetDateTaken()) { return true; } if (sf.SyncMethod == SyncFolder.Methods.SyncTitleOrFilename) { string title = ii.GetTitle(); if (string.IsNullOrEmpty(title)) { title = name; } if (pi.Title == title) { return true; } } return false; }
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; }