/// <summary> /// Reload a file, insert it into the file list at the specified index, view it, and reload the given tags and notes. /// </summary> public void ReloadFile(string filename, int fileIndex, string[] tags = null, string note = null) { fileIndex = (fileIndex < 0) ? 0 : fileIndex; fileIndex = (fileIndex > files.Count) ? files.Count : fileIndex; files.Insert(fileIndex, filename); UpdateFileIndex(fileIndex); if (tags != null) { while (EnabledTags.Count > 0) { EnabledTags.RemoveAt(0); } foreach (string tag in tags) { EnabledTags.Add(tag); } } if (note != null) { this.note = note; } form.ValidateChildren(); }
/// <summary> /// Move/Rename a file. /// Optionally move it to a new directory, enter null for no moving. /// </summary> public void Move(string toDirectory) { if (toDirectory == null) { toDirectory = directory; } if (Settings.Default.MoveSortedFiles && toDirectory == directory) { toDirectory = Path.Combine(toDirectory, "Sorted"); if (!Directory.Exists(toDirectory)) { Directory.CreateDirectory(toDirectory); } } Classes.Actions.SortActions.Move moveAction = new Classes.Actions.SortActions.Move( this, Path.Combine(directory, files[fileIndex]), toDirectory, EnabledTags.ToArray(), form.notesTextBox.Text, fileIndex ); DoAction(moveAction); }
private bool LoadPreviousTags() { const bool EMPTY_CURRENT_TAGS = false; for (int i = 0; i < doneActions.Count; i++) { SortAction action = doneActions.ElementAt(i); //Search through doneActions for the most recent "Move" action that will have the previously used tags in it. if (action.GetType() == typeof(Move)) { if (EMPTY_CURRENT_TAGS) { while (EnabledTags.Count > 0) { EnabledTags.Clear(); } } /*for (int t = 0; t < (action as Move).tags.Length; t++) * { * EnabledTags.Add((action as Move).tags[t]); * }*/ EnabledTags.AddRange((action as Move).tags); // The most recent move action was found and the tags were loaded. return(true); } } // No recent move action was found and no tags were loaded. return(false); }
public void ToggleTag(string tag) { if (EnabledTags.Contains(tag)) { EnabledTags.Remove(tag); } else { EnabledTags.Add(tag); } }
public void TagButtonClicked(TagButtonClickedEventArgs e) { if (e.Button == MouseButtons.Left) { ToggleTag(e.Tag); } else //Right Click { Tags.Remove(e.Tag); EnabledTags.Remove(e.Tag); } }
//TODO: Add more checks for the fileIndex being equal to or less than current fileIndex and changing behaviour. public void RemoveFile(int fileIndex) { if (fileIndex == this.fileIndex) { form.mediaViewer.UnloadMedia(true); } files.RemoveAt(fileIndex); //while (EnabledTags.Count > 0) //EnabledTags.RemoveAt(0); EnabledTags.Clear(); note = String.Empty; UpdateFileIndex(fileIndex); form.ValidateChildren(); }